I am doing a project that requires me to create 15 double arrays of dimensions 100000*100000. All of them are lower triangular matrix. So it's not a surprise that ran out of memory just for 1 such array giving an error terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
How should I remove the zeros in those matrices and code them like this
#define WIDTH 100000
#define HEIGHT 100000
int jimmy [HEIGHT * WIDTH];
int n,m;
int main ()
{
for (n=0; n<HEIGHT; n++)
for (m=0; m<WIDTH; m++)
{
jimmy[n*WIDTH+m]=(n+1)*(m+1);
}
}
This is a snippet of the code that I am working on. I have used the following matrices which I haven't shown. All of them are Lower triangular. I don't need all of them at once.
double T = 0.3; // final time.
double iN = 100; // samples(I want it 100000)
double h = T/N; // step-size
double a_i11[iN][iN],a_i12[iN][iN],a_i13[iN][iN];
double a_i21[iN][iN],a_i22[iN][iN],a_i23[iN][iN];
double a_i31[iN][iN],a_i32[iN][iN],a_i33[iN][iN];
double a_f[iN][iN];
double b_i12[iN][iN],b_i13[iN][iN];
double b_i22[iN][iN],b_i23[iN][iN];
double b_p[iN][iN];
This answer shows the best efficient way to store a lower triangular matrix. Can anyone please tell me the most efficient way to combine these two methods? My last goal is to convert this C++ code to CUDA code.