help-gsl
[Top][All Lists]
Advanced

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

[Help-gsl] gsl_vector_alloc question.


From: Sang Oh
Subject: [Help-gsl] gsl_vector_alloc question.
Date: Tue, 13 Jul 2004 15:43:31 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2) Gecko/20040308

Hi,

I'm trying to allocate memory in a function.

file: ruler.c
******************
void ruler(double xa, double xb, double dx, gsl_vector *vc) {
 //reates a vector with left limit xa, right limit xb
 //with dx intervals

 int i;
 size_t len=(int)((xb-xa)/dx)+1;
 vc = gsl_vector_alloc(len);
 for (i=0;i<len;++i) {
   gsl_vector_set(vc,i,xa+i*dx);
 }
 vc->owner = 0;
}
********************

file: mainprog.c
**********************
int main() {

gsl_vector *v;
ruler(-1.0,1.0,0.5,v);

}
**********************

I am compiling with,

>gcc -c ruler.c
>gcc mainprog.c ruler.o -lgsl -lcblas -latlas -lm

vector "vc" seems to be fine, but it returns nonsense when i try to access "v" in the main program.
i'm setting the owner flag to zero in case it is being deallocated.

what am I doing wrong?

help~

Thanks.  =)

Sang





reply via email to

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