[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gsl] error in multifit/multiwlinear.c in gsl-2.3 and gsl-2.4
From: |
Patrick Alken |
Subject: |
Re: [Bug-gsl] error in multifit/multiwlinear.c in gsl-2.3 and gsl-2.4 |
Date: |
Sun, 11 Feb 2018 14:28:59 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 |
Hello,
I responded to this yesterday. The issue was the
gsl_multifit_wlinear_svd function is deprecated (replaced by
gsl_multifit_wlinear_tsvd), and I hadn't tested the old function. The
issue should be fixed now in the git repository. Could you checkout the
latest git code and test your program?
Thanks,
Patrick
On 02/11/2018 12:44 PM, Vlad Koli wrote:
> 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:---------
>
>
>