G
Gary Wessle
Hi
in the gsl, I am trying to use a function but getting this error
****************************************************************
read_data.o: In function `read_data::matrix_the_file()':
read_data.cpp.text+0x4e): undefined reference to `read_data::gsl_matrix_alloc(unsigned int, unsigned int)'
read_data.cpp.text+0x8c): undefined reference to `gsl_matrix_fscanf'
Function: gsl_matrix * gsl_matrix_alloc (size_t n1, size_t n2)
****************************************************************
the docs/example say
****************************************************************
This function creates a matrix of size n1 rows by n2 columns,
returning a pointer to a newly initialized matrix struct. A new
block is allocated for the elements of the matrix, and stored in
the block component of the matrix struct. The block is owned by
the matrix, and will be deallocated when the matrix is
deallocated.
example given:
gsl_matrix * m = gsl_matrix_alloc (10, 3);
****************************************************************
my code
**************** file.h ****************
class read_data
{
int nRows, nCol;
void No_of_Rows_Cols();
gsl_matrix * m;
gsl_matrix * gsl_matrix_alloc(size_t, size_t);
void matrix_the_file();
....
};
**************** file.cpp ****************
....
void read_data::matrix_the_file(){
// allocate memory for the matrix
// needs to be freed later using
// void gsl_matrix_free (gsl_matrix * m)
m = gsl_matrix_alloc (nRows, nCol); //<<------- here
FILE * f = fopen(file_name.c_str(), "rb");
gsl_matrix_fscanf (f, m);
fclose(f);
}
....
****************************************************************
how can I case an int into size_t?
thanks
in the gsl, I am trying to use a function but getting this error
****************************************************************
read_data.o: In function `read_data::matrix_the_file()':
read_data.cpp.text+0x4e): undefined reference to `read_data::gsl_matrix_alloc(unsigned int, unsigned int)'
read_data.cpp.text+0x8c): undefined reference to `gsl_matrix_fscanf'
Function: gsl_matrix * gsl_matrix_alloc (size_t n1, size_t n2)
****************************************************************
the docs/example say
****************************************************************
This function creates a matrix of size n1 rows by n2 columns,
returning a pointer to a newly initialized matrix struct. A new
block is allocated for the elements of the matrix, and stored in
the block component of the matrix struct. The block is owned by
the matrix, and will be deallocated when the matrix is
deallocated.
example given:
gsl_matrix * m = gsl_matrix_alloc (10, 3);
****************************************************************
my code
**************** file.h ****************
class read_data
{
int nRows, nCol;
void No_of_Rows_Cols();
gsl_matrix * m;
gsl_matrix * gsl_matrix_alloc(size_t, size_t);
void matrix_the_file();
....
};
**************** file.cpp ****************
....
void read_data::matrix_the_file(){
// allocate memory for the matrix
// needs to be freed later using
// void gsl_matrix_free (gsl_matrix * m)
m = gsl_matrix_alloc (nRows, nCol); //<<------- here
FILE * f = fopen(file_name.c_str(), "rb");
gsl_matrix_fscanf (f, m);
fclose(f);
}
....
****************************************************************
how can I case an int into size_t?
thanks