Debian Codegraph @

external/gsl/gsl_multifit__multilinear.c

raw symbols SCIP
1 /* multifit/multilinear.c
2 *
3 * Copyright (C) 2000, 2007 Brian Gough
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20 #include "gsl__config.h"cxx . . $ `<file>/external/gsl/gsl__config.h`/
21 #include "gsl_errno.h"cxx . . $ `<file>/external/gsl/gsl_errno.h`/
22 #include "gsl_multifit.h"cxx . . $ `<file>/external/gsl/gsl_multifit.h`/
23 #include "gsl_blas.h"cxx . . $ `<file>/external/gsl/gsl_blas.h`/
24 #include "gsl_linalg.h"cxx . . $ `<file>/external/gsl/gsl_linalg.h`/
25
26 /* Fit
27 *
28 * y = X c
29 *
30 * where X is an M x N matrix of M observations for N variables.
31 *
32 */
33
34 int
35 gsl_multifit_linearcxx . . $ gsl_multifit_linear(6cc60e40782e5de). (const gsl_matrixcxx . . $ gsl_matrix# * X,
36 const gsl_vectorcxx . . $ gsl_vector# * y,
37 gsl_vectorcxx . . $ gsl_vector# * c,
38 gsl_matrixcxx . . $ gsl_matrix# * cov,
39 double *chisq, gsl_multifit_linear_workspacecxx . . $ gsl_multifit_linear_workspace# * work)
40 {
41 size_tcxx . . $ size_t# rank;
42 int status = gsl_multifit_linear_svdcxx . . $ gsl_multifit_linear_svd(2af8e00357212136). (X, y, GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`!, &rank, c,
43 cov, chisq, work);
44 return status;
45 }
46
47 /* Handle the general case of the SVD with tolerance and rank */
48
49 int
50 gsl_multifit_linear_svdcxx . . $ gsl_multifit_linear_svd(2af8e00357212136). (const gsl_matrixcxx . . $ gsl_matrix# * X,
51 const gsl_vectorcxx . . $ gsl_vector# * y,
52 double tol,
53 size_tcxx . . $ size_t# * rank,
54 gsl_vectorcxx . . $ gsl_vector# * c,
55 gsl_matrixcxx . . $ gsl_matrix# * cov,
56 double *chisq, gsl_multifit_linear_workspacecxx . . $ gsl_multifit_linear_workspace# * work)
57 {
58 if (X->size1cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size1. != y->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size.)
59 {
60 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`!
61 ("number of observations in y does not match rows of matrix X",
62 GSL_EBADLEN);
63 }
64 else if (X->size2cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size2. != c->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size.)
65 {
66 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("number of parameters c does not match columns of matrix X",
67 GSL_EBADLEN);
68 }
69 else if (cov->size1cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size1. != cov->size2cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size2.)
70 {
71 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("covariance matrix is not square", GSL_ENOTSQR);
72 }
73 else if (c->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size. != cov->size1cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size1.)
74 {
75 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`!
76 ("number of parameters does not match size of covariance matrix",
77 GSL_EBADLEN);
78 }
79 else if (X->size1cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size1. != work->ncxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#n. || X->size2cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size2. != work->pcxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#p.)
80 {
81 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`!
82 ("size of workspace does not match size of observation matrix",
83 GSL_EBADLEN);
84 }
85 else if (tol <= 0)
86 {
87 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("tolerance must be positive", GSL_EINVAL);
88 }
89 else
90 {
91 const size_tcxx . . $ size_t# n = X->size1cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size1.;
92 const size_tcxx . . $ size_t# p = X->size2cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size2.;
93
94 size_tcxx . . $ size_t# i, j, p_eff;
95
96 gsl_matrixcxx . . $ gsl_matrix# *A = work->Acxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#A.;
97 gsl_matrixcxx . . $ gsl_matrix# *Q = work->Qcxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#Q.;
98 gsl_matrixcxx . . $ gsl_matrix# *QSI = work->QSIcxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#QSI.;
99 gsl_vectorcxx . . $ gsl_vector# *S = work->Scxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#S.;
100 gsl_vectorcxx . . $ gsl_vector# *xt = work->xtcxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#xt.;
101 gsl_vectorcxx . . $ gsl_vector# *D = work->Dcxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#D.;
102
103 /* Copy X to workspace, A <= X */
104
105 gsl_matrix_memcpycxx . . $ gsl_matrix_memcpy(2d55a18be0e0c72f). (A, X);
106
107 /* Balance the columns of the matrix A */
108
109 gsl_linalg_balance_columnscxx . . $ gsl_linalg_balance_columns(2b074ddc1e11e0af). (A, D);
110
111 /* Decompose A into U S Q^T */
112
113 gsl_linalg_SV_decomp_modcxx . . $ gsl_linalg_SV_decomp_mod(f36b3cd83547cafa). (A, QSI, Q, S, xt);
114
115 /* Solve y = A c for c */
116
117 gsl_blas_dgemvcxx . . $ gsl_blas_dgemv(ae04c3c4cab3cc37). (CblasTranscxx . . $ CblasTrans., 1.0, A, y, 0.0, xt);
118
119 /* Scale the matrix Q, Q' = Q S^-1 */
120
121 gsl_matrix_memcpycxx . . $ gsl_matrix_memcpy(2d55a18be0e0c72f). (QSI, Q);
122
123 {
124 double alpha0 = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (S, 0);
125 p_eff = 0;
126
127 for (j = 0; j < p; j++)
128 {
129 gsl_vector_viewcxx . . $ gsl_vector_view# column = gsl_matrix_columncxx . . $ gsl_matrix_column(127874ddf25d9e6a). (QSI, j);
130 double alpha = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (S, j);
131
132 if (alpha <= tol * alpha0) {
133 alpha = 0.0;
134 } else {
135 alpha = 1.0 / alpha;
136 p_eff++;
137 }
138
139 gsl_vector_scalecxx . . $ gsl_vector_scale(ddf696d31a4a9aeb). (&column.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector., alpha);
140 }
141
142 *rank = p_eff;
143 }
144
145 gsl_vector_set_zerocxx . . $ gsl_vector_set_zero(5d65852ca0326259). (c);
146
147 gsl_blas_dgemvcxx . . $ gsl_blas_dgemv(ae04c3c4cab3cc37). (CblasNoTranscxx . . $ CblasNoTrans., 1.0, QSI, xt, 0.0, c);
148
149 /* Unscale the balancing factors */
150
151 gsl_vector_divcxx . . $ gsl_vector_div(950c164c4e50c555). (c, D);
152
153 /* Compute chisq, from residual r = y - X c */
154
155 {
156 double s2 = 0, r2 = 0;
157
158 for (i = 0; i < n; i++)
159 {
160 double yi = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (y, i);
161 gsl_vector_const_viewcxx . . $ gsl_vector_const_view# row = gsl_matrix_const_rowcxx . . $ gsl_matrix_const_row(ddcc4d81452c888e). (X, i);
162 double y_est, ri;
163 gsl_blas_ddotcxx . . $ gsl_blas_ddot(1ee5503a249d268f). (&row.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_2#vector., c, &y_est);
164 ri = yi - y_est;
165 r2 += ri * ri;
166 }
167
168 s2 = r2 / (n - p_eff); /* p_eff == rank */
169
170 *chisq = r2;
171
172 /* Form variance-covariance matrix cov = s2 * (Q S^-1) (Q S^-1)^T */
173
174 for (i = 0; i < p; i++)
175 {
176 gsl_vector_viewcxx . . $ gsl_vector_view# row_i = gsl_matrix_rowcxx . . $ gsl_matrix_row(127874ddf25d9e6a). (QSI, i);
177 double d_i = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (D, i);
178
179 for (j = i; j < p; j++)
180 {
181 gsl_vector_viewcxx . . $ gsl_vector_view# row_j = gsl_matrix_rowcxx . . $ gsl_matrix_row(127874ddf25d9e6a). (QSI, j);
182 double d_j = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (D, j);
183 double s;
184
185 gsl_blas_ddotcxx . . $ gsl_blas_ddot(1ee5503a249d268f). (&row_i.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector., &row_j.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector., &s);
186
187 gsl_matrix_setcxx . . $ gsl_matrix_set(b56d954874bd7b13). (cov, i, j, s * s2 / (d_i * d_j));
188 gsl_matrix_setcxx . . $ gsl_matrix_set(b56d954874bd7b13). (cov, j, i, s * s2 / (d_i * d_j));
189 }
190 }
191 }
192
193 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
194 }
195 }
196
197 int
198 gsl_multifit_wlinearcxx . . $ gsl_multifit_wlinear(c5d10f9f34e59be). (const gsl_matrixcxx . . $ gsl_matrix# * X,
199 const gsl_vectorcxx . . $ gsl_vector# * w,
200 const gsl_vectorcxx . . $ gsl_vector# * y,
201 gsl_vectorcxx . . $ gsl_vector# * c,
202 gsl_matrixcxx . . $ gsl_matrix# * cov,
203 double *chisq, gsl_multifit_linear_workspacecxx . . $ gsl_multifit_linear_workspace# * work)
204 {
205 size_tcxx . . $ size_t# rank;
206 int status = gsl_multifit_wlinear_svdcxx . . $ gsl_multifit_wlinear_svd(4cb2822643572d53). (X, w, y, GSL_DBL_EPSILONcxx . . $ `external/gsl/gsl_machine.h:17:9`!, &rank, c,
207 cov, chisq, work);
208 return status;
209 }
210
211
212 int
213 gsl_multifit_wlinear_svdcxx . . $ gsl_multifit_wlinear_svd(4cb2822643572d53). (const gsl_matrixcxx . . $ gsl_matrix# * X,
214 const gsl_vectorcxx . . $ gsl_vector# * w,
215 const gsl_vectorcxx . . $ gsl_vector# * y,
216 double tol,
217 size_tcxx . . $ size_t# * rank,
218 gsl_vectorcxx . . $ gsl_vector# * c,
219 gsl_matrixcxx . . $ gsl_matrix# * cov,
220 double *chisq, gsl_multifit_linear_workspacecxx . . $ gsl_multifit_linear_workspace# * work)
221 {
222 if (X->size1cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size1. != y->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size.)
223 {
224 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`!
225 ("number of observations in y does not match rows of matrix X",
226 GSL_EBADLEN);
227 }
228 else if (X->size2cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size2. != c->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size.)
229 {
230 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("number of parameters c does not match columns of matrix X",
231 GSL_EBADLEN);
232 }
233 else if (w->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size. != y->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size.)
234 {
235 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("number of weights does not match number of observations",
236 GSL_EBADLEN);
237 }
238 else if (cov->size1cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size1. != cov->size2cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size2.)
239 {
240 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("covariance matrix is not square", GSL_ENOTSQR);
241 }
242 else if (c->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size. != cov->size1cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size1.)
243 {
244 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`!
245 ("number of parameters does not match size of covariance matrix",
246 GSL_EBADLEN);
247 }
248 else if (X->size1cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size1. != work->ncxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#n. || X->size2cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size2. != work->pcxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#p.)
249 {
250 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`!
251 ("size of workspace does not match size of observation matrix",
252 GSL_EBADLEN);
253 }
254 else
255 {
256 const size_tcxx . . $ size_t# n = X->size1cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size1.;
257 const size_tcxx . . $ size_t# p = X->size2cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size2.;
258
259 size_tcxx . . $ size_t# i, j, p_eff;
260
261 gsl_matrixcxx . . $ gsl_matrix# *A = work->Acxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#A.;
262 gsl_matrixcxx . . $ gsl_matrix# *Q = work->Qcxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#Q.;
263 gsl_matrixcxx . . $ gsl_matrix# *QSI = work->QSIcxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#QSI.;
264 gsl_vectorcxx . . $ gsl_vector# *S = work->Scxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#S.;
265 gsl_vectorcxx . . $ gsl_vector# *t = work->tcxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#t.;
266 gsl_vectorcxx . . $ gsl_vector# *xt = work->xtcxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#xt.;
267 gsl_vectorcxx . . $ gsl_vector# *D = work->Dcxx . . $ $anonymous_type_d33a18e1d59ca0ff_0#D.;
268
269 /* Scale X, A = sqrt(w) X */
270
271 gsl_matrix_memcpycxx . . $ gsl_matrix_memcpy(2d55a18be0e0c72f). (A, X);
272
273 for (i = 0; i < n; i++)
274 {
275 double wi = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (w, i);
276
277 if (wi < 0)
278 wi = 0;
279
280 {
281 gsl_vector_viewcxx . . $ gsl_vector_view# row = gsl_matrix_rowcxx . . $ gsl_matrix_row(127874ddf25d9e6a). (A, i);
282 gsl_vector_scalecxx . . $ gsl_vector_scale(ddf696d31a4a9aeb). (&row.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector., sqrt (wi));
283 }
284 }
285
286 /* Balance the columns of the matrix A */
287
288 gsl_linalg_balance_columnscxx . . $ gsl_linalg_balance_columns(2b074ddc1e11e0af). (A, D);
289
290 /* Decompose A into U S Q^T */
291
292 gsl_linalg_SV_decomp_modcxx . . $ gsl_linalg_SV_decomp_mod(f36b3cd83547cafa). (A, QSI, Q, S, xt);
293
294 /* Solve sqrt(w) y = A c for c, by first computing t = sqrt(w) y */
295
296 for (i = 0; i < n; i++)
297 {
298 double wi = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (w, i);
299 double yi = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (y, i);
300 if (wi < 0)
301 wi = 0;
302 gsl_vector_setcxx . . $ gsl_vector_set(c35f863a529e8fae). (t, i, sqrt (wi) * yi);
303 }
304
305 gsl_blas_dgemvcxx . . $ gsl_blas_dgemv(ae04c3c4cab3cc37). (CblasTranscxx . . $ CblasTrans., 1.0, A, t, 0.0, xt);
306
307 /* Scale the matrix Q, Q' = Q S^-1 */
308
309 gsl_matrix_memcpycxx . . $ gsl_matrix_memcpy(2d55a18be0e0c72f). (QSI, Q);
310
311 {
312 double alpha0 = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (S, 0);
313 p_eff = 0;
314
315 for (j = 0; j < p; j++)
316 {
317 gsl_vector_viewcxx . . $ gsl_vector_view# column = gsl_matrix_columncxx . . $ gsl_matrix_column(127874ddf25d9e6a). (QSI, j);
318 double alpha = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (S, j);
319
320 if (alpha <= tol * alpha0) {
321 alpha = 0.0;
322 } else {
323 alpha = 1.0 / alpha;
324 p_eff++;
325 }
326
327 gsl_vector_scalecxx . . $ gsl_vector_scale(ddf696d31a4a9aeb). (&column.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector., alpha);
328 }
329
330 *rank = p_eff;
331 }
332
333 gsl_vector_set_zerocxx . . $ gsl_vector_set_zero(5d65852ca0326259). (c);
334
335 /* Solution */
336
337 gsl_blas_dgemvcxx . . $ gsl_blas_dgemv(ae04c3c4cab3cc37). (CblasNoTranscxx . . $ CblasNoTrans., 1.0, QSI, xt, 0.0, c);
338
339 /* Unscale the balancing factors */
340
341 gsl_vector_divcxx . . $ gsl_vector_div(950c164c4e50c555). (c, D);
342
343 /* Form covariance matrix cov = (Q S^-1) (Q S^-1)^T */
344
345 for (i = 0; i < p; i++)
346 {
347 gsl_vector_viewcxx . . $ gsl_vector_view# row_i = gsl_matrix_rowcxx . . $ gsl_matrix_row(127874ddf25d9e6a). (QSI, i);
348 double d_i = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (D, i);
349
350 for (j = i; j < p; j++)
351 {
352 gsl_vector_viewcxx . . $ gsl_vector_view# row_j = gsl_matrix_rowcxx . . $ gsl_matrix_row(127874ddf25d9e6a). (QSI, j);
353 double d_j = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (D, j);
354 double s;
355
356 gsl_blas_ddotcxx . . $ gsl_blas_ddot(1ee5503a249d268f). (&row_i.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector., &row_j.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_1#vector., &s);
357
358 gsl_matrix_setcxx . . $ gsl_matrix_set(b56d954874bd7b13). (cov, i, j, s / (d_i * d_j));
359 gsl_matrix_setcxx . . $ gsl_matrix_set(b56d954874bd7b13). (cov, j, i, s / (d_i * d_j));
360 }
361 }
362
363 /* Compute chisq, from residual r = y - X c */
364
365 {
366 double r2 = 0;
367
368 for (i = 0; i < n; i++)
369 {
370 double yi = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (y, i);
371 double wi = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (w, i);
372 gsl_vector_const_viewcxx . . $ gsl_vector_const_view# row = gsl_matrix_const_rowcxx . . $ gsl_matrix_const_row(ddcc4d81452c888e). (X, i);
373 double y_est, ri;
374 gsl_blas_ddotcxx . . $ gsl_blas_ddot(1ee5503a249d268f). (&row.vectorcxx . . $ $anonymous_type_a8c2e3e00d6867c2_2#vector., c, &y_est);
375 ri = yi - y_est;
376 r2 += wi * ri * ri;
377 }
378
379 *chisq = r2;
380 }
381
382 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
383 }
384 }
385
386
387 int
388 gsl_multifit_linear_estcxx . . $ gsl_multifit_linear_est(93ef1d3aad9c3a5c). (const gsl_vectorcxx . . $ gsl_vector# * x,
389 const gsl_vectorcxx . . $ gsl_vector# * c,
390 const gsl_matrixcxx . . $ gsl_matrix# * cov, double *y, double *y_err)
391 {
392
393 if (x->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size. != c->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size.)
394 {
395 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("number of parameters c does not match number of observations x",
396 GSL_EBADLEN);
397 }
398 else if (cov->size1cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size1. != cov->size2cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size2.)
399 {
400 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("covariance matrix is not square", GSL_ENOTSQR);
401 }
402 else if (c->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size. != cov->size1cxx . . $ $anonymous_type_2f547ace9ee68af9_0#size1.)
403 {
404 GSL_ERRORcxx . . $ `external/gsl/gsl_errno.h:104:9`! ("number of parameters c does not match size of covariance matrix cov",
405 GSL_EBADLEN);
406 }
407 else
408 {
409 size_tcxx . . $ size_t# i, j;
410 double var = 0;
411
412 gsl_blas_ddotcxx . . $ gsl_blas_ddot(1ee5503a249d268f).(x, c, y); /* y = x.c */
413
414 /* var = x' cov x */
415
416 for (i = 0; i < x->sizecxx . . $ $anonymous_type_a8c2e3e00d6867c2_0#size.; i++)
417 {
418 const double xi = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (x, i);
419 var += xi * xi * gsl_matrix_getcxx . . $ gsl_matrix_get(dfa4c0641bd665a5). (cov, i, i);
420
421 for (j = 0; j < i; j++)
422 {
423 const double xj = gsl_vector_getcxx . . $ gsl_vector_get(bd1f20df78adc7a). (x, j);
424 var += 2 * xi * xj * gsl_matrix_getcxx . . $ gsl_matrix_get(dfa4c0641bd665a5). (cov, i, j);
425 }
426 }
427
428 *y_err = sqrt (var);
429
430 return GSL_SUCCESScxx . . $ GSL_SUCCESS.;
431 }
432 }