[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-gsl] Matrix memory deallocation problem

From: James Bergstra
Subject: Re: [Help-gsl] Matrix memory deallocation problem
Date: Thu, 6 Jul 2006 17:19:26 +0200
User-agent: Mutt/1.5.11+cvs20060403

On Thu, Jul 06, 2006 at 04:02:06PM +0100, Wei Cheng wrote:
> I know it would be more efficient to do it in  BLAS way, but , the reason i
> need the matrix matrix multiplication function to return a matrix result is
> because I have very complicated matrix operations, this matrix product is just
> an argument of another matrix  operation whose result may be the argument of
> another matrix operation. If the function returns the product ,i don't need to
> declare extra result matrix, which make the code neat and easy to understand,
> an example can be:
> gsl_matrix* A,B,C,D;
> matrix_matrix_add(matrix_matrix_mul(A,B),matrix_matrix_mul(C,D)); 
> //(AXB)+(CXD)

This looks like a functional programming style. I think the convention
in functional programming is for functions to destroy their arguments.
In that view, the problem with your original test loop is that you
weren't doing anything with your result.  If you had passed it into a
determinant function for example, the determinant function would have
freed your matrix and returned a scalar on the stack, there would be no


reply via email to

[Prev in Thread] Current Thread [Next in Thread]