smp
05-26-2010, 05:30 AM
Hi,
I am using vector() and matrix() functions.
There are 100 numbers to be stored in 2D array of 10 rows and 10 columns.
100 numbers are stored in a 1D array.
I get "segmentation fault" at the line indicated in the segment of my code below:
:
:
#define size 100
#define nl 1
#define nh 10
:
:
float **sensor_matrix, *shift;
shift=vector(1,size);
sensor_matrix=matrix(nl,nh,nl,nh);
:
:
k=1;
for(i=nl;i<=nh;i++)
{
for(j=nl;j<=nh;j++)
{
sensor_matrix[i][j]=shift[k]; // I get segmentation fault here
k++;
}
}
:
:
free_matrix(sensor_matrix,nl,nh,nl,nh);
free_vector(shift,1,size);
Any help will be appreciated.
Thanks and Regards
smp
I am using vector() and matrix() functions.
There are 100 numbers to be stored in 2D array of 10 rows and 10 columns.
100 numbers are stored in a 1D array.
I get "segmentation fault" at the line indicated in the segment of my code below:
:
:
#define size 100
#define nl 1
#define nh 10
:
:
float **sensor_matrix, *shift;
shift=vector(1,size);
sensor_matrix=matrix(nl,nh,nl,nh);
:
:
k=1;
for(i=nl;i<=nh;i++)
{
for(j=nl;j<=nh;j++)
{
sensor_matrix[i][j]=shift[k]; // I get segmentation fault here
k++;
}
}
:
:
free_matrix(sensor_matrix,nl,nh,nl,nh);
free_vector(shift,1,size);
Any help will be appreciated.
Thanks and Regards
smp