3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2006, 2007, 2019 Gerard Jungman, Brian Gough, Patrick Alken
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.
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.
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.
20 #ifndef __GSL_LINALG_H__
21 #define __GSL_LINALG_H__
24 #include <gsl/gsl_mode.h>
25 #include <gsl/gsl_permutation.h>
26 #include <gsl/gsl_vector.h>
27 #include <gsl/gsl_matrix.h>
28 #include <gsl/gsl_math.h>
29 #include <gsl/gsl_inline.h>
30 #include <gsl/gsl_blas.h>
35 #define __BEGIN_DECLS extern "C" {
38 #define __BEGIN_DECLS /* empty */
39 #define __END_DECLS /* empty */
46 GSL_LINALG_MOD_NONE = 0,
47 GSL_LINALG_MOD_TRANSPOSE = 1,
48 GSL_LINALG_MOD_CONJUGATE = 2
50 gsl_linalg_matrix_mod_t;
52 /* Note: You can now use the gsl_blas_dgemm function instead of matmult */
54 /* Simple implementation of matrix multiply.
57 * exceptions: GSL_EBADLEN
59 int gsl_linalg_matmult (const gsl_matrix * A,
64 /* Simple implementation of matrix multiply.
65 * Allows transposition of either matrix, so it
66 * can compute A.B or Trans(A).B or A.Trans(B) or Trans(A).Trans(B)
68 * exceptions: GSL_EBADLEN
70 int gsl_linalg_matmult_mod (const gsl_matrix * A,
71 gsl_linalg_matrix_mod_t modA,
73 gsl_linalg_matrix_mod_t modB,
76 /* Calculate the matrix exponential by the scaling and
77 * squaring method described in Moler + Van Loan,
78 * SIAM Rev 20, 801 (1978). The mode argument allows
79 * choosing an optimal strategy, from the table
80 * given in the paper, for a given precision.
82 * exceptions: GSL_ENOTSQR, GSL_EBADLEN
84 int gsl_linalg_exponential_ss(
91 /* Householder Transformations */
93 double gsl_linalg_householder_transform (gsl_vector * v);
94 double gsl_linalg_householder_transform2 (double * alpha, gsl_vector * v);
95 gsl_complex gsl_linalg_complex_householder_transform (gsl_vector_complex * v);
97 int gsl_linalg_householder_hm (double tau,
101 int gsl_linalg_householder_mh (double tau,
102 const gsl_vector * v,
105 int gsl_linalg_householder_hv (double tau,
106 const gsl_vector * v,
109 int gsl_linalg_householder_left(const double tau,
110 const gsl_vector * v,
114 int gsl_linalg_householder_right(const double tau,
115 const gsl_vector * v,
119 int gsl_linalg_householder_hm1 (double tau,
122 int gsl_linalg_complex_householder_hm (gsl_complex tau,
123 const gsl_vector_complex * v,
124 gsl_matrix_complex * A);
126 int gsl_linalg_complex_householder_mh (gsl_complex tau,
127 const gsl_vector_complex * v,
128 gsl_matrix_complex * A);
130 int gsl_linalg_complex_householder_hv (gsl_complex tau,
131 const gsl_vector_complex * v,
132 gsl_vector_complex * w);
134 int gsl_linalg_complex_householder_left (const gsl_complex tau,
135 const gsl_vector_complex * v,
136 gsl_matrix_complex * A,
137 gsl_vector_complex * work);
139 /* Hessenberg reduction */
141 int gsl_linalg_hessenberg_decomp(gsl_matrix *A, gsl_vector *tau);
142 int gsl_linalg_hessenberg_unpack(gsl_matrix * H, gsl_vector * tau,
144 int gsl_linalg_hessenberg_unpack_accum(gsl_matrix * H, gsl_vector * tau,
146 int gsl_linalg_hessenberg_set_zero(gsl_matrix * H);
147 int gsl_linalg_hessenberg_submatrix(gsl_matrix *M, gsl_matrix *A,
148 size_t top, gsl_vector *tau);
150 /* Hessenberg-Triangular reduction */
152 int gsl_linalg_hesstri_decomp(gsl_matrix * A, gsl_matrix * B,
153 gsl_matrix * U, gsl_matrix * V,
156 /* Singular Value Decomposition
162 gsl_linalg_SV_decomp (gsl_matrix * A,
168 gsl_linalg_SV_decomp_mod (gsl_matrix * A,
174 int gsl_linalg_SV_decomp_jacobi (gsl_matrix * A,
179 gsl_linalg_SV_solve (const gsl_matrix * U,
180 const gsl_matrix * Q,
181 const gsl_vector * S,
182 const gsl_vector * b,
185 int gsl_linalg_SV_leverage(const gsl_matrix *U, gsl_vector *h);
188 /* LU Decomposition, Gaussian elimination with partial pivoting
191 int gsl_linalg_LU_decomp (gsl_matrix * A, gsl_permutation * p, int *signum);
193 int gsl_linalg_LU_solve (const gsl_matrix * LU,
194 const gsl_permutation * p,
195 const gsl_vector * b,
198 int gsl_linalg_LU_svx (const gsl_matrix * LU,
199 const gsl_permutation * p,
202 int gsl_linalg_LU_refine (const gsl_matrix * A,
203 const gsl_matrix * LU,
204 const gsl_permutation * p,
205 const gsl_vector * b,
209 int gsl_linalg_LU_invert (const gsl_matrix * LU,
210 const gsl_permutation * p,
211 gsl_matrix * inverse);
212 int gsl_linalg_LU_invx (gsl_matrix * LU, const gsl_permutation * p);
214 double gsl_linalg_LU_det (gsl_matrix * LU, int signum);
215 double gsl_linalg_LU_lndet (gsl_matrix * LU);
216 int gsl_linalg_LU_sgndet (gsl_matrix * lu, int signum);
218 /* Banded LU decomposition */
220 int gsl_linalg_LU_band_decomp (const size_t M, const size_t lb, const size_t ub, gsl_matrix * AB, gsl_vector_uint * piv);
222 int gsl_linalg_LU_band_solve (const size_t lb, const size_t ub, const gsl_matrix * LUB,
223 const gsl_vector_uint * piv, const gsl_vector * b, gsl_vector * x);
225 int gsl_linalg_LU_band_svx (const size_t lb, const size_t ub, const gsl_matrix * LUB,
226 const gsl_vector_uint * piv, gsl_vector * x);
228 int gsl_linalg_LU_band_unpack (const size_t M, const size_t lb, const size_t ub, const gsl_matrix * LUB,
229 const gsl_vector_uint * piv, gsl_matrix * L, gsl_matrix * U);
231 /* Complex LU Decomposition */
233 int gsl_linalg_complex_LU_decomp (gsl_matrix_complex * A,
237 int gsl_linalg_complex_LU_solve (const gsl_matrix_complex * LU,
238 const gsl_permutation * p,
239 const gsl_vector_complex * b,
240 gsl_vector_complex * x);
242 int gsl_linalg_complex_LU_svx (const gsl_matrix_complex * LU,
243 const gsl_permutation * p,
244 gsl_vector_complex * x);
246 int gsl_linalg_complex_LU_refine (const gsl_matrix_complex * A,
247 const gsl_matrix_complex * LU,
248 const gsl_permutation * p,
249 const gsl_vector_complex * b,
250 gsl_vector_complex * x,
251 gsl_vector_complex * work);
253 int gsl_linalg_complex_LU_invert (const gsl_matrix_complex * LU,
254 const gsl_permutation * p,
255 gsl_matrix_complex * inverse);
256 int gsl_linalg_complex_LU_invx (gsl_matrix_complex * LU, const gsl_permutation * p);
258 gsl_complex gsl_linalg_complex_LU_det (gsl_matrix_complex * LU,
261 double gsl_linalg_complex_LU_lndet (gsl_matrix_complex * LU);
263 gsl_complex gsl_linalg_complex_LU_sgndet (gsl_matrix_complex * LU,
266 /* QR decomposition */
268 int gsl_linalg_QR_decomp (gsl_matrix * A, gsl_vector * tau);
270 int gsl_linalg_QR_decomp_old (gsl_matrix * A, gsl_vector * tau);
272 int gsl_linalg_QR_decomp_r (gsl_matrix * A, gsl_matrix * T);
274 int gsl_linalg_QR_solve (const gsl_matrix * QR, const gsl_vector * tau, const gsl_vector * b, gsl_vector * x);
276 int gsl_linalg_QR_solve_r (const gsl_matrix * QR, const gsl_matrix * T, const gsl_vector * b, gsl_vector * x);
278 int gsl_linalg_QR_svx (const gsl_matrix * QR, const gsl_vector * tau, gsl_vector * x);
280 int gsl_linalg_QR_lssolve (const gsl_matrix * QR, const gsl_vector * tau, const gsl_vector * b,
281 gsl_vector * x, gsl_vector * residual);
283 int gsl_linalg_QR_lssolve_r (const gsl_matrix * QR, const gsl_matrix * T, const gsl_vector * b,
284 gsl_vector * x, gsl_vector * work);
286 int gsl_linalg_QR_QRsolve (gsl_matrix * Q, gsl_matrix * R, const gsl_vector * b, gsl_vector * x);
288 int gsl_linalg_QR_Rsolve (const gsl_matrix * QR, const gsl_vector * b, gsl_vector * x);
290 int gsl_linalg_QR_Rsvx (const gsl_matrix * QR, gsl_vector * x);
292 int gsl_linalg_QR_update (gsl_matrix * Q, gsl_matrix * R, gsl_vector * w, const gsl_vector * v);
294 int gsl_linalg_QR_QTvec (const gsl_matrix * QR, const gsl_vector * tau, gsl_vector * v);
296 int gsl_linalg_QR_QTvec_r(const gsl_matrix * QR, const gsl_matrix * T, gsl_vector * b, gsl_vector * work);
298 int gsl_linalg_QR_Qvec (const gsl_matrix * QR, const gsl_vector * tau, gsl_vector * v);
300 int gsl_linalg_QR_QTmat (const gsl_matrix * QR, const gsl_vector * tau, gsl_matrix * A);
302 int gsl_linalg_QR_QTmat_r(const gsl_matrix * QR, const gsl_matrix * T, gsl_matrix * B, gsl_matrix * work);
304 int gsl_linalg_QR_matQ (const gsl_matrix * QR, const gsl_vector * tau, gsl_matrix * A);
306 int gsl_linalg_QR_unpack (const gsl_matrix * QR, const gsl_vector * tau, gsl_matrix * Q, gsl_matrix * R);
308 int gsl_linalg_QR_unpack_r(const gsl_matrix * QR, const gsl_matrix * T, gsl_matrix * Q, gsl_matrix * R);
310 int gsl_linalg_R_solve (const gsl_matrix * R, const gsl_vector * b, gsl_vector * x);
312 int gsl_linalg_R_svx (const gsl_matrix * R, gsl_vector * x);
314 int gsl_linalg_QR_rcond(const gsl_matrix * QR, double * rcond, gsl_vector * work);
316 /* complex QR decomposition */
318 int gsl_linalg_complex_QR_decomp (gsl_matrix_complex * A, gsl_vector_complex * tau);
320 int gsl_linalg_complex_QR_decomp_r (gsl_matrix_complex * A, gsl_matrix_complex * T);
322 int gsl_linalg_complex_QR_solve (const gsl_matrix_complex * QR, const gsl_vector_complex * tau,
323 const gsl_vector_complex * b, gsl_vector_complex * x);
325 int gsl_linalg_complex_QR_solve_r (const gsl_matrix_complex * QR, const gsl_matrix_complex * T,
326 const gsl_vector_complex * b, gsl_vector_complex * x);
328 int gsl_linalg_complex_QR_svx (const gsl_matrix_complex * QR, const gsl_vector_complex * tau, gsl_vector_complex * x);
330 int gsl_linalg_complex_QR_lssolve (const gsl_matrix_complex * QR, const gsl_vector_complex * tau,
331 const gsl_vector_complex * b, gsl_vector_complex * x,
332 gsl_vector_complex * residual);
334 int gsl_linalg_complex_QR_lssolve_r (const gsl_matrix_complex * QR, const gsl_matrix_complex * T,
335 const gsl_vector_complex * b, gsl_vector_complex * x, gsl_vector_complex * work);
337 int gsl_linalg_complex_QR_QHvec (const gsl_matrix_complex * QR, const gsl_vector_complex * tau, gsl_vector_complex * v);
339 int gsl_linalg_complex_QR_QHvec_r(const gsl_matrix_complex * QR, const gsl_matrix_complex * T,
340 gsl_vector_complex * b, gsl_vector_complex * work);
342 int gsl_linalg_complex_QR_Qvec (const gsl_matrix_complex * QR, const gsl_vector_complex * tau, gsl_vector_complex * v);
344 int gsl_linalg_complex_QR_unpack (const gsl_matrix_complex * QR, const gsl_vector_complex * tau,
345 gsl_matrix_complex * Q, gsl_matrix_complex * R);
347 int gsl_linalg_complex_QR_unpack_r(const gsl_matrix_complex * QR, const gsl_matrix_complex * T,
348 gsl_matrix_complex * Q, gsl_matrix_complex * R);
350 /* banded QR decomposition */
352 int gsl_linalg_QR_band_decomp_L2 (const size_t M, const size_t p, const size_t q,
353 gsl_matrix * AB, gsl_vector * tau);
355 int gsl_linalg_QR_band_unpack_L2 (const size_t p, const size_t q, const gsl_matrix * QRB,
356 const gsl_vector * tau, gsl_matrix * Q, gsl_matrix * R);
358 /* Q R P^T decomposition */
360 int gsl_linalg_QRPT_decomp (gsl_matrix * A,
366 int gsl_linalg_QRPT_decomp2 (const gsl_matrix * A,
367 gsl_matrix * q, gsl_matrix * r,
373 int gsl_linalg_QRPT_solve (const gsl_matrix * QR,
374 const gsl_vector * tau,
375 const gsl_permutation * p,
376 const gsl_vector * b,
379 int gsl_linalg_QRPT_lssolve (const gsl_matrix * QR,
380 const gsl_vector * tau,
381 const gsl_permutation * p,
382 const gsl_vector * b,
384 gsl_vector * residual);
386 int gsl_linalg_QRPT_lssolve2 (const gsl_matrix * QR,
387 const gsl_vector * tau,
388 const gsl_permutation * p,
389 const gsl_vector * b,
392 gsl_vector * residual);
394 int gsl_linalg_QRPT_svx (const gsl_matrix * QR,
395 const gsl_vector * tau,
396 const gsl_permutation * p,
399 int gsl_linalg_QRPT_QRsolve (const gsl_matrix * Q,
400 const gsl_matrix * R,
401 const gsl_permutation * p,
402 const gsl_vector * b,
405 int gsl_linalg_QRPT_Rsolve (const gsl_matrix * QR,
406 const gsl_permutation * p,
407 const gsl_vector * b,
410 int gsl_linalg_QRPT_Rsvx (const gsl_matrix * QR,
411 const gsl_permutation * p,
414 int gsl_linalg_QRPT_update (gsl_matrix * Q,
416 const gsl_permutation * p,
418 const gsl_vector * v);
420 size_t gsl_linalg_QRPT_rank (const gsl_matrix * QR, const double tol);
422 int gsl_linalg_QRPT_rcond(const gsl_matrix * QR, double * rcond, gsl_vector * work);
424 /* triangle on top of diagonal QR decomposition */
426 int gsl_linalg_QR_UD_decomp (gsl_matrix * U, const gsl_vector * D, gsl_matrix * Y, gsl_matrix * T);
428 int gsl_linalg_QR_UD_lssolve (const gsl_matrix * R, const gsl_matrix * Y, const gsl_matrix * T,
429 const gsl_vector * b, gsl_vector * x, gsl_vector * work);
431 /* triangle on top of rectangle QR decomposition */
433 int gsl_linalg_QR_UR_decomp (gsl_matrix * S, gsl_matrix * A, gsl_matrix * T);
435 /* triangle on top of triangle QR decomposition */
437 int gsl_linalg_QR_UU_decomp (gsl_matrix * U, gsl_matrix * S, gsl_matrix * T);
439 int gsl_linalg_QR_UU_lssolve (const gsl_matrix * R, const gsl_matrix * Y, const gsl_matrix * T,
440 const gsl_vector * b, gsl_vector * x, gsl_vector * work);
442 int gsl_linalg_QR_UU_QTvec(const gsl_matrix * Y, const gsl_matrix * T, gsl_vector * b, gsl_vector * work);
444 /* triangle on top of trapezoidal QR decomposition */
446 int gsl_linalg_QR_UZ_decomp (gsl_matrix * S, gsl_matrix * A, gsl_matrix * T);
448 /* QL decomposition */
450 int gsl_linalg_QL_decomp (gsl_matrix * A, gsl_vector * tau);
452 int gsl_linalg_QL_unpack (const gsl_matrix * QL, const gsl_vector * tau, gsl_matrix * Q, gsl_matrix * L);
454 /* COD decomposition */
456 int gsl_linalg_COD_decomp(gsl_matrix * A, gsl_vector * tau_Q, gsl_vector * tau_Z,
457 gsl_permutation * p, size_t * rank, gsl_vector * work);
459 int gsl_linalg_COD_decomp_e(gsl_matrix * A, gsl_vector * tau_Q, gsl_vector * tau_Z,
460 gsl_permutation * p, double tol, size_t * rank, gsl_vector * work);
462 int gsl_linalg_COD_lssolve (const gsl_matrix * QRZT, const gsl_vector * tau_Q, const gsl_vector * tau_Z,
463 const gsl_permutation * perm, const size_t rank, const gsl_vector * b,
464 gsl_vector * x, gsl_vector * residual);
467 gsl_linalg_COD_lssolve2 (const double lambda, const gsl_matrix * QRZT, const gsl_vector * tau_Q, const gsl_vector * tau_Z,
468 const gsl_permutation * perm, const size_t rank, const gsl_vector * b,
469 gsl_vector * x, gsl_vector * residual, gsl_matrix * S, gsl_vector * work);
471 int gsl_linalg_COD_unpack(const gsl_matrix * QRZT, const gsl_vector * tau_Q,
472 const gsl_vector * tau_Z, const size_t rank, gsl_matrix * Q,
473 gsl_matrix * R, gsl_matrix * Z);
475 int gsl_linalg_COD_matZ(const gsl_matrix * QRZT, const gsl_vector * tau_Z, const size_t rank,
476 gsl_matrix * A, gsl_vector * work);
478 /* LQ decomposition */
480 int gsl_linalg_LQ_decomp (gsl_matrix * A, gsl_vector * tau);
482 int gsl_linalg_LQ_lssolve(const gsl_matrix * LQ, const gsl_vector * tau,
483 const gsl_vector * b, gsl_vector * x, gsl_vector * residual);
485 int gsl_linalg_LQ_QTvec(const gsl_matrix * LQ, const gsl_vector * tau, gsl_vector * v);
487 int gsl_linalg_LQ_solve_T (const gsl_matrix * LQ, const gsl_vector * tau,
488 const gsl_vector * b, gsl_vector * x);
490 int gsl_linalg_LQ_svx_T (const gsl_matrix * LQ, const gsl_vector * tau,
493 int gsl_linalg_LQ_lssolve_T (const gsl_matrix * LQ, const gsl_vector * tau,
494 const gsl_vector * b, gsl_vector * x,
495 gsl_vector * residual);
497 int gsl_linalg_LQ_Lsolve_T (const gsl_matrix * LQ, const gsl_vector * b,
500 int gsl_linalg_LQ_Lsvx_T (const gsl_matrix * LQ, gsl_vector * x);
502 int gsl_linalg_L_solve_T (const gsl_matrix * L, const gsl_vector * b,
505 int gsl_linalg_LQ_vecQ (const gsl_matrix * LQ, const gsl_vector * tau,
508 int gsl_linalg_LQ_vecQT (const gsl_matrix * LQ, const gsl_vector * tau,
511 int gsl_linalg_LQ_unpack (const gsl_matrix * LQ, const gsl_vector * tau,
512 gsl_matrix * Q, gsl_matrix * L);
514 int gsl_linalg_LQ_update (gsl_matrix * Q, gsl_matrix * R,
515 const gsl_vector * v, gsl_vector * w);
516 int gsl_linalg_LQ_LQsolve (gsl_matrix * Q, gsl_matrix * L,
517 const gsl_vector * b, gsl_vector * x);
519 /* P^T L Q decomposition */
521 int gsl_linalg_PTLQ_decomp (gsl_matrix * A, gsl_vector * tau,
522 gsl_permutation * p, int *signum,
525 int gsl_linalg_PTLQ_decomp2 (const gsl_matrix * A, gsl_matrix * q,
526 gsl_matrix * r, gsl_vector * tau,
527 gsl_permutation * p, int *signum,
530 int gsl_linalg_PTLQ_solve_T (const gsl_matrix * QR,
531 const gsl_vector * tau,
532 const gsl_permutation * p,
533 const gsl_vector * b,
536 int gsl_linalg_PTLQ_svx_T (const gsl_matrix * LQ,
537 const gsl_vector * tau,
538 const gsl_permutation * p,
541 int gsl_linalg_PTLQ_LQsolve_T (const gsl_matrix * Q, const gsl_matrix * L,
542 const gsl_permutation * p,
543 const gsl_vector * b,
546 int gsl_linalg_PTLQ_Lsolve_T (const gsl_matrix * LQ,
547 const gsl_permutation * p,
548 const gsl_vector * b,
551 int gsl_linalg_PTLQ_Lsvx_T (const gsl_matrix * LQ,
552 const gsl_permutation * p,
555 int gsl_linalg_PTLQ_update (gsl_matrix * Q, gsl_matrix * L,
556 const gsl_permutation * p,
557 const gsl_vector * v, gsl_vector * w);
559 /* Cholesky Decomposition */
561 int gsl_linalg_cholesky_decomp (gsl_matrix * A);
562 int gsl_linalg_cholesky_decomp1 (gsl_matrix * A);
564 int gsl_linalg_cholesky_solve (const gsl_matrix * cholesky,
565 const gsl_vector * b,
567 int gsl_linalg_cholesky_solve_mat (const gsl_matrix * cholesky,
568 const gsl_matrix * B,
571 int gsl_linalg_cholesky_svx (const gsl_matrix * cholesky,
573 int gsl_linalg_cholesky_svx_mat (const gsl_matrix * cholesky,
576 int gsl_linalg_cholesky_invert(gsl_matrix * cholesky);
578 /* Cholesky decomposition with unit-diagonal triangular parts.
579 * A = L D L^T, where diag(L) = (1,1,...,1).
580 * Upon exit, A contains L and L^T as for Cholesky, and
581 * the diagonal of A is (1,1,...,1). The vector Dis set
582 * to the diagonal elements of the diagonal matrix D.
584 int gsl_linalg_cholesky_decomp_unit(gsl_matrix * A, gsl_vector * D);
586 int gsl_linalg_cholesky_scale(const gsl_matrix * A, gsl_vector * S);
588 int gsl_linalg_cholesky_scale_apply(gsl_matrix * A, const gsl_vector * S);
590 int gsl_linalg_cholesky_decomp2(gsl_matrix * A, gsl_vector * S);
592 int gsl_linalg_cholesky_svx2 (const gsl_matrix * LLT,
593 const gsl_vector * S,
596 int gsl_linalg_cholesky_solve2 (const gsl_matrix * LLT,
597 const gsl_vector * S,
598 const gsl_vector * b,
601 int gsl_linalg_cholesky_rcond (const gsl_matrix * LLT, double * rcond,
604 /* Complex Cholesky Decomposition */
606 int gsl_linalg_complex_cholesky_decomp (gsl_matrix_complex * A);
608 int gsl_linalg_complex_cholesky_solve (const gsl_matrix_complex * cholesky,
609 const gsl_vector_complex * b,
610 gsl_vector_complex * x);
612 int gsl_linalg_complex_cholesky_svx (const gsl_matrix_complex * cholesky,
613 gsl_vector_complex * x);
615 int gsl_linalg_complex_cholesky_invert(gsl_matrix_complex * cholesky);
617 /* Pivoted Cholesky LDLT decomposition */
619 int gsl_linalg_pcholesky_decomp (gsl_matrix * A, gsl_permutation * p);
621 int gsl_linalg_pcholesky_solve(const gsl_matrix * LDLT,
622 const gsl_permutation * p,
623 const gsl_vector * b,
626 int gsl_linalg_pcholesky_svx(const gsl_matrix * LDLT,
627 const gsl_permutation * p,
630 int gsl_linalg_pcholesky_decomp2(gsl_matrix * A, gsl_permutation * p,
633 int gsl_linalg_pcholesky_solve2(const gsl_matrix * LDLT,
634 const gsl_permutation * p,
635 const gsl_vector * S,
636 const gsl_vector * b,
639 int gsl_linalg_pcholesky_svx2(const gsl_matrix * LDLT,
640 const gsl_permutation * p,
641 const gsl_vector * S,
644 int gsl_linalg_pcholesky_invert(const gsl_matrix * LDLT, const gsl_permutation * p,
647 int gsl_linalg_pcholesky_rcond (const gsl_matrix * LDLT, const gsl_permutation * p,
648 double * rcond, gsl_vector * work);
650 /* Modified Cholesky decomposition */
652 int gsl_linalg_mcholesky_decomp (gsl_matrix * A, gsl_permutation * p,
655 int gsl_linalg_mcholesky_solve(const gsl_matrix * LDLT,
656 const gsl_permutation * p,
657 const gsl_vector * b,
660 int gsl_linalg_mcholesky_svx(const gsl_matrix * LDLT,
661 const gsl_permutation * p,
664 int gsl_linalg_mcholesky_rcond (const gsl_matrix * LDLT, const gsl_permutation * p,
665 double * rcond, gsl_vector * work);
667 int gsl_linalg_mcholesky_invert(const gsl_matrix * LDLT, const gsl_permutation * p,
670 /* Banded Cholesky decomposition */
672 int gsl_linalg_cholesky_band_decomp(gsl_matrix * A);
674 int gsl_linalg_cholesky_band_solve (const gsl_matrix * LLT, const gsl_vector * b,
677 int gsl_linalg_cholesky_band_svx (const gsl_matrix * LLT, gsl_vector * x);
679 int gsl_linalg_cholesky_band_solvem (const gsl_matrix * LLT, const gsl_matrix * B,
682 int gsl_linalg_cholesky_band_svxm (const gsl_matrix * LLT, gsl_matrix * X);
684 int gsl_linalg_cholesky_band_invert (const gsl_matrix * LLT, gsl_matrix * Ainv);
686 int gsl_linalg_cholesky_band_unpack (const gsl_matrix * LLT, gsl_matrix * L);
688 int gsl_linalg_cholesky_band_scale(const gsl_matrix * A, gsl_vector * S);
690 int gsl_linalg_cholesky_band_scale_apply(gsl_matrix * A, const gsl_vector * S);
692 int gsl_linalg_cholesky_band_rcond (const gsl_matrix * LLT, double * rcond, gsl_vector * work);
694 /* L D L^T decomposition */
696 int gsl_linalg_ldlt_decomp (gsl_matrix * A);
698 int gsl_linalg_ldlt_solve (const gsl_matrix * LDLT, const gsl_vector * b, gsl_vector * x);
700 int gsl_linalg_ldlt_svx (const gsl_matrix * LDLT, gsl_vector * x);
702 int gsl_linalg_ldlt_rcond (const gsl_matrix * LDLT, double * rcond, gsl_vector * work);
704 /* Banded L D L^T decomposition */
706 int gsl_linalg_ldlt_band_decomp (gsl_matrix * A);
708 int gsl_linalg_ldlt_band_solve (const gsl_matrix * LDLT, const gsl_vector * b, gsl_vector * x);
710 int gsl_linalg_ldlt_band_svx (const gsl_matrix * LDLT, gsl_vector * x);
712 int gsl_linalg_ldlt_band_unpack (const gsl_matrix * LDLT, gsl_matrix * L, gsl_vector * D);
714 int gsl_linalg_ldlt_band_rcond (const gsl_matrix * LDLT, double * rcond, gsl_vector * work);
716 /* Symmetric to symmetric tridiagonal decomposition */
718 int gsl_linalg_symmtd_decomp (gsl_matrix * A,
721 int gsl_linalg_symmtd_unpack (const gsl_matrix * A,
722 const gsl_vector * tau,
725 gsl_vector * subdiag);
727 int gsl_linalg_symmtd_unpack_T (const gsl_matrix * A,
729 gsl_vector * subdiag);
731 /* Hermitian to symmetric tridiagonal decomposition */
733 int gsl_linalg_hermtd_decomp (gsl_matrix_complex * A,
734 gsl_vector_complex * tau);
736 int gsl_linalg_hermtd_unpack (const gsl_matrix_complex * A,
737 const gsl_vector_complex * tau,
738 gsl_matrix_complex * U,
740 gsl_vector * sudiag);
742 int gsl_linalg_hermtd_unpack_T (const gsl_matrix_complex * A,
744 gsl_vector * subdiag);
746 /* Linear Solve Using Householder Transformations
751 int gsl_linalg_HH_solve (gsl_matrix * A, const gsl_vector * b, gsl_vector * x);
752 int gsl_linalg_HH_svx (gsl_matrix * A, gsl_vector * x);
754 /* Linear solve for a symmetric tridiagonal system.
756 * The input vectors represent the NxN matrix as follows:
758 * diag[0] offdiag[0] 0 ...
759 * offdiag[0] diag[1] offdiag[1] ...
760 * 0 offdiag[1] diag[2] ...
764 int gsl_linalg_solve_symm_tridiag (const gsl_vector * diag,
765 const gsl_vector * offdiag,
766 const gsl_vector * b,
769 /* Linear solve for a nonsymmetric tridiagonal system.
771 * The input vectors represent the NxN matrix as follows:
773 * diag[0] abovediag[0] 0 ...
774 * belowdiag[0] diag[1] abovediag[1] ...
775 * 0 belowdiag[1] diag[2] ...
776 * 0 0 belowdiag[2] ...
779 int gsl_linalg_solve_tridiag (const gsl_vector * diag,
780 const gsl_vector * abovediag,
781 const gsl_vector * belowdiag,
782 const gsl_vector * b,
786 /* Linear solve for a symmetric cyclic tridiagonal system.
788 * The input vectors represent the NxN matrix as follows:
790 * diag[0] offdiag[0] 0 ..... offdiag[N-1]
791 * offdiag[0] diag[1] offdiag[1] .....
792 * 0 offdiag[1] diag[2] .....
793 * 0 0 offdiag[2] .....
797 int gsl_linalg_solve_symm_cyc_tridiag (const gsl_vector * diag,
798 const gsl_vector * offdiag,
799 const gsl_vector * b,
802 /* Linear solve for a nonsymmetric cyclic tridiagonal system.
804 * The input vectors represent the NxN matrix as follows:
806 * diag[0] abovediag[0] 0 ..... belowdiag[N-1]
807 * belowdiag[0] diag[1] abovediag[1] .....
808 * 0 belowdiag[1] diag[2]
809 * 0 0 belowdiag[2] .....
813 int gsl_linalg_solve_cyc_tridiag (const gsl_vector * diag,
814 const gsl_vector * abovediag,
815 const gsl_vector * belowdiag,
816 const gsl_vector * b,
820 /* Bidiagonal decomposition */
822 int gsl_linalg_bidiag_decomp (gsl_matrix * A,
826 int gsl_linalg_bidiag_unpack (const gsl_matrix * A,
827 const gsl_vector * tau_U,
829 const gsl_vector * tau_V,
832 gsl_vector * superdiag);
834 int gsl_linalg_bidiag_unpack2 (gsl_matrix * A,
839 int gsl_linalg_bidiag_unpack_B (const gsl_matrix * A,
841 gsl_vector * superdiag);
845 int gsl_linalg_balance_matrix (gsl_matrix * A, gsl_vector * D);
846 int gsl_linalg_balance_accum (gsl_matrix * A, gsl_vector * D);
847 int gsl_linalg_balance_columns (gsl_matrix * A, gsl_vector * D);
849 /* condition estimation */
851 int gsl_linalg_tri_rcond(CBLAS_UPLO_t Uplo, const gsl_matrix * A, double * rcond, gsl_vector * work);
852 int gsl_linalg_tri_upper_rcond(const gsl_matrix * A, double * rcond, gsl_vector * work);
853 int gsl_linalg_tri_lower_rcond(const gsl_matrix * A, double * rcond, gsl_vector * work);
854 int gsl_linalg_invnorm1(const size_t N,
855 int (* Ainvx)(CBLAS_TRANSPOSE_t TransA, gsl_vector * x, void * params),
856 void * params, double * Ainvnorm, gsl_vector * work);
858 /* triangular matrices */
860 int gsl_linalg_tri_upper_invert(gsl_matrix * T);
861 int gsl_linalg_tri_lower_invert(gsl_matrix * T);
862 int gsl_linalg_tri_upper_unit_invert(gsl_matrix * T);
863 int gsl_linalg_tri_lower_unit_invert(gsl_matrix * T);
865 int gsl_linalg_tri_invert(CBLAS_UPLO_t Uplo, CBLAS_DIAG_t Diag, gsl_matrix * T);
866 int gsl_linalg_complex_tri_invert(CBLAS_UPLO_t Uplo, CBLAS_DIAG_t Diag, gsl_matrix_complex * T);
868 int gsl_linalg_tri_LTL(gsl_matrix * L);
869 int gsl_linalg_tri_UL(gsl_matrix * LU);
870 int gsl_linalg_complex_tri_LHL(gsl_matrix_complex * L);
871 int gsl_linalg_complex_tri_UL(gsl_matrix_complex * LU);
873 INLINE_DECL void gsl_linalg_givens (const double a, const double b,
874 double *c, double *s);
875 INLINE_DECL void gsl_linalg_givens_gv (gsl_vector * v, const size_t i,
876 const size_t j, const double c,
881 /* Generate a Givens rotation (cos,sin) which takes v=(x,y) to (|v|,0)
882 From Golub and Van Loan, "Matrix Computations", Section 5.1.8 */
885 gsl_linalg_givens (const double a, const double b, double *c, double *s)
892 else if (fabs (b) > fabs (a))
895 double s1 = 1.0 / sqrt (1 + t * t);
902 double c1 = 1.0 / sqrt (1 + t * t);
906 } /* gsl_linalg_givens() */
910 gsl_linalg_givens_gv (gsl_vector * v, const size_t i, const size_t j,
911 const double c, const double s)
913 /* Apply rotation to vector v' = G^T v */
915 double vi = gsl_vector_get (v, i);
916 double vj = gsl_vector_get (v, j);
917 gsl_vector_set (v, i, c * vi - s * vj);
918 gsl_vector_set (v, j, s * vi + c * vj);
921 #endif /* HAVE_INLINE */
925 #endif /* __GSL_LINALG_H__ */