Sang Oh wrote:
I'm trying to allocate memory in a function.
void ruler(double xa, double xb, double dx, gsl_vector *vc) {
vc = gsl_vector_alloc(len);
}
Looks like a common programming error, nothing to do with gsl. You
cannot globally change the _value_ of a parameter. You can only change
the value of the struct it points to. The gsl_vector_alloc call just
changes a local copy of vc and then throws it away when the function
returns, leaving a vector on the heap that you can't point to.
Try rewriting as
gsl_vector *ruler(double xa, double xb, double dx){
...
vc = gsl_vector_alloc(len);
...
return vc;
}