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]
Other format: [Raw text]

Re: gsl_matrix_add


Roman Werpachowski wrote:
Since gsl_matrix_add is a basic function for adding matrices, it should perfom and operation

gsl_matrix_add(a, b, c) --> c = a + b

not just

gsl_matrix_add(a, b) --> a = a + b.

Now to add two matrices and store the result in the third, I have to call two functions instead of just one.


The second is more efficient if you want the equivalent of the C operation


a += b;

You could write your own function

gsl_matrix_Add( gsl_matrix* c,
                const gsl_matrix* a, const gsl_matrix* b ){
  gsl_matrix_copy( c, a );
  gsl_mtarix_add( c, b);
}

Then you only have to call one function. If you use C++, you can even give both functions the same name ;-)



--
JDL


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