Debian Codegraph @

dwsys/NUMlapack.h

raw symbols SCIP
1 #ifndef _NUMlapack_h_
2 #define _NUMlapack_h_
3 /* NUMlapack.h
4 *
5 * Copyright (C) 2020-2026 David Weenink
6 *
7 * This code is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or (at
10 * your option) any later version.
11 *
12 * This code is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this work. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "melder.h"
22 #include "clapack.h"
23 #undef max
24 #undef min
25
26 /*
27 Interface for the lapack routines used in Praat.
28
29 The LAPACK routines all use col major layout of matrices.
30 The matrix
31 1 2
32 3 4
33 can be layed out in memory as 1 2 3 4 (row major, C++) or as 1 3 2 4 (column major, fortran).
34
35 Sometimes we can avoid an explicit matrix conversion to col major layout by using the solution for the transposed problem.
36
37 The purpose of a routine and its parameter descriptions have all been copied from the LAPACK netlib repository.
38
39 Our NUMlapack_<name>_ interface merely removes inconvenient references.
40 We used the following conventions in the interface definitions:
41 1. The interface name is the CLAPACK name with "NUMlapack_" in front.
42 (e.g. the lapack routine dgeev_ becomes NUMlapack_dgeev_)
43 2. We have removed all inconvenient pointers to input only integers.
44 (e.g. "integer *n, the third argument type of dgeev_, has become
45 "integer n" in NUMlapack_dgeev_)
46 3. Array pointers are always zero-based and made explicit by using "[]" after the variable name
47 instead of "*" before the name.
48 (e.g. "double inout_a []" instead of "double *inout_a" as the fourth
49 argument of NUMlapack_dgeev_)
50 4. Scalar pointers should never be the nullptr.
51 5. Array pointers whose name starts with "inout_" should never equal the nullptr.
52 The arrays they point to always have to be of the correct dimension.
53 6. Only an array pointer's name starting with "inoutout_" may contain a nullptr
54 occasionaly if the rest of the parameter settings allow.
55 */
56
57 static inline double NUMlapack_dlamch_ (const char *cmach) {
58 return dlamch_(cmach);
59 }
60
61 static inline int NUMlapack_dgeev_ (const char *jobvl, const char *jobvr, integer n, double inout_a [], integer lda, double inout_wr [], double inout_wi [], double inoutout_vl [], integer ldvl, double inoutout_vr [], integer ldvr, double inout_work [], integer lwork, integer *info)
62 {
63 return dgeev_ (jobvl, jobvr, & n, inout_a, & lda, inout_wr, inout_wi, inoutout_vl, & ldvl, inoutout_vr, & ldvr, inout_work, & lwork, info);
64 }
65 /* -- LAPACK driver routine (version 3.1) -- */
66 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
67 /* November 2006 */
68
69 /* .. Scalar Arguments .. */
70 /* .. */
71 /* .. Array Arguments .. */
72 /* .. */
73
74 /* Purpose */
75 /* ======= */
76
77 /* DGEEV computes for an N-by-N real nonsymmetric matrix A, the */
78 /* eigenvalues and, optionally, the left and/or right eigenvectors. */
79
80 /* The right eigenvector v(j) of A satisfies */
81 /* A * v(j) = lambda(j) * v(j) */
82 /* where lambda(j) is its eigenvalue. */
83 /* The left eigenvector u(j) of A satisfies */
84 /* u(j)**H * A = lambda(j) * u(j)**H */
85 /* where u(j)**H denotes the conjugate transpose of u(j). */
86
87 /* The computed eigenvectors are normalized to have Euclidean norm */
88 /* equal to 1 and largest component real. */
89
90 /* Arguments */
91 /* ========= */
92
93 /* JOBVL (input) CHARACTER*1 */
94 /* = 'N': left eigenvectors of A are not computed; */
95 /* = 'V': left eigenvectors of A are computed. */
96
97 /* JOBVR (input) CHARACTER*1 */
98 /* = 'N': right eigenvectors of A are not computed; */
99 /* = 'V': right eigenvectors of A are computed. */
100
101 /* N (input) INTEGER */
102 /* The order of the matrix A. N >= 0. */
103
104 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
105 /* On entry, the N-by-N matrix A. */
106 /* On exit, A has been overwritten. */
107
108 /* LDA (input) INTEGER */
109 /* The leading dimension of the array A. LDA >= max(1,N). */
110
111 /* WR (output) DOUBLE PRECISION array, dimension (N) */
112 /* WI (output) DOUBLE PRECISION array, dimension (N) */
113 /* WR and WI contain the real and imaginary parts, */
114 /* respectively, of the computed eigenvalues. Complex */
115 /* conjugate pairs of eigenvalues appear consecutively */
116 /* with the eigenvalue having the positive imaginary part */
117 /* first. */
118
119 /* VL (output) DOUBLE PRECISION array, dimension (LDVL,N) */
120 /* If JOBVL = 'V', the left eigenvectors u(j) are stored one */
121 /* after another in the columns of VL, in the same order */
122 /* as their eigenvalues. */
123 /* If JOBVL = 'N', VL is not referenced. */
124 /* If the j-th eigenvalue is real, then u(j) = VL(:,j), */
125 /* the j-th column of VL. */
126 /* If the j-th and (j+1)-st eigenvalues form a complex */
127 /* conjugate pair, then u(j) = VL(:,j) + i*VL(:,j+1) and */
128 /* u(j+1) = VL(:,j) - i*VL(:,j+1). */
129
130 /* LDVL (input) INTEGER */
131 /* The leading dimension of the array VL. LDVL >= 1; if */
132 /* JOBVL = 'V', LDVL >= N. */
133
134 /* VR (output) DOUBLE PRECISION array, dimension (LDVR,N) */
135 /* If JOBVR = 'V', the right eigenvectors v(j) are stored one */
136 /* after another in the columns of VR, in the same order */
137 /* as their eigenvalues. */
138 /* If JOBVR = 'N', VR is not referenced. */
139 /* If the j-th eigenvalue is real, then v(j) = VR(:,j), */
140 /* the j-th column of VR. */
141 /* If the j-th and (j+1)-st eigenvalues form a complex */
142 /* conjugate pair, then v(j) = VR(:,j) + i*VR(:,j+1) and */
143 /* v(j+1) = VR(:,j) - i*VR(:,j+1). */
144
145 /* LDVR (input) INTEGER */
146 /* The leading dimension of the array VR. LDVR >= 1; if */
147 /* JOBVR = 'V', LDVR >= N. */
148
149 /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */
150 /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
151
152 /* LWORK (input) INTEGER */
153 /* The dimension of the array WORK. LWORK >= max(1,3*N), and */
154 /* if JOBVL = 'V' or JOBVR = 'V', LWORK >= 4*N. For good */
155 /* performance, LWORK must generally be larger. */
156
157 /* If LWORK = -1, then a workspace query is assumed; the routine */
158 /* only calculates the optimal size of the WORK array, returns */
159 /* this value as the first entry of the WORK array, and no error */
160 /* message related to LWORK is issued by XERBLA. */
161
162 /* INFO (output) INTEGER */
163 /* = 0: successful exit */
164 /* < 0: if INFO = -i, the i-th argument had an illegal value. */
165 /* > 0: if INFO = i, the QR algorithm failed to compute all the */
166 /* eigenvalues, and no eigenvectors have been computed; */
167 /* elements i+1:N of WR and WI contain eigenvalues which */
168 /* have converged. */
169
170 /* ===================================================================== */
171
172
173 static inline int NUMlapack_dgesvd_ (const char *jobu, const char *jobvt, integer m, integer n, double inout_a [], integer lda, double inout_s [], double inout_u [], integer ldu, double inoutout_vt [], integer ldvt, double inout_work [], integer lwork, integer *info) {
174 return dgesvd_ (jobu, jobvt, & m, & n, inout_a, & lda, inout_s, inout_u, & ldu, inoutout_vt, & ldvt, inout_work, & lwork, info);
175 }
176 /* -- LAPACK driver routine (version 3.1) -- */
177 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
178 /* November 2006 */
179
180 /* .. Scalar Arguments .. */
181 /* .. */
182 /* .. Array Arguments .. */
183 /* .. */
184
185 /* Purpose */
186 /* ======= */
187
188 /* DGESVD computes the singular value decomposition (SVD) of a real */
189 /* M-by-N matrix A, optionally computing the left and/or right singular */
190 /* vectors. The SVD is written */
191
192 /* A = U * SIGMA * transpose(V) */
193
194 /* where SIGMA is an M-by-N matrix which is zero except for its */
195 /* min(m,n) diagonal elements, U is an M-by-M orthogonal matrix, and */
196 /* V is an N-by-N orthogonal matrix. The diagonal elements of SIGMA */
197 /* are the singular values of A; they are real and non-negative, and */
198 /* are returned in descending order. The first min(m,n) columns of */
199 /* U and V are the left and right singular vectors of A. */
200
201 /* Note that the routine returns V**T, not V. */
202
203 /* Arguments */
204 /* ========= */
205
206 /* JOBU (input) CHARACTER*1 */
207 /* Specifies options for computing all or part of the matrix U: */
208 /* = 'A': all M columns of U are returned in array U: */
209 /* = 'S': the first min(m,n) columns of U (the left singular */
210 /* vectors) are returned in the array U; */
211 /* = 'O': the first min(m,n) columns of U (the left singular */
212 /* vectors) are overwritten on the array A; */
213 /* = 'N': no columns of U (no left singular vectors) are */
214 /* computed. */
215
216 /* JOBVT (input) CHARACTER*1 */
217 /* Specifies options for computing all or part of the matrix */
218 /* V**T: */
219 /* = 'A': all N rows of V**T are returned in the array VT; */
220 /* = 'S': the first min(m,n) rows of V**T (the right singular */
221 /* vectors) are returned in the array VT; */
222 /* = 'O': the first min(m,n) rows of V**T (the right singular */
223 /* vectors) are overwritten on the array A; */
224 /* = 'N': no rows of V**T (no right singular vectors) are */
225 /* computed. */
226
227 /* JOBVT and JOBU cannot both be 'O'. */
228
229 /* M (input) INTEGER */
230 /* The number of rows of the input matrix A. M >= 0. */
231
232 /* N (input) INTEGER */
233 /* The number of columns of the input matrix A. N >= 0. */
234
235 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
236 /* On entry, the M-by-N matrix A. */
237 /* On exit, */
238 /* if JOBU = 'O', A is overwritten with the first min(m,n) */
239 /* columns of U (the left singular vectors, */
240 /* stored columnwise); */
241 /* if JOBVT = 'O', A is overwritten with the first min(m,n) */
242 /* rows of V**T (the right singular vectors, */
243 /* stored rowwise); */
244 /* if JOBU .ne. 'O' and JOBVT .ne. 'O', the contents of A */
245 /* are destroyed. */
246
247 /* LDA (input) INTEGER */
248 /* The leading dimension of the array A. LDA >= max(1,M). */
249
250 /* S (output) DOUBLE PRECISION array, dimension (min(M,N)) */
251 /* The singular values of A, sorted so that S(i) >= S(i+1). */
252
253 /* U (output) DOUBLE PRECISION array, dimension (LDU,UCOL) */
254 /* (LDU,M) if JOBU = 'A' or (LDU,min(M,N)) if JOBU = 'S'. */
255 /* If JOBU = 'A', U contains the M-by-M orthogonal matrix U; */
256 /* if JOBU = 'S', U contains the first min(m,n) columns of U */
257 /* (the left singular vectors, stored columnwise); */
258 /* if JOBU = 'N' or 'O', U is not referenced. */
259
260 /* LDU (input) INTEGER */
261 /* The leading dimension of the array U. LDU >= 1; if */
262 /* JOBU = 'S' or 'A', LDU >= M. */
263
264 /* VT (output) DOUBLE PRECISION array, dimension (LDVT,N) */
265 /* If JOBVT = 'A', VT contains the N-by-N orthogonal matrix */
266 /* V**T; */
267 /* if JOBVT = 'S', VT contains the first min(m,n) rows of */
268 /* V**T (the right singular vectors, stored rowwise); */
269 /* if JOBVT = 'N' or 'O', VT is not referenced. */
270
271 /* LDVT (input) INTEGER */
272 /* The leading dimension of the array VT. LDVT >= 1; if */
273 /* JOBVT = 'A', LDVT >= N; if JOBVT = 'S', LDVT >= min(M,N). */
274
275 /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */
276 /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK; */
277 /* if INFO > 0, WORK(2:MIN(M,N)) contains the unconverged */
278 /* superdiagonal elements of an upper bidiagonal matrix B */
279 /* whose diagonal is in S (not necessarily sorted). B */
280 /* satisfies A = U * B * VT, so it has the same singular values */
281 /* as A, and singular vectors related by U and VT. */
282
283 /* LWORK (input) INTEGER */
284 /* The dimension of the array WORK. */
285 /* LWORK >= MAX(1,3*MIN(M,N)+MAX(M,N),5*MIN(M,N)). */
286 /* For good performance, LWORK should generally be larger. */
287
288 /* If LWORK = -1, then a workspace query is assumed; the routine */
289 /* only calculates the optimal size of the WORK array, returns */
290 /* this value as the first entry of the WORK array, and no error */
291 /* message related to LWORK is issued by XERBLA. */
292
293 /* INFO (output) INTEGER */
294 /* = 0: successful exit. */
295 /* < 0: if INFO = -i, the i-th argument had an illegal value. */
296 /* > 0: if DBDSQR did not converge, INFO specifies how many */
297 /* superdiagonals of an intermediate bidiagonal form B */
298 /* did not converge to zero. See the description of WORK */
299 /* above for details. */
300
301 /* ===================================================================== */
302
303
304 static inline int NUMlapack_dggsvd_ (const char *jobu, const char *jobv, const char *jobq, integer m, integer n, integer p, integer *inout_k, integer *inout_l, double inout_a [], integer lda, double b [], integer ldb, double inout_alpha [], double inout_beta [], double out_u [], integer ldu, double out_v [], integer ldv, double out_q [], integer ldq, double inout_work [], integer inout_iwork [], integer *info) {
305 return dggsvd_ (jobu, jobv, jobq, & m, & n, & p, inout_k, inout_l, inout_a, & lda, b, & ldb, inout_alpha, inout_beta, out_u, & ldu, out_v, & ldv, out_q, & ldq, inout_work, inout_iwork, info);
306 }
307 /* -- LAPACK driver routine (version 3.2) -- */
308 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
309 /* November 2006 */
310
311 /* .. Scalar Arguments .. */
312 /* .. */
313 /* .. Array Arguments .. */
314 /* .. */
315
316 /* Purpose */
317 /* ======= */
318
319 /* DGGSVD computes the generalized singular value decomposition (GSVD) */
320 /* of an M-by-N real matrix A and P-by-N real matrix B: */
321
322 /* U'*A*Q = D1*( 0 R ), V'*B*Q = D2*( 0 R ) */
323
324 /* where U, V and Q are orthogonal matrices, and Z' is the transpose */
325 /* of Z. Let K+L = the effective numerical rank of the matrix (A',B')', */
326 /* then R is a K+L-by-K+L nonsingular upper triangular matrix, D1 and */
327 /* D2 are M-by-(K+L) and P-by-(K+L) "diagonal" matrices and of the */
328 /* following structures, respectively: */
329
330 /* If M-K-L >= 0, */
331
332 /* K L */
333 /* D1 = K ( I 0 ) */
334 /* L ( 0 C ) */
335 /* M-K-L ( 0 0 ) */
336
337 /* K L */
338 /* D2 = L ( 0 S ) */
339 /* P-L ( 0 0 ) */
340
341 /* N-K-L K L */
342 /* ( 0 R ) = K ( 0 R11 R12 ) */
343 /* L ( 0 0 R22 ) */
344
345 /* where */
346
347 /* C = diag( ALPHA(K+1), ... , ALPHA(K+L) ), */
348 /* S = diag( BETA(K+1), ... , BETA(K+L) ), */
349 /* C**2 + S**2 = I. */
350
351 /* R is stored in A(1:K+L,N-K-L+1:N) on exit. */
352
353 /* If M-K-L < 0, */
354
355 /* K M-K K+L-M */
356 /* D1 = K ( I 0 0 ) */
357 /* M-K ( 0 C 0 ) */
358
359 /* K M-K K+L-M */
360 /* D2 = M-K ( 0 S 0 ) */
361 /* K+L-M ( 0 0 I ) */
362 /* P-L ( 0 0 0 ) */
363
364 /* N-K-L K M-K K+L-M */
365 /* ( 0 R ) = K ( 0 R11 R12 R13 ) */
366 /* M-K ( 0 0 R22 R23 ) */
367 /* K+L-M ( 0 0 0 R33 ) */
368
369 /* where */
370
371 /* C = diag( ALPHA(K+1), ... , ALPHA(M) ), */
372 /* S = diag( BETA(K+1), ... , BETA(M) ), */
373 /* C**2 + S**2 = I. */
374
375 /* (R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N), and R33 is stored */
376 /* ( 0 R22 R23 ) */
377 /* in B(M-K+1:L,N+M-K-L+1:N) on exit. */
378
379 /* The routine computes C, S, R, and optionally the orthogonal */
380 /* transformation matrices U, V and Q. */
381
382 /* In particular, if B is an N-by-N nonsingular matrix, then the GSVD of */
383 /* A and B implicitly gives the SVD of A*inv(B): */
384 /* A*inv(B) = U*(D1*inv(D2))*V'. */
385 /* If ( A',B')' has orthonormal columns, then the GSVD of A and B is */
386 /* also equal to the CS decomposition of A and B. Furthermore, the GSVD */
387 /* can be used to derive the solution of the eigenvalue problem: */
388 /* A'*A x = lambda* B'*B x. */
389 /* In some literature, the GSVD of A and B is presented in the form */
390 /* U'*A*X = ( 0 D1 ), V'*B*X = ( 0 D2 ) */
391 /* where U and V are orthogonal and X is nonsingular, D1 and D2 are */
392 /* ``diagonal''. The former GSVD form can be converted to the latter */
393 /* form by taking the nonsingular matrix X as */
394
395 /* X = Q*( I 0 ) */
396 /* ( 0 inv(R) ). */
397
398 /* Arguments */
399 /* ========= */
400
401 /* JOBU (input) CHARACTER*1 */
402 /* = 'U': Orthogonal matrix U is computed; */
403 /* = 'N': U is not computed. */
404
405 /* JOBV (input) CHARACTER*1 */
406 /* = 'V': Orthogonal matrix V is computed; */
407 /* = 'N': V is not computed. */
408
409 /* JOBQ (input) CHARACTER*1 */
410 /* = 'Q': Orthogonal matrix Q is computed; */
411 /* = 'N': Q is not computed. */
412
413 /* M (input) INTEGER */
414 /* The number of rows of the matrix A. M >= 0. */
415
416 /* N (input) INTEGER */
417 /* The number of columns of the matrices A and B. N >= 0. */
418
419 /* P (input) INTEGER */
420 /* The number of rows of the matrix B. P >= 0. */
421
422 /* K (output) INTEGER */
423 /* L (output) INTEGER */
424 /* On exit, K and L specify the dimension of the subblocks */
425 /* described in the Purpose section. */
426 /* K + L = effective numerical rank of (A',B')'. */
427
428 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
429 /* On entry, the M-by-N matrix A. */
430 /* On exit, A contains the triangular matrix R, or part of R. */
431 /* See Purpose for details. */
432
433 /* LDA (input) INTEGER */
434 /* The leading dimension of the array A. LDA >= max(1,M). */
435
436 /* B (input/output) DOUBLE PRECISION array, dimension (LDB,N) */
437 /* On entry, the P-by-N matrix B. */
438 /* On exit, B contains the triangular matrix R if M-K-L < 0. */
439 /* See Purpose for details. */
440
441 /* LDB (input) INTEGER */
442 /* The leading dimension of the array B. LDB >= max(1,P). */
443
444 /* ALPHA (output) DOUBLE PRECISION array, dimension (N) */
445 /* BETA (output) DOUBLE PRECISION array, dimension (N) */
446 /* On exit, ALPHA and BETA contain the generalized singular */
447 /* value pairs of A and B; */
448 /* ALPHA(1:K) = 1, */
449 /* BETA(1:K) = 0, */
450 /* and if M-K-L >= 0, */
451 /* ALPHA(K+1:K+L) = C, */
452 /* BETA(K+1:K+L) = S, */
453 /* or if M-K-L < 0, */
454 /* ALPHA(K+1:M)=C, ALPHA(M+1:K+L)=0 */
455 /* BETA(K+1:M) =S, BETA(M+1:K+L) =1 */
456 /* and */
457 /* ALPHA(K+L+1:N) = 0 */
458 /* BETA(K+L+1:N) = 0 */
459
460 /* U (output) DOUBLE PRECISION array, dimension (LDU,M) */
461 /* If JOBU = 'U', U contains the M-by-M orthogonal matrix U. */
462 /* If JOBU = 'N', U is not referenced. */
463
464 /* LDU (input) INTEGER */
465 /* The leading dimension of the array U. LDU >= max(1,M) if */
466 /* JOBU = 'U'; LDU >= 1 otherwise. */
467
468 /* V (output) DOUBLE PRECISION array, dimension (LDV,P) */
469 /* If JOBV = 'V', V contains the P-by-P orthogonal matrix V. */
470 /* If JOBV = 'N', V is not referenced. */
471
472 /* LDV (input) INTEGER */
473 /* The leading dimension of the array V. LDV >= max(1,P) if */
474 /* JOBV = 'V'; LDV >= 1 otherwise. */
475
476 /* Q (output) DOUBLE PRECISION array, dimension (LDQ,N) */
477 /* If JOBQ = 'Q', Q contains the N-by-N orthogonal matrix Q. */
478 /* If JOBQ = 'N', Q is not referenced. */
479
480 /* LDQ (input) INTEGER */
481 /* The leading dimension of the array Q. LDQ >= max(1,N) if */
482 /* JOBQ = 'Q'; LDQ >= 1 otherwise. */
483
484 /* WORK (workspace) DOUBLE PRECISION array, */
485 /* dimension (max(3*N,M,P)+N) */
486
487 /* IWORK (workspace/output) INTEGER array, dimension (N) */
488 /* On exit, IWORK stores the sorting information. More */
489 /* precisely, the following loop will sort ALPHA */
490 /* for I = K+1, min(M,K+L) */
491 /* swap ALPHA(I) and ALPHA(IWORK(I)) */
492 /* endfor */
493 /* such that ALPHA(1) >= ALPHA(2) >= ... >= ALPHA(N). */
494
495 /* INFO (output) INTEGER */
496 /* = 0: successful exit */
497 /* < 0: if INFO = -i, the i-th argument had an illegal value. */
498 /* > 0: if INFO = 1, the Jacobi-type procedure failed to */
499 /* converge. For further details, see subroutine DTGSJA. */
500
501 /* Internal Parameters */
502 /* =================== */
503
504 /* TOLA DOUBLE PRECISION */
505 /* TOLB DOUBLE PRECISION */
506 /* TOLA and TOLB are the thresholds to determine the effective */
507 /* rank of (A',B')'. Generally, they are set to */
508 /* TOLA = MAX(M,N)*norm(A)*MAZHEPS, */
509 /* TOLB = MAX(P,N)*norm(B)*MAZHEPS. */
510 /* The size of TOLA and TOLB may affect the size of backward */
511 /* errors of the decomposition. */
512
513 /* Further Details */
514 /* =============== */
515
516 /* 2-96 Based on modifications by */
517 /* Ming Gu and Huan Ren, Computer Science Division, University of */
518 /* California at Berkeley, USA */
519
520 /* ===================================================================== */
521
522 static inline int NUMlapack_dhseqr_ (const char *job, const char *compz, integer n, integer ilo, integer ihi, double inout_h [], integer ldh, double inout_wr [], double inout_wi [], double inoutout_z [], integer ldz, double inout_work [], integer lwork, integer *info)
523 {
524 return dhseqr_ (job, compz, & n, & ilo, & ihi, inout_h, & ldh, inout_wr, inout_wi, inoutout_z, & ldz, inout_work, & lwork, info);
525 }
526 /* -- LAPACK driver routine (version 3.2) -- */
527 /* Univ. of Tennessee, Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd.. */
528 /* November 2006 */
529
530 /* .. Scalar Arguments .. */
531 /* .. */
532 /* .. Array Arguments .. */
533 /* .. */
534 /* Purpose */
535 /* ======= */
536
537 /* DHSEQR computes the eigenvalues of a Hessenberg matrix H */
538 /* and, optionally, the matrices T and Z from the Schur decomposition */
539 /* H = Z T Z**T, where T is an upper quasi-triangular matrix (the */
540 /* Schur form), and Z is the orthogonal matrix of Schur vectors. */
541
542 /* Optionally Z may be postmultiplied into an input orthogonal */
543 /* matrix Q so that this routine can give the Schur factorization */
544 /* of a matrix A which has been reduced to the Hessenberg form H */
545 /* by the orthogonal matrix Q: A = Q*H*Q**T = (QZ)*T*(QZ)**T. */
546
547 /* Arguments */
548 /* ========= */
549
550 /* JOB (input) CHARACTER*1 */
551 /* = 'E': compute eigenvalues only; */
552 /* = 'S': compute eigenvalues and the Schur form T. */
553
554 /* COMPZ (input) CHARACTER*1 */
555 /* = 'N': no Schur vectors are computed; */
556 /* = 'I': Z is initialized to the unit matrix and the matrix Z */
557 /* of Schur vectors of H is returned; */
558 /* = 'V': Z must contain an orthogonal matrix Q on entry, and */
559 /* the product Q*Z is returned. */
560
561 /* N (input) INTEGER */
562 /* The order of the matrix H. N .GE. 0. */
563
564 /* ILO (input) INTEGER */
565 /* IHI (input) INTEGER */
566 /* It is assumed that H is already upper triangular in rows */
567 /* and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally */
568 /* set by a previous call to DGEBAL, and then passed to DGEHRD */
569 /* when the matrix output by DGEBAL is reduced to Hessenberg */
570 /* form. Otherwise ILO and IHI should be set to 1 and N */
571 /* respectively. If N.GT.0, then 1.LE.ILO.LE.IHI.LE.N. */
572 /* If N = 0, then ILO = 1 and IHI = 0. */
573
574 /* H (input/output) DOUBLE PRECISION array, dimension (LDH,N) */
575 /* On entry, the upper Hessenberg matrix H. */
576 /* On exit, if INFO = 0 and JOB = 'S', then H contains the */
577 /* upper quasi-triangular matrix T from the Schur decomposition */
578 /* (the Schur form); 2-by-2 diagonal blocks (corresponding to */
579 /* complex conjugate pairs of eigenvalues) are returned in */
580 /* standard form, with H(i,i) = H(i+1,i+1) and */
581 /* H(i+1,i)*H(i,i+1).LT.0. If INFO = 0 and JOB = 'E', the */
582 /* contents of H are unspecified on exit. (The output value of */
583 /* H when INFO.GT.0 is given under the description of INFO */
584 /* below.) */
585
586 /* Unlike earlier versions of DHSEQR, this subroutine may */
587 /* explicitly H(i,j) = 0 for i.GT.j and j = 1, 2, ... ILO-1 */
588 /* or j = IHI+1, IHI+2, ... N. */
589
590 /* LDH (input) INTEGER */
591 /* The leading dimension of the array H. LDH .GE. max(1,N). */
592
593 /* WR (output) DOUBLE PRECISION array, dimension (N) */
594 /* WI (output) DOUBLE PRECISION array, dimension (N) */
595 /* The real and imaginary parts, respectively, of the computed */
596 /* eigenvalues. If two eigenvalues are computed as a complex */
597 /* conjugate pair, they are stored in consecutive elements of */
598 /* WR and WI, say the i-th and (i+1)th, with WI(i) .GT. 0 and */
599 /* WI(i+1) .LT. 0. If JOB = 'S', the eigenvalues are stored in */
600 /* the same order as on the diagonal of the Schur form returned */
601 /* in H, with WR(i) = H(i,i) and, if H(i:i+1,i:i+1) is a 2-by-2 */
602 /* diagonal block, WI(i) = sqrt(-H(i+1,i)*H(i,i+1)) and */
603 /* WI(i+1) = -WI(i). */
604
605 /* Z (input/output) DOUBLE PRECISION array, dimension (LDZ,N) */
606 /* If COMPZ = 'N', Z is not referenced. */
607 /* If COMPZ = 'I', on entry Z need not be set and on exit, */
608 /* if INFO = 0, Z contains the orthogonal matrix Z of the Schur */
609 /* vectors of H. If COMPZ = 'V', on entry Z must contain an */
610 /* N-by-N matrix Q, which is assumed to be equal to the unit */
611 /* matrix except for the submatrix Z(ILO:IHI,ILO:IHI). On exit, */
612 /* if INFO = 0, Z contains Q*Z. */
613 /* Normally Q is the orthogonal matrix generated by DORGHR */
614 /* after the call to DGEHRD which formed the Hessenberg matrix */
615 /* H. (The output value of Z when INFO.GT.0 is given under */
616 /* the description of INFO below.) */
617
618 /* LDZ (input) INTEGER */
619 /* The leading dimension of the array Z. if COMPZ = 'I' or */
620 /* COMPZ = 'V', then LDZ.GE.MAX(1,N). Otherwize, LDZ.GE.1. */
621
622 /* WORK (workspace/output) DOUBLE PRECISION array, dimension (LWORK) */
623 /* On exit, if INFO = 0, WORK(1) returns an estimate of */
624 /* the optimal value for LWORK. */
625
626 /* LWORK (input) INTEGER */
627 /* The dimension of the array WORK. LWORK .GE. max(1,N) */
628 /* is sufficient and delivers very good and sometimes */
629 /* optimal performance. However, LWORK as large as 11*N */
630 /* may be required for optimal performance. A workspace */
631 /* query is recommended to determine the optimal workspace */
632 /* size. */
633
634 /* If LWORK = -1, then DHSEQR does a workspace query. */
635 /* In this case, DHSEQR checks the input parameters and */
636 /* estimates the optimal workspace size for the given */
637 /* values of N, ILO and IHI. The estimate is returned */
638 /* in WORK(1). No error message related to LWORK is */
639 /* issued by XERBLA. Neither H nor Z are accessed. */
640
641
642 /* INFO (output) INTEGER */
643 /* = 0: successful exit */
644 /* .LT. 0: if INFO = -i, the i-th argument had an illegal */
645 /* value */
646 /* .GT. 0: if INFO = i, DHSEQR failed to compute all of */
647 /* the eigenvalues. Elements 1:ilo-1 and i+1:n of WR */
648 /* and WI contain those eigenvalues which have been */
649 /* successfully computed. (Failures are rare.) */
650
651 /* If INFO .GT. 0 and JOB = 'E', then on exit, the */
652 /* remaining unconverged eigenvalues are the eigen- */
653 /* values of the upper Hessenberg matrix rows and */
654 /* columns ILO through INFO of the final, output */
655 /* value of H. */
656
657 /* If INFO .GT. 0 and JOB = 'S', then on exit */
658
659 /* (*) (initial value of H)*U = U*(final value of H) */
660
661 /* where U is an orthogonal matrix. The final */
662 /* value of H is upper Hessenberg and quasi-triangular */
663 /* in rows and columns INFO+1 through IHI. */
664
665 /* If INFO .GT. 0 and COMPZ = 'V', then on exit */
666
667 /* (final value of Z) = (initial value of Z)*U */
668
669 /* where U is the orthogonal matrix in (*) (regard- */
670 /* less of the value of JOB.) */
671
672 /* If INFO .GT. 0 and COMPZ = 'I', then on exit */
673 /* (final value of Z) = U */
674 /* where U is the orthogonal matrix in (*) (regard- */
675 /* less of the value of JOB.) */
676
677 /* If INFO .GT. 0 and COMPZ = 'N', then Z is not */
678 /* accessed. */
679
680 /* ================================================================ */
681 /* Default values supplied by */
682 /* ILAENV(ISPEC,'DHSEQR',JOB(:1)//COMPZ(:1),N,ILO,IHI,LWORK). */
683 /* It is suggested that these defaults be adjusted in order */
684 /* to attain best performance in each particular */
685 /* computational environment. */
686
687 /* ISPEC=12: The DLAHQR vs DLAQR0 crossover point. */
688 /* Default: 75. (Must be at least 11.) */
689
690 /* ISPEC=13: Recommended deflation window size. */
691 /* This depends on ILO, IHI and NS. NS is the */
692 /* number of simultaneous shifts returned */
693 /* by ILAENV(ISPEC=15). (See ISPEC=15 below.) */
694 /* The default for (IHI-ILO+1).LE.500 is NS. */
695 /* The default for (IHI-ILO+1).GT.500 is 3*NS/2. */
696
697 /* ISPEC=14: Nibble crossover point. (See IPARMQ for */
698 /* details.) Default: 14% of deflation window */
699 /* size. */
700
701 /* ISPEC=15: Number of simultaneous shifts in a multishift */
702 /* QR iteration. */
703
704 /* If IHI-ILO+1 is ... */
705
706 /* greater than ...but less ... the */
707 /* or equal to ... than default is */
708
709 /* 1 30 NS = 2(+) */
710 /* 30 60 NS = 4(+) */
711 /* 60 150 NS = 10(+) */
712 /* 150 590 NS = ** */
713 /* 590 3000 NS = 64 */
714 /* 3000 6000 NS = 128 */
715 /* 6000 infinity NS = 256 */
716
717 /* (+) By default some or all matrices of this order */
718 /* are passed to the implicit double shift routine */
719 /* DLAHQR and this parameter is ignored. See */
720 /* ISPEC=12 above and comments in IPARMQ for */
721 /* details. */
722
723 /* (**) The asterisks (**) indicate an ad-hoc */
724 /* function of N increasing from 10 to 64. */
725
726 /* ISPEC=16: Select structured matrix multiply. */
727 /* If the number of simultaneous shifts (specified */
728 /* by ISPEC=15) is less than 14, then the default */
729 /* for ISPEC=16 is 0. Otherwise the default for */
730 /* ISPEC=16 is 2. */
731
732 /* ================================================================ */
733 /* Based on contributions by */
734 /* Karen Braman and Ralph Byers, Department of Mathematics, */
735 /* University of Kansas, USA */
736
737 /* ================================================================ */
738 /* References: */
739 /* K. Braman, R. Byers and R. Mathias, The Multi-Shift QR */
740 /* Algorithm Part I: Maintaining Well Focused Shifts, and Level 3 */
741 /* Performance, SIAM Journal of Matrix Analysis, volume 23, pages */
742 /* 929--947, 2002. */
743
744 /* K. Braman, R. Byers and R. Mathias, The Multi-Shift QR */
745 /* Algorithm Part II: Aggressive Early Deflation, SIAM Journal */
746 /* of Matrix Analysis, volume 23, pages 948--973, 2002. */
747
748 /* ================================================================ */
749
750 static inline int NUMlapack_dstevr (const char *jobz, const char *range, integer n,
751 double inout_d [], double inout_e [], double vl, double vu, integer il, integer iu,
752 double abstol, integer *numberOfEigenvaluesFound, double inout_eigenvalues [],
753 double out_eigenvectors [], integer ldz, integer isuppz [], double work [],
754 integer lwork, integer iwork [], integer liwork, integer *info)
755 {
756 return dstevr_ (jobz, range, & n, inout_d, inout_e, & vl, & vu, & il, & iu, & abstol, numberOfEigenvaluesFound,
757 inout_eigenvalues, out_eigenvectors, & ldz, isuppz, work,
758 & lwork, iwork, & liwork, info);
759 }
760 /*
761 DSTEVR computes selected eigenvalues and, optionally, eigenvectors
762 of a real symmetric tridiagonal matrix T. Eigenvalues and
763 eigenvectors can be selected by specifying either a range of values
764 or a range of indices for the desired eigenvalues.
765
766 Whenever possible, DSTEVR calls DSTEMR to compute the
767 eigenspectrum using Relatively Robust Representations. DSTEMR
768 computes eigenvalues by the dqds algorithm, while orthogonal
769 eigenvectors are computed from various 'good' L D L^T representations
770 (also known as Relatively Robust Representations). Gram-Schmidt
771 orthogonalization is avoided as far as possible. More specifically,
772 the various steps of the algorithm are as follows. For the i-th
773 unreduced block of T,
774 (a) Compute T - sigma_i = L_i D_i L_i^T, such that L_i D_i L_i^T
775 is a relatively robust representation,
776 (b) Compute the eigenvalues, lambda_j, of L_i D_i L_i^T to high
777 relative accuracy by the dqds algorithm,
778 (c) If there is a cluster of close eigenvalues, 'choose' sigma_i
779 close to the cluster, and go to step (a),
780 (d) Given the approximate eigenvalue lambda_j of L_i D_i L_i^T,
781 compute the corresponding eigenvector by forming a
782 rank-revealing twisted factorization.
783 The desired accuracy of the output can be specified by the input
784 parameter ABSTOL.
785
786 For more details, see 'A new O(n^2) algorithm for the symmetric
787 tridiagonal eigenvalue/eigenvector problem', by Inderjit Dhillon,
788 Computer Science Division Technical Report No. UCB//CSD-97-971,
789 UC Berkeley, May 1997.
790
791 Note 1 : DSTEVR calls DSTEMR when the full spectrum is requested
792 on machines which conform to the ieee-754 floating point standard.
793 DSTEVR calls DSTEBZ and DSTEIN on non-ieee machines and
794 when partial spectrum requests are made.
795
796 Normal execution of DSTEMR may create NaNs and infinities and
797 hence may abort due to a floating point exception in environments
798 which do not handle NaNs and infinities in the ieee standard default
799 manner.
800
801 Parameters
802
803 JOBZ
804
805 JOBZ is CHARACTER*1
806 = 'N': Compute eigenvalues only;
807 = 'V': Compute eigenvalues and eigenvectors.
808
809 RANGE
810
811 RANGE is CHARACTER*1
812 = 'A': all eigenvalues will be found.
813 = 'V': all eigenvalues in the half-open interval (VL,VU]
814 will be found.
815 = 'I': the IL-th through IU-th eigenvalues will be found.
816 For RANGE = 'V' or 'I' and IU - IL < N - 1, DSTEBZ and
817 DSTEIN are called
818
819 N
820
821 N is INTEGER
822 The order of the matrix. N >= 0.
823
824 D
825
826 D is DOUBLE PRECISION array, dimension (N)
827 On entry, the n diagonal elements of the tridiagonal matrix
828 A.
829 On exit, D may be multiplied by a constant factor chosen
830 to avoid over/underflow in computing the eigenvalues.
831
832 E
833
834 E is DOUBLE PRECISION array, dimension (max(1,N-1))
835 On entry, the (n-1) subdiagonal elements of the tridiagonal
836 matrix A in elements 1 to N-1 of E.
837 On exit, E may be multiplied by a constant factor chosen
838 to avoid over/underflow in computing the eigenvalues.
839
840 VL
841
842 VL is DOUBLE PRECISION
843 If RANGE='V', the lower bound of the interval to
844 be searched for eigenvalues. VL < VU.
845 Not referenced if RANGE = 'A' or 'I'.
846
847 VU
848
849 VU is DOUBLE PRECISION
850 If RANGE='V', the upper bound of the interval to
851 be searched for eigenvalues. VL < VU.
852 Not referenced if RANGE = 'A' or 'I'.
853
854 IL
855
856 IL is INTEGER
857 If RANGE='I', the index of the
858 smallest eigenvalue to be returned.
859 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
860 Not referenced if RANGE = 'A' or 'V'.
861
862 IU
863
864 IU is INTEGER
865 If RANGE='I', the index of the
866 largest eigenvalue to be returned.
867 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
868 Not referenced if RANGE = 'A' or 'V'.
869
870 ABSTOL
871
872 ABSTOL is DOUBLE PRECISION
873 The absolute error tolerance for the eigenvalues.
874 An approximate eigenvalue is accepted as converged
875 when it is determined to lie in an interval [a,b]
876 of width less than or equal to
877
878 ABSTOL + EPS * max( |a|,|b| ) ,
879
880 where EPS is the machine precision. If ABSTOL is less than
881 or equal to zero, then EPS*|T| will be used in its place,
882 where |T| is the 1-norm of the tridiagonal matrix obtained
883 by reducing A to tridiagonal form.
884
885 See 'Computing Small Singular Values of Bidiagonal Matrices
886 with Guaranteed High Relative Accuracy,' by Demmel and
887 Kahan, LAPACK Working Note #3.
888
889 If high relative accuracy is important, set ABSTOL to
890 DLAMCH( 'Safe minimum' ). Doing so will guarantee that
891 eigenvalues are computed to high relative accuracy when
892 possible in future releases. The current code does not
893 make any guarantees about high relative accuracy, but
894 future releases will. See J. Barlow and J. Demmel,
895 'Computing Accurate Eigensystems of Scaled Diagonally
896 Dominant Matrices', LAPACK Working Note #7, for a discussion
897 of which matrices define their eigenvalues to high relative
898 accuracy.
899
900 M
901
902 M is INTEGER
903 The total number of eigenvalues found. 0 <= M <= N.
904 If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
905
906 W
907
908 W is DOUBLE PRECISION array, dimension (N)
909 The first M elements contain the selected eigenvalues in
910 ascending order.
911
912 Z
913
914 Z is DOUBLE PRECISION array, dimension (LDZ, max(1,M) )
915 If JOBZ = 'V', then if INFO = 0, the first M columns of Z
916 contain the orthonormal eigenvectors of the matrix A
917 corresponding to the selected eigenvalues, with the i-th
918 column of Z holding the eigenvector associated with W(i).
919 Note: the user must ensure that at least max(1,M) columns are
920 supplied in the array Z; if RANGE = 'V', the exact value of M
921 is not known in advance and an upper bound must be used.
922
923 LDZ
924
925 LDZ is INTEGER
926 The leading dimension of the array Z. LDZ >= 1, and if
927 JOBZ = 'V', LDZ >= max(1,N).
928
929 ISUPPZ
930
931 ISUPPZ is INTEGER array, dimension ( 2*max(1,M) )
932 The support of the eigenvectors in Z, i.e., the indices
933 indicating the nonzero elements in Z. The i-th eigenvector
934 is nonzero only in elements ISUPPZ( 2*i-1 ) through
935 ISUPPZ( 2*i ).
936 Implemented only for RANGE = 'A' or 'I' and IU - IL = N - 1
937
938 WORK
939
940 WORK is DOUBLE PRECISION array, dimension (MAX(1,LWORK))
941 On exit, if INFO = 0, WORK(1) returns the optimal (and
942 minimal) LWORK.
943
944 LWORK
945
946 LWORK is INTEGER
947 The dimension of the array WORK. LWORK >= max(1,20*N).
948
949 If LWORK = -1, then a workspace query is assumed; the routine
950 only calculates the optimal sizes of the WORK and IWORK
951 arrays, returns these values as the first entries of the WORK
952 and IWORK arrays, and no error message related to LWORK or
953 LIWORK is issued by XERBLA.
954
955 IWORK
956
957 IWORK is INTEGER array, dimension (MAX(1,LIWORK))
958 On exit, if INFO = 0, IWORK(1) returns the optimal (and
959 minimal) LIWORK.
960
961 LIWORK
962
963 LIWORK is INTEGER
964 The dimension of the array IWORK. LIWORK >= max(1,10*N).
965
966 If LIWORK = -1, then a workspace query is assumed; the
967 routine only calculates the optimal sizes of the WORK and
968 IWORK arrays, returns these values as the first entries of
969 the WORK and IWORK arrays, and no error message related to
970 LWORK or LIWORK is issued by XERBLA.
971
972 INFO
973
974 INFO is INTEGER
975 = 0: successful exit
976 < 0: if INFO = -i, the i-th argument had an illegal value
977 > 0: Internal error
978 */
979
980 static inline int NUMlapack_dpotf2_ (const char *uplo, integer n, double inout_a [], integer lda, integer *info)
981 {
982 return dpotf2_ (uplo, & n, inout_a, & lda, info);
983 }
984 /* -- LAPACK routine (version 3.2) -- */
985 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
986 /* November 2006 */
987
988 /* .. Scalar Arguments .. */
989 /* .. */
990 /* .. Array Arguments .. */
991 /* .. */
992
993 /* Purpose */
994 /* ======= */
995
996 /* DPOTF2 computes the Cholesky factorization of a real symmetric */
997 /* positive definite matrix A. */
998
999 /* The factorization has the form */
1000 /* A = U' * U , if UPLO = 'U', or */
1001 /* A = L * L', if UPLO = 'L', */
1002 /* where U is an upper triangular matrix and L is lower triangular. */
1003
1004 /* This is the unblocked version of the algorithm, calling Level 2 BLAS. */
1005
1006 /* Arguments */
1007 /* ========= */
1008
1009 /* UPLO (input) CHARACTER*1 */
1010 /* Specifies whether the upper or lower triangular part of the */
1011 /* symmetric matrix A is stored. */
1012 /* = 'U': Upper triangular */
1013 /* = 'L': Lower triangular */
1014
1015 /* N (input) INTEGER */
1016 /* The order of the matrix A. N >= 0. */
1017
1018 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
1019 /* On entry, the symmetric matrix A. If UPLO = 'U', the leading */
1020 /* n by n upper triangular part of A contains the upper */
1021 /* triangular part of the matrix A, and the strictly lower */
1022 /* triangular part of A is not referenced. If UPLO = 'L', the */
1023 /* leading n by n lower triangular part of A contains the lower */
1024 /* triangular part of the matrix A, and the strictly upper */
1025 /* triangular part of A is not referenced. */
1026
1027 /* On exit, if INFO = 0, the factor U or L from the Cholesky */
1028 /* factorization A = U'*U or A = L*L'. */
1029
1030 /* LDA (input) INTEGER */
1031 /* The leading dimension of the array A. LDA >= max(1,N). */
1032
1033 /* INFO (output) INTEGER */
1034 /* = 0: successful exit */
1035 /* < 0: if INFO = -k, the k-th argument had an illegal value */
1036 /* > 0: if INFO = k, the leading minor of order k is not */
1037 /* positive definite, and the factorization could not be */
1038 /* completed. */
1039
1040 /* ===================================================================== */
1041
1042 static inline int NUMlapack_dsyev_ (const char *jobz, const char *uplo, integer n,
1043 double inout_a [], integer lda, double inout_w [], double inout_work [],
1044 integer lwork, integer *info)
1045 {
1046 return dsyev_ (jobz, uplo, & n, inout_a, & lda, inout_w, inout_work, & lwork, info);
1047 }
1048 /* -- LAPACK driver routine (version 3.2) -- */
1049 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
1050 /* November 2006 */
1051
1052 /* .. Scalar Arguments .. */
1053 /* .. */
1054 /* .. Array Arguments .. */
1055 /* .. */
1056
1057 /* Purpose */
1058 /* ======= */
1059
1060 /* DSYEV computes all eigenvalues and, optionally, eigenvectors of a */
1061 /* real symmetric matrix A. */
1062
1063 /* Arguments */
1064 /* ========= */
1065
1066 /* JOBZ (input) CHARACTER*1 */
1067 /* = 'N': Compute eigenvalues only; */
1068 /* = 'V': Compute eigenvalues and eigenvectors. */
1069
1070 /* UPLO (input) CHARACTER*1 */
1071 /* = 'U': Upper triangle of A is stored; */
1072 /* = 'L': Lower triangle of A is stored. */
1073
1074 /* N (input) INTEGER */
1075 /* The order of the matrix A. N >= 0. */
1076
1077 /* A (input/output) DOUBLE PRECISION array, dimension (LDA, N) */
1078 /* On entry, the symmetric matrix A. If UPLO = 'U', the */
1079 /* leading N-by-N upper triangular part of A contains the */
1080 /* upper triangular part of the matrix A. If UPLO = 'L', */
1081 /* the leading N-by-N lower triangular part of A contains */
1082 /* the lower triangular part of the matrix A. */
1083 /* On exit, if JOBZ = 'V', then if INFO = 0, A contains the */
1084 /* orthonormal eigenvectors of the matrix A. */
1085 /* If JOBZ = 'N', then on exit the lower triangle (if UPLO='L') */
1086 /* or the upper triangle (if UPLO='U') of A, including the */
1087 /* diagonal, is destroyed. */
1088
1089 /* LDA (input) INTEGER */
1090 /* The leading dimension of the array A. LDA >= max(1,N). */
1091
1092 /* W (output) DOUBLE PRECISION array, dimension (N) */
1093 /* If INFO = 0, the eigenvalues in ascending order. */
1094
1095 /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */
1096 /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
1097
1098 /* LWORK (input) INTEGER */
1099 /* The length of the array WORK. LWORK >= max(1,3*N-1). */
1100 /* For optimal efficiency, LWORK >= (NB+2)*N, */
1101 /* where NB is the blocksize for DSYTRD returned by ILAENV. */
1102
1103 /* If LWORK = -1, then a workspace query is assumed; the routine */
1104 /* only calculates the optimal size of the WORK array, returns */
1105 /* this value as the first entry of the WORK array, and no error */
1106 /* message related to LWORK is issued by XERBLA. */
1107
1108 /* INFO (output) INTEGER */
1109 /* = 0: successful exit */
1110 /* < 0: if INFO = -i, the i-th argument had an illegal value */
1111 /* > 0: if INFO = i, the algorithm failed to converge; i */
1112 /* off-diagonal elements of an intermediate tridiagonal */
1113 /* form did not converge to zero. */
1114
1115 /* ===================================================================== */
1116
1117
1118 static inline int NUMlapack_dtrtri_ (const char *uplo, const char *diag, integer n, double
1119 inout_a [], integer lda, integer *inout_info)
1120 {
1121 return dtrtri_ (uplo, diag, & n, inout_a, & lda, inout_info);
1122 }
1123 /* -- LAPACK routine (version 3.1) -- */
1124 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
1125 /* November 2006 */
1126
1127 /* .. Scalar Arguments .. */
1128 /* .. */
1129 /* .. Array Arguments .. */
1130 /* .. */
1131
1132 /* Purpose */
1133 /* ======= */
1134
1135 /* DTRTRI computes the inverse of a real upper or lower triangular */
1136 /* matrix A. */
1137
1138 /* This is the Level 3 BLAS version of the algorithm. */
1139
1140 /* Arguments */
1141 /* ========= */
1142
1143 /* UPLO (input) CHARACTER*1 */
1144 /* = 'U': A is upper triangular; */
1145 /* = 'L': A is lower triangular. */
1146
1147 /* DIAG (input) CHARACTER*1 */
1148 /* = 'N': A is non-unit triangular; */
1149 /* = 'U': A is unit triangular. */
1150
1151 /* N (input) INTEGER */
1152 /* The order of the matrix A. N >= 0. */
1153
1154 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
1155 /* On entry, the triangular matrix A. If UPLO = 'U', the */
1156 /* leading N-by-N upper triangular part of the array A contains */
1157 /* the upper triangular matrix, and the strictly lower */
1158 /* triangular part of A is not referenced. If UPLO = 'L', the */
1159 /* leading N-by-N lower triangular part of the array A contains */
1160 /* the lower triangular matrix, and the strictly upper */
1161 /* triangular part of A is not referenced. If DIAG = 'U', the */
1162 /* diagonal elements of A are also not referenced and are */
1163 /* assumed to be 1. */
1164 /* On exit, the (triangular) inverse of the original matrix, in */
1165 /* the same storage format. */
1166
1167 /* LDA (input) INTEGER */
1168 /* The leading dimension of the array A. LDA >= max(1,N). */
1169
1170 /* INFO (output) INTEGER */
1171 /* = 0: successful exit */
1172 /* < 0: if INFO = -i, the i-th argument had an illegal value */
1173 /* > 0: if INFO = i, A(i,i) is exactly zero. The triangular */
1174 /* matrix is singular and its inverse can not be computed. */
1175 /* ===================================================================== */
1176
1177 static inline int NUMlapack_dtrti2_ (const char *uplo, const char *diag, integer n, double inout_a [], integer lda, integer *inout_info)
1178 {
1179 return dtrti2_ (uplo, diag, & n, inout_a, & lda, inout_info);
1180 }
1181 /* -- LAPACK routine (version 3.2) -- */
1182 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
1183 /* November 2006 */
1184
1185 /* .. Scalar Arguments .. */
1186 /* .. */
1187 /* .. Array Arguments .. */
1188 /* .. */
1189
1190 /* Purpose */
1191 /* ======= */
1192
1193 /* DTRTI2 computes the inverse of a real upper or lower triangular */
1194 /* matrix. */
1195
1196 /* This is the Level 2 BLAS version of the algorithm. */
1197
1198 /* Arguments */
1199 /* ========= */
1200
1201 /* UPLO (input) CHARACTER*1 */
1202 /* Specifies whether the matrix A is upper or lower triangular. */
1203 /* = 'U': Upper triangular */
1204 /* = 'L': Lower triangular */
1205
1206 /* DIAG (input) CHARACTER*1 */
1207 /* Specifies whether or not the matrix A is unit triangular. */
1208 /* = 'N': Non-unit triangular */
1209 /* = 'U': Unit triangular */
1210
1211 /* N (input) INTEGER */
1212 /* The order of the matrix A. N >= 0. */
1213
1214 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
1215 /* On entry, the triangular matrix A. If UPLO = 'U', the */
1216 /* leading n by n upper triangular part of the array A contains */
1217 /* the upper triangular matrix, and the strictly lower */
1218 /* triangular part of A is not referenced. If UPLO = 'L', the */
1219 /* leading n by n lower triangular part of the array A contains */
1220 /* the lower triangular matrix, and the strictly upper */
1221 /* triangular part of A is not referenced. If DIAG = 'U', the */
1222 /* diagonal elements of A are also not referenced and are */
1223 /* assumed to be 1. */
1224
1225 /* On exit, the (triangular) inverse of the original matrix, in */
1226 /* the same storage format. */
1227
1228 /* LDA (input) INTEGER */
1229 /* The leading dimension of the array A. LDA >= max(1,N). */
1230
1231 /* INFO (output) INTEGER */
1232 /* = 0: successful exit */
1233 /* < 0: if INFO = -k, the k-th argument had an illegal value */
1234 /* ===================================================================== */
1235
1236
1237 static inline int NUMlapack_dsytrf_(const char *uplo, integer n, double *inout_a, integer lda, integer *out_ipiv,
1238 double *work, integer lwork, integer *inout_info) {
1239 return dsytrf_(uplo, & n, inout_a, & lda, out_ipiv, work, & lwork, inout_info);
1240 }
1241 /* -- LAPACK routine (version 3.1) -- */
1242 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
1243 /* November 2006 */
1244
1245 /* .. Scalar Arguments .. */
1246 /* .. */
1247 /* .. Array Arguments .. */
1248 /* .. */
1249
1250 /* Purpose */
1251 /* ======= */
1252
1253 /* DSYTRF computes the factorization of a real symmetric matrix A using */
1254 /* the Bunch-Kaufman diagonal pivoting method. The form of the */
1255 /* factorization is */
1256
1257 /* A = U*D*U**T or A = L*D*L**T */
1258
1259 /* where U (or L) is a product of permutation and unit upper (lower) */
1260 /* triangular matrices, and D is symmetric and block diagonal with */
1261 /* 1-by-1 and 2-by-2 diagonal blocks. */
1262
1263 /* This is the blocked version of the algorithm, calling Level 3 BLAS. */
1264
1265 /* Arguments */
1266 /* ========= */
1267
1268 /* UPLO (input) CHARACTER*1 */
1269 /* = 'U': Upper triangle of A is stored; */
1270 /* = 'L': Lower triangle of A is stored. */
1271
1272 /* N (input) INTEGER */
1273 /* The order of the matrix A. N >= 0. */
1274
1275 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
1276 /* On entry, the symmetric matrix A. If UPLO = 'U', the leading */
1277 /* N-by-N upper triangular part of A contains the upper */
1278 /* triangular part of the matrix A, and the strictly lower */
1279 /* triangular part of A is not referenced. If UPLO = 'L', the */
1280 /* leading N-by-N lower triangular part of A contains the lower */
1281 /* triangular part of the matrix A, and the strictly upper */
1282 /* triangular part of A is not referenced. */
1283
1284 /* On exit, the block diagonal matrix D and the multipliers used */
1285 /* to obtain the factor U or L (see below for further details). */
1286
1287 /* LDA (input) INTEGER */
1288 /* The leading dimension of the array A. LDA >= max(1,N). */
1289
1290 /* IPIV (output) INTEGER array, dimension (N) */
1291 /* Details of the interchanges and the block structure of D. */
1292 /* If IPIV(k) > 0, then rows and columns k and IPIV(k) were */
1293 /* interchanged and D(k,k) is a 1-by-1 diagonal block. */
1294 /* If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and */
1295 /* columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k) */
1296 /* is a 2-by-2 diagonal block. If UPLO = 'L' and IPIV(k) = */
1297 /* IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were */
1298 /* interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block. */
1299
1300 /* WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK)) */
1301 /* On exit, if INFO = 0, WORK(1) returns the optimal LWORK. */
1302
1303 /* LWORK (input) INTEGER */
1304 /* The length of WORK. LWORK >=1. For best performance */
1305 /* LWORK >= N*NB, where NB is the block size returned by ILAENV. */
1306
1307 /* If LWORK = -1, then a workspace query is assumed; the routine */
1308 /* only calculates the optimal size of the WORK array, returns */
1309 /* this value as the first entry of the WORK array, and no error */
1310 /* message related to LWORK is issued by XERBLA. */
1311
1312 /* INFO (output) INTEGER */
1313 /* = 0: successful exit */
1314 /* < 0: if INFO = -i, the i-th argument had an illegal value */
1315 /* > 0: if INFO = i, D(i,i) is exactly zero. The factorization */
1316 /* has been completed, but the block diagonal matrix D is */
1317 /* exactly singular, and division by zero will occur if it */
1318 /* is used to solve a system of equations. */
1319
1320 /* Further Details */
1321 /* =============== */
1322
1323 /* If UPLO = 'U', then A = U*D*U', where */
1324 /* U = P(n)*U(n)* ... *P(k)U(k)* ..., */
1325 /* i.e., U is a product of terms P(k)*U(k), where k decreases from n to */
1326 /* 1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1 */
1327 /* and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as */
1328 /* defined by IPIV(k), and U(k) is a unit upper triangular matrix, such */
1329 /* that if the diagonal block D(k) is of order s (s = 1 or 2), then */
1330
1331 /* ( I v 0 ) k-s */
1332 /* U(k) = ( 0 I 0 ) s */
1333 /* ( 0 0 I ) n-k */
1334 /* k-s s n-k */
1335
1336 /* If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k). */
1337 /* If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k), */
1338 /* and A(k,k), and v overwrites A(1:k-2,k-1:k). */
1339
1340 /* If UPLO = 'L', then A = L*D*L', where */
1341 /* L = P(1)*L(1)* ... *P(k)*L(k)* ..., */
1342 /* i.e., L is a product of terms P(k)*L(k), where k increases from 1 to */
1343 /* n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1 */
1344 /* and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as */
1345 /* defined by IPIV(k), and L(k) is a unit lower triangular matrix, such */
1346 /* that if the diagonal block D(k) is of order s (s = 1 or 2), then */
1347
1348 /* ( I 0 0 ) k-1 */
1349 /* L(k) = ( 0 I 0 ) s */
1350 /* ( 0 v I ) n-k-s+1 */
1351 /* k-1 s n-k-s+1 */
1352
1353 /* If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k). */
1354 /* If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k), */
1355 /* and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1). */
1356 /* ===================================================================== */
1357
1358
1359 static inline int NUMlapack_dsytri_ (const char *uplo, integer n, double *inout_a, integer lda, integer *ipiv,
1360 double *work, integer *inout_info)
1361 {
1362 return dsytri_ (uplo, & n, inout_a, & lda, ipiv, work, inout_info);
1363 }
1364 /* -- LAPACK routine (version 3.1) -- */
1365 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
1366 /* November 2006 */
1367
1368 /* .. Scalar Arguments .. */
1369 /* .. */
1370 /* .. Array Arguments .. */
1371 /* .. */
1372
1373 /* Purpose */
1374 /* ======= */
1375
1376 /* DSYTRI computes the inverse of a real symmetric indefinite matrix */
1377 /* A using the factorization A = U*D*U**T or A = L*D*L**T computed by */
1378 /* DSYTRF. */
1379
1380 /* Arguments */
1381 /* ========= */
1382
1383 /* UPLO (input) CHARACTER*1 */
1384 /* Specifies whether the details of the factorization are stored */
1385 /* as an upper or lower triangular matrix. */
1386 /* = 'U': Upper triangular, form is A = U*D*U**T; */
1387 /* = 'L': Lower triangular, form is A = L*D*L**T. */
1388
1389 /* N (input) INTEGER */
1390 /* The order of the matrix A. N >= 0. */
1391
1392 /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
1393 /* On entry, the block diagonal matrix D and the multipliers */
1394 /* used to obtain the factor U or L as computed by DSYTRF. */
1395
1396 /* On exit, if INFO = 0, the (symmetric) inverse of the original */
1397 /* matrix. If UPLO = 'U', the upper triangular part of the */
1398 /* inverse is formed and the part of A below the diagonal is not */
1399 /* referenced; if UPLO = 'L' the lower triangular part of the */
1400 /* inverse is formed and the part of A above the diagonal is */
1401 /* not referenced. */
1402
1403 /* LDA (input) INTEGER */
1404 /* The leading dimension of the array A. LDA >= max(1,N). */
1405
1406 /* IPIV (input) INTEGER array, dimension (N) */
1407 /* Details of the interchanges and the block structure of D */
1408 /* as determined by DSYTRF. */
1409
1410 /* WORK (workspace) DOUBLE PRECISION array, dimension (N) */
1411
1412 /* INFO (output) INTEGER */
1413 /* = 0: successful exit */
1414 /* < 0: if INFO = -i, the i-th argument had an illegal value */
1415 /* > 0: if INFO = i, D(i,i) = 0; the matrix is singular and its */
1416 /* inverse could not be computed. */
1417
1418
1419 #endif /*_NUMlapack_h_ */