Proposal for new functions for matrix manipulation.
Lukas Dobrek
dobrek@itp.uni-hannover.de
Tue Jan 28 16:05:00 GMT 2003
Whould anyone opose for adding int GSL the set of functions giving the
easy posibility of adding something to matrix element. For instanca
gsl_matrix_addto_el(gsl_matrix * M, size_t i, size_t j, add);
whould corespond to M->data[i*M->tda+j]+=add
and so on. Ofcourse with full rank checking and stuff.
Now the situation is a litle unconforteble if one wants to do it one can.
use gsl :
gsl_matrix_set(M,i,j,add+gsl_matrix_get(M,i,j));
or
M->data[i*M->lda+j]+=add;
the first one I dont like when I start thinking yes and what happends if
I set GSL_RANGE_CHECK_OFF.
I get something like:
M->data[i*M->tda+j]=M->data[i*M->tda+j]+add
and this of course I dont like.
Or I am wrong and compiler will optimize it to the same ?
But the simple test :
[dobrek@maldini ~]$ cat t.c
#define GSL_RANGE_CHECK_OFF 1
#include<gsl/gsl_matrix.h>
int main(){
gsl_matrix *M;
double add;
int i,j;
gsl_matrix_set(M,i,j,add+gsl_matrix_get(M,i,j));
}
[dobrek@maldini ~]$ gcc -S -O2 t.c
One can see in t.s that bouth functions are consecutively called
gsl_matrix_get and gsl_matrix_set.
Concluding I belive that this functions could be usefull and should be added.
Take care
Lukasz Dobrek
--
Łukasz Dobrek
An optimist believes that we live in the best of all possible worlds.
A pessimist is sure that this must be so.
http://www.pld-linux.org
More information about the Gsl-discuss
mailing list