Debian Codegraph @

external/gsl/gsl_linalg.h

raw
1 /* linalg/gsl_linalg.h
2 *
3 * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2006, 2007 Gerard Jungman, Brian Gough, Patrick Alken
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 #ifndef __GSL_LINALG_H__
21 #define __GSL_LINALG_H__
22
23 #include "gsl_mode.h"
24 #include "gsl_permutation.h"
25 #include "gsl_vector.h"
26 #include "gsl_matrix.h"
27
28 #undef __BEGIN_DECLS
29 #undef __END_DECLS
30 #ifdef __cplusplus
31 #define __BEGIN_DECLS extern "C" {
32 #define __END_DECLS }
33 #else
34 #define __BEGIN_DECLS /* empty */
35 #define __END_DECLS /* empty */
36 #endif
37
38 __BEGIN_DECLS
39
40 typedef enum
41 {
42 GSL_LINALG_MOD_NONE = 0,
43 GSL_LINALG_MOD_TRANSPOSE = 1,
44 GSL_LINALG_MOD_CONJUGATE = 2
45 }
46 gsl_linalg_matrix_mod_t;
47
48
49 /* Note: You can now use the gsl_blas_dgemm function instead of matmult */
50
51 /* Simple implementation of matrix multiply.
52 * Calculates C = A.B
53 *
54 * exceptions: GSL_EBADLEN
55 */
56 int gsl_linalg_matmult (const gsl_matrix * A,
57 const gsl_matrix * B,
58 gsl_matrix * C);
59
60
61 /* Simple implementation of matrix multiply.
62 * Allows transposition of either matrix, so it
63 * can compute A.B or Trans(A).B or A.Trans(B) or Trans(A).Trans(B)
64 *
65 * exceptions: GSL_EBADLEN
66 */
67 int gsl_linalg_matmult_mod (const gsl_matrix * A,
68 gsl_linalg_matrix_mod_t modA,
69 const gsl_matrix * B,
70 gsl_linalg_matrix_mod_t modB,
71 gsl_matrix * C);
72
73 /* Calculate the matrix exponential by the scaling and
74 * squaring method described in Moler + Van Loan,
75 * SIAM Rev 20, 801 (1978). The mode argument allows
76 * choosing an optimal strategy, from the table
77 * given in the paper, for a given precision.
78 *
79 * exceptions: GSL_ENOTSQR, GSL_EBADLEN
80 */
81 int gsl_linalg_exponential_ss(
82 const gsl_matrix * A,
83 gsl_matrix * eA,
84 gsl_mode_t mode
85 );
86
87
88 /* Householder Transformations */
89
90 double gsl_linalg_householder_transform (gsl_vector * v);
91 gsl_complex gsl_linalg_complex_householder_transform (gsl_vector_complex * v);
92
93 int gsl_linalg_householder_hm (double tau,
94 const gsl_vector * v,
95 gsl_matrix * A);
96
97 int gsl_linalg_householder_mh (double tau,
98 const gsl_vector * v,
99 gsl_matrix * A);
100
101 int gsl_linalg_householder_hv (double tau,
102 const gsl_vector * v,
103 gsl_vector * w);
104
105 int gsl_linalg_householder_hm1 (double tau,
106 gsl_matrix * A);
107
108 int gsl_linalg_complex_householder_hm (gsl_complex tau,
109 const gsl_vector_complex * v,
110 gsl_matrix_complex * A);
111
112 int gsl_linalg_complex_householder_mh (gsl_complex tau,
113 const gsl_vector_complex * v,
114 gsl_matrix_complex * A);
115
116 int gsl_linalg_complex_householder_hv (gsl_complex tau,
117 const gsl_vector_complex * v,
118 gsl_vector_complex * w);
119
120 /* Hessenberg reduction */
121
122 int gsl_linalg_hessenberg_decomp(gsl_matrix *A, gsl_vector *tau);
123 int gsl_linalg_hessenberg_unpack(gsl_matrix * H, gsl_vector * tau,
124 gsl_matrix * U);
125 int gsl_linalg_hessenberg_unpack_accum(gsl_matrix * H, gsl_vector * tau,
126 gsl_matrix * U);
127 int gsl_linalg_hessenberg_set_zero(gsl_matrix * H);
128 int gsl_linalg_hessenberg_submatrix(gsl_matrix *M, gsl_matrix *A,
129 size_t top, gsl_vector *tau);
130
131 /* Hessenberg-Triangular reduction */
132
133 int gsl_linalg_hesstri_decomp(gsl_matrix * A, gsl_matrix * B,
134 gsl_matrix * U, gsl_matrix * V,
135 gsl_vector * work);
136
137 /* Singular Value Decomposition
138
139 * exceptions:
140 */
141
142 int
143 gsl_linalg_SV_decomp (gsl_matrix * A,
144 gsl_matrix * V,
145 gsl_vector * S,
146 gsl_vector * work);
147
148 int
149 gsl_linalg_SV_decomp_mod (gsl_matrix * A,
150 gsl_matrix * X,
151 gsl_matrix * V,
152 gsl_vector * S,
153 gsl_vector * work);
154
155 int gsl_linalg_SV_decomp_jacobi (gsl_matrix * A,
156 gsl_matrix * Q,
157 gsl_vector * S);
158
159 int
160 gsl_linalg_SV_solve (const gsl_matrix * U,
161 const gsl_matrix * Q,
162 const gsl_vector * S,
163 const gsl_vector * b,
164 gsl_vector * x);
165
166
167 /* LU Decomposition, Gaussian elimination with partial pivoting
168 */
169
170 int gsl_linalg_LU_decomp (gsl_matrix * A, gsl_permutation * p, int *signum);
171
172 int gsl_linalg_LU_solve (const gsl_matrix * LU,
173 const gsl_permutation * p,
174 const gsl_vector * b,
175 gsl_vector * x);
176
177 int gsl_linalg_LU_svx (const gsl_matrix * LU,
178 const gsl_permutation * p,
179 gsl_vector * x);
180
181 int gsl_linalg_LU_refine (const gsl_matrix * A,
182 const gsl_matrix * LU,
183 const gsl_permutation * p,
184 const gsl_vector * b,
185 gsl_vector * x,
186 gsl_vector * residual);
187
188 int gsl_linalg_LU_invert (const gsl_matrix * LU,
189 const gsl_permutation * p,
190 gsl_matrix * inverse);
191
192 double gsl_linalg_LU_det (gsl_matrix * LU, int signum);
193 double gsl_linalg_LU_lndet (gsl_matrix * LU);
194 int gsl_linalg_LU_sgndet (gsl_matrix * lu, int signum);
195
196 /* Complex LU Decomposition */
197
198 int gsl_linalg_complex_LU_decomp (gsl_matrix_complex * A,
199 gsl_permutation * p,
200 int *signum);
201
202 int gsl_linalg_complex_LU_solve (const gsl_matrix_complex * LU,
203 const gsl_permutation * p,
204 const gsl_vector_complex * b,
205 gsl_vector_complex * x);
206
207 int gsl_linalg_complex_LU_svx (const gsl_matrix_complex * LU,
208 const gsl_permutation * p,
209 gsl_vector_complex * x);
210
211 int gsl_linalg_complex_LU_refine (const gsl_matrix_complex * A,
212 const gsl_matrix_complex * LU,
213 const gsl_permutation * p,
214 const gsl_vector_complex * b,
215 gsl_vector_complex * x,
216 gsl_vector_complex * residual);
217
218 int gsl_linalg_complex_LU_invert (const gsl_matrix_complex * LU,
219 const gsl_permutation * p,
220 gsl_matrix_complex * inverse);
221
222 gsl_complex gsl_linalg_complex_LU_det (gsl_matrix_complex * LU,
223 int signum);
224
225 double gsl_linalg_complex_LU_lndet (gsl_matrix_complex * LU);
226
227 gsl_complex gsl_linalg_complex_LU_sgndet (gsl_matrix_complex * LU,
228 int signum);
229
230 /* QR decomposition */
231
232 int gsl_linalg_QR_decomp (gsl_matrix * A,
233 gsl_vector * tau);
234
235 int gsl_linalg_QR_solve (const gsl_matrix * QR,
236 const gsl_vector * tau,
237 const gsl_vector * b,
238 gsl_vector * x);
239
240 int gsl_linalg_QR_svx (const gsl_matrix * QR,
241 const gsl_vector * tau,
242 gsl_vector * x);
243
244 int gsl_linalg_QR_lssolve (const gsl_matrix * QR,
245 const gsl_vector * tau,
246 const gsl_vector * b,
247 gsl_vector * x,
248 gsl_vector * residual);
249
250
251 int gsl_linalg_QR_QRsolve (gsl_matrix * Q,
252 gsl_matrix * R,
253 const gsl_vector * b,
254 gsl_vector * x);
255
256 int gsl_linalg_QR_Rsolve (const gsl_matrix * QR,
257 const gsl_vector * b,
258 gsl_vector * x);
259
260 int gsl_linalg_QR_Rsvx (const gsl_matrix * QR,
261 gsl_vector * x);
262
263 int gsl_linalg_QR_update (gsl_matrix * Q,
264 gsl_matrix * R,
265 gsl_vector * w,
266 const gsl_vector * v);
267
268 int gsl_linalg_QR_QTvec (const gsl_matrix * QR,
269 const gsl_vector * tau,
270 gsl_vector * v);
271
272 int gsl_linalg_QR_Qvec (const gsl_matrix * QR,
273 const gsl_vector * tau,
274 gsl_vector * v);
275
276 int gsl_linalg_QR_QTmat (const gsl_matrix * QR,
277 const gsl_vector * tau,
278 gsl_matrix * A);
279
280 int gsl_linalg_QR_unpack (const gsl_matrix * QR,
281 const gsl_vector * tau,
282 gsl_matrix * Q,
283 gsl_matrix * R);
284
285 int gsl_linalg_R_solve (const gsl_matrix * R,
286 const gsl_vector * b,
287 gsl_vector * x);
288
289 int gsl_linalg_R_svx (const gsl_matrix * R,
290 gsl_vector * x);
291
292
293 /* Q R P^T decomposition */
294
295 int gsl_linalg_QRPT_decomp (gsl_matrix * A,
296 gsl_vector * tau,
297 gsl_permutation * p,
298 int *signum,
299 gsl_vector * norm);
300
301 int gsl_linalg_QRPT_decomp2 (const gsl_matrix * A,
302 gsl_matrix * q, gsl_matrix * r,
303 gsl_vector * tau,
304 gsl_permutation * p,
305 int *signum,
306 gsl_vector * norm);
307
308 int gsl_linalg_QRPT_solve (const gsl_matrix * QR,
309 const gsl_vector * tau,
310 const gsl_permutation * p,
311 const gsl_vector * b,
312 gsl_vector * x);
313
314
315 int gsl_linalg_QRPT_svx (const gsl_matrix * QR,
316 const gsl_vector * tau,
317 const gsl_permutation * p,
318 gsl_vector * x);
319
320 int gsl_linalg_QRPT_QRsolve (const gsl_matrix * Q,
321 const gsl_matrix * R,
322 const gsl_permutation * p,
323 const gsl_vector * b,
324 gsl_vector * x);
325
326 int gsl_linalg_QRPT_Rsolve (const gsl_matrix * QR,
327 const gsl_permutation * p,
328 const gsl_vector * b,
329 gsl_vector * x);
330
331 int gsl_linalg_QRPT_Rsvx (const gsl_matrix * QR,
332 const gsl_permutation * p,
333 gsl_vector * x);
334
335 int gsl_linalg_QRPT_update (gsl_matrix * Q,
336 gsl_matrix * R,
337 const gsl_permutation * p,
338 gsl_vector * u,
339 const gsl_vector * v);
340
341 /* LQ decomposition */
342
343 int gsl_linalg_LQ_decomp (gsl_matrix * A, gsl_vector * tau);
344
345 int gsl_linalg_LQ_solve_T (const gsl_matrix * LQ, const gsl_vector * tau,
346 const gsl_vector * b, gsl_vector * x);
347
348 int gsl_linalg_LQ_svx_T (const gsl_matrix * LQ, const gsl_vector * tau,
349 gsl_vector * x);
350
351 int gsl_linalg_LQ_lssolve_T (const gsl_matrix * LQ, const gsl_vector * tau,
352 const gsl_vector * b, gsl_vector * x,
353 gsl_vector * residual);
354
355 int gsl_linalg_LQ_Lsolve_T (const gsl_matrix * LQ, const gsl_vector * b,
356 gsl_vector * x);
357
358 int gsl_linalg_LQ_Lsvx_T (const gsl_matrix * LQ, gsl_vector * x);
359
360 int gsl_linalg_L_solve_T (const gsl_matrix * L, const gsl_vector * b,
361 gsl_vector * x);
362
363 int gsl_linalg_LQ_vecQ (const gsl_matrix * LQ, const gsl_vector * tau,
364 gsl_vector * v);
365
366 int gsl_linalg_LQ_vecQT (const gsl_matrix * LQ, const gsl_vector * tau,
367 gsl_vector * v);
368
369 int gsl_linalg_LQ_unpack (const gsl_matrix * LQ, const gsl_vector * tau,
370 gsl_matrix * Q, gsl_matrix * L);
371
372 int gsl_linalg_LQ_update (gsl_matrix * Q, gsl_matrix * R,
373 const gsl_vector * v, gsl_vector * w);
374 int gsl_linalg_LQ_LQsolve (gsl_matrix * Q, gsl_matrix * L,
375 const gsl_vector * b, gsl_vector * x);
376
377 /* P^T L Q decomposition */
378
379 int gsl_linalg_PTLQ_decomp (gsl_matrix * A, gsl_vector * tau,
380 gsl_permutation * p, int *signum,
381 gsl_vector * norm);
382
383 int gsl_linalg_PTLQ_decomp2 (const gsl_matrix * A, gsl_matrix * q,
384 gsl_matrix * r, gsl_vector * tau,
385 gsl_permutation * p, int *signum,
386 gsl_vector * norm);
387
388 int gsl_linalg_PTLQ_solve_T (const gsl_matrix * QR,
389 const gsl_vector * tau,
390 const gsl_permutation * p,
391 const gsl_vector * b,
392 gsl_vector * x);
393
394 int gsl_linalg_PTLQ_svx_T (const gsl_matrix * LQ,
395 const gsl_vector * tau,
396 const gsl_permutation * p,
397 gsl_vector * x);
398
399 int gsl_linalg_PTLQ_LQsolve_T (const gsl_matrix * Q, const gsl_matrix * L,
400 const gsl_permutation * p,
401 const gsl_vector * b,
402 gsl_vector * x);
403
404 int gsl_linalg_PTLQ_Lsolve_T (const gsl_matrix * LQ,
405 const gsl_permutation * p,
406 const gsl_vector * b,
407 gsl_vector * x);
408
409 int gsl_linalg_PTLQ_Lsvx_T (const gsl_matrix * LQ,
410 const gsl_permutation * p,
411 gsl_vector * x);
412
413 int gsl_linalg_PTLQ_update (gsl_matrix * Q, gsl_matrix * L,
414 const gsl_permutation * p,
415 const gsl_vector * v, gsl_vector * w);
416
417 /* Cholesky Decomposition */
418
419 int gsl_linalg_cholesky_decomp (gsl_matrix * A);
420
421 int gsl_linalg_cholesky_solve (const gsl_matrix * cholesky,
422 const gsl_vector * b,
423 gsl_vector * x);
424
425 int gsl_linalg_cholesky_svx (const gsl_matrix * cholesky,
426 gsl_vector * x);
427
428
429 /* Cholesky decomposition with unit-diagonal triangular parts.
430 * A = L D L^T, where diag(L) = (1,1,...,1).
431 * Upon exit, A contains L and L^T as for Cholesky, and
432 * the diagonal of A is (1,1,...,1). The vector Dis set
433 * to the diagonal elements of the diagonal matrix D.
434 */
435 int gsl_linalg_cholesky_decomp_unit(gsl_matrix * A, gsl_vector * D);
436
437 /* Complex Cholesky Decomposition */
438
439 int gsl_linalg_complex_cholesky_decomp (gsl_matrix_complex * A);
440
441 int gsl_linalg_complex_cholesky_solve (const gsl_matrix_complex * cholesky,
442 const gsl_vector_complex * b,
443 gsl_vector_complex * x);
444
445 int gsl_linalg_complex_cholesky_svx (const gsl_matrix_complex * cholesky,
446 gsl_vector_complex * x);
447
448 /* Symmetric to symmetric tridiagonal decomposition */
449
450 int gsl_linalg_symmtd_decomp (gsl_matrix * A,
451 gsl_vector * tau);
452
453 int gsl_linalg_symmtd_unpack (const gsl_matrix * A,
454 const gsl_vector * tau,
455 gsl_matrix * Q,
456 gsl_vector * diag,
457 gsl_vector * subdiag);
458
459 int gsl_linalg_symmtd_unpack_T (const gsl_matrix * A,
460 gsl_vector * diag,
461 gsl_vector * subdiag);
462
463 /* Hermitian to symmetric tridiagonal decomposition */
464
465 int gsl_linalg_hermtd_decomp (gsl_matrix_complex * A,
466 gsl_vector_complex * tau);
467
468 int gsl_linalg_hermtd_unpack (const gsl_matrix_complex * A,
469 const gsl_vector_complex * tau,
470 gsl_matrix_complex * Q,
471 gsl_vector * diag,
472 gsl_vector * sudiag);
473
474 int gsl_linalg_hermtd_unpack_T (const gsl_matrix_complex * A,
475 gsl_vector * diag,
476 gsl_vector * subdiag);
477
478 /* Linear Solve Using Householder Transformations
479
480 * exceptions:
481 */
482
483 int gsl_linalg_HH_solve (gsl_matrix * A, const gsl_vector * b, gsl_vector * x);
484 int gsl_linalg_HH_svx (gsl_matrix * A, gsl_vector * x);
485
486 /* Linear solve for a symmetric tridiagonal system.
487
488 * The input vectors represent the NxN matrix as follows:
489 *
490 * diag[0] offdiag[0] 0 ...
491 * offdiag[0] diag[1] offdiag[1] ...
492 * 0 offdiag[1] diag[2] ...
493 * 0 0 offdiag[2] ...
494 * ... ... ... ...
495 */
496 int gsl_linalg_solve_symm_tridiag (const gsl_vector * diag,
497 const gsl_vector * offdiag,
498 const gsl_vector * b,
499 gsl_vector * x);
500
501 /* Linear solve for a nonsymmetric tridiagonal system.
502
503 * The input vectors represent the NxN matrix as follows:
504 *
505 * diag[0] abovediag[0] 0 ...
506 * belowdiag[0] diag[1] abovediag[1] ...
507 * 0 belowdiag[1] diag[2] ...
508 * 0 0 belowdiag[2] ...
509 * ... ... ... ...
510 */
511 int gsl_linalg_solve_tridiag (const gsl_vector * diag,
512 const gsl_vector * abovediag,
513 const gsl_vector * belowdiag,
514 const gsl_vector * b,
515 gsl_vector * x);
516
517
518 /* Linear solve for a symmetric cyclic tridiagonal system.
519
520 * The input vectors represent the NxN matrix as follows:
521 *
522 * diag[0] offdiag[0] 0 ..... offdiag[N-1]
523 * offdiag[0] diag[1] offdiag[1] .....
524 * 0 offdiag[1] diag[2] .....
525 * 0 0 offdiag[2] .....
526 * ... ...
527 * offdiag[N-1] ...
528 */
529 int gsl_linalg_solve_symm_cyc_tridiag (const gsl_vector * diag,
530 const gsl_vector * offdiag,
531 const gsl_vector * b,
532 gsl_vector * x);
533
534 /* Linear solve for a nonsymmetric cyclic tridiagonal system.
535
536 * The input vectors represent the NxN matrix as follows:
537 *
538 * diag[0] abovediag[0] 0 ..... belowdiag[N-1]
539 * belowdiag[0] diag[1] abovediag[1] .....
540 * 0 belowdiag[1] diag[2]
541 * 0 0 belowdiag[2] .....
542 * ... ...
543 * abovediag[N-1] ...
544 */
545 int gsl_linalg_solve_cyc_tridiag (const gsl_vector * diag,
546 const gsl_vector * abovediag,
547 const gsl_vector * belowdiag,
548 const gsl_vector * b,
549 gsl_vector * x);
550
551
552 /* Bidiagonal decomposition */
553
554 int gsl_linalg_bidiag_decomp (gsl_matrix * A,
555 gsl_vector * tau_U,
556 gsl_vector * tau_V);
557
558 int gsl_linalg_bidiag_unpack (const gsl_matrix * A,
559 const gsl_vector * tau_U,
560 gsl_matrix * U,
561 const gsl_vector * tau_V,
562 gsl_matrix * V,
563 gsl_vector * diag,
564 gsl_vector * superdiag);
565
566 int gsl_linalg_bidiag_unpack2 (gsl_matrix * A,
567 gsl_vector * tau_U,
568 gsl_vector * tau_V,
569 gsl_matrix * V);
570
571 int gsl_linalg_bidiag_unpack_B (const gsl_matrix * A,
572 gsl_vector * diag,
573 gsl_vector * superdiag);
574
575 /* Balancing */
576
577 int gsl_linalg_balance_matrix (gsl_matrix * A, gsl_vector * D);
578 int gsl_linalg_balance_accum (gsl_matrix * A, gsl_vector * D);
579 int gsl_linalg_balance_columns (gsl_matrix * A, gsl_vector * D);
580
581
582 __END_DECLS
583
584 #endif /* __GSL_LINALG_H__ */