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: simple question on passing matrix arguments to functions


On July 3, 2003 10:57, John Boik wrote:
> Hello.  I have another simple question for the group.  There are no
> examples in the gsl manual (that I could find) of passing a matrix or
> vector to a function.  

Actually, there are quite a few examples throughout the Manual. For example, 
have a look at:
http://sources.redhat.com/gsl/ref/gsl-ref_33.html#SEC445

> If you create a matrix, say M, in main(), how do you
> pass it on to newfunction()?  I assume you pass the pointer as *M, but that
> does not seem to work for me.  In the new function, calls to
> gsl_matrix_get(M,i,j) give me an error on compilation.  

The newfunction should look something like this:

void newfunction ( gsl_matrix * M )
{
blah, blah, blah...
}

and you call it from main as
newfunction(M);

> Do you need to use
> a gsl_matrix_view_array command to remake the matrix in newfunction()?

I don't think so.

Slaven


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