In the constructor of my program I am generating a very large lookup table of 2048 * 2048 floats using nested std::vector<std::vector<float>>
.
The lookup table is always the same each time, so I'd like to write this table to a file to save recalculating it.
What is the best way to achieve this? Is it best to write the values to a big header, or is it wiser to save a binary copy of the object?
Thanks in advance!
Edit:
If it is of any conceqence, perhaps it's related to the time take to allocate the memory which is being done with the following pattern:
dataStructure.resize(numberOfRows);
for (int i = 0; i < numberOfRows; i++)
dataStructure[i].resize(numberOfColumns);
Where datastructure is a std::vector<std::vector<float>>
The answer in this case has been to optimise the lookup table generation. I was doing much, much more work than was required, and now load times are practically instant.
For those in the future looking at this thread with a similar problem, there is great general advice in the commments.
Thanks to the attention of all who contributed!