[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] gsl alloc runtime error
From: |
Petr Ent |
Subject: |
[Help-gsl] gsl alloc runtime error |
Date: |
Wed, 28 Jun 2006 14:31:30 +0200 (CEST) |
i have been experiencing troubles with allocating objects with gsl functions
i copied example code of nonlinear fitting from manual. it could be compiled
and linked with no problem. but when i run it and call some memory-allocation
function, it crashes because of "AccesViolation runtime error in libgsl.dll"
here is the code
const gsl_multifit_fdfsolver_type *T;
gsl_multifit_fdfsolver *s;
int status;
size_t i, iter = 0;
const size_t n = N;
const size_t p = 3;
gsl_matrix *covar = gsl_matrix_alloc (p, p);
double y[N], sigma[N];
struct data d = { n, y, sigma};
gsl_multifit_function_fdf f;
double x_init[3] = { 1.0, 0.0, 0.0 };
gsl_vector_view x = gsl_vector_view_array (x_init, p);
const gsl_rng_type * type;
gsl_rng * r;
gsl_rng_env_setup();
type = gsl_rng_default;
r = gsl_rng_alloc (type);
<--------------------------------------------------- this causes crash
f.f = &expb_f;
f.df = &expb_df;
f.fdf = &expb_fdf;
f.n = n;
f.p = p;
f.params = &d;
/* This is the data to be fitted */
for (i = 0; i < n; i++)
{
double t = i;
y[i] = 1.0 + 5 * exp (-0.1 * t)
+ gsl_ran_gaussian (r, 0.1);
sigma[i] = 0.1;
printf ("data: %d %g %g\n", i, y[i], sigma[i]);
};
T = gsl_multifit_fdfsolver_lmsder;
s = gsl_multifit_fdfsolver_alloc (T, n, p);
gsl_multifit_fdfsolver_set (s, &f, &x.vector);
when i comment it out, it crashes at next alloc
("s=gsl_multifit_fdfsolver_alloc (T, n, p);" line)
anybody has some idea what it is caused by?
Petr Ent
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Help-gsl] gsl alloc runtime error,
Petr Ent <=