Hi,
i'm rather new to C/C++ Programming. Always worked with java till now. I
have a problem in Construction an Object the has a gsl_matrix * pointer.
I wanna have a constant pointer so that i can call function like det,
inverse and so on the object. For example i wann call A.get_det, wich
give me the determinate of the matrix i created. My problem is that the
pointer changes..... attached ist the code.... Hope someone can help
me!!!! Thanks in advance!!!!
#include "GaussMatrix.h"
#include <iostream>
#include <vector>
#include <string>
namespace std {
GaussMatrix::GaussMatrix(vector<double> init_vector, unsigned int rows,
unsigned int columns) {
cout << init_vector[0] << endl;
_rows = rows;_columns=columns;
ProcessArray ( &init_vector[0], init_vector.size() );
cout << init_vector[0] << endl;
_array = &init_vector[0];
gsl_matrix_view a = gsl_matrix_view_array( _array, _rows,
_columns );
GaussMatrix::p_matrix = gsl_matrix_calloc(rows,columns);
GaussMatrix::p_matrix = &a.matrix;
cout << "pointer value:" << p_matrix << endl;
for (int i = 0; i < 2; i++) /* OUT OF RANGE ERROR */
for (int j = 0; j < 2; j++)
printf ("n(%d,%d) = %g\n", i, j,
gsl_matrix_get (p_matrix, i, j));
}
//GaussMatrix::~GaussMatrix() {
// TODO Auto-generated destructor stub
//}
void GaussMatrix::ProcessArray ( const double * , size_t numDoubles )
{};
void GaussMatrix::print_matrix(){
for (int i = 0; i < 2; i++) /* OUT OF RANGE ERROR */
for (int j = 0; j < 2; j++)
printf ("m(%d,%d) = %g\n", i, j,
gsl_matrix_get ( p_matrix, i, j));
}
}
in the main prog i make
GaussMatrix gaus(p_values, 2, 2);
gaus.print_matrix();
_______________________________________________
Help-gsl mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gsl