[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-gsl] error in multifit/multiwlinear.c in gsl-2.3 and gsl-2.4
From: |
Vlad Koli |
Subject: |
[Bug-gsl] error in multifit/multiwlinear.c in gsl-2.3 and gsl-2.4 |
Date: |
Sun, 11 Feb 2018 21:44:47 +0200 |
User-agent: |
NeoMutt/20170113 (1.7.2) |
Hi,
There is an error in file multifit/multiwlinear.c. It is present at least
in sources for gsl-2.3, gsl-2.4.
Line 69 should be replaced (I think) from:
else if (X->size1 != work->n || X->size2 != work->p)
to
else if (X->size1 != work->nmax || X->size2 != work->pmax) // vk:
Values of "work->n", "work->p" for this file, for example, are nulls.
After this replacement, re-compilation, and re-installation the tests
began to work correctly.
Check, for example the test file "linfit-pseudoinv.c" quoted below.
** compilation:
cc -o a -lm -lgsl -lgslcblas linfit-pseudoinv.c
** execution:
./a
** result:
> gsl: multiwlinear.c:73: ERROR: size of workspace does not match size of
> observation matrix
> Default GSL error handler invoked.
> Aborted
Regards,
Vladimir Koliadin
----- begin file: linfit-pseudoinv.c:---------
// compile:
// cc -o a -lm -lgsl -lgslcblas linfit-pseudoinv.c
#include <stdio.h>
#include <gsl/gsl_multifit.h>
double tol = 1.e-08; // tolerance
main()
{
int n = 3; // observations
int m = 2; // parameters
size_t rank; // rank
double chisq; // sum of squares of residuals
// allocate:
gsl_vector *x = gsl_vector_alloc(m); // solution
gsl_vector *y = gsl_vector_alloc(n); // data
gsl_vector *w = gsl_vector_alloc(n); // weights
gsl_matrix *A = gsl_matrix_alloc(n, m);
gsl_matrix *cov = gsl_matrix_alloc(m, m); // covariances
gsl_multifit_linear_workspace* wsp = gsl_multifit_linear_alloc (n, m);
// set matrix
gsl_matrix_set(A, 0,0, 1.);
gsl_matrix_set(A, 0,1, 1.);
gsl_matrix_set(A, 1,0, 2.);
gsl_matrix_set(A, 1,1, 2.);
gsl_matrix_set(A, 2,0, 3.);
gsl_matrix_set(A, 2,1, 3.);
// set data
gsl_vector_set(y, 0, 1.);
gsl_vector_set(y, 1, 2.);
gsl_vector_set(y, 2, 3.1);
// set weights
gsl_vector_set_all(w,1.);
gsl_vector_set(w, 0, 0.);
gsl_vector_set(w, 2, 100.);
gsl_multifit_wlinear_svd (A, w, y, tol, &rank, x, cov, &chisq, wsp);
printf("solution: x=%.4f y=%.4f (rank=%d, chi2=%.3f)\n",
gsl_vector_get(x,0), gsl_vector_get(x,1), rank, chisq);
}
----- end file: linfit-pseudoinv.c:---------
- [Bug-gsl] error in multifit/multiwlinear.c in gsl-2.3 and gsl-2.4,
Vlad Koli <=