I have encountered a very bizzare (at least for me) problem when writing the output from my program to a file. I've written a program to solve numerically mean-reverting SDEs. The program takes some parameters and returns several dynamic arrays corresponding to the number of SDEs I have. I store each realization in a row; the columns correspond to the discretized time steps.
Seems to be working fine but sometimes when I write the results to a .txt or .csv file, some of the data elements are "-1.#IND". Doesn't always happen and seems to be correlated with the size of the arrays I'm working with. With smaller arrays there is usually no problem. When the size increases I sometimes get this kind of corrupted data but not always.
The problem is the whole thing is unstable and I can never be sure if I'll be able to replicate my results. I searched on the Internet for this but did not find anything. Does anyone have an idea what -1.#IND means, in the first place, and what might be potentially causing this problem?
I can think if two possible explanations. One is that this is due to some numerical error, but this is unlikely since the values prior to the -1.#IND elements are perfectly fine, then I suddenly get some sequence of -1.#IND elements and then normal values again. The second reason I can think of is that something happens during the writing of the data to the file. Again, this shouldn't be the case as the size of the arrays I'm storing does not exceed the file's storage potential.
I'm lost. Hope someone can help me resolve this. Thank you very much in advance.