Memory allocation while initialise matrix

Hi,

I'm about to solve least-squares problems within a C++-Program. (Equations like inverse(transpose(A)*A) * b and so on)

So I use cmatrix as library and there is the following problem:

1
2
3
4
5
6
7
#include <cmatrix>
typedef techsoft::matrix<double> dMatrix;

dMatrix A(nDataPoints, numCol);
dMatrix z(numCol, 1);
dMatrix b(nDataPoints, 1);
dMatrix help(nDataPoints, nDataPoints);


nDataPoints and numCol are globally defined integers which get the values 120 and 13 (just so you have an idea about the size of those matrices).

So, A is not a problem, help is not a problem, but as soon as it gets to z and b there is a dialog "Out of Memory" and it stops at the line
return HeapAlloc(_crtheap, 0, size ? size : 1);
(in malloc.c).

I researched in the web but I could not find anything - any idea?

Note: This program debugged without any problem with same code - now I just edited the size of the matrices.
And I tried the same with another library called "Eigen" and I get the same problem - so I guess there is a problem with the heap and I have to do some kind of memory allocation...
Last edited on
Are A, z, b and help defined inside a function or are they static variables?
Sorry, I should have made that clear! Yes, they are inside a function.
And you have assigned values to nDataPoints and numCol before this code run?
Yes of course ;) as I wrote, the assigned values in this case are 120 and 13. I checked that in the debugger and with an output file, they are assigned for sure.
Topic archived. No new replies allowed.