gsl_matrix_add

John Lamb J.D.Lamb@btinternet.com
Wed Aug 4 17:51:00 GMT 2004


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



More information about the Gsl-discuss mailing list