Debian Codegraph @

lib/PDL/LinearAlgebra/Complex.pd

raw
1 do('./Config');
2
3 { # required because PAUSE will reject undefined $VERSION
4 require ExtUtils::MM;
5 my $MM = bless { NAME => 'Fake' }, 'MM';
6 my $global_version = $MM->parse_version('lib/PDL/LinearAlgebra.pm');
7 pp_setversion($global_version);
8 }
9
10 { no warnings 'once'; # pass info back to Makefile.PL
11 $PDL::Core::Dev::EXTRAS{$::PDLMOD}{OBJECT} .= join '', map " $::PDLBASE-$_\$(OBJ_EXT)", qw(selectfunc);
12 }
13
14 if ($config{CBLAS}){
15 pp_addhdr('#include <cblas.h>');
16 }
17
18 if ($^O =~ /MSWin/) {
19 pp_addhdr('
20 #include <float.h>
21 ');
22 }
23
24 pp_addhdr('
25 #include <math.h>
26
27 #define CONCAT_(A, B) A ## B
28 #define CONCAT(A, B) CONCAT_(A, B)
29 #define FORTRAN(name) CONCAT(name, F77_USCORE)
30
31 typedef PDL_Long logical;
32 typedef PDL_Long integer;
33 typedef PDL_Long ftnlen;
34
35 #define DEF_SEL_FUNC(letter, letter2, args) \
36 void letter ## letter2 ## select_func_set(SV* func); \
37 logical letter ## letter2 ## select_wrapper args; \
38 typedef logical (*L_ ## letter ## letter2 ## p) args;
39 DEF_SEL_FUNC(f, , (complex float *p))
40 DEF_SEL_FUNC(d, , (complex double *p))
41 DEF_SEL_FUNC(f, g, (complex float *p, complex float *q))
42 DEF_SEL_FUNC(d, g, (complex double *p, complex double *q))
43
44 extern integer FORTRAN(ilaenv)(integer *ispec, char *name__, char *opts, integer *n1,
45 integer *n2, integer *n3, integer *n4, ftnlen name_len, ftnlen
46 opts_len);
47
48 static integer c_zero = 0;
49 static integer c_nine = 9;
50
51 #define PDL_MAYBE_SIZE(flagpdltype, flagval, flagcond, outpdl, outdim, indim) \
52 { \
53 flagpdltype tmp = flagval; \
54 outdim = (flagcond) ? indim : 1; \
55 }
56 ');
57
58 sub generate_code($){
59 if ($config{WITHOUT_THREAD}){
60 return '
61 #if 0
62 broadcastloop%{
63 %}
64 #endif'.$_[0];
65 }
66 else{
67 return $_[0];
68 }
69 }
70
71 do './pp_defc.pl'; die if $@;
72
73 pp_addpm({At=>'Top'},<<'EOD');
74 use strict;
75 use PDL::LinearAlgebra::Real;
76
77 =encoding utf8
78
79 =head1 NAME
80
81 PDL::LinearAlgebra::Complex - PDL interface to the lapack linear algebra programming library (complex number)
82
83 =head1 SYNOPSIS
84
85 use PDL;
86 use PDL::LinearAlgebra::Complex;
87 $a = random(cdouble, 100, 100);
88 $s = zeroes(cdouble, 100);
89 $u = zeroes(cdouble, 100, 100);
90 $v = zeroes(cdouble, 100, 100);
91 $info = 0;
92 $job = 0;
93 cgesdd($a, $job, $info, $s , $u, $v);
94
95 =head1 DESCRIPTION
96
97 This module provides an interface to parts of the lapack library (complex numbers).
98 These routines accept either float or double ndarrays.
99
100 =cut
101 EOD
102
103 pp_defc("gtsv",
104 _decl => <<'EOF',
105 extern int FORTRAN($TFD(c,z)gtsv)(integer *n, integer *nrhs,
106 $GENERIC() *dl, $GENERIC() *d, $GENERIC() *du, $GENERIC() *b,
107 integer *ldb, integer *info);
108 EOF
109 HandleBad => 0,
110 Pars => '[io]DL(2,n); [io]D(2,n); [io]DU(2,n); [io]B(2,n,nrhs); int [o]info()',
111 Code => generate_code '
112 FORTRAN($TFD(c,z)gtsv)(
113 &(integer){$SIZE(n)},
114 &(integer){$SIZE(nrhs)},
115 $P(DL),
116 $P(D),
117 $P(DU),
118 $P(B),
119 &(integer){$SIZE(n)},
120 $P(info));
121 ',
122 Doc => '
123
124 =for ref
125
126 Solves the equation
127
128 A * X = B
129
130 where A is an C<n> by C<n> tridiagonal matrix, by Gaussian elimination with
131 partial pivoting, and B is an C<n> by C<nrhs> matrix.
132
133 Note that the equation C<A**T*X = B> may be solved by interchanging the
134 order of the arguments DU and DL.
135
136 B<NB> This differs from the LINPACK function C<cgtsl> in that C<DL>
137 starts from its first element, while the LINPACK equivalent starts from
138 its second element.
139
140 Arguments
141 =========
142
143 DL: On entry, DL must contain the (n-1) sub-diagonal elements of A.
144
145 On exit, DL is overwritten by the (n-2) elements of the
146 second super-diagonal of the upper triangular matrix U from
147 the LU factorization of A, in DL(1), ..., DL(n-2).
148
149 D: On entry, D must contain the diagonal elements of A.
150
151 On exit, D is overwritten by the n diagonal elements of U.
152
153 DU: On entry, DU must contain the (n-1) super-diagonal elements of A.
154
155 On exit, DU is overwritten by the (n-1) elements of the
156 first super-diagonal of the U.
157
158 B: On entry, the n by nrhs matrix of right hand side matrix B.
159 On exit, if info = 0, the n by nrhs solution matrix X.
160
161 info: = 0: successful exit
162 < 0: if info = -i, the i-th argument had an illegal value
163 > 0: if info = i, U(i,i) is exactly zero, and the solution
164 has not been computed. The factorization has not been
165 completed unless i = n.
166
167 =for example
168
169 $dl = random(float, 9) + random(float, 9) * i;
170 $d = random(float, 10) + random(float, 10) * i;
171 $du = random(float, 9) + random(float, 9) * i;
172 $b = random(10,5) + random(10,5) * i;
173 cgtsv($dl, $d, $du, $b, ($info=null));
174 print "X is:\n$b" unless $info;
175
176 ');
177
178 pp_defc("gesvd",
179 _decl => <<'EOF',
180 extern int FORTRAN($TFD(c,z)gesvd)(char *jobu, char *jobvt, integer *m, integer *n, $GENERIC() *a,
181 integer *lda, $GENERIC() *s, $GENERIC() *u, int *ldu,
182 $GENERIC() *vt, integer *ldvt, $GENERIC() *work, integer *lwork, $GENERIC() *rwork,
183 integer *info);
184 EOF
185 HandleBad => 0,
186 Pars => '[io]A(2,m,n); [o]s(minmn=CALC(PDLMIN($SIZE(m),$SIZE(n)))); [o]U(2,p,p); [o]VT(2,s,s); int [o]info(); [t]rwork(rworkn=CALC(5*$SIZE(minmn)));',
187 OtherPars => 'int jobu; int jobvt',
188 ArgOrder => [qw{A jobu jobvt s U VT info}],
189 RedoDimsCode => '
190 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobu), tmp==1 || tmp==2, $PDL(U), $SIZE(p), $SIZE(m))
191 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobvt), tmp==1 || tmp==2, $PDL(VT), $SIZE(s), $SIZE(n))
192 ',
193 Code => generate_code '
194 integer lwork = -1;
195 char trau, travt;
196 $GENERIC() *rwork;
197 $GENERIC() tmp_work[2];
198
199 switch ($COMP(jobu))
200 {
201 case 1: trau = \'A\';
202 break;
203 case 2: trau = \'S\';
204 break;
205 case 3: trau = \'O\';
206 break;
207 default: trau = \'N\';
208 }
209 switch ($COMP(jobvt))
210 {
211 case 1: travt = \'A\';
212 break;
213 case 2: travt = \'S\';
214 break;
215 case 3: travt = \'O\';
216 break;
217 default: travt = \'N\';
218 }
219
220 FORTRAN($TFD(c,z)gesvd)(
221 &trau,
222 &travt,
223 &(integer){$SIZE(m)},
224 &(integer){$SIZE(n)},
225 $P(A),
226 &(integer){$SIZE(m)},
227 $P(s),
228 $P(U),
229 &(integer){$SIZE(p)},
230 $P(VT),
231 &(integer){$SIZE(s)},
232 &tmp_work[0],
233 &lwork,
234 $P(rwork),
235 $P(info));
236
237 lwork = (integer )tmp_work[0];
238 {
239 $GENERIC() *work = ($GENERIC() *)malloc(2*lwork * sizeof($GENERIC()));
240 FORTRAN($TFD(c,z)gesvd)(
241 &trau,
242 &travt,
243 &(integer){$SIZE(m)},
244 &(integer){$SIZE(n)},
245 $P(A),
246 &(integer){$SIZE(m)},
247 $P(s),
248 $P(U),
249 &(integer){$SIZE(p)},
250 $P(VT),
251 &(integer){$SIZE(s)},
252 work,
253 &lwork,
254 $P(rwork),
255 $P(info));
256 free(work);
257 }
258 ',
259 Doc=>'
260
261 =for ref
262
263 Complex version of L<PDL::LinearAlgebra::Real/gesvd>.
264
265 The SVD is written
266
267 A = U * SIGMA * ConjugateTranspose(V)
268
269 ');
270
271 pp_defc("gesdd",
272 _decl => <<'EOF',
273 extern int FORTRAN($TFD(c,z)gesdd)(char *jobz, integer *m, integer *n, $GENERIC() *
274 a, integer *lda, $GENERIC() *s, $GENERIC() *u, int *ldu,
275 $GENERIC() *vt, integer *ldvt, $GENERIC() *work, integer *lwork,
276 $GENERIC() *rwork, integer *iwork, integer *info);
277 EOF
278 HandleBad => 0,
279 Pars => '[io]A(2,m,n); [o]s(minmn=CALC(PDLMIN($SIZE(m),$SIZE(n)))); [o]U(2,p,p); [o]VT(2,s,s); int [o]info(); int [t]iwork(iworkn);',
280 OtherPars => 'int jobz',
281 ArgOrder => [qw{A jobz s U VT info}],
282 RedoDimsCode => '
283 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobz), tmp==1 || (tmp==2) || (tmp==3 && $SIZE(m)<$SIZE(n)), $PDL(U), $SIZE(p), $SIZE(m))
284 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobz), tmp==1 || (tmp==2) || (tmp==3 && $SIZE(m)>=$SIZE(n)), $PDL(VT), $SIZE(s), $SIZE(n))
285 $SIZE(iworkn) = 8 * $SIZE(minmn);
286 ',
287 Code => generate_code '
288 integer lwork;
289 char tra;
290 $GENERIC() *rwork;
291 $GENERIC() tmp_work[2];
292 lwork = $SIZE(minmn);
293
294 switch ($COMP(jobz))
295 {
296
297 case 1: tra = \'A\';
298 rwork = ($GENERIC() *)malloc( (5 * lwork *lwork + 5 * lwork) * sizeof($GENERIC()));
299 break;
300 case 2: tra = \'S\';
301 rwork = ($GENERIC() *)malloc( (5 * lwork *lwork + 5 * lwork) * sizeof($GENERIC()));
302 break;
303 case 3: tra = \'O\';
304 rwork = ($GENERIC() *)malloc( (5 * lwork *lwork + 5 * lwork) * sizeof($GENERIC()));
305 break;
306 default: tra = \'N\';
307 rwork = ($GENERIC() *)malloc( 7 * lwork * sizeof($GENERIC()));
308 break;
309
310 }
311 lwork = -1;
312 FORTRAN($TFD(c,z)gesdd)(
313 &tra,
314 &(integer){$SIZE(m)},
315 &(integer){$SIZE(n)},
316 $P(A),
317 &(integer){$SIZE(m)},
318 $P(s),
319 $P(U),
320 &(integer){$SIZE(p)},
321 $P(VT),
322 &(integer){$SIZE(s)},
323 &tmp_work[0],
324 &lwork,
325 rwork,
326 $P(iwork),
327 $P(info));
328
329 lwork = (integer )tmp_work[0];
330 {
331
332 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
333 FORTRAN($TFD(c,z)gesdd)(
334 &tra,
335 &(integer){$SIZE(m)},
336 &(integer){$SIZE(n)},
337 $P(A),
338 &(integer){$SIZE(m)},
339 $P(s),
340 $P(U),
341 &(integer){$SIZE(p)},
342 $P(VT),
343 &(integer){$SIZE(s)},
344 work,
345 &lwork,
346 rwork,
347 $P(iwork),
348 $P(info));
349 free(work);
350 }
351 free(rwork);
352 ',
353 Doc=>'
354
355 =for ref
356
357 Complex version of L<PDL::LinearAlgebra::Real/gesdd>.
358
359 The SVD is written
360
361 A = U * SIGMA * ConjugateTranspose(V)
362
363 ');
364
365 pp_defc("ggsvd",
366 _decl => <<'EOF',
367 extern int FORTRAN($TFD(c,z)ggsvd3)(char *jobu, char *jobv, char *jobq, integer *m,
368 integer *n, integer *p, integer *k, integer *l, $GENERIC() *a,
369 integer *lda, $GENERIC() *b, integer *ldb, $GENERIC() *alpha,
370 $GENERIC() *beta, $GENERIC() *u, integer *ldu, $GENERIC() *v, integer
371 *ldv, $GENERIC() *q, integer *ldq, $GENERIC() *work, integer *lwork, $GENERIC() *rwork, integer *iwork,
372 integer *info);
373 EOF
374 HandleBad => 0,
375 Pars => '[io]A(2,m,n); [io]B(2,p,n); int [o]k(); int [o]l();[o]alpha(n);[o]beta(n); [o]U(2,q,q); [o]V(2,r,r); [o]Q(2,s,s); int [o]iwork(n); int [o]info(); [t]rwork(rworkn=CALC(2*$SIZE(n)));',
376 OtherPars => 'int jobu; int jobv; int jobq',
377 ArgOrder => [qw{A jobu jobv jobq B k l alpha beta U V Q iwork info}],
378 RedoDimsCode => '
379 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobu), tmp, $PDL(U), $SIZE(q), $SIZE(m))
380 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobv), tmp, $PDL(V), $SIZE(r), $SIZE(p))
381 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobq), tmp, $PDL(Q), $SIZE(s), $SIZE(n))
382 ',
383 Code => generate_code '
384 char pjobu = \'N\';
385 char pjobv = \'N\';
386 char pjobq = \'N\';
387 $GENERIC() *work, twork[2];
388 integer lwork = -1;
389
390 if ($COMP(jobu))
391 pjobu = \'U\';
392 if ($COMP(jobv))
393 pjobv = \'V\';
394 if ($COMP(jobq))
395 pjobq = \'Q\';
396
397 FORTRAN($TFD(c,z)ggsvd3)(
398 &pjobu,
399 &pjobv,
400 &pjobq,
401 &(integer){$SIZE(m)},
402 &(integer){$SIZE(n)},
403 &(integer){$SIZE(p)},
404 $P(k),
405 $P(l),
406 $P(A),
407 &(integer){$SIZE(m)},
408 $P(B),
409 &(integer){$SIZE(p)},
410 $P(alpha),
411 $P(beta),
412 $P(U),
413 &(integer){$SIZE(q)},
414 $P(V),
415 &(integer){$SIZE(r)},
416 $P(Q),
417 &(integer){$SIZE(s)},
418 &twork[0],
419 &lwork,
420 $P(rwork),
421 $P(iwork),
422 $P(info));
423
424 lwork = (integer) twork[0];
425 work = ($GENERIC() *)malloc(2*(lwork * sizeof($GENERIC())));
426
427 FORTRAN($TFD(c,z)ggsvd3)(
428 &pjobu,
429 &pjobv,
430 &pjobq,
431 &(integer){$SIZE(m)},
432 &(integer){$SIZE(n)},
433 &(integer){$SIZE(p)},
434 $P(k),
435 $P(l),
436 $P(A),
437 &(integer){$SIZE(m)},
438 $P(B),
439 &(integer){$SIZE(p)},
440 $P(alpha),
441 $P(beta),
442 $P(U),
443 &(integer){$SIZE(q)},
444 $P(V),
445 &(integer){$SIZE(r)},
446 $P(Q),
447 &(integer){$SIZE(s)},
448 work,
449 &lwork,
450 $P(rwork),
451 $P(iwork),
452 $P(info));
453 free(work);
454 ');
455
456 pp_defc("geev",
457 _decl => <<'EOF',
458 extern int FORTRAN($TFD(c,z)geev)(char *jobvl, char *jobvr, integer *n, $GENERIC() *a,
459 integer *lda, $GENERIC() *w, $GENERIC() *vl, integer *ldvl, $GENERIC() *vr,
460 integer *ldvr, $GENERIC() *work, integer *lwork, $GENERIC() *rwork, integer *info);
461 EOF
462 HandleBad => 0,
463 Pars => '[io]A(2,n,n); [o]w(2,n); [o]vl(2,m,m); [o]vr(2,p,p); int [o]info(); [t]rwork(rworkn=CALC(2*$SIZE(n)));',
464 OtherPars => 'int jobvl; int jobvr',
465 ArgOrder => [qw{A jobvl jobvr w vl vr info}],
466 RedoDimsCode => '
467 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobvl), tmp, $PDL(vl), $SIZE(m), $SIZE(n))
468 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobvr), tmp, $PDL(vr), $SIZE(p), $SIZE(n))
469 ',
470 Code => generate_code '
471 char jvl = \'N\';
472 char jvr = \'N\';
473 $GENERIC() tmp_work[2];
474 integer lwork = -1;
475
476 if ($COMP(jobvl))
477 jvl = \'V\';
478 if ($COMP(jobvr))
479 jvr = \'V\';
480 FORTRAN($TFD(c,z)geev)(
481 &jvl,
482 &jvr,
483 &(integer){$SIZE(n)},
484 $P(A),
485 &(integer){$SIZE(n)},
486 $P(w),
487 $P(vl),
488 &(integer){$SIZE(m)},
489 $P(vr),
490 &(integer){$SIZE(p)},
491 &tmp_work[0],
492 &lwork,
493 $P(rwork),
494 $P(info));
495 lwork = (integer )tmp_work[0];
496 {
497 $GENERIC() *work = ($GENERIC() *)malloc(2*lwork * sizeof($GENERIC()));
498 FORTRAN($TFD(c,z)geev)(
499 &jvl,
500 &jvr,
501 &(integer){$SIZE(n)},
502 $P(A),
503 &(integer){$SIZE(n)},
504 $P(w),
505 $P(vl),
506 &(integer){$SIZE(m)},
507 $P(vr),
508 &(integer){$SIZE(p)},
509 work,
510 &lwork,
511 $P(rwork),
512 $P(info));
513 free(work);
514 }
515 ');
516
517 pp_defc("geevx",
518 _decl => <<'EOF',
519 extern int FORTRAN($TFD(c,z)geevx)(char *balanc, char *jobvl, char *jobvr, char *
520 sense, integer *n, $GENERIC() *a, integer *lda, $GENERIC() *w,
521 $GENERIC() *vl, integer *ldvl, $GENERIC() *vr,
522 integer *ldvr, integer *ilo, integer *ihi, $GENERIC() *scale,
523 $GENERIC() *abnrm, $GENERIC() *rconde, $GENERIC() *rcondv, $GENERIC()
524 *work, integer *lwork, $GENERIC() *rwork, integer *info);
525 EOF
526 HandleBad => 0,
527 Pars => '[io]A(2,n,n); [o]w(2,n); [o]vl(2,m,m); [o]vr(2,p,p); int [o]ilo(); int [o]ihi(); [o]scale(n); [o]abnrm(); [o]rconde(q); [o]rcondv(r); int [o]info(); [t]rwork(rworkn=CALC(2*$SIZE(n)));',
528 OtherPars => 'int jobvl; int jobvr; int balance; int sense',
529 ArgOrder => [qw{A jobvl jobvr balance sense w vl vr ilo ihi scale abnrm rconde rcondv info}],
530 RedoDimsCode => '
531 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobvl), tmp, $PDL(vl), $SIZE(m), $SIZE(n))
532 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobvr), tmp, $PDL(vr), $SIZE(p), $SIZE(n))
533 PDL_MAYBE_SIZE(PDL_Long, $COMP(sense), tmp == 1 || tmp == 3, $PDL(rconde), $SIZE(q), $SIZE(n))
534 PDL_MAYBE_SIZE(PDL_Long, $COMP(sense), tmp == 2 || tmp == 3, $PDL(rcondv), $SIZE(r), $SIZE(n))
535 ',
536 Code => generate_code '
537 char jvl = \'N\';
538 char jvr = \'N\';
539 char balanc, sens;
540 integer lwork = -1;
541 $GENERIC() tmp_work[2];
542
543 if ($COMP(jobvl))
544 jvl = \'V\';
545 if ($COMP(jobvr))
546 jvr = \'V\';
547
548 switch ($COMP(balance))
549 {
550 case 1: balanc = \'P\';
551 break;
552 case 2: balanc = \'S\';
553 break;
554 case 3: balanc = \'B\';
555 break;
556 default: balanc = \'N\';
557 }
558 switch ($COMP(sense))
559 {
560 case 1: sens = \'E\';
561 break;
562 case 2: sens = \'V\';
563 break;
564 case 3: sens = \'B\';
565 break;
566 default: sens = \'N\';
567 }
568 FORTRAN($TFD(c,z)geevx)(
569 &balanc,
570 &jvl,
571 &jvr,
572 &sens,
573 &(integer){$SIZE(n)},
574 $P(A),
575 &(integer){$SIZE(n)},
576 $P(w),
577 $P(vl),
578 &(integer){$SIZE(m)},
579 $P(vr),
580 &(integer){$SIZE(p)},
581 $P(ilo),
582 $P(ihi),
583 $P(scale),
584 $P(abnrm),
585 $P(rconde),
586 $P(rcondv),
587 &tmp_work[0],
588 &lwork,
589 $P(rwork),
590 $P(info));
591
592 lwork = (integer )tmp_work[0];
593 {
594 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
595 FORTRAN($TFD(c,z)geevx)(
596 &balanc,
597 &jvl,
598 &jvr,
599 &sens,
600 &(integer){$SIZE(n)},
601 $P(A),
602 &(integer){$SIZE(n)},
603 $P(w),
604 $P(vl),
605 &(integer){$SIZE(m)},
606 $P(vr),
607 &(integer){$SIZE(p)},
608 $P(ilo),
609 $P(ihi),
610 $P(scale),
611 $P(abnrm),
612 $P(rconde),
613 $P(rcondv),
614 work,
615 &lwork,
616 $P(rwork),
617 $P(info));
618 free(work);
619 }
620 ');
621
622 pp_defc("ggev",
623 _decl => <<'EOF',
624 extern int FORTRAN($TFD(c,z)ggev)(char *jobvl, char *jobvr, integer *n, $GENERIC() *
625 a, integer *lda, $GENERIC() *b, integer *ldb, $GENERIC() *alpha,
626 $GENERIC() *beta, $GENERIC() *vl, integer *ldvl,
627 $GENERIC() *vr, integer *ldvr, $GENERIC() *work, integer *lwork,
628 $GENERIC() *rwork, integer *info);
629 EOF
630 HandleBad => 0,
631 Pars => '[io]A(2,n,n);[io]B(2,n,n);[o]alpha(2,n);[o]beta(2,n);[o]VL(2,m,m);[o]VR(2,p,p);int [o]info(); [t]rwork(rworkn=CALC(8*$SIZE(n)));',
632 OtherPars => 'int jobvl; int jobvr',
633 ArgOrder => [qw{A jobvl jobvr B alpha beta VL VR info}],
634 RedoDimsCode => '
635 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobvl), tmp, $PDL(VL), $SIZE(m), $SIZE(n))
636 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobvr), tmp, $PDL(VR), $SIZE(p), $SIZE(n))
637 ',
638 Code => generate_code '
639 integer lwork = -1;
640 char pjobvl = \'N\', pjobvr = \'N\';
641 $GENERIC() tmp_work[2];
642 if ($COMP(jobvl))
643 pjobvl = \'V\';
644 if ($COMP(jobvr))
645 pjobvr = \'V\';
646
647 FORTRAN($TFD(c,z)ggev)(
648 &pjobvl,
649 &pjobvr,
650 &(integer){$SIZE(n)},
651 $P(A),
652 &(integer){$SIZE(n)},
653 $P(B),
654 &(integer){$SIZE(n)},
655 $P(alpha),
656 $P(beta),
657 $P(VL),
658 &(integer){$SIZE(m)},
659 $P(VR),
660 &(integer){$SIZE(p)},
661 &tmp_work[0],
662 &lwork,
663 $P(rwork),
664 $P(info));
665
666 lwork = (integer )tmp_work[0];
667 {
668 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
669
670 FORTRAN($TFD(c,z)ggev)(
671 &pjobvl,
672 &pjobvr,
673 &(integer){$SIZE(n)},
674 $P(A),
675 &(integer){$SIZE(n)},
676 $P(B),
677 &(integer){$SIZE(n)},
678 $P(alpha),
679 $P(beta),
680 $P(VL),
681 &(integer){$SIZE(m)},
682 $P(VR),
683 &(integer){$SIZE(p)},
684 work,
685 &lwork,
686 $P(rwork),
687 $P(info));
688 free(work);
689 }
690 ');
691
692 pp_defc("ggevx",
693 _decl => <<'EOF',
694 extern int FORTRAN($TFD(c,z)ggevx)(char *balanc, char *jobvl, char *jobvr, char *
695 sense, integer *n, $GENERIC() *a, integer *lda, $GENERIC() *b,
696 integer *ldb, $GENERIC() *alpha, $GENERIC() *
697 beta, $GENERIC() *vl, integer *ldvl, $GENERIC() *vr, integer *ldvr,
698 integer *ilo, integer *ihi, $GENERIC() *lscale, $GENERIC() *rscale,
699 $GENERIC() *abnrm, $GENERIC() *bbnrm, $GENERIC() *rconde, $GENERIC() *
700 rcondv, $GENERIC() *work, integer *lwork, $GENERIC() *rwork, integer *iwork, logical *
701 bwork, integer *info);
702 EOF
703 HandleBad => 0,
704 Pars => '[io]A(2,n,n);[io]B(2,n,n);[o]alpha(2,n);[o]beta(2,n);[o]VL(2,m,m);[o]VR(2,p,p);int [o]ilo();int [o]ihi();[o]lscale(n);[o]rscale(n);[o]abnrm();[o]bbnrm();[o]rconde(r);[o]rcondv(s);int [o]info(); [t]rwork(rworkn=CALC(6*$SIZE(n))); int [t]bwork(bworkn); int [t]iwork(iworkn);',
705 OtherPars => 'int balanc; int jobvl; int jobvr; int sense',
706 ArgOrder => [qw{A balanc jobvl jobvr sense B alpha beta VL VR ilo ihi lscale rscale abnrm bbnrm rconde rcondv info}],
707 RedoDimsCode => '
708 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobvl), tmp, $PDL(VL), $SIZE(m), $SIZE(n))
709 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobvr), tmp, $PDL(VR), $SIZE(p), $SIZE(n))
710 PDL_MAYBE_SIZE(PDL_Long, $COMP(sense), tmp != 2, $PDL(rconde), $SIZE(r), $SIZE(n))
711 PDL_MAYBE_SIZE(PDL_Long, $COMP(sense), tmp != 1, $PDL(rcondv), $SIZE(s), $SIZE(n))
712 PDL_MAYBE_SIZE(PDL_Long, $COMP(sense), tmp != 1, $PDL(iwork), $SIZE(iworkn), $SIZE(n) + 2)
713 PDL_MAYBE_SIZE(PDL_Long, $COMP(sense), tmp == 1 || tmp == 2 || tmp == 3, $PDL(bwork), $SIZE(bworkn), $SIZE(n))
714 ',
715 Code => generate_code '
716 integer lwork = -1;
717 char pjobvl = \'N\', pjobvr = \'N\';
718 char pbalanc, psens;
719
720 $GENERIC() tmp_work[2];
721 if ($COMP(jobvl))
722 pjobvl = \'V\';
723 if ($COMP(jobvr))
724 pjobvr = \'V\';
725
726 switch ($COMP(balanc))
727 {
728 case 1: pbalanc = \'P\';
729 break;
730 case 2: pbalanc = \'S\';
731 break;
732 case 3: pbalanc = \'B\';
733 break;
734 default: pbalanc = \'N\';
735 }
736 switch ($COMP(sense))
737 {
738 case 1: psens = \'E\';
739 break;
740 case 2: psens = \'V\';
741 break;
742 case 3: psens = \'B\';
743 break;
744 default: psens = \'N\';
745 }
746
747 FORTRAN($TFD(c,z)ggevx)(
748 &pbalanc,
749 &pjobvl,
750 &pjobvr,
751 &psens,
752 &(integer){$SIZE(n)},
753 $P(A),
754 &(integer){$SIZE(n)},
755 $P(B),
756 &(integer){$SIZE(n)},
757 $P(alpha),
758 $P(beta),
759 $P(VL),
760 &(integer){$SIZE(m)},
761 $P(VR),
762 &(integer){$SIZE(p)},
763 $P(ilo),
764 $P(ihi),
765 $P(lscale),
766 $P(rscale),
767 $P(abnrm),
768 $P(bbnrm),
769 $P(rconde),
770 $P(rcondv),
771 &tmp_work[0],
772 &lwork,
773 $P(rwork),
774 $P(iwork),
775 $P(bwork),
776 $P(info));
777
778 lwork = (integer )tmp_work[0];
779 {
780 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
781 FORTRAN($TFD(c,z)ggevx)(
782 &pbalanc,
783 &pjobvl,
784 &pjobvr,
785 &psens,
786 &(integer){$SIZE(n)},
787 $P(A),
788 &(integer){$SIZE(n)},
789 $P(B),
790 &(integer){$SIZE(n)},
791 $P(alpha),
792 $P(beta),
793 $P(VL),
794 &(integer){$SIZE(m)},
795 $P(VR),
796 &(integer){$SIZE(p)},
797 $P(ilo),
798 $P(ihi),
799 $P(lscale),
800 $P(rscale),
801 $P(abnrm),
802 $P(bbnrm),
803 $P(rconde),
804 $P(rcondv),
805 work,
806 &lwork,
807 $P(rwork),
808 $P(iwork),
809 $P(bwork),
810 $P(info));
811 free(work);
812 }
813 ');
814
815 pp_defc("gees",
816 _decl => <<'EOF',
817 extern int FORTRAN($TFD(c,z)gees)(char *jobvs, char *sort, L_$TFD(f,d)p select, integer *n,
818 $GENERIC() *a, integer *lda, integer *sdim, $GENERIC() *w,
819 $GENERIC() *vs, integer *ldvs, $GENERIC() *work,
820 integer *lwork, $GENERIC() *rwork, logical *bwork, integer *info);
821 EOF
822 HandleBad => 0,
823 Pars => '[io]A(2,n,n); [o]w(2,n); [o]vs(2,p,p); int [o]sdim(); int [o]info(); [t]rwork(n); int [t]bwork(bworkn);',
824 OtherPars => 'int jobvs; int sort; SV* select_func',
825 ArgOrder => [qw{A jobvs sort select_func w vs sdim info}],
826 RedoDimsCode => '
827 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobvs), tmp, $PDL(vs), $SIZE(p), $SIZE(n))
828 PDL_MAYBE_SIZE(PDL_Long, $COMP(sort), tmp, $PDL(bwork), $SIZE(bworkn), $SIZE(n))
829 ',
830 Code => generate_code '
831 char jvs = \'N\';
832 char psort = \'N\';
833 integer lwork = -1;
834
835 $GENERIC() tmp_work[2];
836 $GENERIC() *work;
837 $TFD(f,d)select_func_set($COMP(select_func));
838
839 if ($COMP(jobvs))
840 jvs = \'V\';
841 if ($COMP(sort)){
842 psort = \'S\';
843 }
844 FORTRAN($TFD(c,z)gees)(
845 &jvs,
846 &psort,
847 $TFD(f,d)select_wrapper,
848 &(integer){$SIZE(n)},
849 $P(A),
850 &(integer){$SIZE(n)},
851 $P(sdim),
852 $P(w),
853 $P(vs),
854 &(integer){$SIZE(p)},
855 &tmp_work[0],
856 &lwork,
857 $P(rwork),
858 $P(bwork),
859 $P(info));
860
861 lwork = (integer )tmp_work[0];
862
863 work = ($GENERIC() *) malloc(2 * lwork * sizeof($GENERIC()));
864 FORTRAN($TFD(c,z)gees)(
865 &jvs,
866 &psort,
867 $TFD(f,d)select_wrapper,
868 &(integer){$SIZE(n)},
869 $P(A),
870 &(integer){$SIZE(n)},
871 $P(sdim),
872 $P(w),
873 $P(vs),
874 &(integer){$SIZE(p)},
875 work,
876 &lwork,
877 $P(rwork),
878 $P(bwork),
879 $P(info));
880 free(work);
881 ',
882 Doc=>'
883 =for ref
884
885 Complex version of L<PDL::LinearAlgebra::Real/gees>
886
887 select_func:
888 If sort = 1, select_func is used to select eigenvalues to sort
889 to the top left of the Schur form.
890 If sort = 0, select_func is not referenced.
891 An complex eigenvalue w is selected if
892 select_func(complex(w)) is true;
893 Note that a selected complex eigenvalue may no longer
894 satisfy select_func(complex(w)) = 1 after ordering, since
895 ordering may change the value of complex eigenvalues
896 (especially if the eigenvalue is ill-conditioned); in this
897 case info is set to N+2.
898
899
900 ');
901
902
903 pp_defc("geesx",
904 _decl => <<'EOF',
905 extern int FORTRAN($TFD(c,z)geesx)(char *jobvs, char *sort, L_$TFD(f,d)p select, char * sense,
906 integer *n, $GENERIC() *a, integer *lda, integer *sdim, $GENERIC() *w,
907 $GENERIC() *vs, integer *ldvs, $GENERIC() *rconde, $GENERIC() *rcondv,
908 $GENERIC() *work, integer *lwork, $GENERIC() *rwork,
909 logical *bwork, integer *info);
910 EOF
911 HandleBad => 0,
912 Pars => '[io]A(2,n,n); [o]w(2,n);[o]vs(2,p,p); int [o]sdim(); [o]rconde();[o]rcondv(); int [o]info(); [t]rwork(n); int [t]bwork(bworkn);',
913 OtherPars => 'int jobvs; int sort; int sense; SV* select_func',
914 ArgOrder => [qw{A jobvs sort sense select_func w vs sdim rconde rcondv info}],
915 RedoDimsCode => '
916 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobvs), tmp, $PDL(vs), $SIZE(p), $SIZE(n))
917 PDL_MAYBE_SIZE(PDL_Long, $COMP(sort), tmp, $PDL(bwork), $SIZE(bworkn), $SIZE(n))
918 ',
919 Code => generate_code '
920 char jvs = \'N\';
921 char psort = \'N\';
922 integer lwork = -1;
923 char sens;
924
925 $GENERIC() *work;
926 $TFD(f,d)select_func_set($COMP(select_func));
927
928 if ($COMP(jobvs))
929 jvs = \'V\';
930 if ($COMP(sort))
931 psort = \'S\';
932
933 switch ($COMP(sense))
934 {
935 case 1: sens = \'E\';
936 break;
937 case 2: sens = \'V\';
938 break;
939 case 3: sens = \'B\';
940 break;
941 default: sens = \'N\';
942 }
943
944 $GENERIC() tmp_work[2];
945 FORTRAN($TFD(c,z)geesx)(
946 &jvs,
947 &psort,
948 $TFD(f,d)select_wrapper,
949 &sens,
950 &(integer){$SIZE(n)},
951 $P(A),
952 &(integer){$SIZE(n)},
953 $P(sdim),
954 $P(w),
955 $P(vs),
956 &(integer){$SIZE(p)},
957 $P(rconde),
958 $P(rcondv),
959 &tmp_work[0],
960 &lwork,
961 $P(rwork),
962 $P(bwork),
963 $P(info));
964
965 lwork = (integer )tmp_work[0];
966 work = ($GENERIC() * )malloc(2*lwork * sizeof ($GENERIC()));
967
968 FORTRAN($TFD(c,z)geesx)(
969 &jvs,
970 &psort,
971 $TFD(f,d)select_wrapper,
972 &sens,
973 &(integer){$SIZE(n)},
974 $P(A),
975 &(integer){$SIZE(n)},
976 $P(sdim),
977 $P(w),
978 $P(vs),
979 &(integer){$SIZE(p)},
980 $P(rconde),
981 $P(rcondv),
982 work,
983 &lwork,
984 $P(rwork),
985 $P(bwork),
986 $P(info));
987 free(work);
988 ',
989 Doc => '
990 =for ref
991
992 Complex version of L<PDL::LinearAlgebra::Real/geesx>
993
994 select_func:
995 If sort = 1, select_func is used to select eigenvalues to sort
996 to the top left of the Schur form.
997 If sort = 0, select_func is not referenced.
998 An complex eigenvalue w is selected if
999 select_func(complex(w)) is true;
1000 Note that a selected complex eigenvalue may no longer
1001 satisfy select_func(complex(w)) = 1 after ordering, since
1002 ordering may change the value of complex eigenvalues
1003 (especially if the eigenvalue is ill-conditioned); in this
1004 case info is set to N+2.
1005 ');
1006
1007 pp_defc("gges",
1008 _decl => <<'EOF',
1009 extern int FORTRAN($TFD(c,z)gges)(char *jobvsl, char *jobvsr, char *sort, L_$TFD(f,d)gp
1010 delctg, integer *n, $GENERIC() *a, integer *lda, $GENERIC() *b,
1011 integer *ldb, integer *sdim, $GENERIC() *alpha,
1012 $GENERIC() *beta, $GENERIC() *vsl, integer *ldvsl, $GENERIC() *vsr,
1013 integer *ldvsr, $GENERIC() *work, integer *lwork, $GENERIC() *rwork,
1014 logical *bwork, integer *info);
1015 EOF
1016 HandleBad => 0,
1017 Pars => '[io]A(2,n,n);[io]B(2,n,n);[o]alpha(2,n);[o]beta(2,n);[o]VSL(2,m,m);[o]VSR(2,p,p);int [o]sdim();int [o]info(); [t]rwork(rworkn=CALC(8*$SIZE(n))); int [t]bwork(bworkn);',
1018 OtherPars => 'int jobvsl; int jobvsr; int sort; SV* select_func',
1019 ArgOrder => [qw{A jobvsl jobvsr sort B select_func alpha beta VSL VSR sdim info}],
1020 RedoDimsCode => '
1021 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobvsl), tmp, $PDL(VSL), $SIZE(m), $SIZE(n))
1022 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobvsr), tmp, $PDL(VSR), $SIZE(p), $SIZE(n))
1023 PDL_MAYBE_SIZE(PDL_Long, $COMP(sort), tmp, $PDL(bwork), $SIZE(bworkn), $SIZE(n))
1024 ',
1025 Code => generate_code '
1026 integer lwork = -1;
1027 char pjobvsl = \'N\', pjobvsr = \'N\', psort = \'N\';
1028 $GENERIC() tmp_work[2];
1029 $TFD(f,d)gselect_func_set($COMP(select_func));
1030 if ($COMP(jobvsl))
1031 pjobvsl = \'V\';
1032 if ($COMP(jobvsr))
1033 pjobvsr = \'V\';
1034 if ($COMP(sort))
1035 psort = \'S\';
1036 FORTRAN($TFD(c,z)gges)(
1037 &pjobvsl,
1038 &pjobvsr,
1039 &psort,
1040 $TFD(f,d)gselect_wrapper,
1041 &(integer){$SIZE(n)},
1042 $P(A),
1043 &(integer){$SIZE(n)},
1044 $P(B),
1045 &(integer){$SIZE(n)},
1046 $P(sdim),
1047 $P(alpha),
1048 $P(beta),
1049 $P(VSL),
1050 &(integer){$SIZE(m)},
1051 $P(VSR),
1052 &(integer){$SIZE(p)},
1053 &tmp_work[0],
1054 &lwork,
1055 $P(rwork),
1056 $P(bwork),
1057 $P(info));
1058
1059 lwork = (integer )tmp_work[0];
1060 {
1061 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
1062 FORTRAN($TFD(c,z)gges)(
1063 &pjobvsl,
1064 &pjobvsr,
1065 &psort,
1066 $TFD(f,d)gselect_wrapper,
1067 &(integer){$SIZE(n)},
1068 $P(A),
1069 &(integer){$SIZE(n)},
1070 $P(B),
1071 &(integer){$SIZE(n)},
1072 $P(sdim),
1073 $P(alpha),
1074 $P(beta),
1075 $P(VSL),
1076 &(integer){$SIZE(m)},
1077 $P(VSR),
1078 &(integer){$SIZE(p)},
1079 work,
1080 &lwork,
1081 $P(rwork),
1082 $P(bwork),
1083 $P(info));
1084 free(work);
1085 }
1086 ',
1087 Doc=>'
1088
1089 =for ref
1090
1091 Complex version of L<PDL::LinearAlgebra::Real/ggees>
1092
1093 select_func:
1094 If sort = 1, select_func is used to select eigenvalues to sort
1095 to the top left of the Schur form.
1096 If sort = 0, select_func is not referenced.
1097 An eigenvalue w = w/beta is selected if
1098 select_func(complex(w), complex(beta)) is true;
1099 Note that a selected complex eigenvalue may no longer
1100 satisfy select_func(complex(w),complex(beta)) = 1 after ordering, since
1101 ordering may change the value of complex eigenvalues
1102 (especially if the eigenvalue is ill-conditioned); in this
1103 case info is set to N+2.
1104
1105
1106 ');
1107
1108 pp_defc("ggesx",
1109 _decl => <<'EOF',
1110 extern int FORTRAN($TFD(c,z)ggesx)(char *jobvsl, char *jobvsr, char *sort, L_$TFD(f,d)gp
1111 delctg, char *sense, integer *n, $GENERIC() *a, integer *lda, $GENERIC() *b,
1112 integer *ldb, integer *sdim, $GENERIC() *alpha,
1113 $GENERIC() *beta, $GENERIC() *vsl, integer *ldvsl, $GENERIC() *vsr,
1114 integer *ldvsr, $GENERIC() *rconde, $GENERIC() *rcondv, $GENERIC() *work,
1115 integer *lwork, $GENERIC() *rwork, integer *iwork, integer *liwork, logical *bwork,
1116 integer *info);
1117 EOF
1118 HandleBad => 0,
1119 Pars => '[io]A(2,n,n);[io]B(2,n,n);[o]alpha(2,n);[o]beta(2,n);[o]VSL(2,m,m);[o]VSR(2,p,p);int [o]sdim();[o]rconde(q=2);[o]rcondv(q=2);int [o]info(); [t]rwork(rworkn=CALC(8*$SIZE(n))); int [t]bwork(bworkn); int [t]iwork(iworkn=CALC($SIZE(n)+2));',
1120 OtherPars => 'int jobvsl; int jobvsr; int sort; int sense; SV* select_func',
1121 ArgOrder => [qw{A jobvsl jobvsr sort sense B select_func alpha beta VSL VSR sdim rconde rcondv info}],
1122 RedoDimsCode => '
1123 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobvsl), tmp, $PDL(VSL), $SIZE(m), $SIZE(n))
1124 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobvsr), tmp, $PDL(VSR), $SIZE(p), $SIZE(n))
1125 PDL_MAYBE_SIZE(PDL_Long, $COMP(sort), tmp, $PDL(bwork), $SIZE(bworkn), $SIZE(n))
1126 ',
1127 Code => generate_code '
1128 integer lwork, maxwrk;
1129 integer minwrk = 1;
1130 static integer c__0 = 0;
1131 static integer c__1 = 1;
1132 static integer c_n1 = -1;
1133 char pjobvsl = \'N\';
1134 char pjobvsr = \'N\';
1135 char psort = \'N\';
1136 char psens = \'N\';
1137 $TFD(f,d)gselect_func_set($COMP(select_func));
1138 if ($COMP(jobvsr))
1139 pjobvsr = \'V\';
1140 if ($COMP(sort))
1141 psort = \'S\';
1142
1143 switch ($COMP(sense))
1144 {
1145 case 1: psens = \'E\';
1146 break;
1147 case 2: psens = \'V\';
1148 break;
1149 case 3: psens = \'B\';
1150 break;
1151 default: psens = \'N\';
1152 }
1153
1154 // Code modified from Lapack
1155 // TODO other schur form above
1156 // The actual updated release (clapack 09/20/2000) do not allow
1157 // the workspace query. See release notes of Lapack
1158 // for this feature.
1159
1160 minwrk = $SIZE(n) << 1;
1161 maxwrk = $SIZE(n) + $SIZE(n) * FORTRAN(ilaenv)(&c__1, "ZGEQRF", " ", &(integer){$SIZE(n)}, &c__1,
1162 &(integer){$SIZE(n)}, &c__0, (ftnlen)6, (ftnlen)1);
1163
1164 if ($COMP(jobvsl))
1165 {
1166 integer i__1 = maxwrk;
1167 integer i__2 = $SIZE(n) + $SIZE(n) * FORTRAN(ilaenv)(&c__1, "ZUNGQR"
1168 , " ", &(integer){$SIZE(n)}, &c__1, &(integer){$SIZE(n)}, &c_n1, (ftnlen)6, (ftnlen)1);
1169 maxwrk = PDLMAX(i__1,i__2);
1170 pjobvsl = \'V\';
1171 }
1172 lwork = PDLMAX(maxwrk,minwrk);
1173
1174 {
1175 $GENERIC() *work = ($GENERIC() *)malloc( 2 * lwork * sizeof($GENERIC()));
1176 FORTRAN($TFD(c,z)ggesx)(
1177 &pjobvsl,
1178 &pjobvsr,
1179 &psort,
1180 $TFD(f,d)gselect_wrapper,
1181 &psens,
1182 &(integer){$SIZE(n)},
1183 $P(A),
1184 &(integer){$SIZE(n)},
1185 $P(B),
1186 &(integer){$SIZE(n)},
1187 $P(sdim),
1188 $P(alpha),
1189 $P(beta),
1190 $P(VSL),
1191 &(integer){$SIZE(m)},
1192 $P(VSR),
1193 &(integer){$SIZE(p)},
1194 $P(rconde),
1195 $P(rcondv),
1196 work,
1197 &lwork,
1198 $P(rwork),
1199 $P(iwork),
1200 &(integer){$SIZE(iworkn)},
1201 $P(bwork),
1202 $P(info));
1203 free(work);
1204 }
1205 ',
1206 Doc=>'
1207
1208 =for ref
1209
1210 Complex version of L<PDL::LinearAlgebra::Real/ggeesx>
1211
1212 select_func:
1213 If sort = 1, select_func is used to select eigenvalues to sort
1214 to the top left of the Schur form.
1215 If sort = 0, select_func is not referenced.
1216 An eigenvalue w = w/beta is selected if
1217 select_func(complex(w), complex(beta)) is true;
1218 Note that a selected complex eigenvalue may no longer
1219 satisfy select_func(complex(w),complex(beta)) = 1 after ordering, since
1220 ordering may change the value of complex eigenvalues
1221 (especially if the eigenvalue is ill-conditioned); in this
1222 case info is set to N+3.
1223
1224
1225 ');
1226
1227
1228 pp_defc("heev",
1229 _decl => <<'EOF',
1230 extern int FORTRAN($TFD(c,z)heev)(char *jobz, char *uplo, integer *n, $GENERIC() *a,
1231 integer *lda, $GENERIC() *w, $GENERIC() *work, integer *lwork, $GENERIC() *rwork,
1232 integer *info);
1233 EOF
1234 HandleBad => 0,
1235 Pars => '[io]A(2,n,n); int jobz(); int uplo(); [o]w(n); int [o]info(); [t]rwork(rworkn=CALC(3*($SIZE(n)-2)));',
1236 Code => generate_code '
1237 char jz = \'N\';
1238 char puplo = \'U\';
1239 integer lwork = -1;
1240 $GENERIC() tmp_work[2];
1241 if ($jobz())
1242 jz = \'V\';
1243 if ($uplo())
1244 puplo = \'L\';
1245
1246 FORTRAN($TFD(c,z)heev)(
1247 &jz,
1248 &puplo,
1249 &(integer){$SIZE(n)},
1250 $P(A),
1251 &(integer){$SIZE(n)},
1252 $P(w),
1253 &tmp_work[0],
1254 &lwork,
1255 $P(rwork),
1256 $P(info));
1257
1258 lwork = (integer )tmp_work[0];
1259 {
1260 $GENERIC() *work = ($GENERIC() *)malloc(2*lwork * sizeof($GENERIC()));
1261 FORTRAN($TFD(c,z)heev)(
1262 &jz,
1263 &puplo,
1264 &(integer){$SIZE(n)},
1265 $P(A),
1266 &(integer){$SIZE(n)},
1267 $P(w),
1268 work,
1269 &lwork,
1270 $P(rwork),
1271 $P(info));
1272 free(work);
1273 }
1274 ',
1275 Doc=>'
1276
1277 =for ref
1278
1279 Complex version of L<PDL::LinearAlgebra::Real/syev> for Hermitian matrix
1280
1281 ');
1282
1283 pp_defc("heevd",
1284 _decl => <<'EOF',
1285 extern int FORTRAN($TFD(c,z)heevd)(char *jobz, char *uplo, integer *n, $GENERIC() *a,
1286 integer *lda, $GENERIC() *w, $GENERIC() *work, integer *lwork, $GENERIC() *rwork, integer *lrwork,
1287 integer *iwork, integer *liwork, integer *info);
1288 EOF
1289 HandleBad => 0,
1290 Pars => '[io]A(2,n,n); int jobz(); int uplo(); [o]w(n); int [o]info()',
1291 Code => generate_code '
1292 char jz = \'N\';
1293 char puplo = \'U\';
1294 integer lwork = -1;
1295 integer lrwork, liwork;
1296 integer tmpi_work;
1297 integer *iwork;
1298 $GENERIC() tmp_work[2];
1299 $GENERIC() tmpr_work;
1300
1301 if ($jobz())
1302 jz = \'V\';
1303 if ($uplo())
1304 puplo = \'L\';
1305
1306
1307 FORTRAN($TFD(c,z)heevd)(
1308 &jz,
1309 &puplo,
1310 &(integer){$SIZE(n)},
1311 $P(A),
1312 &(integer){$SIZE(n)},
1313 $P(w),
1314 &tmp_work[0],
1315 &lwork,
1316 &tmpr_work,
1317 &lwork,
1318 &tmpi_work,
1319 &lwork,
1320 $P(info));
1321
1322 lwork = (integer )tmp_work[0];
1323 lrwork = (integer )tmpr_work;
1324 liwork = (integer )tmpi_work;
1325
1326 iwork = (integer *)malloc(liwork * sizeof(integer));
1327
1328 {
1329 $GENERIC() *work = ($GENERIC() *)malloc(2*lwork * sizeof($GENERIC()));
1330 $GENERIC() *rwork = ($GENERIC() *)malloc(lrwork * sizeof($GENERIC()));
1331 FORTRAN($TFD(c,z)heevd)(
1332 &jz,
1333 &puplo,
1334 &(integer){$SIZE(n)},
1335 $P(A),
1336 &(integer){$SIZE(n)},
1337 $P(w),
1338 work,
1339 &lwork,
1340 rwork,
1341 &lrwork,
1342 iwork,
1343 &liwork,
1344 $P(info));
1345 free(rwork);
1346 free(work);
1347 }
1348
1349 free(iwork);
1350 ',
1351 Doc=>'
1352
1353 =for ref
1354
1355 Complex version of L<PDL::LinearAlgebra::Real/syevd> for Hermitian matrix
1356
1357 ');
1358
1359
1360 pp_defc("heevx",
1361 _decl => <<'EOF',
1362 extern int FORTRAN($TFD(c,z)heevx)(char *jobz, char *range, char *uplo, integer *n,
1363 $GENERIC() *a, integer *lda, $GENERIC() *vl, $GENERIC() *vu, integer *
1364 il, integer *iu, $GENERIC() *abstol, integer *m, $GENERIC() *w,
1365 $GENERIC() *z__, integer *ldz, $GENERIC() *work, integer *lwork,
1366 $GENERIC() *rwork, integer *iwork, integer *ifail, integer *info);
1367 EOF
1368 HandleBad => 0,
1369 Pars => '[io]A(2,n,n); vl(); vu(); int il(); int iu(); abstol(); int [o]m(); [o]w(n); [o]z(2,p,p);int [o]ifail(n); int [o]info(); [t]rwork(rworkn=CALC(7*$SIZE(n))); int [t]iwork(iworkn=CALC(5*$SIZE(n)));',
1370 OtherPars => 'int jobz; int range; int uplo',
1371 ArgOrder => [qw{A jobz range uplo vl vu il iu abstol m w z ifail info}],
1372 RedoDimsCode => '
1373 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobz), tmp, $PDL(z), $SIZE(p), $SIZE(n))
1374 ',
1375 Code => generate_code '
1376 char jz = \'N\';
1377 char puplo = \'U\';
1378 char prange = \'A\';
1379 integer lwork = -1;
1380 $GENERIC() tmp_work[2];
1381 if ($COMP(jobz))
1382 jz = \'V\';
1383 if ($COMP(uplo))
1384 puplo = \'L\';
1385
1386 switch ($COMP(range))
1387 {
1388 case 1: prange = \'V\';
1389 break;
1390 case 2: prange = \'I\';
1391 break;
1392 default: prange = \'A\';
1393 }
1394
1395 FORTRAN($TFD(c,z)heevx)(
1396 &jz,
1397 &prange,
1398 &puplo,
1399 &(integer){$SIZE(n)},
1400 $P(A),
1401 &(integer){$SIZE(n)},
1402 $P(vl),
1403 $P(vu),
1404 $P(il),
1405 $P(iu),
1406 $P(abstol),
1407 $P(m),
1408 $P(w),
1409 $P(z),
1410 &(integer){$SIZE(p)},
1411 &tmp_work[0],
1412 &lwork,
1413 $P(rwork),
1414 $P(iwork),
1415 $P(ifail),
1416 $P(info));
1417
1418 lwork = (integer )tmp_work[0];
1419 {
1420 $GENERIC() *work = ($GENERIC() *)malloc(2* lwork * sizeof($GENERIC()));
1421 FORTRAN($TFD(c,z)heevx)(
1422 &jz,
1423 &prange,
1424 &puplo,
1425 &(integer){$SIZE(n)},
1426 $P(A),
1427 &(integer){$SIZE(n)},
1428 $P(vl),
1429 $P(vu),
1430 $P(il),
1431 $P(iu),
1432 $P(abstol),
1433 $P(m),
1434 $P(w),
1435 $P(z),
1436 &(integer){$SIZE(p)},
1437 work,
1438 &lwork,
1439 $P(rwork),
1440 $P(iwork),
1441 $P(ifail),
1442 $P(info));
1443 free(work);
1444 }
1445 ',
1446 Doc=>'
1447
1448 =for ref
1449
1450 Complex version of L<PDL::LinearAlgebra::Real/syevx> for Hermitian matrix
1451
1452 ');
1453
1454 pp_defc("heevr",
1455 _decl => <<'EOF',
1456 extern int FORTRAN($TFD(c,z)heevr)(char *jobz, char *range, char *uplo, integer *n,
1457 $GENERIC() *a, integer *lda, $GENERIC() *vl, $GENERIC() *vu, integer *
1458 il, integer *iu, $GENERIC() *abstol, integer *m, $GENERIC() *w,
1459 $GENERIC() *z__, integer *ldz, integer *isuppz, $GENERIC() *work, integer *lwork, $GENERIC() *rwork, integer *lrwork,
1460 integer *iwork, integer *liwork, integer *info);
1461 EOF
1462 HandleBad => 0,
1463 Pars => '[io]A(2,n,n); int jobz(); int range(); int uplo(); vl(); vu(); int il(); int iu(); abstol(); int [o]m(); [o]w(n); [o]z(2,p,q);int [o]isuppz(r); int [o]info()',
1464 Code => generate_code '
1465 char jz = \'N\';
1466 char puplo = \'U\';
1467 char prange = \'A\';
1468 integer lwork = -1;
1469 integer liwork,lrwork;
1470 integer tmpi_work;
1471
1472 $GENERIC() tmp_work[2];
1473 $GENERIC() tmpr_work;
1474
1475 if ($jobz())
1476 jz = \'V\';
1477 if ($uplo())
1478 puplo = \'L\';
1479
1480 switch ($range())
1481 {
1482 case 1: prange = \'V\';
1483 break;
1484 case 2: prange = \'I\';
1485 break;
1486 default: prange = \'A\';
1487 }
1488
1489 FORTRAN($TFD(c,z)heevr)(
1490 &jz,
1491 &prange,
1492 &puplo,
1493 &(integer){$SIZE(n)},
1494 $P(A),
1495 &(integer){$SIZE(n)},
1496 $P(vl),
1497 $P(vu),
1498 $P(il),
1499 $P(iu),
1500 $P(abstol),
1501 $P(m),
1502 $P(w),
1503 $P(z),
1504 &(integer){$SIZE(p)},
1505 $P(isuppz),
1506 &tmp_work[0],
1507 &lwork,
1508 &tmpr_work,
1509 &lwork,
1510 &tmpi_work,
1511 &lwork,
1512 $P(info));
1513
1514 lwork = (integer )tmp_work[0];
1515 lrwork = (integer )tmpr_work;
1516 liwork = (integer )tmpi_work;
1517 {
1518 $GENERIC() *work = ($GENERIC() *)malloc(2* lwork * sizeof($GENERIC()));
1519 $GENERIC() *rwork = ($GENERIC() *)malloc(lrwork * sizeof($GENERIC()));
1520 integer *iwork = (integer *)malloc(liwork * sizeof(integer));
1521 FORTRAN($TFD(c,z)heevr)(
1522 &jz,
1523 &prange,
1524 &puplo,
1525 &(integer){$SIZE(n)},
1526 $P(A),
1527 &(integer){$SIZE(n)},
1528 $P(vl),
1529 $P(vu),
1530 $P(il),
1531 $P(iu),
1532 $P(abstol),
1533 $P(m),
1534 $P(w),
1535 $P(z),
1536 &(integer){$SIZE(p)},
1537 $P(isuppz),
1538 work,
1539 &lwork,
1540 rwork,
1541 &lrwork,
1542 iwork,
1543 &liwork,
1544 $P(info));
1545 free(work);
1546 free(iwork);
1547 free(rwork);
1548 }
1549
1550 ',
1551 Doc=>'
1552
1553 =for ref
1554
1555 Complex version of L<PDL::LinearAlgebra::Real/syevr> for Hermitian matrix
1556
1557 ');
1558
1559 pp_defc("hegv",
1560 _decl => <<'EOF',
1561 extern int FORTRAN($TFD(c,z)hegv)(integer *itype, char *jobz, char *uplo, integer *
1562 n, $GENERIC() *a, integer *lda, $GENERIC() *b, integer *ldb,
1563 $GENERIC() *w, $GENERIC() *work, integer *lwork, $GENERIC() *rwork, integer *info);
1564 EOF
1565 HandleBad => 0,
1566 Pars => '[io]A(2,n,n);int itype();int jobz(); int uplo();[io]B(2,n,n);[o]w(n); int [o]info(); [t]rwork(rworkn=CALC(3*($SIZE(n)-2)));',
1567 Code => generate_code '
1568 char jz = \'N\';
1569 char puplo = \'U\';
1570 integer lwork = -1;
1571
1572 $GENERIC() tmp_work[2];
1573 if ($jobz())
1574 jz = \'V\';
1575 if ($uplo())
1576 puplo = \'L\';
1577
1578 FORTRAN($TFD(c,z)hegv)(
1579 $P(itype),
1580 &jz,
1581 &puplo,
1582 &(integer){$SIZE(n)},
1583 $P(A),
1584 &(integer){$SIZE(n)},
1585 $P(B),
1586 &(integer){$SIZE(n)},
1587 $P(w),
1588 &tmp_work[0],
1589 &lwork,
1590 $P(rwork),
1591 $P(info));
1592
1593 lwork = (integer )tmp_work[0];
1594 {
1595 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
1596 FORTRAN($TFD(c,z)hegv)(
1597 $P(itype),
1598 &jz,
1599 &puplo,
1600 &(integer){$SIZE(n)},
1601 $P(A),
1602 &(integer){$SIZE(n)},
1603 $P(B),
1604 &(integer){$SIZE(n)},
1605 $P(w),
1606 work,
1607 &lwork,
1608 $P(rwork),
1609 $P(info));
1610 free(work);
1611 }
1612 ',
1613 Doc=>'
1614 =for ref
1615
1616 Complex version of L<PDL::LinearAlgebra::Real/sygv> for Hermitian matrix
1617 ');
1618
1619
1620 pp_defc("hegvd",
1621 _decl => <<'EOF',
1622 extern int FORTRAN($TFD(c,z)hegvd)(integer *itype, char *jobz, char *uplo, integer *
1623 n, $GENERIC() *a, integer *lda, $GENERIC() *b, integer *ldb,
1624 $GENERIC() *w, $GENERIC() *work, integer *lwork, $GENERIC() *rwork, integer *lrwork,
1625 integer *iwork, integer *liwork, integer *info);
1626 EOF
1627 HandleBad => 0,
1628 Pars => '[io]A(2,n,n);int itype();int jobz(); int uplo();[io]B(2,n,n);[o]w(n); int [o]info()',
1629 Code => generate_code '
1630 char jz = \'N\';
1631 char puplo = \'U\';
1632 integer lwork = -1;
1633 integer liwork = -1;
1634 integer lrwork = -1;
1635 integer *iwork;
1636 integer tmp_iwork;
1637 $GENERIC() tmp_work[2], tmp_rwork;
1638
1639 if ($jobz())
1640 jz = \'V\';
1641 if ($uplo())
1642 puplo = \'L\';
1643
1644
1645 FORTRAN($TFD(c,z)hegvd)(
1646 $P(itype),
1647 &jz,
1648 &puplo,
1649 &(integer){$SIZE(n)},
1650 $P(A),
1651 &(integer){$SIZE(n)},
1652 $P(B),
1653 &(integer){$SIZE(n)},
1654 $P(w),
1655 &tmp_work[0],
1656 &lwork,
1657 &tmp_rwork,
1658 &lrwork,
1659 &tmp_iwork,
1660 &liwork,
1661 $P(info));
1662
1663 lwork = (integer )tmp_work[0];
1664 lrwork = (integer )tmp_rwork;
1665 liwork = (integer )tmp_iwork;
1666 iwork = (integer *)malloc(liwork * sizeof(integer));
1667
1668 {
1669 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
1670 $GENERIC() *rwork = ($GENERIC() *)malloc(lrwork * sizeof($GENERIC()));
1671 FORTRAN($TFD(c,z)hegvd)(
1672 $P(itype),
1673 &jz,
1674 &puplo,
1675 &(integer){$SIZE(n)},
1676 $P(A),
1677 &(integer){$SIZE(n)},
1678 $P(B),
1679 &(integer){$SIZE(n)},
1680 $P(w),
1681 work,
1682 &lwork,
1683 rwork,
1684 &lrwork,
1685 iwork,
1686 &liwork,
1687 $P(info));
1688 free(work);
1689 free(rwork);
1690 }
1691 free(iwork);
1692 ',
1693 Doc=>'
1694
1695 =for ref
1696
1697 Complex version of L<PDL::LinearAlgebra::Real/sygvd> for Hermitian matrix
1698
1699 ');
1700
1701
1702 pp_defc("hegvx",
1703 _decl => <<'EOF',
1704 extern int FORTRAN($TFD(c,z)hegvx)(integer *itype, char *jobz, char *range, char *
1705 uplo, integer *n, $GENERIC() *a, integer *lda, $GENERIC() *b, integer
1706 *ldb, $GENERIC() *vl, $GENERIC() *vu, integer *il, integer *iu,
1707 $GENERIC() *abstol, integer *m, $GENERIC() *w, $GENERIC() *z__,
1708 integer *ldz, $GENERIC() *work, integer *lwork, $GENERIC() *rwork,
1709 integer *iwork, integer *ifail, integer *info);
1710 EOF
1711 HandleBad => 0,
1712 Pars => '[io]A(2,n,n);int itype();
1713 [io]B(2,n,n);vl();vu();int il();
1714 int iu();abstol();int [o]m();[o]w(n);
1715 [o]Z(2,p,p);int [o]ifail(n);int [o]info(); [t]rwork(rworkn=CALC(7*$SIZE(n))); int [t]iwork(iworkn=CALC(5*$SIZE(n)));
1716 ',
1717 OtherPars => 'int jobz; int range; int uplo',
1718 ArgOrder => [qw{A itype jobz range uplo B vl vu il iu abstol m w Z ifail info}],
1719 RedoDimsCode => '
1720 PDL_MAYBE_SIZE(PDL_Long, $COMP(jobz), tmp, $PDL(Z), $SIZE(p), $SIZE(n))
1721 ',
1722 Code => generate_code '
1723 char jz = \'N\';
1724 char puplo = \'U\';
1725 char prange;
1726 integer lwork = -1;
1727 $GENERIC() tmp_work[2];
1728 if ($COMP(jobz))
1729 jz = \'V\';
1730 if ($COMP(uplo))
1731 puplo = \'L\';
1732
1733 switch ($COMP(range))
1734 {
1735 case 1: prange = \'V\';
1736 break;
1737 case 2: prange = \'I\';
1738 break;
1739 default: prange = \'A\';
1740 }
1741
1742 FORTRAN($TFD(c,z)hegvx)(
1743 $P(itype),
1744 &jz,
1745 &prange,
1746 &puplo,
1747 &(integer){$SIZE(n)},
1748 $P(A),
1749 &(integer){$SIZE(n)},
1750 $P(B),
1751 &(integer){$SIZE(n)},
1752 $P(vl),
1753 $P(vu),
1754 $P(il),
1755 $P(iu),
1756 $P(abstol),
1757 $P(m),
1758 $P(w),
1759 $P(Z),
1760 &(integer){$SIZE(p)},
1761 &tmp_work[0],
1762 &lwork,
1763 $P(rwork),
1764 $P(iwork),
1765 $P(ifail),
1766 $P(info));
1767
1768 lwork = (integer )tmp_work[0];
1769 {
1770 $GENERIC() *work = ($GENERIC() *)malloc( 2 * lwork * sizeof($GENERIC()));
1771 FORTRAN($TFD(c,z)hegvx)(
1772 $P(itype),
1773 &jz,
1774 &prange,
1775 &puplo,
1776 &(integer){$SIZE(n)},
1777 $P(A),
1778 &(integer){$SIZE(n)},
1779 $P(B),
1780 &(integer){$SIZE(n)},
1781 $P(vl),
1782 $P(vu),
1783 $P(il),
1784 $P(iu),
1785 $P(abstol),
1786 $P(m),
1787 $P(w),
1788 $P(Z),
1789 &(integer){$SIZE(p)},
1790 work,
1791 &lwork,
1792 $P(rwork),
1793 $P(iwork),
1794 $P(ifail),
1795 $P(info));
1796 free(work);
1797 }
1798 ',
1799 Doc=>'
1800
1801 =for ref
1802
1803 Complex version of L<PDL::LinearAlgebra::Real/sygvx> for Hermitian matrix
1804
1805 ');
1806
1807
1808 pp_defc("gesv",
1809 _decl => <<'EOF',
1810 extern int FORTRAN($TFD(c,z)gesv)(integer *n, integer *nrhs, $GENERIC() *a, integer
1811 *lda, integer *ipiv, $GENERIC() *b, integer *ldb, integer *info);
1812 EOF
1813 HandleBad => 0,
1814 Pars => '[io]A(2,n,n); [io]B(2,n,m); int [o]ipiv(n); int [o]info()',
1815 Code => generate_code '
1816 FORTRAN($TFD(c,z)gesv)(
1817 &(integer){$SIZE(n)},
1818 &(integer){$SIZE(m)},
1819 $P(A),
1820 &(integer){$SIZE(n)},
1821 $P(ipiv),
1822 $P(B),
1823 &(integer){$SIZE(n)},
1824 $P(info));
1825 ');
1826 pp_defc("gesvx",
1827 _decl => <<'EOF',
1828 extern int FORTRAN($TFD(c,z)gesvx)(char *fact, char *trans, integer *n, integer *
1829 nrhs, $GENERIC() *a, integer *lda, $GENERIC() *af, integer *ldaf,
1830 integer *ipiv, char *equed, $GENERIC() *r__, $GENERIC() *c__,
1831 $GENERIC() *b, integer *ldb, $GENERIC() *x, integer *ldx, $GENERIC() *
1832 rcond, $GENERIC() *ferr, $GENERIC() *berr, $GENERIC() *work, $GENERIC() *
1833 rwork, integer *info);
1834 EOF
1835 HandleBad => 0,
1836 Pars => '[io]A(2,n,n); int trans(); int fact(); [io]B(2,n,m); [io]af(2,n,n); int [io]ipiv(n); int [io]equed(); [o]r(p); [o]c(q); [o]X(2,n,m); [o]rcond(); [o]ferr(m); [o]berr(m); [o]rpvgrw(); int [o]info(); [t]rwork(rworkn=CALC(4*$SIZE(n))); [t]work(rworkn);',
1837 RedoDimsCode => '
1838 $SIZE(p) = $SIZE(n); /* Ubuntu LAPACK 3 writes to r anyway */
1839 $SIZE(q) = $SIZE(n); /* Ubuntu LAPACK 3 writes to c anyway */
1840 ',
1841 Code => generate_code '
1842 char ptrans, pfact, pequed;
1843 switch ($trans())
1844 {
1845 case 1: ptrans = \'T\';
1846 break;
1847 case 2: ptrans = \'C\';
1848 break;
1849 default: ptrans = \'N\';
1850 }
1851 switch ($fact())
1852 {
1853 case 1: pfact = \'N\';
1854 break;
1855 case 2: pfact = \'E\';
1856 break;
1857 default: pfact = \'F\';
1858 }
1859 switch ($equed())
1860 {
1861 case 1: pequed = \'R\';
1862 break;
1863 case 2: pequed = \'C\';
1864 break;
1865 case 3: pequed = \'B\';
1866 break;
1867 default: pequed = \'N\';
1868 }
1869
1870
1871 FORTRAN($TFD(c,z)gesvx)(
1872 &pfact,
1873 &ptrans,
1874 &(integer){$SIZE(n)},
1875 &(integer){$SIZE(m)},
1876 $P(A),
1877 &(integer){$SIZE(n)},
1878 $P(af),
1879 &(integer){$SIZE(n)},
1880 $P(ipiv),
1881 &pequed,
1882 $P(r),
1883 $P(c),
1884 $P(B),
1885 &(integer){$SIZE(n)},
1886 $P(X),
1887 &(integer){$SIZE(n)},
1888 $P(rcond),
1889 $P(ferr),
1890 $P(berr),
1891 $P(work),
1892 $P(rwork),
1893 $P(info));
1894
1895 switch (pequed)
1896 {
1897 case \'R\': $equed() = 1;
1898 break;
1899 case \'C\': $equed() = 2;
1900 break;
1901 case \'B\': $equed() = 3;
1902 break;
1903 default: $equed()= 0;
1904 }
1905 $rpvgrw()=$rwork(rworkn=>0);
1906 ',
1907 Doc => '
1908 =for ref
1909
1910 Complex version of L<PDL::LinearAlgebra::Real/gesvx>.
1911
1912 trans: Specifies the form of the system of equations:
1913 = 0: A * X = B (No transpose)
1914 = 1: A\' * X = B (Transpose)
1915 = 2: A**H * X = B (Conjugate transpose)
1916 ');
1917
1918 pp_defc("sysv",
1919 _decl => <<'EOF',
1920 extern int FORTRAN($TFD(c,z)sysv)(char *uplo, integer *n, integer *nrhs, $GENERIC()
1921 *a, integer *lda, integer *ipiv, $GENERIC() *b, integer *ldb,
1922 $GENERIC() *work, integer *lwork, integer *info);
1923 EOF
1924 HandleBad => 0,
1925 Pars => '[io]A(2,n,n); int uplo(); [io]B(2,n,m); int [o]ipiv(n); int [o]info()',
1926 Code => generate_code '
1927 char puplo = \'U\';
1928 integer lwork = -1;
1929 $GENERIC() tmp_work[2];
1930 if ($uplo())
1931 puplo = \'L\';
1932
1933 FORTRAN($TFD(c,z)sysv)(
1934 &puplo,
1935 &(integer){$SIZE(n)},
1936 &(integer){$SIZE(m)},
1937 $P(A),
1938 &(integer){$SIZE(n)},
1939 $P(ipiv),
1940 $P(B),
1941 &(integer){$SIZE(n)},
1942 &tmp_work[0],
1943 &lwork,
1944 $P(info));
1945
1946 lwork = (integer )tmp_work[0];
1947 {
1948 $GENERIC() *work = ($GENERIC() *)malloc(2*lwork * sizeof($GENERIC()));
1949 FORTRAN($TFD(c,z)sysv)(
1950 &puplo,
1951 &(integer){$SIZE(n)},
1952 &(integer){$SIZE(m)},
1953 $P(A),
1954 &(integer){$SIZE(n)},
1955 $P(ipiv),
1956 $P(B),
1957 &(integer){$SIZE(n)},
1958 work,
1959 &lwork,
1960 $P(info));
1961 free(work);
1962 }
1963 ');
1964
1965 pp_defc("sysvx",
1966 _decl => <<'EOF',
1967 extern int FORTRAN($TFD(c,z)sysvx)(char *fact, char *uplo, integer *n, integer *
1968 nrhs, $GENERIC() *a, integer *lda, $GENERIC() *af, integer *ldaf,
1969 integer *ipiv, $GENERIC() *b, integer *ldb, $GENERIC() *x, integer *
1970 ldx, $GENERIC() *rcond, $GENERIC() *ferr, $GENERIC() *berr,
1971 $GENERIC() *work, integer *lwork, $GENERIC() *rwork, integer *info);
1972 EOF
1973 HandleBad => 0,
1974 Pars => 'A(2,n,n); int uplo(); int fact(); B(2,n,m); [io]af(2,n,n); int [io]ipiv(n); [o]X(2,n,m); [o]rcond(); [o]ferr(m); [o]berr(m); int [o]info(); [t]rwork(n);',
1975 Code => generate_code '
1976 char pfact = \'N\';
1977 char puplo = \'U\';
1978 integer lwork = -1;
1979 $GENERIC() tmp_work[2];
1980
1981 if($fact())
1982 pfact = \'F\';
1983
1984 if ($uplo())
1985 puplo = \'L\';
1986
1987 FORTRAN($TFD(c,z)sysvx)(
1988 &pfact,
1989 &puplo,
1990 &(integer){$SIZE(n)},
1991 &(integer){$SIZE(m)},
1992 $P(A),
1993 &(integer){$SIZE(n)},
1994 $P(af),
1995 &(integer){$SIZE(n)},
1996 $P(ipiv),
1997 $P(B),
1998 &(integer){$SIZE(n)},
1999 $P(X),
2000 &(integer){$SIZE(n)},
2001 $P(rcond),
2002 $P(ferr),
2003 $P(berr),
2004 &tmp_work[0],
2005 &lwork,
2006 $P(rwork),
2007 $P(info));
2008
2009 lwork = (integer )tmp_work[0];
2010 {
2011 $GENERIC() *work = ($GENERIC() *)malloc(2*lwork * sizeof($GENERIC()));
2012 FORTRAN($TFD(c,z)sysvx)(
2013 &pfact,
2014 &puplo,
2015 &(integer){$SIZE(n)},
2016 &(integer){$SIZE(m)},
2017 $P(A),
2018 &(integer){$SIZE(n)},
2019 $P(af),
2020 &(integer){$SIZE(n)},
2021 $P(ipiv),
2022 $P(B),
2023 &(integer){$SIZE(n)},
2024 $P(X),
2025 &(integer){$SIZE(n)},
2026 $P(rcond),
2027 $P(ferr),
2028 $P(berr),
2029 work,
2030 &lwork,
2031 $P(rwork),
2032 $P(info));
2033 free(work);
2034 }
2035 ');
2036
2037 pp_defc("hesv",
2038 _decl => <<'EOF',
2039 extern int FORTRAN($TFD(c,z)hesv)(char *uplo, integer *n, integer *nrhs, $GENERIC()
2040 *a, integer *lda, integer *ipiv, $GENERIC() *b, integer *ldb,
2041 $GENERIC() *work, integer *lwork, integer *info);
2042 EOF
2043 HandleBad => 0,
2044 Pars => '[io]A(2,n,n); int uplo(); [io]B(2,n,m); int [o]ipiv(n); int [o]info()',
2045 Code => generate_code '
2046 char puplo = \'U\';
2047 integer lwork = -1;
2048 $GENERIC() tmp_work[2];
2049 if ($uplo())
2050 puplo = \'L\';
2051
2052 FORTRAN($TFD(c,z)hesv)(
2053 &puplo,
2054 &(integer){$SIZE(n)},
2055 &(integer){$SIZE(m)},
2056 $P(A),
2057 &(integer){$SIZE(n)},
2058 $P(ipiv),
2059 $P(B),
2060 &(integer){$SIZE(n)},
2061 &tmp_work[0],
2062 &lwork,
2063 $P(info));
2064
2065 lwork = (integer )tmp_work[0];
2066 {
2067 $GENERIC() *work = ($GENERIC() *)malloc(2*lwork * sizeof($GENERIC()));
2068 FORTRAN($TFD(c,z)hesv)(
2069 &puplo,
2070 &(integer){$SIZE(n)},
2071 &(integer){$SIZE(m)},
2072 $P(A),
2073 &(integer){$SIZE(n)},
2074 $P(ipiv),
2075 $P(B),
2076 &(integer){$SIZE(n)},
2077 work,
2078 &lwork,
2079 $P(info));
2080 }
2081 ',
2082 Doc=>'
2083 =for ref
2084
2085 Complex version of L<PDL::LinearAlgebra::Real/sysv> for Hermitian matrix
2086 ');
2087
2088 pp_defc("hesvx",
2089 _decl => <<'EOF',
2090 extern int FORTRAN($TFD(c,z)hesvx)(char *fact, char *uplo, integer *n, integer *
2091 nrhs, $GENERIC() *a, integer *lda, $GENERIC() *af, integer *ldaf,
2092 integer *ipiv, $GENERIC() *b, integer *ldb, $GENERIC() *x, integer *
2093 ldx, $GENERIC() *rcond, $GENERIC() *ferr, $GENERIC() *berr,
2094 $GENERIC() *work, integer *lwork, $GENERIC() *rwork, integer *info);
2095 EOF
2096 HandleBad => 0,
2097 Pars => 'A(2,n,n); int uplo(); int fact(); B(2,n,m); [io]af(2,n,n); int [io]ipiv(n); [o]X(2,n,m); [o]rcond(); [o]ferr(m); [o]berr(m); int [o]info(); [t]rwork(n);',
2098 Code => generate_code '
2099 char pfact = \'N\';
2100 char puplo = \'U\';
2101 integer lwork = -1;
2102 $GENERIC() tmp_work[2];
2103
2104 if($fact())
2105 pfact = \'F\';
2106
2107 if ($uplo())
2108 puplo = \'L\';
2109
2110 FORTRAN($TFD(c,z)hesvx)(
2111 &pfact,
2112 &puplo,
2113 &(integer){$SIZE(n)},
2114 &(integer){$SIZE(m)},
2115 $P(A),
2116 &(integer){$SIZE(n)},
2117 $P(af),
2118 &(integer){$SIZE(n)},
2119 $P(ipiv),
2120 $P(B),
2121 &(integer){$SIZE(n)},
2122 $P(X),
2123 &(integer){$SIZE(n)},
2124 $P(rcond),
2125 $P(ferr),
2126 $P(berr),
2127 &tmp_work[0],
2128 &lwork,
2129 $P(rwork),
2130 $P(info));
2131
2132 lwork = (integer )tmp_work[0];
2133 {
2134 $GENERIC() *work = ($GENERIC() *)malloc(2*lwork * sizeof($GENERIC()));
2135 FORTRAN($TFD(c,z)hesvx)(
2136 &pfact,
2137 &puplo,
2138 &(integer){$SIZE(n)},
2139 &(integer){$SIZE(m)},
2140 $P(A),
2141 &(integer){$SIZE(n)},
2142 $P(af),
2143 &(integer){$SIZE(n)},
2144 $P(ipiv),
2145 $P(B),
2146 &(integer){$SIZE(n)},
2147 $P(X),
2148 &(integer){$SIZE(n)},
2149 $P(rcond),
2150 $P(ferr),
2151 $P(berr),
2152 work,
2153 &lwork,
2154 $P(rwork),
2155 $P(info));
2156 free(work);
2157 }
2158 ',
2159 Doc=>'
2160 =for ref
2161
2162 Complex version of L<PDL::LinearAlgebra::Real/sysvx> for Hermitian matrix
2163 ');
2164
2165
2166 pp_defc("posv",
2167 _decl => <<'EOF',
2168 extern int FORTRAN($TFD(c,z)posv)(char *uplo, integer *n, integer *nrhs, $GENERIC()
2169 *a, integer *lda, $GENERIC() *b, integer *ldb, integer *info);
2170 EOF
2171 HandleBad => 0,
2172 Pars => '[io]A(2,n,n); int uplo(); [io]B(2,n,m); int [o]info()',
2173 Code => generate_code '
2174 char puplo = \'U\';
2175 if ($uplo())
2176 puplo = \'L\';
2177
2178 FORTRAN($TFD(c,z)posv)(
2179 &puplo,
2180 &(integer){$SIZE(n)},
2181 &(integer){$SIZE(m)},
2182 $P(A),
2183 &(integer){$SIZE(n)},
2184 $P(B),
2185 &(integer){$SIZE(n)},
2186 $P(info));
2187 ',
2188 Doc=>'
2189
2190 =for ref
2191
2192 Complex version of L<PDL::LinearAlgebra::Real/posv> for Hermitian positive definite matrix
2193
2194 ');
2195 pp_defc("posvx",
2196 _decl => <<'EOF',
2197 extern int FORTRAN($TFD(c,z)posvx)(char *fact, char *uplo, integer *n, integer *
2198 nrhs, $GENERIC() *a, integer *lda, $GENERIC() *af, integer *ldaf,
2199 char *equed, $GENERIC() *s, $GENERIC() *b, integer *ldb, $GENERIC() *
2200 x, integer *ldx, $GENERIC() *rcond, $GENERIC() *ferr, $GENERIC() *
2201 berr, $GENERIC() *work, $GENERIC() *rwork, integer *info);
2202 EOF
2203 HandleBad => 0,
2204 Pars => '[io]A(2,n,n); int uplo(); int fact(); [io]B(2,n,m); [io]af(2,n,n); int [io]equed(); [o]s(p); [o]X(2,n,m); [o]rcond(); [o]ferr(m); [o]berr(m); int [o]info(); [t]rwork(rworkn=CALC(2*$SIZE(n))); [t]work(workn=CALC(4*$SIZE(n)));',
2205 RedoDimsCode => '
2206 $SIZE(p) = $SIZE(n); /* Ubuntu LAPACK 3 writes to s anyway */
2207 ',
2208 Code => generate_code '
2209 char pfact;
2210 char pequed = \'N\';
2211 char puplo = \'U\';
2212
2213 switch ($fact())
2214 {
2215 case 1: pfact = \'N\';
2216 break;
2217 case 2: pfact = \'E\';
2218 break;
2219 default: pfact = \'F\';
2220 }
2221 if ($equed())
2222 pequed = \'Y\';
2223 if ($uplo())
2224 puplo = \'L\';
2225
2226 FORTRAN($TFD(c,z)posvx)(
2227 &pfact,
2228 &puplo,
2229 &(integer){$SIZE(n)},
2230 &(integer){$SIZE(m)},
2231 $P(A),
2232 &(integer){$SIZE(n)},
2233 $P(af),
2234 &(integer){$SIZE(n)},
2235 &pequed,
2236 $P(s),
2237 $P(B),
2238 &(integer){$SIZE(n)},
2239 $P(X),
2240 &(integer){$SIZE(n)},
2241 $P(rcond),
2242 $P(ferr),
2243 $P(berr),
2244 $P(work),
2245 $P(rwork),
2246 $P(info));
2247 switch (pequed)
2248 {
2249 case \'Y\': $equed() = 1;
2250 break;
2251 default: $equed()= 0;
2252 }
2253 ',
2254 Doc => '
2255 =for ref
2256
2257 Complex version of L<PDL::LinearAlgebra::Real/posvx> for Hermitian positive definite matrix
2258 ');
2259
2260 pp_defc("gels",
2261 _decl => <<'EOF',
2262 extern int FORTRAN($TFD(c,z)gels)(char *trans, integer *m, integer *n, integer *
2263 nrhs, $GENERIC() *a, integer *lda, $GENERIC() *b, integer *ldb,
2264 $GENERIC() *work, integer *lwork, integer *info);
2265 EOF
2266 HandleBad => 0,
2267 Pars => '[io]A(2,m,n); int trans(); [io]B(2,p,q);int [o]info()',
2268 Code => generate_code '
2269 char ptrans = \'N\';
2270 integer lwork = -1;
2271 $GENERIC() tmp_work[2];
2272
2273 if($trans())
2274 ptrans = \'C\';
2275
2276 FORTRAN($TFD(c,z)gels)(
2277 &ptrans,
2278 &(integer){$SIZE(m)},
2279 &(integer){$SIZE(n)},
2280 &(integer){$SIZE(q)},
2281 $P(A),
2282 &(integer){$SIZE(m)},
2283 $P(B),
2284 &(integer){$SIZE(p)},
2285 &tmp_work[0],
2286 &lwork,
2287 $P(info));
2288
2289 lwork = (integer )tmp_work[0];
2290 {
2291 $GENERIC() *work = ($GENERIC() *)malloc(2*lwork * sizeof($GENERIC()));
2292 FORTRAN($TFD(c,z)gels)(
2293 &ptrans,
2294 &(integer){$SIZE(m)},
2295 &(integer){$SIZE(n)},
2296 &(integer){$SIZE(q)},
2297 $P(A),
2298 &(integer){$SIZE(m)},
2299 $P(B),
2300 &(integer){$SIZE(p)},
2301 work,
2302 &lwork,
2303 $P(info));
2304 free(work);
2305 }
2306 ',
2307 Doc=>'
2308 =for ref
2309
2310 Solves overdetermined or underdetermined complex linear systems
2311 involving an M-by-N matrix A, or its conjugate-transpose.
2312 Complex version of L<PDL::LinearAlgebra::Real/gels>.
2313
2314 trans: = 0: the linear system involves A;
2315 = 1: the linear system involves A**H.
2316 ');
2317
2318 pp_defc("gelsy",
2319 _decl => <<'EOF',
2320 extern int FORTRAN($TFD(c,z)gelsy)(integer *m, integer *n, integer *nrhs,
2321 $GENERIC() *a, integer *lda, $GENERIC() *b, integer *ldb, integer *
2322 jpvt, $GENERIC() *rcond, integer *rank, $GENERIC() *work, integer *
2323 lwork, $GENERIC() *rwork, integer *info);
2324 EOF
2325 HandleBad => 0,
2326 Pars => '[io]A(2,m,n); [io]B(2,p,q); rcond(); int [io]jpvt(n); int [o]rank();int [o]info(); [t]rwork(rworkn=CALC(2*$SIZE(n)));',
2327 Code => generate_code '
2328 integer lwork = -1;
2329 $GENERIC() tmp_work[2];
2330 FORTRAN($TFD(c,z)gelsy)(
2331 &(integer){$SIZE(m)},
2332 &(integer){$SIZE(n)},
2333 &(integer){$SIZE(q)},
2334 $P(A),
2335 &(integer){$SIZE(m)},
2336 $P(B),
2337 &(integer){$SIZE(p)},
2338 $P(jpvt),
2339 $P(rcond),
2340 $P(rank),
2341 &tmp_work[0],
2342 &lwork,
2343 $P(rwork),
2344 $P(info));
2345
2346 lwork = (integer )tmp_work[0];
2347 {
2348 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
2349 FORTRAN($TFD(c,z)gelsy)(
2350 &(integer){$SIZE(m)},
2351 &(integer){$SIZE(n)},
2352 &(integer){$SIZE(q)},
2353 $P(A),
2354 &(integer){$SIZE(m)},
2355 $P(B),
2356 &(integer){$SIZE(p)},
2357 $P(jpvt),
2358 $P(rcond),
2359 $P(rank),
2360 work,
2361 &lwork,
2362 $P(rwork),
2363 $P(info));
2364 free(work);
2365 }
2366 ');
2367
2368 pp_defc("gelss",
2369 _decl => <<'EOF',
2370 extern int FORTRAN($TFD(c,z)gelss)(integer *m, integer *n, integer *nrhs,
2371 $GENERIC() *a, integer *lda, $GENERIC() *b, integer *ldb, $GENERIC() *s,
2372 $GENERIC() *rcond, integer *rank, $GENERIC() *work, integer *
2373 lwork, $GENERIC() *rwork, integer *info);
2374 EOF
2375 HandleBad => 0,
2376 Pars => '[io]A(2,m,n); [io]B(2,p,q); rcond(); [o]s(r); int [o]rank();int [o]info(); [t]rwork(rworkn=CALC(5*PDLMIN($SIZE(m),$SIZE(n))));',
2377 Code => generate_code '
2378 integer lwork = -1;
2379 $GENERIC() tmp_work[2];
2380 FORTRAN($TFD(c,z)gelss)(
2381 &(integer){$SIZE(m)},
2382 &(integer){$SIZE(n)},
2383 &(integer){$SIZE(q)},
2384 $P(A),
2385 &(integer){$SIZE(m)},
2386 $P(B),
2387 &(integer){$SIZE(p)},
2388 $P(s),
2389 $P(rcond),
2390 $P(rank),
2391 &tmp_work[0],
2392 &lwork,
2393 $P(rwork),
2394 $P(info));
2395
2396 lwork = (integer )tmp_work[0];
2397 {
2398 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
2399 FORTRAN($TFD(c,z)gelss)(
2400 &(integer){$SIZE(m)},
2401 &(integer){$SIZE(n)},
2402 &(integer){$SIZE(q)},
2403 $P(A),
2404 &(integer){$SIZE(m)},
2405 $P(B),
2406 &(integer){$SIZE(p)},
2407 $P(s),
2408 $P(rcond),
2409 $P(rank),
2410 work,
2411 &lwork,
2412 $P(rwork),
2413 $P(info));
2414 free(work);
2415 }
2416 ');
2417
2418 pp_defc("gelsd",
2419 _decl => <<'EOF',
2420 extern int FORTRAN($TFD(c,z)gelsd)(integer *m, integer *n, integer *nrhs,
2421 $GENERIC() *a, integer *lda, $GENERIC() *b, integer *ldb, $GENERIC() *s,
2422 $GENERIC() *rcond, integer *rank, $GENERIC() *work, integer *
2423 lwork, $GENERIC() *rwork, integer *iwork, integer *info);
2424 EOF
2425 HandleBad => 0,
2426 Pars => '[io]A(2,m,n); [io]B(2,p,q); rcond(); [o]s(minmn=CALC(PDLMAX(1,PDLMIN($SIZE(m),$SIZE(n))))); int [o]rank();int [o]info(); int [t]iwork(iworkn); [t]rwork(rworkn);',
2427 RedoDimsCode => '
2428 integer smlsiz = FORTRAN(ilaenv)(&c_nine, "CGELSD", " ", &c_zero, &c_zero, &c_zero, &c_zero, (ftnlen)6, (ftnlen)1);
2429 integer size_i = (integer) (log((double) $SIZE(minmn) / (double) (smlsiz + 1)) /log(2.)) + 1;
2430 $SIZE(iworkn) = $SIZE(minmn) * (3 * PDLMAX(size_i,0) + 11);
2431 $SIZE(rworkn) = $SIZE(minmn) * (10 + 2 * smlsiz + 8 * size_i) + 3 * smlsiz * $SIZE(q) + pow(smlsiz+1,2);
2432 ',
2433 Code => generate_code '
2434 integer lwork = -1;
2435 $GENERIC() tmp_work[2];
2436 FORTRAN($TFD(c,z)gelsd)(
2437 &(integer){$SIZE(m)},
2438 &(integer){$SIZE(n)},
2439 &(integer){$SIZE(q)},
2440 $P(A),
2441 &(integer){$SIZE(m)},
2442 $P(B),
2443 &(integer){$SIZE(p)},
2444 $P(s),
2445 $P(rcond),
2446 $P(rank),
2447 &tmp_work[0],
2448 &lwork,
2449 $P(rwork),
2450 $P(iwork),
2451 $P(info));
2452
2453 lwork = (integer )tmp_work[0];
2454 {
2455 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
2456 FORTRAN($TFD(c,z)gelsd)(
2457 &(integer){$SIZE(m)},
2458 &(integer){$SIZE(n)},
2459 &(integer){$SIZE(q)},
2460 $P(A),
2461 &(integer){$SIZE(m)},
2462 $P(B),
2463 &(integer){$SIZE(p)},
2464 $P(s),
2465 $P(rcond),
2466 $P(rank),
2467 work,
2468 &lwork,
2469 $P(rwork),
2470 $P(iwork),
2471 $P(info));
2472 free(work);
2473 }
2474 ');
2475
2476 pp_defc("gglse",
2477 _decl => <<'EOF',
2478 extern int FORTRAN($TFD(c,z)gglse)(integer *m, integer *n, integer *p, $GENERIC() *
2479 a, integer *lda, $GENERIC() *b, integer *ldb, $GENERIC() *c__,
2480 $GENERIC() *d__, $GENERIC() *x, $GENERIC() *work, integer *lwork,
2481 integer *info);
2482 EOF
2483 HandleBad => 0,
2484 Pars => '[io]A(2,m,n); [io]B(2,p,n);[io]c(2,m);[io]d(2,p);[o]x(2,n);int [o]info()',
2485 Code => generate_code '
2486 integer lwork = -1;
2487 $GENERIC() tmp_work[2];
2488
2489 FORTRAN($TFD(c,z)gglse)(
2490 &(integer){$SIZE(m)},
2491 &(integer){$SIZE(n)},
2492 &(integer){$SIZE(p)},
2493 $P(A),
2494 &(integer){$SIZE(m)},
2495 $P(B),
2496 &(integer){$SIZE(p)},
2497 $P(c),
2498 $P(d),
2499 $P(x),
2500 &tmp_work[0],
2501 &lwork,
2502 $P(info));
2503
2504 lwork = (integer )tmp_work[0];
2505 {
2506 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
2507 FORTRAN($TFD(c,z)gglse)(
2508 &(integer){$SIZE(m)},
2509 &(integer){$SIZE(n)},
2510 &(integer){$SIZE(p)},
2511 $P(A),
2512 &(integer){$SIZE(m)},
2513 $P(B),
2514 &(integer){$SIZE(p)},
2515 $P(c),
2516 $P(d),
2517 $P(x),
2518 work,
2519 &lwork,
2520 $P(info));
2521 free(work);
2522 }
2523
2524 ');
2525
2526 pp_defc("ggglm",
2527 _decl => <<'EOF',
2528 extern int FORTRAN($TFD(c,z)ggglm)(integer *n, integer *m, integer *p, $GENERIC() *
2529 a, integer *lda, $GENERIC() *b, integer *ldb, $GENERIC() *d__,
2530 $GENERIC() *x, $GENERIC() *y, $GENERIC() *work, integer *lwork,
2531 integer *info);
2532 EOF
2533 HandleBad => 0,
2534 Pars => '[io]A(2,n,m); [io]B(2,n,p);[io]d(2,n);[o]x(2,m);[o]y(2,p);int [o]info()',
2535 Code => generate_code '
2536 integer lwork = -1;
2537 $GENERIC() tmp_work[2];
2538
2539 FORTRAN($TFD(c,z)ggglm)(
2540 &(integer){$SIZE(n)},
2541 &(integer){$SIZE(m)},
2542 &(integer){$SIZE(p)},
2543 $P(A),
2544 &(integer){$SIZE(n)},
2545 $P(B),
2546 &(integer){$SIZE(n)},
2547 $P(d),
2548 $P(x),
2549 $P(y),
2550 &tmp_work[0],
2551 &lwork,
2552 $P(info));
2553
2554 lwork = (integer )tmp_work[0];
2555 {
2556 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
2557 FORTRAN($TFD(c,z)ggglm)(
2558 &(integer){$SIZE(n)},
2559 &(integer){$SIZE(m)},
2560 &(integer){$SIZE(p)},
2561 $P(A),
2562 &(integer){$SIZE(n)},
2563 $P(B),
2564 &(integer){$SIZE(n)},
2565 $P(d),
2566 $P(x),
2567 $P(y),
2568 work,
2569 &lwork,
2570 $P(info));
2571 free(work);
2572 }
2573
2574 ');
2575
2576 ################################################################################
2577 #
2578 # COMPUTATIONAL LEVEL ROUTINES
2579 #
2580 ################################################################################
2581 pp_defc("getrf",
2582 _decl => <<'EOF',
2583 extern int FORTRAN($TFD(c,z)getrf)(integer *m, integer *n, $GENERIC() *a, integer *
2584 lda, integer *ipiv, integer *info);
2585 EOF
2586 HandleBad => 0,
2587 Pars => '[io]A(2,m,n); int [o]ipiv(p=CALC(PDLMIN($SIZE(m),$SIZE(n)))); int [o]info()',
2588 Code => generate_code '
2589 FORTRAN($TFD(c,z)getrf)(
2590 &(integer){$SIZE(m)},
2591 &(integer){$SIZE(n)},
2592 $P(A),
2593 &(integer){$SIZE(m)},
2594 $P(ipiv),
2595 $P(info));
2596 ');
2597
2598 pp_defc("getf2",
2599 _decl => <<'EOF',
2600 extern int FORTRAN($TFD(c,z)getf2)(integer *m, integer *n, $GENERIC() *a, integer *
2601 lda, integer *ipiv, integer *info);
2602 EOF
2603 HandleBad => 0,
2604 Pars => '[io]A(2,m,n); int [o]ipiv(p=CALC(PDLMIN($SIZE(m),$SIZE(n)))); int [o]info()',
2605 Code => generate_code '
2606 FORTRAN($TFD(c,z)getf2)(
2607 &(integer){$SIZE(m)},
2608 &(integer){$SIZE(n)},
2609 $P(A),
2610 &(integer){$SIZE(m)},
2611 $P(ipiv),
2612 $P(info));
2613 ');
2614
2615 pp_defc("sytrf",
2616 _decl => <<'EOF',
2617 extern int FORTRAN($TFD(c,z)sytrf)(char *uplo, integer *n, $GENERIC() *a, integer *
2618 lda, integer *ipiv, $GENERIC() *work, integer *lwork, integer *info);
2619 EOF
2620 HandleBad => 0,
2621 Pars => '[io]A(2,n,n); int uplo(); int [o]ipiv(n); int [o]info()',
2622 Code => generate_code '
2623 char puplo = \'U\';
2624 integer lwork = -1;
2625 $GENERIC() tmp_work[2];
2626 if ($uplo())
2627 puplo = \'L\';
2628
2629 FORTRAN($TFD(c,z)sytrf)(
2630 &puplo,
2631 &(integer){$SIZE(n)},
2632 $P(A),
2633 &(integer){$SIZE(n)},
2634 $P(ipiv),
2635 &tmp_work[0],
2636 &lwork,
2637 $P(info));
2638
2639 lwork = (integer )tmp_work[0];
2640 {
2641 $GENERIC() *work = ($GENERIC() *)malloc(2*lwork * sizeof($GENERIC()));
2642 FORTRAN($TFD(c,z)sytrf)(
2643 &puplo,
2644 &(integer){$SIZE(n)},
2645 $P(A),
2646 &(integer){$SIZE(n)},
2647 $P(ipiv),
2648 work,
2649 &lwork,
2650 $P(info));
2651 free (work);
2652 }
2653 ');
2654
2655 pp_defc("sytf2",
2656 _decl => <<'EOF',
2657 extern int FORTRAN($TFD(c,z)sytf2)(char *uplo, integer *n, $GENERIC() *a, integer *
2658 lda, integer *ipiv, integer *info);
2659 EOF
2660 HandleBad => 0,
2661 Pars => '[io]A(2,n,n); int uplo(); int [o]ipiv(n); int [o]info()',
2662 Code => generate_code '
2663 char puplo = \'U\';
2664 if ($uplo())
2665 puplo = \'L\';
2666
2667 FORTRAN($TFD(c,z)sytf2)(
2668 &puplo,
2669 &(integer){$SIZE(n)},
2670 $P(A),
2671 &(integer){$SIZE(n)},
2672 $P(ipiv),
2673 $P(info));
2674 ');
2675
2676 pp_defc("chetrf",
2677 _decl => <<'EOF',
2678 extern int FORTRAN($TFD(c,z)hetrf)(char *uplo, integer *n, $GENERIC() *a, integer *
2679 lda, integer *ipiv, $GENERIC() *work, integer *lwork, integer *info);
2680 EOF
2681 HandleBad => 0,
2682 Pars => '[io]A(2,n,n); int uplo(); int [o]ipiv(n); int [o]info(); [t]work(workn);',
2683 RedoDimsCode => '
2684 $SIZE(workn) = 2 * $SIZE(n) * FORTRAN(ilaenv)(&c_nine, "CHETRF", " ", &c_zero, &c_zero, &c_zero, &c_zero, (ftnlen)6, (ftnlen)1);
2685 ',
2686 Code => generate_code '
2687 char puplo = \'U\';
2688 if ($uplo())
2689 puplo = \'L\';
2690 FORTRAN($TFD(c,z)hetrf)(
2691 &puplo,
2692 &(integer){$SIZE(n)},
2693 $P(A),
2694 &(integer){$SIZE(n)},
2695 $P(ipiv),
2696 $P(work),
2697 &(integer){$SIZE(workn)},
2698 $P(info));
2699 ',
2700 Doc=>'
2701 =for ref
2702
2703 Complex version of L<PDL::LinearAlgebra::Real/sytrf> for Hermitian matrix
2704 ');
2705
2706 pp_defc("hetf2",
2707 _decl => <<'EOF',
2708 extern int FORTRAN($TFD(c,z)hetf2)(char *uplo, integer *n, $GENERIC() *a, integer *
2709 lda, integer *ipiv, integer *info);
2710 EOF
2711 HandleBad => 0,
2712 Pars => '[io]A(2,n,n); int uplo(); int [o]ipiv(n); int [o]info()',
2713 Code => generate_code '
2714 char puplo = \'U\';
2715 if ($uplo())
2716 puplo = \'L\';
2717 FORTRAN($TFD(c,z)hetf2)(
2718 &puplo,
2719 &(integer){$SIZE(n)},
2720 $P(A),
2721 &(integer){$SIZE(n)},
2722 $P(ipiv),
2723 $P(info));
2724 ',
2725 Doc=>'
2726 =for ref
2727
2728 Complex version of L<PDL::LinearAlgebra::Real/sytf2> for Hermitian matrix
2729 ');
2730
2731 pp_defc("potrf",
2732 _decl => <<'EOF',
2733 extern int FORTRAN($TFD(c,z)potrf)(char *uplo, integer *n, $GENERIC() *a, integer *
2734 lda, integer *info);
2735 EOF
2736 HandleBad => 0,
2737 Pars => '[io]A(2,n,n); int uplo(); int [o]info()',
2738 Code => generate_code '
2739 char puplo = \'U\';
2740 if ($uplo())
2741 puplo = \'L\';
2742
2743 FORTRAN($TFD(c,z)potrf)(
2744 &puplo,
2745 &(integer){$SIZE(n)},
2746 $P(A),
2747 &(integer){$SIZE(n)},
2748 $P(info));
2749 ',
2750 Doc=>'
2751
2752 =for ref
2753
2754 Complex version of L<PDL::LinearAlgebra::Real/potrf> for Hermitian positive definite matrix
2755
2756 ');
2757
2758 pp_defc("potf2",
2759 _decl => <<'EOF',
2760 extern int FORTRAN($TFD(c,z)potf2)(char *uplo, integer *n, $GENERIC() *a, integer *
2761 lda, integer *info);
2762 EOF
2763 HandleBad => 0,
2764 Pars => '[io]A(2,n,n); int uplo(); int [o]info()',
2765 Code => generate_code '
2766 char puplo = \'U\';
2767 if ($uplo())
2768 puplo = \'L\';
2769
2770 FORTRAN($TFD(c,z)potf2)(
2771 &puplo,
2772 &(integer){$SIZE(n)},
2773 $P(A),
2774 &(integer){$SIZE(n)},
2775 $P(info));
2776 ',
2777 Doc => '
2778
2779 =for ref
2780
2781 Complex version of L<PDL::LinearAlgebra::Real/potf2> for Hermitian positive definite matrix
2782
2783 ');
2784
2785 pp_defc("getri",
2786 _decl => <<'EOF',
2787 extern int FORTRAN($TFD(c,z)getri)(integer *n, $GENERIC() *a, integer *lda, integer
2788 *ipiv, $GENERIC() *work, integer *lwork, integer *info);
2789 EOF
2790 HandleBad => 0,
2791 Pars => '[io]A(2,n,n); int ipiv(n); int [o]info()',
2792 Code => generate_code '
2793 integer lwork = -1;
2794 $GENERIC() tmp_work[2];
2795
2796 FORTRAN($TFD(c,z)getri)(
2797 &(integer){$SIZE(n)},
2798 $P(A),
2799 &(integer){$SIZE(n)},
2800 $P(ipiv),
2801 &tmp_work[0],
2802 &lwork,
2803 $P(info));
2804
2805 lwork = (integer )tmp_work[0];
2806 {
2807 $GENERIC() *work = ($GENERIC() *)malloc(2*lwork * sizeof($GENERIC()));
2808 FORTRAN($TFD(c,z)getri)(
2809 &(integer){$SIZE(n)},
2810 $P(A),
2811 &(integer){$SIZE(n)},
2812 $P(ipiv),
2813 work,
2814 &lwork,
2815 $P(info));
2816 free(work);
2817 }
2818 ');
2819
2820
2821 pp_defc("sytri",
2822 _decl => <<'EOF',
2823 extern int FORTRAN($TFD(c,z)sytri)(char *uplo, integer *n, $GENERIC() *a, integer *
2824 lda, integer *ipiv, $GENERIC() *work, integer *info);
2825 EOF
2826 HandleBad => 0,
2827 Pars => '[io]A(2,n,n); int uplo(); int ipiv(n); int [o]info(); [t]work(workn=CALC(2*$SIZE(n)));',
2828 Code => generate_code '
2829 char puplo = \'U\';
2830 if ($uplo())
2831 puplo = \'L\';
2832 FORTRAN($TFD(c,z)sytri)(
2833 &puplo,
2834 &(integer){$SIZE(n)},
2835 $P(A),
2836 &(integer){$SIZE(n)},
2837 $P(ipiv),
2838 $P(work),
2839 $P(info));
2840 ');
2841
2842 pp_defc("hetri",
2843 _decl => <<'EOF',
2844 extern int FORTRAN($TFD(c,z)hetri)(char *uplo, integer *n, $GENERIC() *a, integer *
2845 lda, integer *ipiv, $GENERIC() *work, integer *info);
2846 EOF
2847 HandleBad => 0,
2848 Pars => '[io]A(2,n,n); int uplo(); int ipiv(n); int [o]info(); [t]work(workn=CALC(2*$SIZE(n)));',
2849 Code => generate_code '
2850 char puplo = \'U\';
2851 if ($uplo())
2852 puplo = \'L\';
2853
2854 FORTRAN($TFD(c,z)hetri)(
2855 &puplo,
2856 &(integer){$SIZE(n)},
2857 $P(A),
2858 &(integer){$SIZE(n)},
2859 $P(ipiv),
2860 $P(work),
2861 $P(info));
2862 ',
2863 Doc => '
2864 =for ref
2865
2866 Complex version of L<PDL::LinearAlgebra::Real/sytri> for Hermitian matrix
2867 ');
2868
2869 pp_defc("potri",
2870 _decl => <<'EOF',
2871 extern int FORTRAN($TFD(c,z)potri)(char *uplo, integer *n, $GENERIC() *a, integer *
2872 lda, integer *info);
2873 EOF
2874 HandleBad => 0,
2875 Pars => '[io]A(2,n,n); int uplo(); int [o]info()',
2876 Code => generate_code '
2877 char puplo = \'U\';
2878 if ($uplo())
2879 puplo = \'L\';
2880
2881 FORTRAN($TFD(c,z)potri)(
2882 &puplo,
2883 &(integer){$SIZE(n)},
2884 $P(A),
2885 &(integer){$SIZE(n)},
2886 $P(info));
2887 ');
2888
2889 pp_defc("trtri",
2890 _decl => <<'EOF',
2891 extern int FORTRAN($TFD(c,z)trtri)(char *uplo, char *diag, integer *n, $GENERIC() *a, integer *
2892 lda, integer *info);
2893 EOF
2894 HandleBad => 0,
2895 Pars => '[io]A(2,n,n); int uplo(); int diag(); int [o]info()',
2896 Code => generate_code '
2897 char puplo = \'U\';
2898 char pdiag = \'N\';
2899 if ($uplo())
2900 puplo = \'L\';
2901 if ($diag())
2902 pdiag = \'U\';
2903
2904 FORTRAN($TFD(c,z)trtri)(
2905 &puplo,
2906 &pdiag,
2907 &(integer){$SIZE(n)},
2908 $P(A),
2909 &(integer){$SIZE(n)},
2910 $P(info));
2911 ');
2912
2913 pp_defc("trti2",
2914 _decl => <<'EOF',
2915 extern int FORTRAN($TFD(c,z)trti2)(char *uplo, char *diag, integer *n, $GENERIC() *a, integer *
2916 lda, integer *info);
2917 EOF
2918 HandleBad => 0,
2919 Pars => '[io]A(2,n,n); int uplo(); int diag(); int [o]info()',
2920 Code => generate_code '
2921 char puplo = \'U\';
2922 char pdiag = \'N\';
2923 if ($uplo())
2924 puplo = \'L\';
2925 if ($diag())
2926 pdiag = \'U\';
2927
2928 FORTRAN($TFD(c,z)trti2)(
2929 &puplo,
2930 &pdiag,
2931 &(integer){$SIZE(n)},
2932 $P(A),
2933 &(integer){$SIZE(n)},
2934 $P(info));
2935 ');
2936
2937 pp_defc("getrs",
2938 _decl => <<'EOF',
2939 extern int FORTRAN($TFD(c,z)getrs)(char *trans, integer *n, integer *nrhs,
2940 $GENERIC() *a, integer *lda, integer *ipiv, $GENERIC() *b, integer *
2941 ldb, integer *info);
2942 EOF
2943 HandleBad => 0,
2944 Pars => 'A(2,n,n); int trans(); [io]B(2,n,m); int ipiv(n); int [o]info()',
2945 Code => generate_code '
2946 char transp = \'N\';
2947 if($trans() == 1)
2948 transp = \'T\';
2949 else if($trans() == 2)
2950 transp = \'C\';
2951
2952 FORTRAN($TFD(c,z)getrs)(
2953 &transp,
2954 &(integer){$SIZE(n)},
2955 &(integer){$SIZE(m)},
2956 $P(A),
2957 &(integer){$SIZE(n)},
2958 $P(ipiv),
2959 $P(B),
2960 &(integer){$SIZE(n)},
2961 $P(info));
2962 ',
2963 Doc=>'
2964
2965 =for ref
2966
2967 Complex version of L<PDL::LinearAlgebra::Real/getrs>
2968
2969 Arguments
2970 =========
2971 trans: = 0: No transpose;
2972 = 1: Transpose;
2973 = 2: Conjugate transpose;
2974
2975 ');
2976
2977 pp_defc("sytrs",
2978 _decl => <<'EOF',
2979 extern int FORTRAN($TFD(c,z)sytrs)(char *uplo, integer *n, integer *nrhs,
2980 $GENERIC() *a, integer *lda, integer *ipiv, $GENERIC() *b, integer *
2981 ldb, integer *info);
2982 EOF
2983 HandleBad => 0,
2984 Pars => 'A(2,n,n); int uplo();[io]B(2,n,m); int ipiv(n); int [o]info()',
2985 Code => generate_code '
2986 char puplo = \'U\';
2987 if($uplo())
2988 puplo = \'L\';
2989
2990 FORTRAN($TFD(c,z)sytrs)(
2991 &puplo,
2992 &(integer){$SIZE(n)},
2993 &(integer){$SIZE(m)},
2994 $P(A),
2995 &(integer){$SIZE(n)},
2996 $P(ipiv),
2997 $P(B),
2998 &(integer){$SIZE(n)},
2999 $P(info));
3000 ');
3001
3002
3003 pp_defc("hetrs",
3004 _decl => <<'EOF',
3005 extern int FORTRAN($TFD(c,z)hetrs)(char *uplo, integer *n, integer *nrhs,
3006 $GENERIC() *a, integer *lda, integer *ipiv, $GENERIC() *b, integer *
3007 ldb, integer *info);
3008 EOF
3009 HandleBad => 0,
3010 Pars => 'A(2,n,n); int uplo();[io]B(2,n,m); int ipiv(n); int [o]info()',
3011 Code => generate_code '
3012 char puplo = \'U\';
3013 if($uplo())
3014 puplo = \'L\';
3015
3016 FORTRAN($TFD(c,z)hetrs)(
3017 &puplo,
3018 &(integer){$SIZE(n)},
3019 &(integer){$SIZE(m)},
3020 $P(A),
3021 &(integer){$SIZE(n)},
3022 $P(ipiv),
3023 $P(B),
3024 &(integer){$SIZE(n)},
3025 $P(info));
3026 ',
3027 Doc => '
3028
3029 =for ref
3030
3031 Complex version of L<PDL::LinearAlgebra::Real/sytrs> for Hermitian matrix
3032
3033 ');
3034
3035 pp_defc("potrs",
3036 _decl => <<'EOF',
3037 extern int FORTRAN($TFD(c,z)potrs)(char *uplo, integer *n, integer *nrhs,
3038 $GENERIC() *a, integer *lda, $GENERIC() *b, integer *ldb, integer *
3039 info);
3040 EOF
3041 HandleBad => 0,
3042 Pars => 'A(2,n,n); int uplo(); [io]B(2,n,m); int [o]info()',
3043 Code => generate_code '
3044 char puplo = \'U\';
3045 if($uplo())
3046 puplo = \'L\';
3047
3048 FORTRAN($TFD(c,z)potrs)(
3049 &puplo,
3050 &(integer){$SIZE(n)},
3051 &(integer){$SIZE(m)},
3052 $P(A),
3053 &(integer){$SIZE(n)},
3054 $P(B),
3055 &(integer){$SIZE(n)},
3056 $P(info));
3057 ',
3058
3059 Doc=>'
3060
3061 =for ref
3062
3063 Complex version of L<PDL::LinearAlgebra::Real/potrs> for Hermitian positive definite matrix
3064
3065 ');
3066
3067 pp_defc("trtrs",
3068 _decl => <<'EOF',
3069 extern int FORTRAN($TFD(c,z)trtrs)(char *uplo, char *trans, char *diag,
3070 integer *n, integer *nrhs,
3071 $GENERIC() *a, integer *lda, $GENERIC() *b, integer *
3072 ldb, integer *info);
3073 EOF
3074 HandleBad => 0,
3075 Pars => 'A(2,n,n); int uplo(); int trans(); int diag();[io]B(2,n,m); int [o]info()',
3076 Code => generate_code '
3077 char puplo = \'U\';
3078 char ptrans = \'N\';
3079 char pdiag = \'N\';
3080 if($uplo())
3081 puplo = \'L\';
3082 if($trans() == 1)
3083 ptrans = \'T\';
3084 else if($trans() == 2)
3085 ptrans = \'C\';
3086 if($diag())
3087 pdiag = \'U\';
3088
3089 FORTRAN($TFD(c,z)trtrs)(
3090 &puplo,
3091 &ptrans,
3092 &pdiag,
3093 &(integer){$SIZE(n)},
3094 &(integer){$SIZE(m)},
3095 $P(A),
3096 &(integer){$SIZE(n)},
3097 $P(B),
3098 &(integer){$SIZE(n)},
3099 $P(info));
3100 ',
3101 Doc=>'
3102
3103 =for ref
3104
3105 Complex version of L<PDL::LinearAlgebra::Real/trtrs>
3106
3107 Arguments
3108 =========
3109 trans: = 0: No transpose;
3110 = 1: Transpose;
3111 = 2: Conjugate transpose;
3112
3113 ');
3114
3115
3116 pp_defc("latrs",
3117 _decl => <<'EOF',
3118 extern int FORTRAN($TFD(c,z)latrs)(char *uplo, char *trans, char *diag, char *
3119 normin, integer *n, $GENERIC() *a, integer *lda, $GENERIC() *x,
3120 $GENERIC() *scale, $GENERIC() *cnorm, integer *info);
3121 EOF
3122 HandleBad => 0,
3123 Pars => 'A(2,n,n); int uplo(); int trans(); int diag(); int normin();[io]x(2,n); [o]scale();[io]cnorm(n);int [o]info()',
3124 Code => generate_code '
3125 char puplo = \'U\';
3126 char ptrans = \'N\';
3127 char pdiag = \'N\';
3128 char pnormin = \'N\';
3129
3130 if($uplo())
3131 puplo = \'L\';
3132 if($trans())
3133 ptrans = \'T\';
3134 else if($trans() == 2)
3135 ptrans = \'C\';
3136 if($diag())
3137 pdiag = \'U\';
3138 if($normin())
3139 pnormin = \'Y\';
3140
3141 FORTRAN($TFD(c,z)latrs)(
3142 &puplo,
3143 &ptrans,
3144 &pdiag,
3145 &pnormin,
3146 &(integer){$SIZE(n)},
3147 $P(A),
3148 &(integer){$SIZE(n)},
3149 $P(x),
3150 $P(scale),
3151 $P(cnorm),
3152 $P(info));
3153 ',
3154 Doc=>'
3155
3156 =for ref
3157
3158 Complex version of L<PDL::LinearAlgebra::Real/latrs>
3159
3160 Arguments
3161 =========
3162 trans: = 0: No transpose;
3163 = 1: Transpose;
3164 = 2: Conjugate transpose;
3165 ');
3166
3167 pp_defc("gecon",
3168 _decl => <<'EOF',
3169 extern int FORTRAN($TFD(c,z)gecon)(char *norm, integer *n, $GENERIC() *a, integer *
3170 lda, $GENERIC() *anorm, $GENERIC() *rcond, $GENERIC() *work, $GENERIC() *
3171 rwork, integer *info);
3172 EOF
3173 HandleBad => 0,
3174 Pars => 'A(2,n,n); int norm(); anorm(); [o]rcond();int [o]info(); [t]rwork(rworkn=CALC(2*$SIZE(n))); [t]work(workn=CALC(4*$SIZE(n)));',
3175 Code => generate_code '
3176 char pnorm = \'I\';
3177 if($norm())
3178 pnorm = \'O\';
3179 FORTRAN($TFD(c,z)gecon)(
3180 &pnorm,
3181 &(integer){$SIZE(n)},
3182 $P(A),
3183 &(integer){$SIZE(n)},
3184 $P(anorm),
3185 $P(rcond),
3186 $P(work),
3187 $P(rwork),
3188 $P(info));
3189 ');
3190
3191 pp_defc("sycon",
3192 _decl => <<'EOF',
3193 extern int FORTRAN($TFD(c,z)sycon)(char *uplo, integer *n, $GENERIC() *a, integer *
3194 lda, integer *ipiv, $GENERIC() *anorm, $GENERIC() *rcond, $GENERIC() *
3195 work, integer *info);
3196 EOF
3197 HandleBad => 0,
3198 Pars => 'A(2,n,n); int uplo(); int ipiv(n); anorm(); [o]rcond();int [o]info(); [t]work(workn=CALC(4*$SIZE(n)));',
3199 Code => generate_code '
3200 char puplo = \'U\';
3201 if($uplo())
3202 puplo = \'L\';
3203 FORTRAN($TFD(c,z)sycon)(
3204 &puplo,
3205 &(integer){$SIZE(n)},
3206 $P(A),
3207 &(integer){$SIZE(n)},
3208 $P(ipiv),
3209 $P(anorm),
3210 $P(rcond),
3211 $P(work),
3212 $P(info));
3213 ');
3214
3215 pp_defc("hecon",
3216 _decl => <<'EOF',
3217 extern int FORTRAN($TFD(c,z)hecon)(char *uplo, integer *n, $GENERIC() *a, integer *
3218 lda, integer *ipiv, $GENERIC() *anorm, $GENERIC() *rcond, $GENERIC() *
3219 work, integer *info);
3220 EOF
3221 HandleBad => 0,
3222 Pars => 'A(2,n,n); int uplo(); int ipiv(n); anorm(); [o]rcond();int [o]info(); [t]work(workn=CALC(4*$SIZE(n)));',
3223 Code => generate_code '
3224 char puplo = \'U\';
3225 if($uplo())
3226 puplo = \'L\';
3227 FORTRAN($TFD(c,z)hecon)(
3228 &puplo,
3229 &(integer){$SIZE(n)},
3230 $P(A),
3231 &(integer){$SIZE(n)},
3232 $P(ipiv),
3233 $P(anorm),
3234 $P(rcond),
3235 $P(work),
3236 $P(info));
3237 ',
3238 Doc => '
3239 =for ref
3240
3241 Complex version of L<PDL::LinearAlgebra::Real/sycon> for Hermitian matrix
3242 ');
3243
3244 pp_defc("pocon",
3245 _decl => <<'EOF',
3246 extern int FORTRAN($TFD(c,z)pocon)(char *uplo, integer *n, $GENERIC() *a, integer *
3247 lda, $GENERIC() *anorm, $GENERIC() *rcond, $GENERIC() *work, $GENERIC() *
3248 rwork, integer *info);
3249 EOF
3250 HandleBad => 0,
3251 Pars => 'A(2,n,n); int uplo(); anorm(); [o]rcond();int [o]info(); [t]work(workn=CALC(4*$SIZE(n))); [t]rwork(n);',
3252 Code => generate_code '
3253 char puplo = \'U\';
3254 if($uplo())
3255 puplo = \'L\';
3256 FORTRAN($TFD(c,z)pocon)(
3257 &puplo,
3258 &(integer){$SIZE(n)},
3259 $P(A),
3260 &(integer){$SIZE(n)},
3261 $P(anorm),
3262 $P(rcond),
3263 $P(work),
3264 $P(rwork),
3265 $P(info));
3266 ',
3267 Doc => '
3268 =for ref
3269
3270 Complex version of L<PDL::LinearAlgebra::Real/pocon> for Hermitian positive definite matrix
3271 ');
3272
3273 pp_defc("trcon",
3274 _decl => <<'EOF',
3275 extern int FORTRAN($TFD(c,z)trcon)(char *norm, char *uplo, char *diag,integer *n, $GENERIC() *a, integer *
3276 lda, $GENERIC() *rcond, $GENERIC() *work, $GENERIC() *rwork, integer *info);
3277 EOF
3278 HandleBad => 0,
3279 Pars => 'A(2,n,n); int norm();int uplo();int diag(); [o]rcond();int [o]info(); [t]work(workn=CALC(4*$SIZE(n))); [t]rwork(n);',
3280 Code => generate_code '
3281 char puplo = \'U\';
3282 char pdiag = \'N\';
3283 char pnorm = \'I\';
3284 if($uplo())
3285 puplo = \'L\';
3286 if($diag())
3287 pdiag = \'U\';
3288 if($norm())
3289 pnorm = \'O\';
3290 FORTRAN($TFD(c,z)trcon)(
3291 &pnorm,
3292 &puplo,
3293 &pdiag,
3294 &(integer){$SIZE(n)},
3295 $P(A),
3296 &(integer){$SIZE(n)},
3297 $P(rcond),
3298 $P(work),
3299 $P(rwork),
3300 $P(info));
3301 ');
3302
3303 pp_defc("geqp3",
3304 _decl => <<'EOF',
3305 extern int FORTRAN($TFD(c,z)geqp3)(integer *m, integer *n, $GENERIC() *a, integer *
3306 lda, integer *jpvt, $GENERIC() *tau, $GENERIC() *work, integer *lwork,
3307 $GENERIC() *rwork, integer *info);
3308 EOF
3309 HandleBad => 0,
3310 Pars => '[io]A(2,m,n); int [io]jpvt(n); [o]tau(2,k); int [o]info(); [t]rwork(rworkn=CALC(2*$SIZE(n)));',
3311 Code => generate_code '
3312 integer lwork = -1;
3313 $GENERIC() tmp_work[2];
3314 FORTRAN($TFD(c,z)geqp3)(
3315 &(integer){$SIZE(m)},
3316 &(integer){$SIZE(n)},
3317 $P(A),
3318 &(integer){$SIZE(m)},
3319 $P(jpvt),
3320 $P(tau),
3321 &tmp_work[0],
3322 &lwork,
3323 $P(rwork),
3324 $P(info));
3325 lwork = (integer )tmp_work[0];
3326 {
3327 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
3328 FORTRAN($TFD(c,z)geqp3)(
3329 &(integer){$SIZE(m)},
3330 &(integer){$SIZE(n)},
3331 $P(A),
3332 &(integer){$SIZE(m)},
3333 $P(jpvt),
3334 $P(tau),
3335 work,
3336 &lwork,
3337 $P(rwork),
3338 $P(info));
3339 free(work);
3340 }
3341 '
3342 );
3343
3344 pp_defc("geqrf",
3345 _decl => <<'EOF',
3346 extern int FORTRAN($TFD(c,z)geqrf)(integer *m, integer *n, $GENERIC() *a, integer *
3347 lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork,
3348 integer *info);
3349 EOF
3350 HandleBad => 0,
3351 Pars => '[io]A(2,m,n); [o]tau(2,k); int [o]info()',
3352 Code => generate_code '
3353 integer lwork = -1;
3354 $GENERIC() tmp_work[2];
3355 FORTRAN($TFD(c,z)geqrf)(
3356 &(integer){$SIZE(m)},
3357 &(integer){$SIZE(n)},
3358 $P(A),
3359 &(integer){$SIZE(m)},
3360 $P(tau),
3361 &tmp_work[0],
3362 &lwork,
3363 $P(info));
3364
3365 lwork = (integer )tmp_work[0];
3366 {
3367 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
3368 FORTRAN($TFD(c,z)geqrf)(
3369 &(integer){$SIZE(m)},
3370 &(integer){$SIZE(n)},
3371 $P(A),
3372 &(integer){$SIZE(m)},
3373 $P(tau),
3374 work,
3375 &lwork,
3376 $P(info));
3377 free(work);
3378 }
3379
3380 ');
3381
3382 pp_defc("ungqr",
3383 _decl => <<'EOF',
3384 extern int FORTRAN($TFD(c,z)ungqr)(integer *m, integer *n, integer *k, $GENERIC() *
3385 a, integer *lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork,
3386 integer *info);
3387 EOF
3388 HandleBad => 0,
3389 Pars => '[io]A(2,m,n); tau(2,k); int [o]info()',
3390 Code => generate_code '
3391 integer lwork = -1;
3392 $GENERIC() tmp_work[2];
3393 FORTRAN($TFD(c,z)ungqr)(
3394 &(integer){$SIZE(m)},
3395 &(integer){$SIZE(n)},
3396 &(integer){$SIZE(k)},
3397 $P(A),
3398 &(integer){$SIZE(m)},
3399 $P(tau),
3400 &tmp_work[0],
3401 &lwork,
3402 $P(info));
3403
3404 lwork = (integer )tmp_work[0];
3405 {
3406 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
3407 FORTRAN($TFD(c,z)ungqr)(
3408 &(integer){$SIZE(m)},
3409 &(integer){$SIZE(n)},
3410 &(integer){$SIZE(k)},
3411 $P(A),
3412 &(integer){$SIZE(m)},
3413 $P(tau),
3414 work,
3415 &lwork,
3416 $P(info));
3417 free(work);
3418 }
3419
3420 ',
3421 Doc=>'
3422
3423 =for ref
3424
3425 Complex version of L<PDL::LinearAlgebra::Real/orgqr>
3426
3427 ');
3428
3429
3430 pp_defc("unmqr",
3431 _decl => <<'EOF',
3432 extern int FORTRAN($TFD(c,z)unmqr)(char *side, char *trans, integer *m, integer *n,
3433 integer *k, $GENERIC() *a, integer *lda, $GENERIC() *tau, $GENERIC() *
3434 c__, integer *ldc, $GENERIC() *work, integer *lwork, integer *info);
3435 EOF
3436 HandleBad => 0,
3437 Pars => 'A(2,p,k); int side(); int trans(); tau(2,k); [io]C(2,m,n);int [o]info()',
3438 Code => generate_code '
3439 char ptrans = \'N\', pside = \'L\';
3440 integer lwork = -1;
3441 $GENERIC() tmp_work[2];
3442 if($trans())
3443 ptrans = \'C\';
3444 if($side())
3445 pside = \'R\';
3446
3447 FORTRAN($TFD(c,z)unmqr)(
3448 &pside,
3449 &ptrans,
3450 &(integer){$SIZE(m)},
3451 &(integer){$SIZE(n)},
3452 &(integer){$SIZE(k)},
3453 $P(A),
3454 &(integer){$SIZE(p)},
3455 $P(tau),
3456 $P(C),
3457 &(integer){$SIZE(m)},
3458 &tmp_work[0],
3459 &lwork,
3460 $P(info));
3461
3462 lwork = (integer )tmp_work[0];
3463 {
3464 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
3465 FORTRAN($TFD(c,z)unmqr)(
3466 &pside,
3467 &ptrans,
3468 &(integer){$SIZE(m)},
3469 &(integer){$SIZE(n)},
3470 &(integer){$SIZE(k)},
3471 $P(A),
3472 &(integer){$SIZE(p)},
3473 $P(tau),
3474 $P(C),
3475 &(integer){$SIZE(m)},
3476 work,
3477 &lwork,
3478 $P(info));
3479 free(work);
3480 }
3481 ',
3482 Doc=>'
3483 =for ref
3484
3485 Complex version of L<PDL::LinearAlgebra::Real/ormqr>. Here trans = 1 means conjugate transpose.
3486 ');
3487
3488 pp_defc("gelqf",
3489 _decl => <<'EOF',
3490 extern int FORTRAN($TFD(c,z)gelqf)(integer *m, integer *n, $GENERIC() *a, integer *
3491 lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork, integer *info);
3492 EOF
3493 HandleBad => 0,
3494 Pars => '[io]A(2,m,n); [o]tau(2,k); int [o]info()',
3495 Code => generate_code '
3496 integer lwork = -1;
3497 $GENERIC() tmp_work[2];
3498 FORTRAN($TFD(c,z)gelqf)(
3499 &(integer){$SIZE(m)},
3500 &(integer){$SIZE(n)},
3501 $P(A),
3502 &(integer){$SIZE(m)},
3503 $P(tau),
3504 &tmp_work[0],
3505 &lwork,
3506 $P(info));
3507
3508 lwork = (integer )tmp_work[0];
3509 {
3510 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
3511 FORTRAN($TFD(c,z)gelqf)(
3512 &(integer){$SIZE(m)},
3513 &(integer){$SIZE(n)},
3514 $P(A),
3515 &(integer){$SIZE(m)},
3516 $P(tau),
3517 work,
3518 &lwork,
3519 $P(info));
3520 free(work);
3521 }
3522
3523 ');
3524
3525 pp_defc("unglq",
3526 _decl => <<'EOF',
3527 extern int FORTRAN($TFD(c,z)unglq)(integer *m, integer *n, integer *k, $GENERIC() *
3528 a, integer *lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork,
3529 integer *info);
3530 EOF
3531 HandleBad => 0,
3532 Pars => '[io]A(2,m,n); tau(2,k); int [o]info()',
3533 Code => generate_code '
3534 integer lwork = -1;
3535 $GENERIC() tmp_work[2];
3536 FORTRAN($TFD(c,z)unglq)(
3537 &(integer){$SIZE(m)},
3538 &(integer){$SIZE(n)},
3539 &(integer){$SIZE(k)},
3540 $P(A),
3541 &(integer){$SIZE(m)},
3542 $P(tau),
3543 &tmp_work[0],
3544 &lwork,
3545 $P(info));
3546
3547 lwork = (integer )tmp_work[0];
3548 {
3549 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
3550 FORTRAN($TFD(c,z)unglq)(
3551 &(integer){$SIZE(m)},
3552 &(integer){$SIZE(n)},
3553 &(integer){$SIZE(k)},
3554 $P(A),
3555 &(integer){$SIZE(m)},
3556 $P(tau),
3557 work,
3558 &lwork,
3559 $P(info));
3560 free(work);
3561 }
3562 ',
3563 Doc=>'
3564 =for ref
3565
3566 Complex version of L<PDL::LinearAlgebra::Real/orglq>
3567 ');
3568
3569 pp_defc("unmlq",
3570 _decl => <<'EOF',
3571 extern int FORTRAN($TFD(c,z)unmlq)(char *side, char *trans, integer *m, integer *n,
3572 integer *k, $GENERIC() *a, integer *lda, $GENERIC() *tau, $GENERIC() *
3573 c__, integer *ldc, $GENERIC() *work, integer *lwork, integer *info);
3574 EOF
3575 HandleBad => 0,
3576 Pars => 'A(2,k,p); int side(); int trans(); tau(2,k); [io]C(2,m,n);int [o]info()',
3577 Code => generate_code '
3578 char ptrans = \'N\', pside = \'L\';
3579 integer lwork = -1;
3580 $GENERIC() tmp_work[2];
3581 if($trans())
3582 ptrans = \'C\';
3583 if($side())
3584 pside = \'R\';
3585
3586 FORTRAN($TFD(c,z)unmlq)(
3587 &pside,
3588 &ptrans,
3589 &(integer){$SIZE(m)},
3590 &(integer){$SIZE(n)},
3591 &(integer){$SIZE(k)},
3592 $P(A),
3593 &(integer){$SIZE(k)},
3594 $P(tau),
3595 $P(C),
3596 &(integer){$SIZE(m)},
3597 &tmp_work[0],
3598 &lwork,
3599 $P(info));
3600
3601 lwork = (integer )tmp_work[0];
3602 {
3603 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
3604 FORTRAN($TFD(c,z)unmlq)(
3605 &pside,
3606 &ptrans,
3607 &(integer){$SIZE(m)},
3608 &(integer){$SIZE(n)},
3609 &(integer){$SIZE(k)},
3610 $P(A),
3611 &(integer){$SIZE(k)},
3612 $P(tau),
3613 $P(C),
3614 &(integer){$SIZE(m)},
3615 work,
3616 &lwork,
3617 $P(info));
3618 free(work);
3619 }
3620
3621 ',
3622 Doc=>'
3623
3624 =for ref
3625
3626 Complex version of L<PDL::LinearAlgebra::Real/ormlq>. Here trans = 1 means conjugate transpose.
3627
3628 ');
3629
3630
3631 pp_defc("geqlf",
3632 _decl => <<'EOF',
3633 extern int FORTRAN($TFD(c,z)geqlf)(integer *m, integer *n, $GENERIC() *a, integer *
3634 lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork, integer *info);
3635 EOF
3636 HandleBad => 0,
3637 Pars => '[io]A(2,m,n); [o]tau(2,k); int [o]info()',
3638 Code => generate_code '
3639 integer lwork = -1;
3640 $GENERIC() tmp_work[2];
3641 FORTRAN($TFD(c,z)geqlf)(
3642 &(integer){$SIZE(m)},
3643 &(integer){$SIZE(n)},
3644 $P(A),
3645 &(integer){$SIZE(m)},
3646 $P(tau),
3647 &tmp_work[0],
3648 &lwork,
3649 $P(info));
3650
3651 lwork = (integer )tmp_work[0];
3652 {
3653 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
3654 FORTRAN($TFD(c,z)geqlf)(
3655 &(integer){$SIZE(m)},
3656 &(integer){$SIZE(n)},
3657 $P(A),
3658 &(integer){$SIZE(m)},
3659 $P(tau),
3660 work,
3661 &lwork,
3662 $P(info));
3663 free(work);
3664 }
3665 ');
3666
3667 pp_defc("ungql",
3668 _decl => <<'EOF',
3669 extern int FORTRAN($TFD(c,z)ungql)(integer *m, integer *n, integer *k, $GENERIC() *
3670 a, integer *lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork,
3671 integer *info);
3672 EOF
3673 HandleBad => 0,
3674 Pars => '[io]A(2,m,n); tau(2,k); int [o]info()',
3675 Code => generate_code '
3676 integer lwork = -1;
3677 $GENERIC() tmp_work[2];
3678 FORTRAN($TFD(c,z)ungql)(
3679 &(integer){$SIZE(m)},
3680 &(integer){$SIZE(n)},
3681 &(integer){$SIZE(k)},
3682 $P(A),
3683 &(integer){$SIZE(m)},
3684 $P(tau),
3685 &tmp_work[0],
3686 &lwork,
3687 $P(info));
3688
3689 lwork = (integer )tmp_work[0];
3690 {
3691 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
3692 FORTRAN($TFD(c,z)ungql)(
3693 &(integer){$SIZE(m)},
3694 &(integer){$SIZE(n)},
3695 &(integer){$SIZE(k)},
3696 $P(A),
3697 &(integer){$SIZE(m)},
3698 $P(tau),
3699 work,
3700 &lwork,
3701 $P(info));
3702 free(work);
3703 }
3704
3705 ',
3706 Doc=>'
3707
3708 =for ref
3709 Complex version of L<PDL::LinearAlgebra::Real/orgql>.
3710 ');
3711
3712 pp_defc("unmql",
3713 _decl => <<'EOF',
3714 extern int FORTRAN($TFD(c,z)unmql)(char *side, char *trans, integer *m, integer *n,
3715 integer *k, $GENERIC() *a, integer *lda, $GENERIC() *tau, $GENERIC() *
3716 c__, integer *ldc, $GENERIC() *work, integer *lwork, integer *info);
3717 EOF
3718 HandleBad => 0,
3719 Pars => 'A(2,p,k); int side(); int trans(); tau(2,k); [io]C(2,m,n);int [o]info()',
3720 Code => generate_code '
3721 char ptrans = \'N\', pside = \'L\';
3722 integer lwork = -1;
3723 $GENERIC() tmp_work[2];
3724 if($trans())
3725 ptrans = \'C\';
3726 if($side())
3727 pside = \'R\';
3728
3729 FORTRAN($TFD(c,z)unmql)(
3730 &pside,
3731 &ptrans,
3732 &(integer){$SIZE(m)},
3733 &(integer){$SIZE(n)},
3734 &(integer){$SIZE(k)},
3735 $P(A),
3736 &(integer){$SIZE(p)},
3737 $P(tau),
3738 $P(C),
3739 &(integer){$SIZE(m)},
3740 &tmp_work[0],
3741 &lwork,
3742 $P(info));
3743
3744 lwork = (integer )tmp_work[0];
3745 {
3746 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
3747 FORTRAN($TFD(c,z)unmql)(
3748 &pside,
3749 &ptrans,
3750 &(integer){$SIZE(m)},
3751 &(integer){$SIZE(n)},
3752 &(integer){$SIZE(k)},
3753 $P(A),
3754 &(integer){$SIZE(p)},
3755 $P(tau),
3756 $P(C),
3757 &(integer){$SIZE(m)},
3758 work,
3759 &lwork,
3760 $P(info));
3761 free(work);
3762 }
3763 ',
3764 Doc=>'
3765 =for ref
3766
3767 Complex version of L<PDL::LinearAlgebra::Real/ormql>. Here trans = 1 means conjugate transpose.
3768 ');
3769
3770 pp_defc("gerqf",
3771 _decl => <<'EOF',
3772 extern int FORTRAN($TFD(c,z)gerqf)(integer *m, integer *n, $GENERIC() *a, integer *
3773 lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork, integer *info);
3774 EOF
3775 HandleBad => 0,
3776 Pars => '[io]A(2,m,n); [o]tau(2,k); int [o]info()',
3777 Code => generate_code '
3778 integer lwork = -1;
3779 $GENERIC() tmp_work[2];
3780 FORTRAN($TFD(c,z)gerqf)(
3781 &(integer){$SIZE(m)},
3782 &(integer){$SIZE(n)},
3783 $P(A),
3784 &(integer){$SIZE(m)},
3785 $P(tau),
3786 &tmp_work[0],
3787 &lwork,
3788 $P(info));
3789
3790 lwork = (integer )tmp_work[0];
3791 {
3792 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
3793 FORTRAN($TFD(c,z)gerqf)(
3794 &(integer){$SIZE(m)},
3795 &(integer){$SIZE(n)},
3796 $P(A),
3797 &(integer){$SIZE(m)},
3798 $P(tau),
3799 work,
3800 &lwork,
3801 $P(info));
3802 free(work);
3803 }
3804
3805 ');
3806
3807 pp_defc("ungrq",
3808 _decl => <<'EOF',
3809 extern int FORTRAN($TFD(c,z)ungrq)(integer *m, integer *n, integer *k, $GENERIC() *
3810 a, integer *lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork,
3811 integer *info);
3812 EOF
3813 HandleBad => 0,
3814 Pars => '[io]A(2,m,n); tau(2,k); int [o]info()',
3815 Code => generate_code '
3816 integer lwork = -1;
3817 $GENERIC() tmp_work[2];
3818 FORTRAN($TFD(c,z)ungrq)(
3819 &(integer){$SIZE(m)},
3820 &(integer){$SIZE(n)},
3821 &(integer){$SIZE(k)},
3822 $P(A),
3823 &(integer){$SIZE(m)},
3824 $P(tau),
3825 &tmp_work[0],
3826 &lwork,
3827 $P(info));
3828
3829 lwork = (integer )tmp_work[0];
3830 {
3831 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
3832 FORTRAN($TFD(c,z)ungrq)(
3833 &(integer){$SIZE(m)},
3834 &(integer){$SIZE(n)},
3835 &(integer){$SIZE(k)},
3836 $P(A),
3837 &(integer){$SIZE(m)},
3838 $P(tau),
3839 work,
3840 &lwork,
3841 $P(info));
3842 free(work);
3843 }
3844 ',
3845 Doc=>'
3846 =for ref
3847
3848 Complex version of L<PDL::LinearAlgebra::Real/orgrq>.
3849 ');
3850
3851 pp_defc("unmrq",
3852 _decl => <<'EOF',
3853 extern int FORTRAN($TFD(c,z)unmrq)(char *side, char *trans, integer *m, integer *n,
3854 integer *k, $GENERIC() *a, integer *lda, $GENERIC() *tau, $GENERIC() *
3855 c__, integer *ldc, $GENERIC() *work, integer *lwork, integer *info);
3856 EOF
3857 HandleBad => 0,
3858 Pars => 'A(2,k,p); int side(); int trans(); tau(2,k); [io]C(2,m,n);int [o]info()',
3859 Code => generate_code '
3860 char ptrans = \'N\', pside = \'L\';
3861 integer lwork = -1;
3862 $GENERIC() tmp_work[2];
3863 if($trans())
3864 ptrans = \'C\';
3865 if($side())
3866 pside = \'R\';
3867
3868 FORTRAN($TFD(c,z)unmrq)(
3869 &pside,
3870 &ptrans,
3871 &(integer){$SIZE(m)},
3872 &(integer){$SIZE(n)},
3873 &(integer){$SIZE(k)},
3874 $P(A),
3875 &(integer){$SIZE(k)},
3876 $P(tau),
3877 $P(C),
3878 &(integer){$SIZE(m)},
3879 &tmp_work[0],
3880 &lwork,
3881 $P(info));
3882
3883 lwork = (integer )tmp_work[0];
3884 {
3885 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
3886 FORTRAN($TFD(c,z)unmrq)(
3887 &pside,
3888 &ptrans,
3889 &(integer){$SIZE(m)},
3890 &(integer){$SIZE(n)},
3891 &(integer){$SIZE(k)},
3892 $P(A),
3893 &(integer){$SIZE(k)},
3894 $P(tau),
3895 $P(C),
3896 &(integer){$SIZE(m)},
3897 work,
3898 &lwork,
3899 $P(info));
3900 free(work);
3901 }
3902
3903 ',
3904 Doc=>'
3905
3906 =for ref
3907
3908 Complex version of L<PDL::LinearAlgebra::Real/ormrq>. Here trans = 1 means conjugate transpose.
3909
3910 ');
3911
3912 pp_defc("tzrzf",
3913 _decl => <<'EOF',
3914 extern int FORTRAN($TFD(c,z)tzrzf)(integer *m, integer *n, $GENERIC() *a, integer *
3915 lda, $GENERIC() *tau, $GENERIC() *work, integer *lwork, integer *info);
3916 EOF
3917 HandleBad => 0,
3918 Pars => '[io]A(2,m,n); [o]tau(2,k); int [o]info()',
3919 Code => generate_code '
3920 integer lwork = -1;
3921 $GENERIC() tmp_work[2];
3922 FORTRAN($TFD(c,z)tzrzf)(
3923 &(integer){$SIZE(m)},
3924 &(integer){$SIZE(n)},
3925 $P(A),
3926 &(integer){$SIZE(m)},
3927 $P(tau),
3928 &tmp_work[0],
3929 &lwork,
3930 $P(info));
3931
3932 lwork = (integer )tmp_work[0];
3933 {
3934 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
3935 FORTRAN($TFD(c,z)tzrzf)(
3936 &(integer){$SIZE(m)},
3937 &(integer){$SIZE(n)},
3938 $P(A),
3939 &(integer){$SIZE(m)},
3940 $P(tau),
3941 work,
3942 &lwork,
3943 $P(info));
3944 free(work);
3945 }
3946 ');
3947
3948 pp_defc("unmrz",
3949 _decl => <<'EOF',
3950 extern int FORTRAN($TFD(c,z)unmrz)(char *side, char *trans, integer *m, integer *n,
3951 integer *k, integer *l, $GENERIC() *a, integer *lda, $GENERIC() *tau, $GENERIC() *
3952 c__, integer *ldc, $GENERIC() *work, integer *lwork, integer *info);
3953 EOF
3954 HandleBad => 0,
3955 Pars => 'A(2,k,p); int side(); int trans(); tau(2,k); [io]C(2,m,n);int [o]info()',
3956 Code => generate_code '
3957 char ptrans = \'N\', pside = \'L\';
3958 integer lwork = -1;
3959 integer kk = $SIZE(p) - $SIZE(k);
3960 $GENERIC() tmp_work[2];
3961 if($trans())
3962 ptrans = \'C\';
3963 if($side())
3964 pside = \'R\';
3965
3966 FORTRAN($TFD(c,z)unmrz)(
3967 &pside,
3968 &ptrans,
3969 &(integer){$SIZE(m)},
3970 &(integer){$SIZE(n)},
3971 &(integer){$SIZE(k)},
3972 &kk,
3973 $P(A),
3974 &(integer){$SIZE(k)},
3975 $P(tau),
3976 $P(C),
3977 &(integer){$SIZE(m)},
3978 &tmp_work[0],
3979 &lwork,
3980 $P(info));
3981
3982 lwork = (integer )tmp_work[0];
3983 {
3984 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
3985 FORTRAN($TFD(c,z)unmrz)(
3986 &pside,
3987 &ptrans,
3988 &(integer){$SIZE(m)},
3989 &(integer){$SIZE(n)},
3990 &(integer){$SIZE(k)},
3991 &kk,
3992 $P(A),
3993 &(integer){$SIZE(k)},
3994 $P(tau),
3995 $P(C),
3996 &(integer){$SIZE(m)},
3997 work,
3998 &lwork,
3999 $P(info));
4000 free(work);
4001 }
4002
4003 ',
4004 Doc=>'
4005 =for ref
4006
4007 Complex version of L<PDL::LinearAlgebra::Real/ormrz>. Here trans = 1 means conjugate transpose.
4008 ');
4009
4010 pp_defc("gehrd",
4011 _decl => <<'EOF',
4012 extern int FORTRAN($TFD(c,z)gehrd)(integer *n, integer *ilo, integer *ihi,
4013 $GENERIC() *a, integer *lda, $GENERIC() *tau, $GENERIC() *work,
4014 integer *lwork, integer *info);
4015 EOF
4016 HandleBad => 0,
4017 Pars => '[io]A(2,n,n); int ilo();int ihi();[o]tau(2,k); int [o]info()',
4018 Code => generate_code '
4019 integer lwork = -1;
4020 $GENERIC() tmp_work[2];
4021 FORTRAN($TFD(c,z)gehrd)(
4022 &(integer){$SIZE(n)},
4023 $P(ilo),
4024 $P(ihi),
4025 $P(A),
4026 &(integer){$SIZE(n)},
4027 $P(tau),
4028 &tmp_work[0],
4029 &lwork,
4030 $P(info));
4031
4032 lwork = (integer )tmp_work[0];
4033 {
4034 $GENERIC() *work = ($GENERIC() *)malloc(2*lwork * sizeof($GENERIC()));
4035 FORTRAN($TFD(c,z)gehrd)(
4036 &(integer){$SIZE(n)},
4037 $P(ilo),
4038 $P(ihi),
4039 $P(A),
4040 &(integer){$SIZE(n)},
4041 $P(tau),
4042 work,
4043 &lwork,
4044 $P(info));
4045 free(work);
4046 }
4047 ');
4048
4049 pp_defc("unghr",
4050 _decl => <<'EOF',
4051 extern int FORTRAN($TFD(c,z)unghr)(integer *n, integer *ilo, integer *ihi,
4052 $GENERIC() *a, integer *lda, $GENERIC() *tau, $GENERIC() *work,
4053 integer *lwork, integer *info);
4054 EOF
4055 HandleBad => 0,
4056 Pars => '[io]A(2,n,n); int ilo();int ihi();tau(2,k); int [o]info()',
4057 Code => generate_code '
4058 integer lwork = -1;
4059 $GENERIC() tmp_work[2];
4060 FORTRAN($TFD(c,z)unghr)(
4061 &(integer){$SIZE(n)},
4062 $P(ilo),
4063 $P(ihi),
4064 $P(A),
4065 &(integer){$SIZE(n)},
4066 $P(tau),
4067 &tmp_work[0],
4068 &lwork,
4069 $P(info));
4070
4071 lwork = (integer )tmp_work[0];
4072 {
4073 $GENERIC() *work = ($GENERIC() *)malloc(2*lwork * sizeof($GENERIC()));
4074 FORTRAN($TFD(c,z)unghr)(
4075 &(integer){$SIZE(n)},
4076 $P(ilo),
4077 $P(ihi),
4078 $P(A),
4079 &(integer){$SIZE(n)},
4080 $P(tau),
4081 work,
4082 &lwork,
4083 $P(info));
4084 free(work);
4085 }
4086
4087 ',
4088 Doc=>'
4089 =for ref
4090
4091 Complex version of L<PDL::LinearAlgebra::Real/orghr>
4092 ');
4093
4094 pp_defc("hseqr",
4095 _decl => <<'EOF',
4096 extern int FORTRAN($TFD(c,z)hseqr)(char *job, char *compz, integer *n, integer *ilo,
4097 integer *ihi, $GENERIC() *h__, integer *ldh, $GENERIC() *w,
4098 $GENERIC() *z__, integer *ldz, $GENERIC() *work,
4099 integer *lwork, integer *info);
4100 EOF
4101 HandleBad => 0,
4102 Pars => '[io]H(2,n,n); int job();int compz();int ilo();int ihi();[o]w(2,n); [o]Z(2,m,m); int [o]info()',
4103 Code => generate_code '
4104 char pcompz;
4105 char pjob = \'E\';
4106 integer lwork = -1;
4107 $GENERIC() tmp_work[2];
4108 if($job())
4109 pjob = \'S\';
4110
4111 switch ($compz())
4112 {
4113 case 1: pcompz = \'I\';
4114 break;
4115 case 2: pcompz = \'V\';
4116 break;
4117 default: pcompz = \'N\';
4118 }
4119
4120 FORTRAN($TFD(c,z)hseqr)(
4121 &pjob,
4122 &pcompz,
4123 &(integer){$SIZE(n)},
4124 $P(ilo),
4125 $P(ihi),
4126 $P(H),
4127 &(integer){$SIZE(n)},
4128 $P(w),
4129 $P(Z),
4130 &(integer){$SIZE(m)},
4131 &tmp_work[0],
4132 &lwork,
4133 $P(info));
4134
4135 lwork = (integer )tmp_work[0];
4136 {
4137 $GENERIC() *work = ($GENERIC() *)malloc(2 * lwork * sizeof($GENERIC()));
4138 FORTRAN($TFD(c,z)hseqr)(
4139 &pjob,
4140 &pcompz,
4141 &(integer){$SIZE(n)},
4142 $P(ilo),
4143 $P(ihi),
4144 $P(H),
4145 &(integer){$SIZE(n)},
4146 $P(w),
4147 $P(Z),
4148 &(integer){$SIZE(m)},
4149 work,
4150 &lwork,
4151 $P(info));
4152 free(work);
4153 }
4154 ');
4155
4156 pp_defc("trevc",
4157 _decl => <<'EOF',
4158 extern int FORTRAN($TFD(c,z)trevc)(char *side, char *howmny, logical *select,
4159 integer *n, $GENERIC() *t, integer *ldt, $GENERIC() *vl, integer *
4160 ldvl, $GENERIC() *vr, integer *ldvr, integer *mm, integer *m,
4161 $GENERIC() *work, $GENERIC() *rwork, integer *info);
4162 EOF
4163 HandleBad => 0,
4164 Pars => 'T(2,n,n);int select(q);[o]VL(2,m,m); [o]VR(2,p,p);int [o]m(); int [o]info(); [t]work(workn=CALC(5*$SIZE(n)));',
4165 OtherPars => 'int side; int howmny',
4166 ArgOrder => [qw{T side howmny select VL VR m info}],
4167 RedoDimsCode => '
4168 PDL_MAYBE_SIZE(PDL_Long, $COMP(side), tmp != 1, $PDL(VL), $SIZE(m), $SIZE(n))
4169 PDL_MAYBE_SIZE(PDL_Long, $COMP(side), tmp != 2, $PDL(VR), $SIZE(p), $SIZE(n))
4170 ',
4171 Code => generate_code '
4172 char pside,phowmny;
4173 integer mm = PDLMAX($SIZE(m),$SIZE(p));
4174 switch ($COMP(howmny))
4175 {
4176 case 1: phowmny = \'B\';
4177 break;
4178 case 2: phowmny = \'S\';
4179 break;
4180 default: phowmny = \'A\';
4181 }
4182
4183 switch ($COMP(side))
4184 {
4185 case 1: pside = \'R\';
4186 break;
4187 case 2: pside = \'L\';
4188 break;
4189 default:pside = \'B\';
4190 }
4191
4192 FORTRAN($TFD(c,z)trevc)(
4193 &pside,
4194 &phowmny,
4195 $P(select),
4196 &(integer){$SIZE(n)},
4197 $P(T),
4198 &(integer){$SIZE(n)},
4199 $P(VL),
4200 &(integer){$SIZE(m)},
4201 $P(VR),
4202 &(integer){$SIZE(p)},
4203 &mm,
4204 $P(m),
4205 $P(work) + $SIZE(n),
4206 $P(work),
4207 $P(info));
4208 ');
4209
4210 pp_defc("tgevc",
4211 _decl => <<'EOF',
4212 extern int FORTRAN($TFD(c,z)tgevc)(char *side, char *howmny, logical *select,
4213 integer *n, $GENERIC() *a, integer *lda, $GENERIC() *b, integer *ldb,
4214 $GENERIC() *vl, integer *ldvl, $GENERIC() *vr, integer *ldvr,
4215 integer *mm, integer *m, $GENERIC() *work, $GENERIC() *rwork, integer *info);
4216 EOF
4217 HandleBad => 0,
4218 Pars => 'A(2,n,n); B(2,n,n);int select(q);[o]VL(2,m,m); [o]VR(2,p,p);int [o]m(); int [o]info(); [t]work(workn=CALC(6*$SIZE(n)));',
4219 OtherPars => 'int side; int howmny',
4220 ArgOrder => [qw{A side howmny B select VL VR m info}],
4221 RedoDimsCode => '
4222 PDL_MAYBE_SIZE(PDL_Long, $COMP(side), tmp != 1, $PDL(VL), $SIZE(m), $SIZE(n))
4223 PDL_MAYBE_SIZE(PDL_Long, $COMP(side), tmp != 2, $PDL(VR), $SIZE(p), $SIZE(n))
4224 ',
4225 Code => generate_code '
4226 char pside,phowmny;
4227 integer mm = PDLMAX($SIZE(m),$SIZE(p));
4228 switch ($COMP(howmny))
4229 {
4230 case 1: phowmny = \'B\';
4231 break;
4232 case 2: phowmny = \'S\';
4233 break;
4234 default: phowmny = \'A\';
4235 }
4236 switch ($COMP(side))
4237 {
4238 case 1: pside = \'R\';
4239 break;
4240 case 2: pside = \'L\';
4241 break;
4242 default:pside = \'B\';
4243 }
4244 FORTRAN($TFD(c,z)tgevc)(
4245 &pside,
4246 &phowmny,
4247 $P(select),
4248 &(integer){$SIZE(n)},
4249 $P(A),
4250 &(integer){$SIZE(n)},
4251 $P(B),
4252 &(integer){$SIZE(n)},
4253 $P(VL),
4254 &(integer){$SIZE(m)},
4255 $P(VR),
4256 &(integer){$SIZE(p)},
4257 &mm,
4258 $P(m),
4259 $P(work)+2*$SIZE(n),
4260 $P(work),
4261 $P(info));
4262 ');
4263
4264 pp_defc("gebal",
4265 _decl => <<'EOF',
4266 extern int FORTRAN($TFD(c,z)gebal)(char *job, integer *n, $GENERIC() *a, integer *
4267 lda, integer *ilo, integer *ihi, $GENERIC() *scale, integer *info);
4268 EOF
4269 HandleBad => 0,
4270 Pars => '[io]A(2,n,n); int job(); int [o]ilo();int [o]ihi();[o]scale(n); int [o]info()',
4271 Code => generate_code '
4272 char pjob;
4273 switch ($job())
4274 {
4275 case 1: pjob = \'P\';
4276 break;
4277 case 2: pjob = \'S\';
4278 break;
4279 case 3: pjob = \'B\';
4280 break;
4281 default: pjob = \'N\';
4282 }
4283 FORTRAN($TFD(c,z)gebal)(
4284 &pjob,
4285 &(integer){$SIZE(n)},
4286 $P(A),
4287 &(integer){$SIZE(n)},
4288 $P(ilo),
4289 $P(ihi),
4290 $P(scale),
4291 $P(info));
4292 ');
4293
4294 #################################################################################
4295 pp_defc("lange",
4296 _decl => <<'EOF',
4297 extern $GENERIC() FORTRAN($TFD(c,z)lange)(char *norm, integer *m, integer *n, $GENERIC() *a, integer
4298 *lda, $GENERIC() *work);
4299 EOF
4300 HandleBad => 0,
4301 Pars => 'A(2,n,m); [o]b(); [t]work(workn);',
4302 OtherPars => 'int norm',
4303 ArgOrder => [qw{A norm b}],
4304 RedoDimsCode => '
4305 PDL_MAYBE_SIZE(PDL_Long, $COMP(norm), tmp == 2, $PDL(work), $SIZE(workn), $SIZE(n))
4306 ',
4307 Code => '
4308 char pnorm;
4309 switch ($COMP(norm))
4310 {
4311 case 1: pnorm = \'O\';
4312 break;
4313 case 2: pnorm = \'I\';
4314 break;
4315 case 3: pnorm = \'F\';
4316 break;
4317 default: pnorm = \'M\';
4318 }
4319 $b() = FORTRAN($TFD(c,z)lange)(
4320 &pnorm,
4321 &(integer){$SIZE(n)},
4322 &(integer){$SIZE(m)},
4323 $P(A),
4324 &(integer){$SIZE(n)},
4325 $P(work));
4326 ');
4327
4328 pp_defc("lansy",
4329 _decl => <<'EOF',
4330 extern $GENERIC() FORTRAN($TFD(c,z)lansy)(char *norm, char *uplo, integer *n, $GENERIC() *a, integer
4331 *lda, $GENERIC() *work);
4332 EOF
4333 HandleBad => 0,
4334 Pars => 'A(2,n,n); [o]b(); [t]work(workn);',
4335 OtherPars => 'int uplo; int norm',
4336 ArgOrder => [qw{A uplo norm b}],
4337 RedoDimsCode => '
4338 PDL_MAYBE_SIZE(PDL_Long, $COMP(norm), tmp == 1 || tmp == 2, $PDL(work), $SIZE(workn), $SIZE(n))
4339 ',
4340 Code => '
4341 char pnorm, puplo = \'U\';
4342 switch ($COMP(norm))
4343 {
4344 case 1: pnorm = \'O\';
4345 break;
4346 case 2: pnorm = \'I\';
4347 break;
4348 case 3: pnorm = \'F\';
4349 break;
4350 default: pnorm = \'M\';
4351 }
4352 if($COMP(uplo))
4353 puplo = \'L\';
4354 $b() = FORTRAN($TFD(c,z)lansy)(
4355 &pnorm,
4356 &puplo,
4357 &(integer){$SIZE(n)},
4358 $P(A),
4359 &(integer){$SIZE(n)},
4360 $P(work));
4361 ');
4362
4363 pp_defc("lantr",
4364 _decl => <<'EOF',
4365 extern $GENERIC() FORTRAN($TFD(c,z)lantr)(char *norm, char *uplo, char *diag, integer *m, integer *n, $GENERIC() *a, integer
4366 *lda, $GENERIC() *work);
4367 EOF
4368 HandleBad => 0,
4369 Pars => 'A(2,m,n); [o]b(); [t]work(workn);',
4370 OtherPars => 'int uplo; int norm; int diag',
4371 ArgOrder => [qw{A uplo norm diag b}],
4372 RedoDimsCode => '
4373 PDL_MAYBE_SIZE(PDL_Long, $COMP(norm), tmp == 2, $PDL(work), $SIZE(workn), $SIZE(n))
4374 ',
4375 Code => '
4376 char pnorm, puplo = \'U\';
4377 char pdiag = \'N\';
4378 switch ($COMP(norm))
4379 {
4380 case 1: pnorm = \'O\';
4381 break;
4382 case 2: pnorm = \'I\';
4383 break;
4384 case 3: pnorm = \'F\';
4385 break;
4386 default: pnorm = \'M\';
4387 }
4388 if($COMP(uplo))
4389 puplo = \'L\';
4390 if($COMP(diag))
4391 pdiag = \'U\';
4392 $b() = FORTRAN($TFD(c,z)lantr)(
4393 &pnorm,
4394 &puplo,
4395 &pdiag,
4396 &(integer){$SIZE(m)},
4397 &(integer){$SIZE(n)},
4398 $P(A),
4399 &(integer){$SIZE(n)},
4400 $P(work));
4401 ');
4402
4403 ################################################################################
4404 #
4405 # BLAS ROUTINES
4406 #
4407 ################################################################################
4408
4409 pp_defc("gemm",
4410 _decl => <<'EOF',
4411 extern int FORTRAN($TFD(c,z)gemm)(char *transa, char *transb, integer *m, integer *
4412 n, integer *k, $GENERIC() *alpha, $GENERIC() *a, integer *lda,
4413 $GENERIC() *b, integer *ldb, $GENERIC() *beta, $GENERIC() *c__,
4414 integer *ldc);
4415 EOF
4416 HandleBad => 0,
4417 Pars => 'A(2,m,n); int transa(); int transb(); B(2,p,q);alpha(2); beta(2); [io]C(2,r,s)',
4418 Code => '
4419 char ptransa = \'N\';
4420 char ptransb = \'N\';
4421 integer kk = $transa() ? $SIZE(m) : $SIZE(n);
4422
4423 if ($transa() == 1)
4424 ptransa = \'T\';
4425 else if ($transa() == 2)
4426 ptransa = \'C\';
4427 if ($transb())
4428 ptransb = \'T\';
4429 else if ($transb() == 2)
4430 ptransb = \'C\';
4431
4432 FORTRAN($TFD(c,z)gemm)(
4433 &ptransa,
4434 &ptransb,
4435 &(integer){$SIZE(r)},
4436 &(integer){$SIZE(s)},
4437 &kk,
4438 $P(alpha),
4439 $P(A),
4440 &(integer){$SIZE(m)},
4441 $P(B),
4442 &(integer){$SIZE(p)},
4443 $P(beta),
4444 $P(C),
4445 &(integer){$SIZE(r)});
4446 ',
4447 Doc=>'
4448
4449 =for ref
4450
4451 Complex version of L<PDL::LinearAlgebra::Real/gemm>.
4452
4453 Arguments
4454 =========
4455 transa: = 0: No transpose;
4456 = 1: Transpose;
4457 = 2: Conjugate transpose;
4458
4459 transb: = 0: No transpose;
4460 = 1: Transpose;
4461 = 2: Conjugate transpose;
4462
4463 ');
4464
4465 if ($config{CBLAS}){
4466 pp_def("rmcgemm",
4467 HandleBad => 0,
4468 Pars => 'A(2,m,n); int transa(); int transb(); B(2,p,q);alpha(2); beta(2); [io]C(2,r,s)',
4469 Code => '
4470 int ptransa, ptransb;
4471 extern void cblas_$TFD(c,z)gemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA,
4472 const enum CBLAS_TRANSPOSE TransB, const int M, const int N,
4473 const int K, const void *alpha, const void *A,
4474 const int lda, const void *B, const int ldb,
4475 const void *beta, void *C, const int ldc);
4476 integer kk = $transa() ? $SIZE(n) : $SIZE(m);
4477
4478 switch($transa()){
4479 case 1: ptransa = CblasTrans;
4480 break;
4481 case 2: ptransa = CblasConjTrans;
4482 break;
4483 default:ptransa = CblasNoTrans;
4484 }
4485 switch($transb()){
4486 case 1: ptransb = CblasTrans;
4487 break;
4488 case 2: ptransb = CblasConjTrans;
4489 break;
4490 default:ptransb = CblasNoTrans;
4491 }
4492
4493 cblas_$TFD(c,z)gemm(
4494 CblasRowMajor,
4495 ptransa,
4496 ptransb,
4497 $SIZE(s),
4498 $SIZE(r),
4499 kk,
4500 $P(alpha),
4501 $P(A),
4502 $SIZE(m),
4503 $P(B),
4504 $SIZE(p),
4505 $P(beta),
4506 $P(C),
4507 $SIZE(r));
4508 ',
4509 Doc=>'
4510
4511 =for ref
4512
4513 Complex version of L<PDL::LinearAlgebra::Real/rmgemm>.
4514
4515 Arguments
4516 =========
4517 transa: = 0: No transpose;
4518 = 1: Transpose;
4519 = 2: Conjugate transpose;
4520
4521 transb: = 0: No transpose;
4522 = 1: Transpose;
4523 = 2: Conjugate transpose;
4524
4525 ');
4526 }
4527
4528 pp_defc("mmult",
4529 _decl => <<'EOF',
4530 extern int FORTRAN($TFD(c,z)gemm)(char *transa, char *transb, integer *m, integer *
4531 n, integer *k, $GENERIC() *alpha, $GENERIC() *a, integer *lda,
4532 $GENERIC() *b, integer *ldb, $GENERIC() *beta, $GENERIC() *c__,
4533 integer *ldc);
4534 EOF
4535 HandleBad => 0,
4536 Pars => 'A(2,m,n); B(2,p,m); [o]C(2,p,n)',
4537 Code => '
4538 char ptrans = \'N\';
4539 $GENERIC() alpha[2] = {1,0};
4540 $GENERIC() beta[2] = {0,0};
4541 FORTRAN($TFD(c,z)gemm)(
4542 &ptrans,
4543 &ptrans,
4544 &(integer){$SIZE(p)},
4545 &(integer){$SIZE(n)},
4546 &(integer){$SIZE(m)},
4547 &alpha[0],
4548 $P(B),
4549 &(integer){$SIZE(p)},
4550 $P(A),
4551 &(integer){$SIZE(m)},
4552 &beta[0],
4553 $P(C),
4554 &(integer){$SIZE(p)});
4555 ');
4556
4557 if ($config{STRASSEN}){
4558 pp_defc("smmult",
4559 _decl => <<'EOF',
4560 extern int FORTRAN($TFD(c,z)gemmb)(char *transa, char *transb, integer *m, integer *
4561 n, integer *k, $GENERIC() *alpha, $GENERIC() *a, integer *lda,
4562 $GENERIC() *b, integer *ldb, $GENERIC() *beta, $GENERIC() *c__,
4563 integer *ldc);
4564 EOF
4565 HandleBad => 0,
4566 Pars => 'A(2,m,n); B(2,p,m); [o]C(2,p,n)',
4567 Code => '
4568 char ptrans = \'N\';
4569 $GENERIC() alpha[2] = {1,0};
4570 $GENERIC() beta[2] = {0,0};
4571 FORTRAN($TFD(c,z)gemmb)(
4572 &ptrans,
4573 &ptrans,
4574 &(integer){$SIZE(p)},
4575 &(integer){$SIZE(n)},
4576 &(integer){$SIZE(m)},
4577 &alpha[0],
4578 $P(B),
4579 &(integer){$SIZE(p)},
4580 $P(A),
4581 &(integer){$SIZE(m)},
4582 &beta[0],
4583 $P(C),
4584 &(integer){$SIZE(p)});
4585 ');
4586 }
4587
4588 pp_defc("crossprod",
4589 _decl => <<'EOF',
4590 extern int FORTRAN($TFD(c,z)gemm)(char *transa, char *transb, integer *m, integer *
4591 n, integer *k, $GENERIC() *alpha, $GENERIC() *a, integer *lda,
4592 $GENERIC() *b, integer *ldb, $GENERIC() *beta, $GENERIC() *c__,
4593 integer *ldc);
4594 EOF
4595 HandleBad => 0,
4596 Pars => 'A(2,n,m); B(2,p,m); [o]C(2,p,n)',
4597 Code => '
4598 char btrans = \'N\';
4599 char atrans = \'C\';
4600 $GENERIC() alpha[2] = {1,0};
4601 $GENERIC() beta[2] = {0,0};
4602 FORTRAN($TFD(c,z)gemm)(
4603 &btrans,
4604 &atrans,
4605 &(integer){$SIZE(p)},
4606 &(integer){$SIZE(n)},
4607 &(integer){$SIZE(m)},
4608 &alpha[0],
4609 $P(B),
4610 &(integer){$SIZE(p)},
4611 $P(A),
4612 &(integer){$SIZE(n)},
4613 &beta[0],
4614 $P(C),
4615 &(integer){$SIZE(p)});
4616 ');
4617
4618 pp_defc("syrk",
4619 _decl => <<'EOF',
4620 extern int FORTRAN($TFD(c,z)syrk)(char *uplo, char *trans, integer *n, integer *k,
4621 $GENERIC() *alpha, $GENERIC() *a, integer *lda, $GENERIC() *beta,
4622 $GENERIC() *c__, integer *ldc);
4623 EOF
4624 HandleBad => 0,
4625 Pars => 'A(2,m,n); int uplo(); int trans(); alpha(2); beta(2); [io]C(2,p,p)',
4626 RedoDimsCode => '$SIZE(p) = $trans() ? $SIZE(n) : $SIZE(m);',
4627 Code => '
4628 char puplo = \'U\';
4629 char ptrans = \'N\';
4630 integer kk = $trans() ? $SIZE(m) : $SIZE(n);
4631
4632 if ($uplo())
4633 puplo = \'L\';
4634
4635 if ($trans())
4636 ptrans = \'T\';
4637
4638
4639 FORTRAN($TFD(c,z)syrk)(
4640 &puplo,
4641 &ptrans,
4642 &(integer){$SIZE(p)},
4643 &kk,
4644 $P(alpha),
4645 $P(A),
4646 &(integer){$SIZE(m)},
4647 $P(beta),
4648 $P(C),
4649 &(integer){$SIZE(p)});
4650 ');
4651
4652 if ($config{CBLAS}){
4653 pp_def("rmcsyrk",
4654 HandleBad => 0,
4655 Pars => 'A(2,m,n); int uplo(); int trans(); alpha(2); beta(2); [io]C(2,p,p)',
4656 Code => '
4657 int puplo = CblasUpper;
4658 int ptrans;
4659 extern void cblas_$TFD(c,z)syrk(const enum CBLAS_ORDER Order, const enum CBLAS_UPLO Uplo,
4660 const enum CBLAS_TRANSPOSE Trans, const int N, const int K,
4661 const void *alpha, const void *A, const int lda,
4662 const void *beta, void *C, const int ldc);
4663 integer kk = $trans() ? $SIZE(n) : $SIZE(m);
4664
4665 if ($uplo())
4666 puplo = CblasLower;
4667
4668 switch($trans()){
4669 case 1: ptrans = CblasTrans;
4670 break;
4671 case 2: ptrans = CblasConjTrans;
4672 break;
4673 default:ptrans = CblasNoTrans;
4674 }
4675
4676
4677 cblas_$TFD(c,z)syrk(
4678 CblasRowMajor,
4679 puplo,
4680 ptrans,
4681 $SIZE(p),
4682 kk,
4683 $P(alpha),
4684 $P(A),
4685 $SIZE(m),
4686 $P(beta),
4687 $P(C),
4688 $SIZE(p));
4689 ',
4690 Doc=>'
4691
4692 =for ref
4693
4694 Complex version of L<PDL::LinearAlgebra::Real/rmsyrk>
4695
4696 ');
4697 }
4698 pp_defc("dot",
4699 _decl => <<'EOF',
4700 extern complex $TFD(float,double) FORTRAN($TFD(c,z)dotu)(integer *n, $GENERIC() *dx, integer *incx, $GENERIC() *dy,
4701 integer *incy);
4702 EOF
4703 HandleBad => 0,
4704 Pars => 'a(2,n);b(2,n);[o]c(2)',
4705 Code => '
4706 complex $TFD(float,double) *cptr = (void*)$P(c);
4707 *cptr = FORTRAN($TFD(c,z)dotu)(
4708 &(integer){$SIZE(n)},
4709 $P(a),
4710 &(integer){1},
4711 $P(b),
4712 &(integer){1});
4713 ');
4714
4715 pp_defc("dotc",
4716 _decl => <<'EOF',
4717 extern $GENERIC() FORTRAN($TFD(c,z)dotc)(integer *n, $GENERIC() *dx, integer *incx, $GENERIC() *dy,
4718 integer *incy);
4719 EOF
4720 HandleBad => 0,
4721 Pars => 'a(2,n);b(2,n);[o]c(2)',
4722 Code => '
4723 complex $TFD(float,double) *cptr = (void*)$P(c);
4724 *cptr = FORTRAN($TFD(c,z)dotc)(
4725 &(integer){$SIZE(n)},
4726 $P(a),
4727 &(integer){1},
4728 $P(b),
4729 &(integer){1});
4730 ',
4731 Doc=>'
4732 =for ref
4733
4734 Forms the dot product of two vectors, conjugating the first
4735 vector.
4736 ');
4737
4738 pp_defc("axpy",
4739 _decl => <<'EOF',
4740 extern int FORTRAN($TFD(c,z)axpy)(integer *n, $GENERIC() *da, $GENERIC() *dx,
4741 integer *incx, $GENERIC() *dy, integer *incy);
4742 EOF
4743 HandleBad => 0,
4744 Pars => 'a(2,n); alpha(2);[io]b(2,n)',
4745 Code => '
4746 FORTRAN($TFD(c,z)axpy)(
4747 &(integer){$SIZE(n)},
4748 $P(alpha),
4749 $P(a),
4750 &(integer){1},
4751 $P(b),
4752 &(integer){1});
4753 ');
4754
4755 pp_defc("nrm2",
4756 _decl => <<'EOF',
4757 extern $GENERIC() FORTRAN($TFD(sc,dz)nrm2)(integer *n, $GENERIC() *dx,
4758 integer *incx);
4759 EOF
4760 HandleBad => 0,
4761 Pars => 'a(2,n);[o]b()',
4762 Code => '
4763 $b() = FORTRAN($TFD(sc,dz)nrm2)(
4764 &(integer){$SIZE(n)},
4765 $P(a),
4766 &(integer){1});
4767 ');
4768
4769 pp_defc("asum",
4770 _decl => <<'EOF',
4771 extern $GENERIC() FORTRAN($TFD(sc,dz)asum)(integer *n, $GENERIC() *dx,
4772 integer *incx);
4773 EOF
4774 HandleBad => 0,
4775 Pars => 'a(2,n);[o]b()',
4776 Code => '
4777 $b() = FORTRAN($TFD(sc,dz)asum)(
4778 &(integer){$SIZE(n)},
4779 $P(a),
4780 &(integer){1});
4781 ');
4782
4783 pp_defc("scal",
4784 _decl => <<'EOF',
4785 extern int FORTRAN($TFD(c,z)scal)(integer *n, $GENERIC() *sa,
4786 $GENERIC() *dx, integer *incx);
4787 EOF
4788 HandleBad => 0,
4789 Pars => '[io]a(2,n);scale(2)',
4790 Code => '
4791 FORTRAN($TFD(c,z)scal)(
4792 &(integer){$SIZE(n)},
4793 $P(scale),
4794 $P(a),
4795 &(integer){1});
4796 ');
4797
4798 pp_defc("sscal",
4799 _decl => <<'EOF',
4800 extern int FORTRAN($TFD(cs,zd)scal)(integer *n, $GENERIC() *sa,
4801 $GENERIC() *dx, integer *incx);
4802 EOF
4803 HandleBad => 0,
4804 Pars => '[io]a(2,n);scale()',
4805 Code => '
4806 FORTRAN($TFD(cs,zd)scal)(
4807 &(integer){$SIZE(n)},
4808 $P(scale),
4809 $P(a),
4810 &(integer){1});
4811 ',
4812 Doc=>'
4813
4814 =for ref
4815
4816 Scales a complex vector by a real constant.
4817
4818 ');
4819
4820
4821 pp_defc("rotg",
4822 _decl => <<'EOF',
4823 extern int FORTRAN($TFD(c,z)rotg)($GENERIC() *dx,
4824 $GENERIC() *dy, $GENERIC() *c, $GENERIC() *s);
4825 EOF
4826 HandleBad => 0,
4827 Pars => '[io]a(2);b(2);[o]c(); [o]s(2)',
4828 Code => '
4829 FORTRAN($TFD(c,z)rotg)(
4830 $P(a),
4831 $P(b),
4832 $P(c),
4833 $P(s)
4834 );
4835 ');
4836
4837 ################################################################################
4838 #
4839 # LAPACK AUXILIARY ROUTINES
4840 #
4841 ################################################################################
4842 pp_defc("lacpy",
4843 _decl => <<'EOF',
4844 extern int FORTRAN($TFD(c,z)lacpy)(char *uplo, integer *m, integer *n, $GENERIC() *
4845 a, integer *lda, $GENERIC() *b, integer *ldb);
4846 EOF
4847 HandleBad => 0,
4848 Pars => 'A(2,m,n); int uplo(); [o]B(2,p,n)',
4849 Code => '
4850 char puplo;
4851 switch ($uplo())
4852 {
4853 case 0: puplo = \'U\';
4854 break;
4855 case 1: puplo = \'L\';
4856 break;
4857 default: puplo = \'A\';
4858 }
4859
4860 FORTRAN($TFD(c,z)lacpy)(
4861 &puplo,
4862 &(integer){$SIZE(m)},
4863 &(integer){$SIZE(n)},
4864 $P(A),
4865 &(integer){$SIZE(m)},
4866 $P(B),
4867 &(integer){$SIZE(p)});
4868 ');
4869
4870 pp_defc("laswp",
4871 _decl => <<'EOF',
4872 extern int FORTRAN($TFD(c,z)laswp)(integer *n, $GENERIC() *a, integer *lda, integer
4873 *k1, integer *k2, integer *ipiv, integer *incx);
4874 EOF
4875 HandleBad => 0,
4876 Pars => '[io]A(2,m,n); int k1(); int k2(); int ipiv(p)',
4877 Code => '
4878 FORTRAN($TFD(c,z)laswp)(
4879 &(integer){$SIZE(n)},
4880 $P(A),
4881 &(integer){$SIZE(m)},
4882 $P(k1),
4883 $P(k2),
4884 $P(ipiv),
4885 &(integer){1});
4886 ');
4887
4888 pp_addhdr('
4889 void cftrace(int n, void *a1, void *a2);
4890 void cdtrace(int n, void *a1, void *a2);
4891 ');
4892
4893 pp_defc('charpol',
4894 _decl => <<'EOF',
4895 extern int FORTRAN($TFD(c,z)gemm)(char *transa, char *transb, integer *m, integer *
4896 n, integer *k, $GENERIC() *alpha, $GENERIC() *a, integer *lda,
4897 $GENERIC() *b, integer *ldb, $GENERIC() *beta, $GENERIC() *c__,
4898 integer *ldc);
4899 EOF
4900 Pars => 'A(c=2,n,n);[o]Y(c=2,n,n);[o]out(c=2,p=CALC($SIZE(n)+1)); [t]rwork(rworkn=CALC(2*$SIZE(n)*$SIZE(n)));',
4901 Code => '
4902 int i,j,k;
4903 $GENERIC() tr[2], b[2];
4904 //$GENERIC() *tmp;
4905 char ptrans = \'N\';
4906 $GENERIC() alpha[2] = {1,0};
4907 $GENERIC() beta[2] = {0,0};
4908 loop(n0,n1) %{
4909 $Y(c=>0) = (n0 == n1) ? ($GENERIC()) 1.0 : ($GENERIC()) 0.0;
4910 $Y(c=>1) = ($GENERIC()) 0.0;
4911 %}
4912 $out(c=>0,p=>0) = 1;
4913 $out(c=>1,p=>0) = 0;
4914
4915 i = 0;
4916 for (;;)
4917 {
4918 i++;
4919 FORTRAN($TFD(c,z)gemm)(&ptrans,&ptrans,&(integer){$SIZE(n)},&(integer){$SIZE(n)},
4920 &(integer){$SIZE(n)},&alpha[0],$P(Y),&(integer){$SIZE(n)}, $P(A), &(integer){$SIZE(n)},
4921 &beta[0], $P(rwork), &(integer){$SIZE(n)});
4922 if (i == $SIZE(n)) break;
4923
4924 // if (k+1) & 1 without the copy below => return diagonal matrix
4925 // with determinant (on my 5-year-old-pentium (windows)) !!!???
4926 // tmp = $P(Y);
4927 // $P(Y) = $P(rwork);
4928 // $P(rwork) = tmp;
4929
4930 memmove($P(Y), $P(rwork), 2* $SIZE(n) * $SIZE(n) * sizeof($GENERIC()));
4931
4932 // loop(n1,n0,c) %{
4933 // $Y() = $P(rwork)[((n1*$SIZE(n))+n0)*2+c];
4934 // %}
4935
4936 c$TFD(f,d)trace($SIZE(n), $P(Y), &tr[0]);
4937
4938 loop(c) %{ b[c] = $out(p=>i) = - tr[c] / i; %}
4939 loop (n0,c) %{
4940 $Y(n1=>n0) += b[c];
4941 %}
4942 }
4943
4944 k = $SIZE(n);
4945 c$TFD(f,d)trace(k, $P(rwork), &tr[0]);
4946 loop(c) %{ $out(p=>k) = - tr[c] / k; %}
4947 if ((k+1) & 1)
4948 {
4949 loop(n0,n1,c) %{
4950 $Y() = -$Y();
4951 %}
4952 }
4953 '
4954 );
4955
4956 pp_addpm({At=>'Bot'},<<'EOD');
4957 =head1 AUTHOR
4958
4959 Copyright (C) Grégory Vanuxem 2005-2018.
4960
4961 This library is free software; you can redistribute it and/or modify
4962 it under the terms of the Perl Artistic License as in the file Artistic_2
4963 in this distribution.
4964
4965 =cut
4966 EOD
4967
4968 pp_done(); # you will need this to finish pp processing