logo       

Memory allocation for large matrices: msg#00062

lib.gsl.general

Subject: Memory allocation for large matrices

Hi There,



I am trying to load a large matrix (180000*40) to GSL from a matrix.



The data was first saved in Matrix "A" by first initiate "A" as



double *A[180000];

for (i=0;i<180000;i++)

A [i]=malloc(40*sizeof*A[i]);





After reading values in to "A", I wanted to pass the values from "A" to a
GSL matrix "B".



gsl_matrix *B=gsl_matrix_alloc(180000,40);



for (i=0;i<180000;i++)

for (j=0;j<40;j++)

gsl_matrix_set(B,i ,j,A[i][j]);


I got an error message below each time the code reaches the gsl_marix_alloc
line:


Gsl:init_source.c :46: ERROR:failed to allocate space for block data

Default GSL error handler invoked.



I saw similar question posted before, but no answer yet. Is there any way to
solve this problem by first define B as a gsl vector, then assign space for
each element of the vector, similar to what I can do for a C matrix? I was
not able to make it work so far. Any helps or suggestions are highly
appreciated!



Helena


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise