From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2857 invoked by alias); 4 Mar 2005 16:09:05 -0000 Mailing-List: contact gsl-discuss-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gsl-discuss-owner@sources.redhat.com Received: (qmail 32729 invoked from network); 4 Mar 2005 14:11:47 -0000 Date: Fri, 04 Mar 2005 16:09:00 -0000 From: Giulio Bottazzi To: gsl-discuss@sources.redhat.com Subject: gsl_multifit_linear_est Message-Id: <20050304151143.6abcc503.bottazzi@sssup.it> Organization: Scuola Superiore Sant'Anna. Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="Signature=_Fri__4_Mar_2005_15_11_43_+0100_gt+/KpC09tsRqeaL" X-SW-Source: 2005-q1/txt/msg00099.txt.bz2 --Signature=_Fri__4_Mar_2005_15_11_43_+0100_gt+/KpC09tsRqeaL Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: 7bit Content-length: 1629 hello I've noticed that the function in subject is not currently implemented in GSL. The following code is a possible (highly non-optimal) candidate. I can send patch w.r.t. CVS if preferred. Giulio. int gsl_multifit_linear_est (const gsl_vector *x, const gsl_vector *c, const gsl_matrix *cov, double *y, double *y_err) { if (x->size != c->size) { GSL_ERROR ("number of parameters c does not match number of observations x", GSL_EBADLEN); } else if (cov->size1 != cov->size2) { GSL_ERROR ("covariance matrix is not square", GSL_ENOTSQR); } else if (c->size != cov->size1) { GSL_ERROR ("number of parameters does not match size of covariance matrix", GSL_EBADLEN); } else{ size_t dim = x->size; size_t i,j; double estimate,estimate_err; estimate=0.0; for(i=0;isize;i++) estimate += gsl_vector_get (x,i)*gsl_vector_get (c,i); estimate_err=0.0; for(i=0;isize;i++){ const double dtmp1=gsl_vector_get (x,i); estimate_err += dtmp1*dtmp1*gsl_matrix_get(cov,i,i); for(j=0;j