This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gsl matrix


Hello,
We have started to use gsl recently. Currently my group is involved in a
high energy physics experiment at CERN. We are developping the software
for the event reconstruction and display.

Our software is C++ and we use heavyly matrix operations. Thus I had the
idea to build a C++ wrapper class around the gsl matrices. It looks a good
idea to me (opinions?) since the adressing mechanism of the gsl matrices,
"a la valarray" should be fast and they come with a full BLAS interface.

I have been working in the first prototypes and found a couple of problems
which I would like to discuss.

The first one has to do with the absence in the gsl-0.9 library of a
function of the type: 

double * gsl_matrix_ptr(const gsl_matrix * m, const size_t i, const size_t
j);

The function (and all its cousins for the different data types) is
prototyped in the corresponding headers but not implemented. It must have
been supressed on purpose since the implementation is trivial. On the
other hand I would argue such a function is necessary for the "write
element" operator, which requires a pointer. We implement the operator
like this:

double& Rmatrix::operator () (int row, int col) const {
  double* elementPointer = gsl_matrix_ptr(gslMatrix, row-1, col-1);
  return *elementPointer;

}

Could this function be (re)-added to the package?

This is my provisional implementation of the function:

BASE *
FUNCTION (gsl_matrix, ptr) (const TYPE (gsl_matrix) * m,
			    const size_t i, const size_t j)
{

  if (gsl_check_range)
    {
      if (i >= m->size1)	/* size_t is unsigned, can't be negative
*/
	{
	  gsl_error ("first index out of range",
		     __FILE__, __LINE__, GSL_EINVAL) ;
	}
      else if (j >= m->size2)	/* size_t is unsigned, can't be negative
*/
	{
	  gsl_error ("second index out of range",
		     __FILE__, __LINE__, GSL_EINVAL) ;
	}
    }
    return (BASE *) (m->data + MULTIPLICITY * (i * m->tda + j));

}

Notice that I use the gsl_error function rather than the macros used in
similar functions (that would not work here).

The second "problem" that I have found appears when
compiling my wrapper class:

make[1]: Entering directory `/home/jj/Packages/PMatrix/v1/cmt'
Rebuilding ../i386_linux22/PMatrix_dependencies.make
make[1]: Leaving directory `/home/jj/Packages/PMatrix/v1/cmt'
make[1]: Entering directory `/home/jj/Packages/PMatrix/v1/cmt'
../i386_linux22/MatrixMachine.o
cd ../i386_linux22/; g++ -c -I"/home/jj/Packages/PMatrix/v1"
-I"../../../GSL/v1/src" -I"usr/local/include" -I"../../../NAGC/v6/src"
-I"/home/jj/Packages/NAGC/v6" -I"/home/jj/Software/NAGC/6.0/include"
-Df2cFortran -D__cplusplus -DHAVE_INLINE -fPIC -shared -D_GNU_SOURCE
-Dlinux -DLINUX -Dunix -pipe -ansi -Wall -W  -D_GNU_SOURCE -o
MatrixMachine.o                   ../src/MatrixMachine.cpp
In file included from
/usr/local/include/gsl/gsl_vector_complex_long_double.h:26,
                 from
/usr/local/include/gsl/gsl_matrix_complex_long_double.h:26,
                 from /usr/local/include/gsl/gsl_matrix.h:4,
                 from /home/jj/Packages/PMatrix/v1/PMatrix/PMatrix.h:11,
                 from ../src/MatrixMachine.cpp:10:
/usr/local/include/gsl/gsl_vector_long_double.h:58: warning: non-static
const member `const
gsl_vector_long_double {anonymous union}::vector' in class without a
constructorIn file included from
/usr/local/include/gsl/gsl_matrix_complex_long_double.h:26,
                 from /usr/local/include/gsl/gsl_matrix.h:4,
                 from /home/jj/Packages/PMatrix/v1/PMatrix/PMatrix.h:11,
                 from ../src/MatrixMachine.cpp:10:
/usr/local/include/gsl/gsl_vector_complex_long_double.h:60: warning:
non-static const member `const
gsl_vector_complex_long_double {anonymous union}::vector' in class without
a constructor
In file included from /usr/local/include/gsl/gsl_matrix.h:4,
                 from /home/jj/Packages/PMatrix/v1/PMatrix/PMatrix.h:11,
                 from ../src/MatrixMachine.cpp:10:
/usr/local/include/gsl/gsl_matrix_complex_long_double.h:59: warning:
non-static const member `const
gsl_matrix_complex_long_double {anonymous union}::matrix' in class without
a constructor
In file included from
/usr/local/include/gsl/gsl_vector_complex_double.h:26,
                 from
/usr/local/include/gsl/gsl_matrix_complex_double.h:26,
                 from /usr/local/include/gsl/gsl_matrix.h:5,
                 from /home/jj/Packages/PMatrix/v1/PMatrix/PMatrix.h:11,
                 from ../src/MatrixMachine.cpp:10:
/usr/local/include/gsl/gsl_vector_double.h:58: warning: non-static const
member `const gsl_vector
{anonymous union}::vector' in class without a constructor
In file included from
/usr/local/include/gsl/gsl_matrix_complex_double.h:26,
                 from /usr/local/include/gsl/gsl_matrix.h:5,
                 from /home/jj/Packages/PMatrix/v1/PMatrix/PMatrix.h:11,
                 from ../src/MatrixMachine.cpp:10:
/usr/local/include/gsl/gsl_vector_complex_double.h:60: warning: non-static
const member `const
gsl_vector_complex {anonymous union}::vector' in class without a
constructor
In file included from /usr/local/include/gsl/gsl_matrix.h:5,
                 from /home/jj/Packages/PMatrix/v1/PMatrix/PMatrix.h:11,
                 from ../src/MatrixMachine.cpp:10:
/usr/local/include/gsl/gsl_matrix_complex_double.h:59: warning: non-static
const member `const
gsl_matrix_complex {anonymous union}::matrix' in class without a
constructor
In file included from
/usr/local/include/gsl/gsl_vector_complex_float.h:26,
                 from
/usr/local/include/gsl/gsl_matrix_complex_float.h:26,
                 from /usr/local/include/gsl/gsl_matrix.h:6,
                 from /home/jj/Packages/PMatrix/v1/PMatrix/PMatrix.h:11,
                 from ../src/MatrixMachine.cpp:10:
/usr/local/include/gsl/gsl_vector_float.h:58: warning: non-static const
member `const gsl_vector_float
{anonymous union}::vector' in class without a constructor
In file included from
/usr/local/include/gsl/gsl_matrix_complex_float.h:26,
                 from /usr/local/include/gsl/gsl_matrix.h:6,
                 from /home/jj/Packages/PMatrix/v1/PMatrix/PMatrix.h:11,
                 from ../src/MatrixMachine.cpp:10:
/usr/local/include/gsl/gsl_vector

and so on. Is all the time the same type of warning. I have no idea how to
fix it.

Apologies for the lengthy mail and congratulations for the impressive work
done with gsl. Our idea is to incorporate as much as possible of the
library to our experiment's software.

best regards,
jj



Juan Jose Gomez Cadenas
Department of Atomic and Nuclear Physics and IFIC
University of Valencia

Edificio de Institutos de Paterna
Apto Correos 2085
46071 Valencia

telf. 96-3864500
fax-  96-3864583

e-mail             gomez@mail.cern.ch
                   gomez@hal.ific.uv.es


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]