21 #ifndef SELDON_FILE_LAPACK_EIGENVALUES_CXX
24 #include "Lapack_Eigenvalues.hxx"
38 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
39 void GetEigenvalues(Matrix<float, Prop, RowMajor, Allocator1>& A,
40 Vector<float, VectFull, Allocator2>& wr,
41 Vector<float, VectFull, Allocator3>& wi,
44 #ifdef SELDON_CHECK_DIMENSIONS
45 if (A.GetM() != A.GetN())
46 throw WrongDim(
"GetEigenvalues",
"Matrix must be squared");
49 int n = A.GetM(), lwork = 6*n;
52 Vector<float> work(lwork);
55 sgeev_(&jobvl, &jobvr, &n, A.GetData(), &n, wr.GetData(), wi.GetData(),
56 A.GetData(), &n, A.GetData(), &n, work.GetData(),
57 &lwork, &info.GetInfoRef());
59 #ifdef SELDON_LAPACK_CHECK_INFO
60 if (info.GetInfo() != 0)
61 throw LapackError(info.GetInfo(),
"GetEigenvalues",
62 "Failed to find eigenvalues ");
68 template<
class Prop,
class Allocator1,
class Allocator2,
69 class Allocator3,
class Allocator4>
70 void GetEigenvaluesEigenvectors(Matrix<float, Prop, RowMajor, Allocator1>& A,
71 Vector<float, VectFull, Allocator2>& wr,
72 Vector<float, VectFull, Allocator3>& wi,
73 Matrix<float, General, RowMajor, Allocator4>& zr,
76 #ifdef SELDON_CHECK_DIMENSIONS
77 if (A.GetM() != A.GetN())
78 throw WrongDim(
"GetEigenvaluesEigenvectors",
"Matrix must be squared");
81 int n = A.GetM(), lwork = 6*n;
84 Vector<float> work(lwork);
88 sgeev_(&jobvl, &jobvr, &n, A.GetData(), &n, wr.GetData(), wi.GetData(),
89 zr.GetData(), &n, zr.GetData(), &n, work.GetData(), &lwork,
92 #ifdef SELDON_LAPACK_CHECK_INFO
93 if (info.GetInfo() != 0)
94 throw LapackError(info.GetInfo(),
"GetEigenvalues",
95 "Failed to find eigenvalues ");
104 if (wr(i) == wr(i+1))
106 for (
int j = 0; j < n; j++)
107 zr(j,i+1) = -zr(j,i+1);
117 template<
class Prop,
class Allocator1,
class Allocator2>
118 void GetEigenvalues(Matrix<complex<float>, Prop, RowMajor, Allocator1>& A,
119 Vector<complex<float>, VectFull, Allocator2>& w,
122 #ifdef SELDON_CHECK_DIMENSIONS
123 if (A.GetM() != A.GetN())
124 throw WrongDim(
"GetEigenvalues",
"Matrix must be squared");
128 char jobl(
'N'), jobr(
'N');
int lwork = 3*n;
129 Vector<complex<float> > work(lwork);
130 Vector<float> rwork(2*n);
132 cgeev_(&jobl, &jobr, &n, A.GetDataVoid(), &n, w.GetDataVoid(),
133 A.GetDataVoid(), &n, A.GetData(), &n, work.GetDataVoid(), &lwork,
134 rwork.GetData(), &info.GetInfoRef());
136 #ifdef SELDON_LAPACK_CHECK_INFO
137 if (info.GetInfo() != 0)
138 throw LapackError(info.GetInfo(),
"GetEigenvalues",
139 "Failed to find eigenvalues ");
145 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
146 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
147 Prop, RowMajor, Allocator1>& A,
148 Vector<complex<float>, VectFull, Allocator2>& w,
149 Matrix<complex<float>,
150 General, RowMajor, Allocator3>& z,
153 #ifdef SELDON_CHECK_DIMENSIONS
154 if (A.GetM() != A.GetN())
155 throw WrongDim(
"GetEigenvaluesEigenvectors",
"Matrix must be squared");
159 char jobl(
'V'), jobr(
'N');
int lwork = 3*n;
160 Vector<complex<float> > work(lwork);
161 Vector<float> rwork(2*n);
164 cgeev_(&jobl, &jobr, &n, A.GetDataVoid(), &n, w.GetDataVoid(),
165 z.GetDataVoid(), &n, z.GetData(), &n, work.GetDataVoid(), &lwork,
166 rwork.GetData(), &info.GetInfoRef());
168 #ifdef SELDON_LAPACK_CHECK_INFO
169 if (info.GetInfo() != 0)
170 throw LapackError(info.GetInfo(),
"GetEigenvalues",
171 "Failed to find eigenvalues ");
178 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
179 void GetEigenvalues(Matrix<double, Prop, RowMajor, Allocator1>& A,
180 Vector<double, VectFull, Allocator2>& wr,
181 Vector<double, VectFull, Allocator3>& wi,
184 #ifdef SELDON_CHECK_DIMENSIONS
185 if (A.GetM() != A.GetN())
186 throw WrongDim(
"GetEigenvalues",
"Matrix must be squared");
189 int n = A.GetM(), lwork = 6*n;
190 char jobvl(
'N'), jobvr(
'N');
191 Vector<double> work(lwork);
194 dgeev_(&jobvl, &jobvr, &n, A.GetData(), &n, wr.GetData(), wi.GetData(),
195 A.GetData(), &n, A.GetData(), &n, work.GetData(),
196 &lwork, &info.GetInfoRef());
198 #ifdef SELDON_LAPACK_CHECK_INFO
199 if (info.GetInfo() != 0)
200 throw LapackError(info.GetInfo(),
"GetEigenvalues",
201 "Failed to find eigenvalues ");
207 template<
class Prop,
class Allocator1,
class Allocator2,
208 class Allocator3,
class Allocator4>
209 void GetEigenvaluesEigenvectors(Matrix<double, Prop, RowMajor, Allocator1>& A,
210 Vector<double, VectFull, Allocator2>& wr,
211 Vector<double, VectFull, Allocator3>& wi,
212 Matrix<double, General, RowMajor, Allocator4>& zr,
215 #ifdef SELDON_CHECK_DIMENSIONS
216 if (A.GetM() != A.GetN())
217 throw WrongDim(
"GetEigenvaluesEigenvectors",
"Matrix must be squared");
220 int n = A.GetM(), lwork = 6*n;
221 char jobvl(
'V'), jobvr(
'N');
222 Vector<double> work(lwork);
226 dgeev_(&jobvl, &jobvr, &n, A.GetData(), &n, wr.GetData(), wi.GetData(),
227 zr.GetData(), &n, zr.GetData(), &n, work.GetData(), &lwork,
230 #ifdef SELDON_LAPACK_CHECK_INFO
231 if (info.GetInfo() != 0)
232 throw LapackError(info.GetInfo(),
"GetEigenvalues",
233 "Failed to find eigenvalues ");
242 if (wr(i) == wr(i+1))
244 for (
int j = 0; j < n; j++)
245 zr(j,i+1) = -zr(j,i+1);
255 template<
class Prop,
class Allocator1,
class Allocator2>
256 void GetEigenvalues(Matrix<complex<double>, Prop, RowMajor, Allocator1>& A,
257 Vector<complex<double>, VectFull, Allocator2>& w,
260 #ifdef SELDON_CHECK_DIMENSIONS
261 if (A.GetM() != A.GetN())
262 throw WrongDim(
"GetEigenvalues",
"Matrix must be squared");
266 char jobl(
'N'), jobr(
'N');
int lwork = 3*n;
267 Vector<complex<double> > work(lwork);
268 Vector<double> rwork(2*n);
270 zgeev_(&jobl, &jobr, &n, A.GetDataVoid(), &n, w.GetDataVoid(),
271 A.GetDataVoid(), &n, A.GetData(), &n, work.GetDataVoid(), &lwork,
272 rwork.GetData(), &info.GetInfoRef());
274 #ifdef SELDON_LAPACK_CHECK_INFO
275 if (info.GetInfo() != 0)
276 throw LapackError(info.GetInfo(),
"GetEigenvalues",
277 "Failed to find eigenvalues ");
283 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
284 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
285 Prop, RowMajor, Allocator1>& A,
286 Vector<complex<double>,
287 VectFull, Allocator2>& w,
288 Matrix<complex<double>,
289 General, RowMajor, Allocator3>& z,
292 #ifdef SELDON_CHECK_DIMENSIONS
293 if (A.GetM() != A.GetN())
294 throw WrongDim(
"GetEigenvaluesEigenvectors",
"Matrix must be squared");
298 char jobl(
'V'), jobr(
'N');
int lwork = 3*n;
299 Vector<complex<double> > work(lwork);
300 Vector<double> rwork(2*n);
303 zgeev_(&jobl, &jobr, &n, A.GetDataVoid(), &n, w.GetDataVoid(),
304 z.GetDataVoid(), &n, z.GetData(), &n, work.GetDataVoid(),
305 &lwork, rwork.GetData(), &info.GetInfoRef());
307 #ifdef SELDON_LAPACK_CHECK_INFO
308 if (info.GetInfo() != 0)
309 throw LapackError(info.GetInfo(),
"GetEigenvalues",
310 "Failed to find eigenvalues ");
320 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
321 void GetEigenvalues(Matrix<float, Prop, ColMajor, Allocator1>& A,
322 Vector<float, VectFull, Allocator2>& wr,
323 Vector<float, VectFull, Allocator3>& wi,
326 #ifdef SELDON_CHECK_DIMENSIONS
327 if (A.GetM() != A.GetN())
328 throw WrongDim(
"GetEigenvalues",
"Matrix must be squared");
331 int n = A.GetM(), lwork = 6*n;
332 char jobvl(
'N'), jobvr(
'N');
333 Vector<float> work(lwork);
336 sgeev_(&jobvl, &jobvr, &n, A.GetData(), &n, wr.GetData(), wi.GetData(),
337 A.GetData(), &n, A.GetData(), &n, work.GetData(), &lwork,
340 #ifdef SELDON_LAPACK_CHECK_INFO
341 if (info.GetInfo() != 0)
342 throw LapackError(info.GetInfo(),
"GetEigenvalues",
343 "Failed to find eigenvalues ");
348 template<
class Prop,
class Allocator1,
class Allocator2,
349 class Allocator3,
class Allocator4>
350 void GetEigenvaluesEigenvectors(Matrix<float, Prop, ColMajor, Allocator1>& A,
351 Vector<float, VectFull, Allocator2>& wr,
352 Vector<float, VectFull, Allocator3>& wi,
353 Matrix<float, General, ColMajor, Allocator4>&zr,
356 #ifdef SELDON_CHECK_DIMENSIONS
357 if (A.GetM() != A.GetN())
358 throw WrongDim(
"GetEigenvaluesEigenvectors",
"Matrix must be squared");
361 int n = A.GetM(), lwork = 6*n;
362 char jobvl(
'N'), jobvr(
'V');
363 Vector<float> work(lwork);
367 sgeev_(&jobvl, &jobvr, &n, A.GetData(), &n, wr.GetData(), wi.GetData(),
368 zr.GetData(), &n, zr.GetData(), &n, work.GetData(),
369 &lwork, &info.GetInfoRef());
371 #ifdef SELDON_LAPACK_CHECK_INFO
372 if (info.GetInfo() != 0)
373 throw LapackError(info.GetInfo(),
"GetEigenvalues",
374 "Failed to find eigenvalues ");
380 template<
class Prop,
class Allocator1,
class Allocator2>
381 void GetEigenvalues(Matrix<complex<float>, Prop, ColMajor, Allocator1>& A,
382 Vector<complex<float>, VectFull, Allocator2>& w,
385 #ifdef SELDON_CHECK_DIMENSIONS
386 if (A.GetM() != A.GetN())
387 throw WrongDim(
"GetEigenvalues",
"Matrix must be squared");
391 char jobl(
'N'), jobr(
'N');
int lwork = 3*n;
392 Vector<complex<float> > work(lwork);
393 Vector<float> rwork(2*n);
395 cgeev_(&jobl, &jobr, &n, A.GetDataVoid(), &n, w.GetDataVoid(),
396 A.GetDataVoid(), &n, A.GetData(), &n, work.GetDataVoid(),
397 &lwork, rwork.GetData(), &info.GetInfoRef());
399 #ifdef SELDON_LAPACK_CHECK_INFO
400 if (info.GetInfo() != 0)
401 throw LapackError(info.GetInfo(),
"GetEigenvalues",
402 "Failed to find eigenvalues ");
408 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
409 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
410 Prop, ColMajor, Allocator1>& A,
411 Vector<complex<float>,
412 VectFull, Allocator2>& w,
413 Matrix<complex<float>,
414 General, ColMajor, Allocator3>& z,
417 #ifdef SELDON_CHECK_DIMENSIONS
418 if (A.GetM() != A.GetN())
419 throw WrongDim(
"GetEigenvaluesEigenvectors",
"Matrix must be squared");
423 char jobl(
'N'), jobr(
'V');
int lwork = 3*n;
424 Vector<complex<float> > work(lwork);
425 Vector<float> rwork(2*n);
428 cgeev_(&jobl, &jobr, &n, A.GetDataVoid(), &n, w.GetDataVoid(),
429 z.GetDataVoid(), &n, z.GetData(), &n, work.GetDataVoid(),
430 &lwork, rwork.GetData(), &info.GetInfoRef());
432 #ifdef SELDON_LAPACK_CHECK_INFO
433 if (info.GetInfo() != 0)
434 throw LapackError(info.GetInfo(),
"GetEigenvalues",
435 "Failed to find eigenvalues ");
440 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
441 void GetEigenvalues(Matrix<double, Prop, ColMajor, Allocator1>& A,
442 Vector<double, VectFull, Allocator2>& wr,
443 Vector<double, VectFull, Allocator3>& wi,
446 #ifdef SELDON_CHECK_DIMENSIONS
447 if (A.GetM() != A.GetN())
448 throw WrongDim(
"GetEigenvalues",
"Matrix must be squared");
451 int n = A.GetM(), lwork = 6*n;
452 char jobvl(
'N'), jobvr(
'N');
453 Vector<double> work(lwork);
456 dgeev_(&jobvl, &jobvr, &n, A.GetData(), &n, wr.GetData(), wi.GetData(),
457 A.GetData(), &n, A.GetData(), &n, work.GetData(), &lwork,
460 #ifdef SELDON_LAPACK_CHECK_INFO
461 if (info.GetInfo() != 0)
462 throw LapackError(info.GetInfo(),
"GetEigenvalues",
463 "Failed to find eigenvalues ");
469 template<
class Prop,
class Allocator1,
class Allocator2,
470 class Allocator3,
class Allocator4>
471 void GetEigenvaluesEigenvectors(Matrix<double, Prop, ColMajor, Allocator1>& A,
472 Vector<double, VectFull, Allocator2>& wr,
473 Vector<double, VectFull, Allocator3>& wi,
474 Matrix<double, General, ColMajor, Allocator4>&zr,
477 #ifdef SELDON_CHECK_DIMENSIONS
478 if (A.GetM() != A.GetN())
479 throw WrongDim(
"GetEigenvaluesEigenvectors",
"Matrix must be squared");
482 int n = A.GetM(), lwork = 6*n;
483 char jobvl(
'N'), jobvr(
'V');
484 Vector<double> work(lwork);
488 dgeev_(&jobvl, &jobvr, &n, A.GetData(), &n, wr.GetData(), wi.GetData(),
489 zr.GetData(), &n, zr.GetData(), &n, work.GetData(),
490 &lwork, &info.GetInfoRef());
492 #ifdef SELDON_LAPACK_CHECK_INFO
493 if (info.GetInfo() != 0)
494 throw LapackError(info.GetInfo(),
"GetEigenvalues",
495 "Failed to find eigenvalues ");
501 template<
class Prop,
class Allocator1,
class Allocator2>
502 void GetEigenvalues(Matrix<complex<double>, Prop, ColMajor, Allocator1>& A,
503 Vector<complex<double>, VectFull, Allocator2>& w,
506 #ifdef SELDON_CHECK_DIMENSIONS
507 if (A.GetM() != A.GetN())
508 throw WrongDim(
"GetEigenvalues",
"Matrix must be squared");
512 char jobl(
'N'), jobr(
'N');
int lwork = 3*n;
513 Vector<complex<double> > work(lwork);
514 Vector<double> rwork(2*n);
516 zgeev_(&jobl, &jobr, &n, A.GetDataVoid(), &n, w.GetDataVoid(),
517 A.GetDataVoid(), &n, A.GetData(), &n, work.GetDataVoid(),
518 &lwork, rwork.GetData(), &info.GetInfoRef());
520 #ifdef SELDON_LAPACK_CHECK_INFO
521 if (info.GetInfo() != 0)
522 throw LapackError(info.GetInfo(),
"GetEigenvalues",
523 "Failed to find eigenvalues ");
529 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
530 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
531 Prop, ColMajor, Allocator1>& A,
532 Vector<complex<double>,
533 VectFull, Allocator2>& w,
534 Matrix<complex<double>,
535 General, ColMajor, Allocator3>& z,
538 #ifdef SELDON_CHECK_DIMENSIONS
539 if (A.GetM() != A.GetN())
540 throw WrongDim(
"GetEigenvaluesEigenvectors",
"Matrix must be squared");
544 char jobl(
'N'), jobr(
'V');
int lwork = 3*n;
545 Vector<complex<double> > work(lwork);
546 Vector<double> rwork(2*n);
549 zgeev_(&jobl, &jobr, &n, A.GetDataVoid(), &n, w.GetDataVoid(),
550 z.GetDataVoid(), &n, z.GetData(), &n, work.GetDataVoid(),
551 &lwork, rwork.GetData(), &info.GetInfoRef());
553 #ifdef SELDON_LAPACK_CHECK_INFO
554 if (info.GetInfo() != 0)
555 throw LapackError(info.GetInfo(),
"GetEigenvalues",
556 "Failed to find eigenvalues ");
565 template<
class Prop,
class Allocator1,
class Allocator2>
566 void GetEigenvalues(Matrix<float, Prop, RowSym, Allocator1>& A,
567 Vector<float, VectFull, Allocator2>& w,
571 char uplo(
'L');
char job(
'N');
573 Vector<float> work(lwork);
575 ssyev_(&job, &uplo, &n, A.GetData(), &n, w.GetData(), work.GetData(),
576 &lwork, &info.GetInfoRef());
578 #ifdef SELDON_LAPACK_CHECK_INFO
579 if (info.GetInfo() != 0)
580 throw LapackError(info.GetInfo(),
"GetEigenvalues",
581 "Failed to find eigenvalues ");
587 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
588 void GetEigenvaluesEigenvectors(Matrix<float, Prop, RowSym, Allocator1>& A,
589 Vector<float, VectFull, Allocator2>& w,
590 Matrix<float, General, RowMajor, Allocator3>& z,
594 char uplo(
'L');
char job(
'V');
597 for (
int i = 0; i < n; i++)
598 for (
int j = 0; j < n; j++)
602 Vector<float> work(lwork);
604 ssyev_(&job, &uplo, &n, z.GetData(), &n, w.GetData(), work.GetData(),
605 &lwork, &info.GetInfoRef());
607 #ifdef SELDON_LAPACK_CHECK_INFO
608 if (info.GetInfo() != 0)
609 throw LapackError(info.GetInfo(),
"GetEigenvalues",
610 "Failed to find eigenvalues ");
616 template<
class Prop,
class Allocator1,
class Allocator2>
617 void GetEigenvalues(Matrix<complex<float>, Prop, RowSym, Allocator1>& A,
618 Vector<complex<float>, VectFull, Allocator2>& w,
622 Matrix<complex<float>, General, ColMajor> B(n,n);
623 for (
int i = 0; i < n; i++)
624 for (
int j = 0; j < n; j++)
628 GetEigenvalues(B, w, info);
631 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
632 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
633 Prop, RowSym, Allocator1>& A,
634 Vector<complex<float>,
635 VectFull, Allocator2>& w,
636 Matrix<complex<float>,
637 General, RowMajor, Allocator3>& z,
641 Matrix<complex<float>, General, RowMajor> B(n,n);
642 for (
int i = 0; i < n; i++)
643 for (
int j = 0; j < n; j++)
647 GetEigenvaluesEigenvectors(B, w, z, info);
651 template<
class Prop,
class Allocator1,
class Allocator2>
652 void GetEigenvalues(Matrix<double, Prop, RowSym, Allocator1>& A,
653 Vector<double, VectFull, Allocator2>& w,
657 char uplo(
'L'), job(
'N');
659 Vector<double> work(lwork);
661 dsyev_(&job, &uplo, &n, A.GetData(), &n, w.GetData(), work.GetData(),
662 &lwork, &info.GetInfoRef());
664 #ifdef SELDON_LAPACK_CHECK_INFO
665 if (info.GetInfo() != 0)
666 throw LapackError(info.GetInfo(),
"GetEigenvalues",
667 "Failed to find eigenvalues ");
673 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
674 void GetEigenvaluesEigenvectors(Matrix<double, Prop, RowSym, Allocator1>& A,
675 Vector<double, VectFull, Allocator2>& w,
676 Matrix<double, General, RowMajor, Allocator3>& z,
680 char uplo(
'L');
char job(
'V');
683 for (
int i = 0; i < n; i++)
684 for (
int j = 0; j < n; j++)
688 Vector<double> work(lwork);
690 dsyev_(&job, &uplo, &n, z.GetData(), &n, w.GetData(), work.GetData(),
691 &lwork, &info.GetInfoRef());
693 #ifdef SELDON_LAPACK_CHECK_INFO
694 if (info.GetInfo() != 0)
695 throw LapackError(info.GetInfo(),
"GetEigenvalues",
696 "Failed to find eigenvalues ");
702 template<
class Prop,
class Allocator1,
class Allocator2>
703 void GetEigenvalues(Matrix<complex<double>, Prop, RowSym, Allocator1>& A,
704 Vector<complex<double>, VectFull, Allocator2>& w,
708 Matrix<complex<double>, General, ColMajor> B(n,n);
709 for (
int i = 0; i < n; i++)
710 for (
int j = 0; j < n; j++)
714 GetEigenvalues(B, w, info);
717 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
718 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
719 Prop, RowSym, Allocator1>& A,
720 Vector<complex<double>,
721 VectFull, Allocator2>& w,
722 Matrix<complex<double>,
723 General, RowMajor, Allocator3>& z,
727 Matrix<complex<double>, General, RowMajor> B(n,n);
728 for (
int i = 0; i < n; i++)
729 for (
int j = 0; j < n; j++)
735 GetEigenvaluesEigenvectors(B, w, z, info);
742 template<
class Prop,
class Allocator1,
class Allocator2>
743 void GetEigenvalues(Matrix<float, Prop, ColSym, Allocator1>& A,
744 Vector<float, VectFull, Allocator2>& w,
748 char uplo(
'U');
char job(
'N');
750 Vector<float> work(lwork);
752 ssyev_(&job, &uplo, &n, A.GetData(), &n, w.GetData(), work.GetData(),
753 &lwork, &info.GetInfoRef());
755 #ifdef SELDON_LAPACK_CHECK_INFO
756 if (info.GetInfo() != 0)
757 throw LapackError(info.GetInfo(),
"GetEigenvalues",
758 "Failed to find eigenvalues ");
764 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
765 void GetEigenvaluesEigenvectors(Matrix<float, Prop, ColSym, Allocator1>& A,
766 Vector<float, VectFull, Allocator2>& w,
767 Matrix<float, General, ColMajor, Allocator3>& z,
771 char uplo(
'U');
char job(
'V');
774 for (
int i = 0; i < n; i++)
775 for (
int j = 0; j < n; j++)
779 Vector<float> work(lwork);
781 ssyev_(&job, &uplo, &n, z.GetData(), &n, w.GetData(),
782 work.GetData(), &lwork, &info.GetInfoRef());
784 #ifdef SELDON_LAPACK_CHECK_INFO
785 if (info.GetInfo() != 0)
786 throw LapackError(info.GetInfo(),
"GetEigenvalues",
787 "Failed to find eigenvalues ");
793 template<
class Prop,
class Allocator1,
class Allocator2>
794 void GetEigenvalues(Matrix<complex<float>, Prop, ColSym, Allocator1>& A,
795 Vector<complex<float>, VectFull, Allocator2>& w,
799 Matrix<complex<float>, General, ColMajor> B(n,n);
800 for (
int i = 0; i < n; i++)
801 for (
int j = 0; j < n; j++)
805 GetEigenvalues(B, w, info);
809 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
810 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
811 Prop, ColSym, Allocator1>& A,
812 Vector<complex<float>,
813 VectFull, Allocator2>& w,
814 Matrix<complex<float>,
815 General, ColMajor, Allocator3>& z,
819 Matrix<complex<float>, General, ColMajor> B(n,n);
820 for (
int i = 0; i < n; i++)
821 for (
int j = 0; j < n; j++)
827 GetEigenvaluesEigenvectors(B, w, z, info);
831 template<
class Prop,
class Allocator1,
class Allocator2>
832 void GetEigenvalues(Matrix<double, Prop, ColSym, Allocator1>& A,
833 Vector<double, VectFull, Allocator2>& w,
837 char uplo(
'U'), job(
'N');
839 Vector<double> work(lwork);
841 dsyev_(&job, &uplo, &n, A.GetData(), &n, w.GetData(), work.GetData(),
842 &lwork, &info.GetInfoRef());
844 #ifdef SELDON_LAPACK_CHECK_INFO
845 if (info.GetInfo() != 0)
846 throw LapackError(info.GetInfo(),
"GetEigenvalues",
847 "Failed to find eigenvalues ");
853 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
854 void GetEigenvaluesEigenvectors(Matrix<double, Prop, ColSym, Allocator1>& A,
855 Vector<double, VectFull, Allocator2>& w,
856 Matrix<double, General, ColMajor, Allocator3>& z,
860 char uplo(
'U'), job(
'V');
863 for (
int i = 0; i < n; i++)
864 for (
int j = 0; j < n; j++)
868 Vector<double> work(lwork);
871 dsyev_(&job, &uplo, &n, z.GetData(), &n, w.GetData(),
872 work.GetData(), &lwork, &info.GetInfoRef());
874 #ifdef SELDON_LAPACK_CHECK_INFO
875 if (info.GetInfo() != 0)
876 throw LapackError(info.GetInfo(),
"GetEigenvalues",
877 "Failed to find eigenvalues ");
883 template<
class Prop,
class Allocator1,
class Allocator2>
884 void GetEigenvalues(Matrix<complex<double>, Prop, ColSym, Allocator1>& A,
885 Vector<complex<double>, VectFull, Allocator2>& w,
889 Matrix<complex<double>, General, ColMajor> B(n,n);
890 for (
int i = 0; i < n; i++)
891 for (
int j = 0; j < n; j++)
896 GetEigenvalues(B, w, info);
900 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
901 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
902 Prop, ColSym, Allocator1>& A,
903 Vector<complex<double>,
904 VectFull, Allocator2>& w,
905 Matrix<complex<double>,
906 General, ColMajor, Allocator3>& z,
910 Matrix<complex<double>, General, ColMajor> B(n,n);
911 for (
int i = 0; i < n; i++)
912 for (
int j = 0; j < n; j++)
918 GetEigenvaluesEigenvectors(B, w, z, info);
925 template<
class Prop,
class Allocator1,
class Allocator2>
926 void GetEigenvalues(Matrix<complex<float>, Prop, RowHerm, Allocator1>& A,
927 Vector<float, VectFull, Allocator2>& w,
931 char uplo(
'L'), job(
'N');
933 Vector<complex<float> > work(lwork);
934 Vector<float> rwork(3*n);
937 cheev_(&job, &uplo, &n, A.GetDataVoid(), &n, w.GetData(),
938 work.GetDataVoid(), &lwork, rwork.GetData(),
941 #ifdef SELDON_LAPACK_CHECK_INFO
942 if (info.GetInfo() != 0)
943 throw LapackError(info.GetInfo(),
"GetEigenvalues",
944 "Failed to find eigenvalues ");
950 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
951 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
952 Prop, RowHerm, Allocator1>& A,
953 Vector<float, VectFull, Allocator2>& w,
954 Matrix<complex<float>,
955 General, RowMajor, Allocator3>& z,
959 char uplo(
'L'), job(
'V');
962 for (
int i = 0; i < n; i++)
963 for (
int j = 0; j < n; j++)
964 z(i, j) = conj(A(i, j));
968 Vector<complex<float> > work(lwork);
969 Vector<float> rwork(3*n);
971 cheev_(&job, &uplo, &n, z.GetDataVoid(), &n,
972 w.GetData(), work.GetDataVoid(),
973 &lwork, rwork.GetData(), &info.GetInfoRef());
975 #ifdef SELDON_LAPACK_CHECK_INFO
976 if (info.GetInfo() != 0)
977 throw LapackError(info.GetInfo(),
"GetEigenvalues",
978 "Failed to find eigenvalues ");
984 template<
class Prop,
class Allocator1,
class Allocator2>
985 void GetEigenvalues(Matrix<complex<double>, Prop, RowHerm, Allocator1>& A,
986 Vector<double, VectFull, Allocator2>& w,
990 char uplo(
'L'), job(
'N');
992 Vector<complex<double> > work(lwork);
993 Vector<double> rwork(3*n);
996 zheev_(&job, &uplo, &n, A.GetDataVoid(), &n, w.GetData(),
997 work.GetDataVoid(), &lwork, rwork.GetData(),
1000 #ifdef SELDON_LAPACK_CHECK_INFO
1001 if (info.GetInfo() != 0)
1002 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1003 "Failed to find eigenvalues ");
1009 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
1010 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
1011 Prop, RowHerm, Allocator1>& A,
1012 Vector<double, VectFull, Allocator2>& w,
1013 Matrix<complex<double>,
1014 General, RowMajor, Allocator3>& z,
1018 char uplo(
'L'), job(
'V');
1021 for (
int i = 0; i < n; i++)
1022 for (
int j = 0; j < n; j++)
1023 z(i,j) = conj(A(i,j));
1026 Vector<complex<double> > work(lwork);
1027 Vector<double> rwork(3*n);
1030 zheev_(&job, &uplo,&n, z.GetDataVoid(),&n, w.GetData(), work.GetDataVoid(),
1031 &lwork, rwork.GetData() , &info.GetInfoRef());
1033 #ifdef SELDON_LAPACK_CHECK_INFO
1034 if (info.GetInfo() != 0)
1035 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1036 "Failed to find eigenvalues ");
1046 template<
class Prop,
class Allocator1,
class Allocator2>
1047 void GetEigenvalues(Matrix<complex<float>, Prop, ColHerm, Allocator1>& A,
1048 Vector<float, VectFull, Allocator2>& w,
1052 char uplo(
'U');
char job(
'N');
int lwork = 2*n;
1053 Vector<complex<float> > work(lwork);
1054 Vector<float> rwork(3*n);
1056 cheev_(&job, &uplo, &n, A.GetDataVoid(), &n, w.GetData(),
1057 work.GetDataVoid(), &lwork, rwork.GetData(),
1058 &info.GetInfoRef());
1060 #ifdef SELDON_LAPACK_CHECK_INFO
1061 if (info.GetInfo() != 0)
1062 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1063 "Failed to find eigenvalues ");
1069 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
1070 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
1071 Prop, ColHerm, Allocator1>& A,
1072 Vector<float, VectFull, Allocator2>& w,
1073 Matrix<complex<float>,
1074 General, ColMajor, Allocator3>& z,
1078 char uplo(
'U'), job(
'V');
1081 for (
int i = 0; i < n; i++)
1082 for (
int j = 0; j < n; j++)
1086 Vector<complex<float> > work(lwork);
1087 Vector<float> rwork(3*n);
1090 cheev_(&job, &uplo, &n, z.GetDataVoid(), &n,
1091 w.GetData(), work.GetDataVoid(),
1092 &lwork, rwork.GetData() , &info.GetInfoRef());
1094 #ifdef SELDON_LAPACK_CHECK_INFO
1095 if (info.GetInfo() != 0)
1096 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1097 "Failed to find eigenvalues ");
1103 template<
class Prop,
class Allocator1,
class Allocator2>
1104 void GetEigenvalues(Matrix<complex<double>, Prop, ColHerm, Allocator1>& A,
1105 Vector<double, VectFull, Allocator2>& w,
1109 char uplo(
'U'), job(
'N');
1111 Vector<complex<double> > work(lwork);
1112 Vector<double> rwork(3*n);
1114 zheev_(&job, &uplo, &n, A.GetDataVoid(), &n, w.GetData(),
1115 work.GetDataVoid(), &lwork, rwork.GetData(),
1116 &info.GetInfoRef());
1118 #ifdef SELDON_LAPACK_CHECK_INFO
1119 if (info.GetInfo() != 0)
1120 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1121 "Failed to find eigenvalues ");
1127 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
1128 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
1129 Prop, ColHerm, Allocator1>& A,
1130 Vector<double, VectFull, Allocator2>& w,
1131 Matrix<complex<double>,
1132 General, ColMajor, Allocator3>& z,
1136 char uplo(
'U'), job(
'V');
1139 for (
int i = 0; i < n; i++)
1140 for (
int j = 0; j < n; j++)
1144 Vector<complex<double> > work(lwork);
1145 Vector<double> rwork(3*n);
1148 zheev_(&job, &uplo, &n, z.GetDataVoid(), &n,
1149 w.GetData(), work.GetDataVoid(),
1150 &lwork, rwork.GetData() , &info.GetInfoRef());
1152 #ifdef SELDON_LAPACK_CHECK_INFO
1153 if (info.GetInfo() != 0)
1154 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1155 "Failed to find eigenvalues ");
1164 template<
class Prop,
class Allocator1,
class Allocator2>
1165 void GetEigenvalues(Matrix<float, Prop, RowSymPacked, Allocator1>& A,
1166 Vector<float, VectFull, Allocator2>& w,
1170 char uplo(
'L');
char job(
'N');
1171 Vector<float> work(3*n);
1173 sspev_(&job, &uplo, &n, A.GetData(), w.GetData(), A.GetData(), &n,
1174 work.GetData() , &info.GetInfoRef());
1176 #ifdef SELDON_LAPACK_CHECK_INFO
1177 if (info.GetInfo() != 0)
1178 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1179 "Failed to find eigenvalues ");
1185 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
1186 void GetEigenvaluesEigenvectors(Matrix<float, Prop,RowSymPacked, Allocator1>& A,
1187 Vector<float, VectFull, Allocator2>& w,
1188 Matrix<float, General, RowMajor, Allocator3>&z,
1192 char uplo(
'L');
char job(
'V');
1193 Vector<float> work(3*n);
1196 sspev_(&job, &uplo, &n, A.GetData(), w.GetData(), z.GetData(), &n,
1197 work.GetData() , &info.GetInfoRef());
1199 #ifdef SELDON_LAPACK_CHECK_INFO
1200 if (info.GetInfo() != 0)
1201 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1202 "Failed to find eigenvalues ");
1209 template<
class Prop,
class Allocator1,
class Allocator2>
1210 void GetEigenvalues(Matrix<complex<float>, Prop, RowSymPacked, Allocator1>& A,
1211 Vector<complex<float>, VectFull, Allocator2>& w,
1215 Matrix<complex<float>, General, ColMajor> B(n,n);
1216 for (
int i = 0; i < n; i++)
1217 for (
int j = 0; j < n; j++)
1222 GetEigenvalues(B, w, info);
1225 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
1226 void GetEigenvaluesEigenvectors(Matrix<complex<float>, Prop,
1227 RowSymPacked, Allocator1>& A,
1228 Vector<complex<float>,VectFull, Allocator2>& w,
1229 Matrix<complex<float>,
1230 General, RowMajor, Allocator3>& z,
1234 Matrix<complex<float>, General, RowMajor> B(n,n);
1235 for (
int i = 0; i < n; i++)
1236 for (
int j = 0; j < n; j++)
1242 GetEigenvaluesEigenvectors(B, w, z, info);
1246 template<
class Prop,
class Allocator1,
class Allocator2>
1247 void GetEigenvalues(Matrix<double, Prop, RowSymPacked, Allocator1>& A,
1248 Vector<double, VectFull, Allocator2>& w,
1252 char uplo(
'L'), job(
'N');
1253 Vector<double> work(3*n);
1255 dspev_(&job, &uplo, &n, A.GetData(), w.GetData(), A.GetData(), &n,
1256 work.GetData() , &info.GetInfoRef());
1258 #ifdef SELDON_LAPACK_CHECK_INFO
1259 if (info.GetInfo() != 0)
1260 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1261 "Failed to find eigenvalues ");
1267 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
1268 void GetEigenvaluesEigenvectors(Matrix<double,Prop,RowSymPacked, Allocator1>& A,
1269 Vector<double, VectFull, Allocator2>& w,
1270 Matrix<double, General, RowMajor, Allocator3>&z,
1274 char uplo(
'L'), job(
'V');
1275 Vector<double> work(3*n);
1278 dspev_(&job, &uplo, &n, A.GetData(), w.GetData(), z.GetData(), &n,
1279 work.GetData() , &info.GetInfoRef());
1281 #ifdef SELDON_LAPACK_CHECK_INFO
1282 if (info.GetInfo() != 0)
1283 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1284 "Failed to find eigenvalues ");
1291 template<
class Prop,
class Allocator1,
class Allocator2>
1292 void GetEigenvalues(Matrix<complex<double>, Prop, RowSymPacked, Allocator1>& A,
1293 Vector<complex<double>, VectFull, Allocator2>& w,
1297 Matrix<complex<double>, General, ColMajor> B(n,n);
1298 for (
int i = 0; i < n; i++)
1299 for (
int j = 0; j < n; j++)
1304 GetEigenvalues(B, w, info);
1308 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
1309 void GetEigenvaluesEigenvectors(Matrix<complex<double>, Prop,
1310 RowSymPacked, Allocator1>& A,
1311 Vector<complex<double>,VectFull, Allocator2>& w,
1312 Matrix<complex<double>,
1313 General, RowMajor, Allocator3>& z,
1317 Matrix<complex<double>, General, RowMajor> B(n,n);
1318 for (
int i = 0; i < n; i++)
1319 for (
int j = 0; j < n; j++)
1325 GetEigenvaluesEigenvectors(B, w, z, info);
1332 template<
class Prop,
class Allocator1,
class Allocator2>
1333 void GetEigenvalues(Matrix<float, Prop, ColSymPacked, Allocator1>& A,
1334 Vector<float, VectFull, Allocator2>& w,
1338 char uplo(
'U'), job(
'N');
1339 Vector<float> work(3*n);
1341 sspev_(&job, &uplo, &n, A.GetData(), w.GetData(), A.GetData(),
1342 &n, work.GetData() , &info.GetInfoRef());
1344 #ifdef SELDON_LAPACK_CHECK_INFO
1345 if (info.GetInfo() != 0)
1346 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1347 "Failed to find eigenvalues ");
1353 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
1354 void GetEigenvaluesEigenvectors(Matrix<float, Prop,ColSymPacked, Allocator1>& A,
1355 Vector<float, VectFull, Allocator2>& w,
1356 Matrix<float, General, ColMajor, Allocator3>&z,
1360 char uplo(
'U'), job(
'V');
1361 Vector<float> work(3*n);
1364 sspev_(&job, &uplo, &n, A.GetData(), w.GetData(), z.GetData(),
1365 &n, work.GetData() , &info.GetInfoRef());
1367 #ifdef SELDON_LAPACK_CHECK_INFO
1368 if (info.GetInfo() != 0)
1369 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1370 "Failed to find eigenvalues ");
1376 template<
class Prop,
class Allocator1,
class Allocator2>
1377 void GetEigenvalues(Matrix<complex<float>,
1378 Prop, ColSymPacked, Allocator1>& A,
1379 Vector<complex<float>, VectFull, Allocator2>& w,
1383 Matrix<complex<float>, General, ColMajor> B(n,n);
1384 for (
int i = 0; i < n; i++)
1385 for (
int j = 0; j < n; j++)
1390 GetEigenvalues(B, w, info);
1394 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
1395 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
1396 Prop, ColSymPacked, Allocator1>& A,
1397 Vector<complex<float>, VectFull, Allocator2>& w,
1398 Matrix<complex<float>,
1399 General, ColMajor, Allocator3>& z,
1403 Matrix<complex<float>, General, ColMajor> B(n,n);
1404 for (
int i = 0; i < n; i++)
1405 for (
int j = 0; j < n; j++)
1411 GetEigenvaluesEigenvectors(B, w, z, info);
1415 template<
class Prop,
class Allocator1,
class Allocator2>
1416 void GetEigenvalues(Matrix<double, Prop, ColSymPacked, Allocator1>& A,
1417 Vector<double, VectFull, Allocator2>& w,
1421 char uplo(
'U'), job(
'N');
1422 Vector<double> work(3*n);
1424 dspev_(&job, &uplo, &n, A.GetData(), w.GetData(), A.GetData(),
1425 &n, work.GetData() , &info.GetInfoRef());
1427 #ifdef SELDON_LAPACK_CHECK_INFO
1428 if (info.GetInfo() != 0)
1429 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1430 "Failed to find eigenvalues ");
1436 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
1437 void GetEigenvaluesEigenvectors(Matrix<double, Prop, ColSymPacked, Allocator1>& A,
1438 Vector<double, VectFull, Allocator2>& w,
1439 Matrix<double, General, ColMajor, Allocator3>&z,
1443 char uplo(
'U'), job(
'V');
1444 Vector<double> work(3*n);
1447 dspev_(&job, &uplo, &n, A.GetData(), w.GetData(), z.GetData(),
1448 &n, work.GetData() , &info.GetInfoRef());
1450 #ifdef SELDON_LAPACK_CHECK_INFO
1451 if (info.GetInfo() != 0)
1452 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1453 "Failed to find eigenvalues ");
1459 template<
class Prop,
class Allocator1,
class Allocator2>
1460 void GetEigenvalues(Matrix<complex<double>,
1461 Prop, ColSymPacked, Allocator1>& A,
1462 Vector<complex<double>, VectFull, Allocator2>& w,
1466 Matrix<complex<double>, General, ColMajor> B(n,n);
1467 for (
int i = 0; i < n; i++)
1468 for (
int j = 0; j < n; j++)
1473 GetEigenvalues(B, w, info);
1477 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
1478 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
1479 Prop, ColSymPacked, Allocator1>& A,
1480 Vector<complex<double>, VectFull, Allocator2>& w,
1481 Matrix<complex<double>,
1482 General, ColMajor, Allocator3>& z,
1486 Matrix<complex<double>, General, ColMajor> B(n,n);
1487 for (
int i = 0; i < n; i++)
1488 for (
int j = 0; j < n; j++)
1494 GetEigenvaluesEigenvectors(B, w, z, info);
1501 template<
class Prop,
class Allocator1,
class Allocator2>
1502 void GetEigenvalues(Matrix<complex<float>,
1503 Prop, RowHermPacked, Allocator1>& A,
1504 Vector<float, VectFull, Allocator2>& w,
1508 char uplo(
'L'), job(
'N');
1509 Vector<complex<float> > work(2*n);
1510 Vector<float> rwork(3*n);
1513 chpev_(&job, &uplo, &n, A.GetDataVoid(), w.GetData(), A.GetDataVoid(), &n,
1514 work.GetDataVoid(), rwork.GetData(), &info.GetInfoRef());
1516 #ifdef SELDON_LAPACK_CHECK_INFO
1517 if (info.GetInfo() != 0)
1518 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1519 "Failed to find eigenvalues ");
1525 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
1526 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
1527 Prop, RowHermPacked, Allocator1>& A,
1528 Vector<float, VectFull, Allocator2>& w,
1529 Matrix<complex<float>,
1530 General, RowMajor, Allocator3>&z,
1534 char uplo(
'L'), job(
'V');
1535 Vector<complex<float> > work(2*n);
1536 Vector<float> rwork(3*n);
1540 chpev_(&job, &uplo, &n, A.GetDataVoid(), w.GetData(), z.GetDataVoid(),
1541 &n, work.GetDataVoid(), rwork.GetData(), &info.GetInfoRef());
1543 #ifdef SELDON_LAPACK_CHECK_INFO
1544 if (info.GetInfo() != 0)
1545 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1546 "Failed to find eigenvalues ");
1553 template<
class Prop,
class Allocator1,
class Allocator2>
1554 void GetEigenvalues(Matrix<complex<double>,
1555 Prop, RowHermPacked, Allocator1>& A,
1556 Vector<double, VectFull, Allocator2>& w,
1560 char uplo(
'L'), job(
'N');
1561 Vector<complex<double> > work(2*n);
1562 Vector<double> rwork(3*n);
1565 zhpev_(&job, &uplo, &n, A.GetDataVoid(), w.GetData(), A.GetDataVoid(), &n,
1566 work.GetDataVoid(), rwork.GetData(), &info.GetInfoRef());
1568 #ifdef SELDON_LAPACK_CHECK_INFO
1569 if (info.GetInfo() != 0)
1570 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1571 "Failed to find eigenvalues ");
1577 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
1578 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
1579 Prop, RowHermPacked, Allocator1>& A,
1580 Vector<double, VectFull, Allocator2>& w,
1581 Matrix<complex<double>,
1582 General, RowMajor, Allocator3>&z,
1586 char uplo(
'L'), job(
'V');
1587 Vector<complex<double> > work(2*n);
1588 Vector<double> rwork(3*n);
1592 zhpev_(&job, &uplo, &n, A.GetDataVoid(), w.GetData(), z.GetDataVoid(),
1593 &n, work.GetDataVoid(), rwork.GetData(), &info.GetInfoRef());
1595 #ifdef SELDON_LAPACK_CHECK_INFO
1596 if (info.GetInfo() != 0)
1597 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1598 "Failed to find eigenvalues ");
1608 template<
class Prop,
class Allocator1,
class Allocator2>
1609 void GetEigenvalues(Matrix<complex<float>,
1610 Prop, ColHermPacked, Allocator1>& A,
1611 Vector<float, VectFull, Allocator2>& w,
1617 Vector<complex<float> > work(2*n);
1618 Vector<float> rwork(3*n);
1620 chpev_(&job, &uplo, &n, A.GetDataVoid(), w.GetData(), A.GetDataVoid(), &n,
1621 work.GetDataVoid(), rwork.GetData(), &info.GetInfoRef());
1623 #ifdef SELDON_LAPACK_CHECK_INFO
1624 if (info.GetInfo() != 0)
1625 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1626 "Failed to find eigenvalues ");
1632 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
1633 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
1634 Prop, ColHermPacked, Allocator1>& A,
1635 Vector<float, VectFull, Allocator2>& w,
1636 Matrix<complex<float>,
1637 General, ColMajor, Allocator3>&z,
1641 char uplo(
'U');
char job(
'V');
1642 Vector<complex<float> > work(2*n);
1643 Vector<float> rwork(3*n);
1646 chpev_(&job, &uplo, &n, A.GetDataVoid(), w.GetData(), z.GetDataVoid(), &n,
1647 work.GetDataVoid(), rwork.GetData(), &info.GetInfoRef());
1649 #ifdef SELDON_LAPACK_CHECK_INFO
1650 if (info.GetInfo() != 0)
1651 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1652 "Failed to find eigenvalues ");
1658 template<
class Prop,
class Allocator1,
class Allocator2>
1659 void GetEigenvalues(Matrix<complex<double>,
1660 Prop, ColHermPacked, Allocator1>& A,
1661 Vector<double, VectFull, Allocator2>& w,
1667 Vector<complex<double> > work(2*n);
1668 Vector<double> rwork(3*n);
1670 zhpev_(&job, &uplo, &n, A.GetDataVoid(), w.GetData(), A.GetDataVoid(), &n,
1671 work.GetDataVoid(), rwork.GetData(), &info.GetInfoRef());
1673 #ifdef SELDON_LAPACK_CHECK_INFO
1674 if (info.GetInfo() != 0)
1675 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1676 "Failed to find eigenvalues ");
1682 template<
class Prop,
class Allocator1,
class Allocator2,
class Allocator3>
1683 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
1684 Prop, ColHermPacked, Allocator1>& A,
1685 Vector<double, VectFull, Allocator2>& w,
1686 Matrix<complex<double>,
1687 General, ColMajor, Allocator3>&z,
1691 char uplo(
'U');
char job(
'V');
1692 Vector<complex<double> > work(2*n);
1693 Vector<double> rwork(3*n);
1696 zhpev_(&job, &uplo, &n, A.GetDataVoid(), w.GetData(), z.GetDataVoid(), &n,
1697 work.GetDataVoid(), rwork.GetData(), &info.GetInfoRef());
1699 #ifdef SELDON_LAPACK_CHECK_INFO
1700 if (info.GetInfo() != 0)
1701 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1702 "Failed to find eigenvalues ");
1719 template<
class Prop1,
class Prop2,
class Allocator1,
1720 class Allocator2,
class Allocator3>
1721 void GetEigenvalues(Matrix<float, Prop1, RowSym, Allocator1>& A,
1722 Matrix<float, Prop2, RowSym, Allocator2>& B,
1723 Vector<float, VectFull, Allocator3>& w,
1726 #ifdef SELDON_CHECK_DIMENSIONS
1727 if (A.GetM() != B.GetM())
1728 throw WrongDim(
"GetEigenvalues",
1729 "Matrix A and B must have the same size");
1735 char uplo(
'L'), job(
'N');
1737 Vector<float> work(lwork);
1739 ssygv_(&itype, &job, &uplo, &n, A.GetData(), &n, B.GetData(), &n,
1740 w.GetData(), work.GetData(), &lwork, &info.GetInfoRef());
1742 #ifdef SELDON_LAPACK_CHECK_INFO
1743 if (info.GetInfo() != 0)
1744 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1745 "Failed to find eigenvalues ");
1751 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
1752 class Allocator3,
class Allocator4>
1753 void GetEigenvaluesEigenvectors(Matrix<float, Prop1, RowSym, Allocator1>& A,
1754 Matrix<float, Prop2, RowSym, Allocator2>& B,
1755 Vector<float, VectFull, Allocator3>& w,
1756 Matrix<float, General, RowMajor, Allocator4>& z,
1759 #ifdef SELDON_CHECK_DIMENSIONS
1760 if (A.GetM() != B.GetM())
1761 throw WrongDim(
"GetEigenvaluesEigenvectors",
1762 "Matrix A and B must have the same size");
1767 char uplo(
'L'), job(
'V');
1770 for (
int i = 0; i < n; i++)
1771 for (
int j = 0; j < n; j++)
1775 Vector<float> work(lwork);
1778 ssygv_(&itype, &job, &uplo, &n, z.GetData(), &n, B.GetData(), &n,
1779 w.GetData(), work.GetData(), &lwork, &info.GetInfoRef());
1781 #ifdef SELDON_LAPACK_CHECK_INFO
1782 if (info.GetInfo() != 0)
1783 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1784 "Failed to find eigenvalues ");
1791 template<
class Prop1,
class Prop2,
class Allocator1,
1792 class Allocator2,
class Allocator4,
class Allocator5>
1793 void GetEigenvalues(Matrix<complex<float>, Prop1, RowSym, Allocator1>& A,
1794 Matrix<complex<float>, Prop2, RowSym, Allocator2>& B,
1795 Vector<complex<float>, VectFull, Allocator4>& alpha,
1796 Vector<complex<float>, VectFull, Allocator5>& beta,
1799 #ifdef SELDON_CHECK_DIMENSIONS
1800 if (A.GetM() != B.GetM())
1801 throw WrongDim(
"GetEigenvalues",
1802 "Matrix A and B must have the same size");
1806 Matrix<complex<float>, General, RowMajor, Allocator1> A2(n, n), B2(n, n);
1807 for (
int i = 0; i < n; i++)
1808 for (
int j = 0; j < n; j++)
1816 GetEigenvalues(A2, B2, alpha, beta, info);
1820 template<
class Prop1,
class Prop2,
class Prop3,
class Allocator1,
1821 class Allocator2,
class Allocator4,
1822 class Allocator5,
class Allocator6>
1823 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
1824 Prop1, RowSym, Allocator1>& A,
1825 Matrix<complex<float>,
1826 Prop2, RowSym, Allocator2>& B,
1827 Vector<complex<float>,
1828 VectFull, Allocator4>& alpha,
1829 Vector<complex<float>,
1830 VectFull, Allocator5>& beta,
1831 Matrix<complex<float>,
1832 Prop3, RowMajor, Allocator6>& V,
1835 #ifdef SELDON_CHECK_DIMENSIONS
1836 if (A.GetM() != B.GetM())
1837 throw WrongDim(
"GetEigenvaluesEigenvectors",
1838 "Matrix A and B must have the same size");
1842 Matrix<complex<float>, General, RowMajor, Allocator1> A2(n, n), B2(n, n);
1843 for (
int i = 0; i < n; i++)
1844 for (
int j = 0; j < n; j++)
1852 GetEigenvaluesEigenvectors(A2, B2, alpha, beta, V, info);
1856 template<
class Prop1,
class Prop2,
class Allocator1,
1857 class Allocator2,
class Allocator3>
1858 void GetEigenvalues(Matrix<double, Prop1, RowSym, Allocator1>& A,
1859 Matrix<double, Prop2, RowSym, Allocator2>& B,
1860 Vector<double, VectFull, Allocator3>& w,
1863 #ifdef SELDON_CHECK_DIMENSIONS
1864 if (A.GetM() != B.GetM())
1865 throw WrongDim(
"GetEigenvalues",
1866 "Matrix A and B must have the same size");
1871 char uplo(
'L'), job(
'N');
1873 Vector<double> work(lwork);
1875 dsygv_(&itype, &job, &uplo, &n, A.GetData(), &n, B.GetData(), &n,
1876 w.GetData(), work.GetData(), &lwork, &info.GetInfoRef());
1878 #ifdef SELDON_LAPACK_CHECK_INFO
1879 if (info.GetInfo() != 0)
1880 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1881 "Failed to find eigenvalues ");
1887 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
1888 class Allocator3,
class Allocator4>
1889 void GetEigenvaluesEigenvectors(Matrix<double, Prop1, RowSym, Allocator1>& A,
1890 Matrix<double, Prop2, RowSym, Allocator2>& B,
1891 Vector<double, VectFull, Allocator3>& w,
1892 Matrix<double, General, RowMajor, Allocator4>& z,
1895 #ifdef SELDON_CHECK_DIMENSIONS
1896 if (A.GetM() != B.GetM())
1897 throw WrongDim(
"GetEigenvaluesEigenvectors",
1898 "Matrix A and B must have the same size");
1903 char uplo(
'L'), job(
'V');
1906 for (
int i = 0; i < n; i++)
1907 for (
int j = 0; j < n; j++)
1911 Vector<double> work(lwork);
1914 dsygv_(&itype, &job, &uplo, &n, z.GetData(), &n, B.GetData(), &n,
1915 w.GetData(), work.GetData(), &lwork, &info.GetInfoRef());
1917 #ifdef SELDON_LAPACK_CHECK_INFO
1918 if (info.GetInfo() != 0)
1919 throw LapackError(info.GetInfo(),
"GetEigenvalues",
1920 "Failed to find eigenvalues ");
1927 template<
class Prop1,
class Prop2,
class Allocator1,
1928 class Allocator2,
class Allocator4,
class Allocator5>
1929 void GetEigenvalues(Matrix<complex<double>, Prop1, RowSym, Allocator1>& A,
1930 Matrix<complex<double>, Prop2, RowSym, Allocator2>& B,
1931 Vector<complex<double>, VectFull, Allocator4>& alpha,
1932 Vector<complex<double>, VectFull, Allocator5>& beta,
1935 #ifdef SELDON_CHECK_DIMENSIONS
1936 if (A.GetM() != B.GetM())
1937 throw WrongDim(
"GetEigenvalues",
1938 "Matrix A and B must have the same size");
1942 Matrix<complex<double>, General, RowMajor, Allocator1> A2(n, n), B2(n, n);
1943 for (
int i = 0; i < n; i++)
1944 for (
int j = 0; j < n; j++)
1952 GetEigenvalues(A2, B2, alpha, beta, info);
1956 template<
class Prop1,
class Prop2,
class Prop3,
class Allocator1,
1957 class Allocator2,
class Allocator4,
1958 class Allocator5,
class Allocator6>
1959 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
1960 Prop1, RowSym, Allocator1>& A,
1961 Matrix<complex<double>,
1962 Prop2, RowSym, Allocator2>& B,
1963 Vector<complex<double>,
1964 VectFull, Allocator4>& alpha,
1965 Vector<complex<double>,
1966 VectFull, Allocator5>& beta,
1967 Matrix<complex<double>,
1968 Prop3, RowMajor, Allocator6>& V,
1971 #ifdef SELDON_CHECK_DIMENSIONS
1972 if (A.GetM() != B.GetM())
1973 throw WrongDim(
"GetEigenvaluesEigenvectors",
1974 "Matrix A and B must have the same size");
1978 Matrix<complex<double>, General, RowMajor, Allocator1> A2(n, n), B2(n, n);
1979 for (
int i = 0; i < n; i++)
1980 for (
int j = 0; j < n; j++)
1988 GetEigenvaluesEigenvectors(A2, B2, alpha, beta, V, info);
1995 template<
class Prop1,
class Prop2,
class Allocator1,
1996 class Allocator2,
class Allocator3>
1997 void GetEigenvalues(Matrix<float, Prop1, ColSym, Allocator1>& A,
1998 Matrix<float, Prop2, ColSym, Allocator2>& B,
1999 Vector<float, VectFull, Allocator3>& w,
2002 #ifdef SELDON_CHECK_DIMENSIONS
2003 if (A.GetM() != B.GetM())
2004 throw WrongDim(
"GetEigenvalues",
2005 "Matrix A and B must have the same size");
2010 char uplo(
'U'), job(
'N');
2012 Vector<float> work(lwork);
2014 ssygv_(&itype, &job, &uplo, &n, A.GetData(), &n, B.GetData(), &n,
2015 w.GetData(), work.GetData(), &lwork, &info.GetInfoRef());
2017 #ifdef SELDON_LAPACK_CHECK_INFO
2018 if (info.GetInfo() != 0)
2019 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2020 "Failed to find eigenvalues ");
2026 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
2027 class Allocator3,
class Allocator4>
2028 void GetEigenvaluesEigenvectors(Matrix<float, Prop1, ColSym, Allocator1>& A,
2029 Matrix<float, Prop2, ColSym, Allocator2>& B,
2030 Vector<float, VectFull, Allocator3>& w,
2031 Matrix<float, General, ColMajor, Allocator4>& z,
2034 #ifdef SELDON_CHECK_DIMENSIONS
2035 if (A.GetM() != B.GetM())
2036 throw WrongDim(
"GetEigenvaluesEigenvectors",
2037 "Matrix A and B must have the same size");
2042 char uplo(
'U'), job(
'V');
2044 Vector<float> work(lwork);
2047 for (
int i = 0; i < n; i++)
2048 for (
int j = 0; j < n; j++)
2051 ssygv_(&itype, &job, &uplo, &n, z.GetData(), &n, B.GetData(), &n,
2052 w.GetData(), work.GetData(), &lwork, &info.GetInfoRef());
2054 #ifdef SELDON_LAPACK_CHECK_INFO
2055 if (info.GetInfo() != 0)
2056 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2057 "Failed to find eigenvalues ");
2063 template<
class Prop1,
class Prop2,
class Allocator1,
2064 class Allocator2,
class Allocator4,
class Allocator5>
2065 void GetEigenvalues(Matrix<complex<float>, Prop1, ColSym, Allocator1>& A,
2066 Matrix<complex<float>, Prop2, ColSym, Allocator2>& B,
2067 Vector<complex<float>, VectFull, Allocator4>& alpha,
2068 Vector<complex<float>, VectFull, Allocator5>& beta,
2071 #ifdef SELDON_CHECK_DIMENSIONS
2072 if (A.GetM() != B.GetM())
2073 throw WrongDim(
"GetEigenvalues",
2074 "Matrix A and B must have the same size");
2078 Matrix<complex<float>, General, ColMajor, Allocator1> A2(n, n), B2(n, n);
2079 for (
int i = 0; i < n; i++)
2080 for (
int j = 0; j < n; j++)
2088 GetEigenvalues(A2, B2, alpha, beta, info);
2092 template<
class Prop1,
class Prop2,
class Prop3,
class Alloc1,
2093 class Alloc2,
class Alloc4,
class Alloc5,
class Alloc6>
2094 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
2095 Prop1, ColSym, Alloc1>& A,
2096 Matrix<complex<float>,
2097 Prop2, ColSym, Alloc2>& B,
2098 Vector<complex<float>, VectFull, Alloc4>& alpha,
2099 Vector<complex<float>, VectFull, Alloc5>& beta,
2100 Matrix<complex<float>,
2101 Prop3, ColMajor, Alloc6>& V,
2104 #ifdef SELDON_CHECK_DIMENSIONS
2105 if (A.GetM() != B.GetM())
2106 throw WrongDim(
"GetEigenvaluesEigenvectors",
2107 "Matrix A and B must have the same size");
2111 Matrix<complex<float>, General, ColMajor, Alloc1> A2(n, n), B2(n, n);
2112 for (
int i = 0; i < n; i++)
2113 for (
int j = 0; j < n; j++)
2121 GetEigenvaluesEigenvectors(A2, B2, alpha, beta, V, info);
2124 template<
class Prop1,
class Prop2,
class Allocator1,
2125 class Allocator2,
class Allocator3>
2126 void GetEigenvalues(Matrix<double, Prop1, ColSym, Allocator1>& A,
2127 Matrix<double, Prop2, ColSym, Allocator2>& B,
2128 Vector<double, VectFull, Allocator3>& w,
2131 #ifdef SELDON_CHECK_DIMENSIONS
2132 if (A.GetM() != B.GetM())
2133 throw WrongDim(
"GetEigenvalues",
2134 "Matrix A and B must have the same size");
2139 char uplo(
'U'), job(
'N');
2141 Vector<double> work(lwork);
2143 dsygv_(&itype, &job, &uplo, &n, A.GetData(), &n, B.GetData(), &n,
2144 w.GetData(), work.GetData(), &lwork, &info.GetInfoRef());
2146 #ifdef SELDON_LAPACK_CHECK_INFO
2147 if (info.GetInfo() != 0)
2148 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2149 "Failed to find eigenvalues ");
2155 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
2156 class Allocator3,
class Allocator4>
2157 void GetEigenvaluesEigenvectors(Matrix<double, Prop1, ColSym, Allocator1>& A,
2158 Matrix<double, Prop2, ColSym, Allocator2>& B,
2159 Vector<double, VectFull, Allocator3>& w,
2160 Matrix<double, General, ColMajor, Allocator4>& z,
2163 #ifdef SELDON_CHECK_DIMENSIONS
2164 if (A.GetM() != B.GetM())
2165 throw WrongDim(
"GetEigenvaluesEigenvectors",
2166 "Matrix A and B must have the same size");
2171 char uplo(
'U'), job(
'V');
2173 for (
int i = 0; i < n; i++)
2174 for (
int j = 0; j < n; j++)
2179 Vector<double> work(lwork);
2182 dsygv_(&itype, &job, &uplo, &n, z.GetData(), &n, B.GetData(), &n,
2183 w.GetData(), work.GetData(), &lwork, &info.GetInfoRef());
2185 #ifdef SELDON_LAPACK_CHECK_INFO
2186 if (info.GetInfo() != 0)
2187 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2188 "Failed to find eigenvalues ");
2194 template<
class Prop1,
class Prop2,
class Allocator1,
2195 class Allocator2,
class Allocator4,
class Allocator5>
2196 void GetEigenvalues(Matrix<complex<double>, Prop1, ColSym, Allocator1>& A,
2197 Matrix<complex<double>, Prop2, ColSym, Allocator2>& B,
2198 Vector<complex<double>, VectFull, Allocator4>& alpha,
2199 Vector<complex<double>, VectFull, Allocator5>& beta,
2202 #ifdef SELDON_CHECK_DIMENSIONS
2203 if (A.GetM() != B.GetM())
2204 throw WrongDim(
"GetEigenvalues",
2205 "Matrix A and B must have the same size");
2209 Matrix<complex<double>, General, ColMajor, Allocator1> A2(n, n), B2(n, n);
2210 for (
int i = 0; i < n; i++)
2211 for (
int j = 0; j < n; j++)
2219 GetEigenvalues(A2, B2, alpha, beta, info);
2223 template<
class Prop1,
class Prop2,
class Prop3,
class Alloc1,
2224 class Alloc2,
class Alloc4,
class Alloc5,
class Alloc6>
2225 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
2226 Prop1, ColSym, Alloc1>& A,
2227 Matrix<complex<double>,
2228 Prop2, ColSym, Alloc2>& B,
2229 Vector<complex<double>, VectFull, Alloc4>& alpha,
2230 Vector<complex<double>, VectFull, Alloc5>& beta,
2231 Matrix<complex<double>,
2232 Prop3, ColMajor, Alloc6>& V,
2235 #ifdef SELDON_CHECK_DIMENSIONS
2236 if (A.GetM() != B.GetM())
2237 throw WrongDim(
"GetEigenvaluesEigenvectors",
2238 "Matrix A and B must have the same size");
2242 Matrix<complex<double>, General, ColMajor, Alloc1> A2(n, n), B2(n, n);
2243 for (
int i = 0; i < n; i++)
2244 for (
int j = 0; j < n; j++)
2252 GetEigenvaluesEigenvectors(A2, B2, alpha, beta, V, info);
2259 template<
class Prop1,
class Prop2,
class Allocator1,
2260 class Allocator2,
class Allocator3>
2261 void GetEigenvalues(Matrix<complex<float>, Prop1, RowHerm, Allocator1>& A,
2262 Matrix<complex<float>, Prop2, RowHerm, Allocator2>& B,
2263 Vector<float, VectFull, Allocator3>& w,
2266 #ifdef SELDON_CHECK_DIMENSIONS
2267 if (A.GetM() != B.GetM())
2268 throw WrongDim(
"GetEigenvalues",
2269 "Matrix A and B must have the same size");
2274 char uplo(
'L'), job(
'N');
2276 Vector<complex<float> > work(lwork);
2277 Vector<float> rwork(3*n);
2280 chegv_(&itype, &job, &uplo, &n, A.GetData(), &n, B.GetData(), &n,
2281 w.GetData(), work.GetData(), &lwork, rwork.GetData(),
2282 &info.GetInfoRef());
2284 #ifdef SELDON_LAPACK_CHECK_INFO
2285 if (info.GetInfo() != 0)
2286 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2287 "Failed to find eigenvalues ");
2293 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
2294 class Allocator3,
class Allocator4>
2295 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
2296 Prop1, RowHerm, Allocator1>& A,
2297 Matrix<complex<float>,
2298 Prop2, RowHerm, Allocator2>& B,
2299 Vector<float, VectFull, Allocator3>& w,
2300 Matrix<complex<float>,
2301 General, RowMajor, Allocator4>& z,
2304 #ifdef SELDON_CHECK_DIMENSIONS
2305 if (A.GetM() != B.GetM())
2306 throw WrongDim(
"GetEigenvaluesEigenvectors",
2307 "Matrix A and B must have the same size");
2312 char uplo(
'L'), job(
'V');
2315 for (
int i = 0; i < n; i++)
2316 for (
int j = 0; j < n; j++)
2317 z(i,j) = conj(A(i,j));
2320 Vector<complex<float> > work(lwork);
2322 Vector<float> rwork(3*n);
2325 chegv_(&itype, &job, &uplo, &n, z.GetData(), &n, B.GetData(), &n,
2326 w.GetData(), work.GetData(), &lwork, rwork.GetData(),
2327 &info.GetInfoRef());
2329 #ifdef SELDON_LAPACK_CHECK_INFO
2330 if (info.GetInfo() != 0)
2331 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2332 "Failed to find eigenvalues ");
2339 template<
class Prop1,
class Prop2,
class Allocator1,
2340 class Allocator2,
class Allocator3>
2341 void GetEigenvalues(Matrix<complex<double>, Prop1, RowHerm, Allocator1>& A,
2342 Matrix<complex<double>, Prop2, RowHerm, Allocator2>& B,
2343 Vector<double, VectFull, Allocator3>& w,
2346 #ifdef SELDON_CHECK_DIMENSIONS
2347 if (A.GetM() != B.GetM())
2348 throw WrongDim(
"GetEigenvalues",
2349 "Matrix A and B must have the same size");
2354 char uplo(
'L'), job(
'N');
2357 Vector<complex<double> > work(lwork);
2358 Vector<double> rwork(3*n);
2363 zhegv_(&itype, &job, &uplo, &n, A.GetData(), &n, B.GetData(), &n,
2364 w.GetData(), work.GetData(), &lwork, rwork.GetData(),
2365 &info.GetInfoRef());
2367 #ifdef SELDON_LAPACK_CHECK_INFO
2368 if (info.GetInfo() != 0)
2369 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2370 "Failed to find eigenvalues ");
2376 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
2377 class Allocator3,
class Allocator4>
2378 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
2379 Prop1, RowHerm, Allocator1>& A,
2380 Matrix<complex<double>,
2381 Prop2, RowHerm, Allocator2>& B,
2382 Vector<double, VectFull, Allocator3>& w,
2383 Matrix<complex<double>,
2384 General, RowMajor, Allocator4>& z,
2387 #ifdef SELDON_CHECK_DIMENSIONS
2388 if (A.GetM() != B.GetM())
2389 throw WrongDim(
"GetEigenvaluesEigenvectors",
2390 "Matrix A and B must have the same size");
2395 char uplo(
'L'), job(
'V');
2397 for (
int i = 0; i < n; i++)
2398 for (
int j = 0; j < n; j++)
2399 z(i,j) = conj(A(i,j));
2403 Vector<complex<double> > work(lwork);
2407 Vector<double> rwork(3*n);
2408 zhegv_(&itype, &job, &uplo, &n, z.GetData(), &n, B.GetData(), &n,
2409 w.GetData(), work.GetData(), &lwork, rwork.GetData(),
2410 &info.GetInfoRef());
2412 #ifdef SELDON_LAPACK_CHECK_INFO
2413 if (info.GetInfo() != 0)
2414 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2415 "Failed to find eigenvalues ");
2425 template<
class Prop1,
class Prop2,
class Allocator1,
2426 class Allocator2,
class Allocator3>
2427 void GetEigenvalues(Matrix<complex<float>, Prop1, ColHerm, Allocator1>& A,
2428 Matrix<complex<float>, Prop2, ColHerm, Allocator2>& B,
2429 Vector<float, VectFull, Allocator3>& w,
2432 #ifdef SELDON_CHECK_DIMENSIONS
2433 if (A.GetM() != B.GetM())
2434 throw WrongDim(
"GetEigenvalues",
2435 "Matrix A and B must have the same size");
2440 char uplo(
'U'), job(
'N');
2442 Vector<complex<float> > work(lwork);
2443 Vector<float> rwork(3*n);
2445 chegv_(&itype, &job, &uplo, &n, A.GetData(), &n, B.GetData(), &n,
2446 w.GetData(), work.GetData(), &lwork, rwork.GetData(),
2447 &info.GetInfoRef());
2449 #ifdef SELDON_LAPACK_CHECK_INFO
2450 if (info.GetInfo() != 0)
2451 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2452 "Failed to find eigenvalues ");
2458 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
2459 class Allocator3,
class Allocator4>
2460 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
2461 Prop1, ColHerm, Allocator1>& A,
2462 Matrix<complex<float>,
2463 Prop2, ColHerm, Allocator2>& B,
2464 Vector<float, VectFull, Allocator3>& w,
2465 Matrix<complex<float>,
2466 General, ColMajor, Allocator4>& z,
2469 #ifdef SELDON_CHECK_DIMENSIONS
2470 if (A.GetM() != B.GetM())
2471 throw WrongDim(
"GetEigenvaluesEigenvectors",
2472 "Matrix A and B must have the same size");
2477 char uplo(
'U');
char job(
'V');
2479 for (
int i = 0; i < n; i++)
2480 for (
int j = 0; j < n; j++)
2485 Vector<complex<float> > work(lwork);
2487 Vector<float> rwork(3*n);
2488 chegv_(&itype, &job, &uplo, &n, z.GetData(), &n, B.GetData(), &n,
2489 w.GetData(), work.GetData(), &lwork,
2490 rwork.GetData(), &info.GetInfoRef());
2492 #ifdef SELDON_LAPACK_CHECK_INFO
2493 if (info.GetInfo() != 0)
2494 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2495 "Failed to find eigenvalues ");
2501 template<
class Prop1,
class Prop2,
class Allocator1,
2502 class Allocator2,
class Allocator3>
2503 void GetEigenvalues(Matrix<complex<double>, Prop1, ColHerm, Allocator1>& A,
2504 Matrix<complex<double>, Prop2, ColHerm, Allocator2>& B,
2505 Vector<double, VectFull, Allocator3>& w,
2508 #ifdef SELDON_CHECK_DIMENSIONS
2509 if (A.GetM() != B.GetM())
2510 throw WrongDim(
"GetEigenvalues",
2511 "Matrix A and B must have the same size");
2516 char uplo(
'U'), job(
'N');
2518 Vector<complex<double> > work(lwork);
2519 Vector<double> rwork(3*n);
2521 zhegv_(&itype, &job, &uplo, &n, A.GetData(), &n, B.GetData(), &n,
2522 w.GetData(), work.GetData(), &lwork, rwork.GetData(),
2523 &info.GetInfoRef());
2525 #ifdef SELDON_LAPACK_CHECK_INFO
2526 if (info.GetInfo() != 0)
2527 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2528 "Failed to find eigenvalues ");
2534 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
2535 class Allocator3,
class Allocator4>
2536 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
2537 Prop1, ColHerm, Allocator1>& A,
2538 Matrix<complex<double>,
2539 Prop2, ColHerm, Allocator2>& B,
2540 Vector<double, VectFull, Allocator3>& w,
2541 Matrix<complex<double>,
2542 General, ColMajor, Allocator4>& z,
2545 #ifdef SELDON_CHECK_DIMENSIONS
2546 if (A.GetM() != B.GetM())
2547 throw WrongDim(
"GetEigenvaluesEigenvectors",
2548 "Matrix A and B must have the same size");
2553 char uplo(
'U'), job(
'V');
2555 for (
int i = 0; i < n; i++)
2556 for (
int j = 0; j < n; j++)
2561 Vector<complex<double> > work(lwork);
2563 Vector<double> rwork(3*n);
2565 zhegv_(&itype, &job, &uplo, &n, z.GetData(), &n, B.GetData(), &n,
2566 w.GetData(), work.GetData(), &lwork,
2567 rwork.GetData(), &info.GetInfoRef());
2569 #ifdef SELDON_LAPACK_CHECK_INFO
2570 if (info.GetInfo() != 0)
2571 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2572 "Failed to find eigenvalues ");
2581 template<
class Prop1,
class Prop2,
class Allocator1,
2582 class Allocator2,
class Allocator3>
2583 void GetEigenvalues(Matrix<float, Prop1, RowSymPacked, Allocator1>& A,
2584 Matrix<float, Prop2, RowSymPacked, Allocator2>& B,
2585 Vector<float, VectFull, Allocator3>& w,
2588 #ifdef SELDON_CHECK_DIMENSIONS
2589 if (A.GetM() != B.GetM())
2590 throw WrongDim(
"GetEigenvalues",
2591 "Matrix A and B must have the same size");
2596 char uplo(
'L');
char job(
'N');
2597 int lwork = 3*n; Vector<float> work(lwork);
2599 sspgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(), w.GetData(),
2600 A.GetData(), &n, work.GetData(), &info.GetInfoRef());
2602 #ifdef SELDON_LAPACK_CHECK_INFO
2603 if (info.GetInfo() != 0)
2604 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2605 "Failed to find eigenvalues ");
2611 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
2612 class Allocator3,
class Allocator4>
2613 void GetEigenvaluesEigenvectors(Matrix<
float,
2614 Prop1, RowSymPacked, Allocator1>& A,
2616 Prop2, RowSymPacked, Allocator2>& B,
2617 Vector<float, VectFull, Allocator3>& w,
2619 General, RowMajor, Allocator4>& z,
2622 #ifdef SELDON_CHECK_DIMENSIONS
2623 if (A.GetM() != B.GetM())
2624 throw WrongDim(
"GetEigenvaluesEigenvectors",
2625 "Matrix A and B must have the same size");
2630 char uplo(
'L');
char job(
'V');
2631 int lwork = 3*n; Vector<float> work(lwork);
2634 sspgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(), w.GetData(),
2635 z.GetData(), &n, work.GetData(), &info.GetInfoRef());
2637 #ifdef SELDON_LAPACK_CHECK_INFO
2638 if (info.GetInfo() != 0)
2639 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2640 "Failed to find eigenvalues ");
2647 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
2648 class Allocator3,
class Allocator4>
2649 void GetEigenvalues(Matrix<complex<float>,
2650 Prop1, RowSymPacked, Allocator1>& A,
2651 Matrix<complex<float>,
2652 Prop2, RowSymPacked, Allocator2>& B,
2653 Vector<complex<float>, VectFull, Allocator3>& alpha,
2654 Vector<complex<float>, VectFull, Allocator4>& beta,
2657 #ifdef SELDON_CHECK_DIMENSIONS
2658 if (A.GetM() != B.GetM())
2659 throw WrongDim(
"GetEigenvalues",
2660 "Matrix A and B must have the same size");
2664 Matrix<complex<float>, General, ColMajor> C(n,n), D(n,n);
2665 for (
int i = 0; i < n; i++)
2666 for (
int j = 0; j < n; j++)
2674 alpha.Reallocate(n);
2676 GetEigenvalues(C, D, alpha, beta, info);
2680 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
2681 class Allocator3,
class Allocator4,
class Allocator5>
2682 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
2683 Prop1, RowSymPacked, Allocator1>& A,
2684 Matrix<complex<float>,
2685 Prop2, RowSymPacked, Allocator2>& B,
2686 Vector<complex<float>,
2687 VectFull, Allocator3>& alpha,
2688 Vector<complex<float>,
2689 VectFull, Allocator4>& beta,
2690 Matrix<complex<float>,
2691 General, RowMajor, Allocator5>& z,
2694 #ifdef SELDON_CHECK_DIMENSIONS
2695 if (A.GetM() != B.GetM())
2696 throw WrongDim(
"GetEigenvaluesEigenvectors",
2697 "Matrix A and B must have the same size");
2701 Matrix<complex<float>, General, RowMajor> C(n,n), D(n,n);
2702 for (
int i = 0; i < n; i++)
2703 for (
int j = 0; j < n; j++)
2711 alpha.Reallocate(n);
2714 GetEigenvaluesEigenvectors(C, D, alpha, beta, z, info);
2718 template<
class Prop1,
class Prop2,
class Allocator1,
2719 class Allocator2,
class Allocator3>
2720 void GetEigenvalues(Matrix<double, Prop1, RowSymPacked, Allocator1>& A,
2721 Matrix<double, Prop2, RowSymPacked, Allocator2>& B,
2722 Vector<double, VectFull, Allocator3>& w,
2725 #ifdef SELDON_CHECK_DIMENSIONS
2726 if (A.GetM() != B.GetM())
2727 throw WrongDim(
"GetEigenvalues",
2728 "Matrix A and B must have the same size");
2733 char uplo(
'L');
char job(
'N');
2734 int lwork = 3*n; Vector<double> work(lwork);
2736 dspgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(), w.GetData(),
2737 A.GetData(), &n, work.GetData(), &info.GetInfoRef());
2739 #ifdef SELDON_LAPACK_CHECK_INFO
2740 if (info.GetInfo() != 0)
2741 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2742 "Failed to find eigenvalues ");
2748 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
2749 class Allocator3,
class Allocator4>
2750 void GetEigenvaluesEigenvectors(Matrix<
double,
2751 Prop1, RowSymPacked, Allocator1>& A,
2753 Prop2, RowSymPacked, Allocator2>& B,
2754 Vector<double, VectFull, Allocator3>& w,
2756 General, RowMajor, Allocator4>& z,
2759 #ifdef SELDON_CHECK_DIMENSIONS
2760 if (A.GetM() != B.GetM())
2761 throw WrongDim(
"GetEigenvaluesEigenvectors",
2762 "Matrix A and B must have the same size");
2767 char uplo(
'L');
char job(
'V');
2768 int lwork = 3*n; Vector<double> work(lwork);
2771 dspgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(), w.GetData(),
2772 z.GetData(), &n, work.GetData(), &info.GetInfoRef());
2774 #ifdef SELDON_LAPACK_CHECK_INFO
2775 if (info.GetInfo() != 0)
2776 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2777 "Failed to find eigenvalues ");
2784 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
2785 class Allocator3,
class Allocator4>
2786 void GetEigenvalues(Matrix<complex<double>,
2787 Prop1, RowSymPacked, Allocator1>& A,
2788 Matrix<complex<double>,
2789 Prop2, RowSymPacked, Allocator2>& B,
2790 Vector<complex<double>, VectFull, Allocator3>& alpha,
2791 Vector<complex<double>, VectFull, Allocator4>& beta,
2794 #ifdef SELDON_CHECK_DIMENSIONS
2795 if (A.GetM() != B.GetM())
2796 throw WrongDim(
"GetEigenvalues",
2797 "Matrix A and B must have the same size");
2801 Matrix<complex<double>, General, ColMajor> C(n,n), D(n,n);
2802 for (
int i = 0; i < n; i++)
2803 for (
int j = 0; j < n; j++)
2811 alpha.Reallocate(n);
2813 GetEigenvalues(C, D, alpha, beta, info);
2817 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
2818 class Allocator3,
class Allocator4,
class Allocator5>
2819 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
2820 Prop1, RowSymPacked, Allocator1>& A,
2821 Matrix<complex<double>,
2822 Prop2, RowSymPacked, Allocator2>& B,
2823 Vector<complex<double>,
2824 VectFull, Allocator3>& alpha,
2825 Vector<complex<double>,
2826 VectFull, Allocator4>& beta,
2827 Matrix<complex<double>,
2828 General, RowMajor, Allocator5>& z,
2831 #ifdef SELDON_CHECK_DIMENSIONS
2832 if (A.GetM() != B.GetM())
2833 throw WrongDim(
"GetEigenvaluesEigenvectors",
2834 "Matrix A and B must have the same size");
2838 Matrix<complex<double>, General, RowMajor> C(n,n), D(n,n);
2839 for (
int i = 0; i < n; i++)
2840 for (
int j = 0; j < n; j++)
2848 alpha.Reallocate(n);
2851 GetEigenvaluesEigenvectors(C, D, alpha, beta, z, info);
2858 template<
class Prop1,
class Prop2,
class Allocator1,
2859 class Allocator2,
class Allocator3>
2860 void GetEigenvalues(Matrix<float, Prop1, ColSymPacked, Allocator1>& A,
2861 Matrix<float, Prop2, ColSymPacked, Allocator2>& B,
2862 Vector<float, VectFull, Allocator3>& w,
2865 #ifdef SELDON_CHECK_DIMENSIONS
2866 if (A.GetM() != B.GetM())
2867 throw WrongDim(
"GetEigenvalues",
2868 "Matrix A and B must have the same size");
2873 char uplo(
'U');
char job(
'N');
2874 int lwork = 3*n; Vector<float> work(lwork);
2876 sspgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(), w.GetData(),
2877 A.GetData(), &n, work.GetData(), &info.GetInfoRef());
2879 #ifdef SELDON_LAPACK_CHECK_INFO
2880 if (info.GetInfo() != 0)
2881 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2882 "Failed to find eigenvalues ");
2888 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
2889 class Allocator3,
class Allocator4>
2890 void GetEigenvaluesEigenvectors(Matrix<
float,
2891 Prop1, ColSymPacked, Allocator1>& A,
2893 Prop2, ColSymPacked, Allocator2>& B,
2894 Vector<float, VectFull, Allocator3>& w,
2896 General, ColMajor, Allocator4>& z,
2899 #ifdef SELDON_CHECK_DIMENSIONS
2900 if (A.GetM() != B.GetM())
2901 throw WrongDim(
"GetEigenvaluesEigenvectors",
2902 "Matrix A and B must have the same size");
2907 char uplo(
'U');
char job(
'V');
int lwork = 3*n;
2908 Vector<float> work(lwork);
2911 sspgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(), w.GetData(),
2912 z.GetData(), &n, work.GetData(), &info.GetInfoRef());
2914 #ifdef SELDON_LAPACK_CHECK_INFO
2915 if (info.GetInfo() != 0)
2916 throw LapackError(info.GetInfo(),
"GetEigenvalues",
2917 "Failed to find eigenvalues ");
2923 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
2924 class Allocator3,
class Allocator4>
2925 void GetEigenvalues(Matrix<complex<float>,
2926 Prop1, ColSymPacked, Allocator1>& A,
2927 Matrix<complex<float>,
2928 Prop2, ColSymPacked, Allocator2>& B,
2929 Vector<complex<float>, VectFull, Allocator3>& alpha,
2930 Vector<complex<float>, VectFull, Allocator4>& beta,
2933 #ifdef SELDON_CHECK_DIMENSIONS
2934 if (A.GetM() != B.GetM())
2935 throw WrongDim(
"GetEigenvalues",
2936 "Matrix A and B must have the same size");
2940 Matrix<complex<float>, General, ColMajor> C(n,n), D(n,n);
2941 for (
int i = 0; i < n; i++)
2942 for (
int j = 0; j < n; j++)
2950 alpha.Reallocate(n);
2952 GetEigenvalues(C, D, alpha, beta, info);
2956 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
2957 class Allocator3,
class Allocator4,
class Allocator5>
2958 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
2959 Prop1, ColSymPacked, Allocator1>& A,
2960 Matrix<complex<float>,
2961 Prop2, ColSymPacked, Allocator2>& B,
2962 Vector<complex<float>,
2963 VectFull, Allocator3>& alpha,
2964 Vector<complex<float>,
2965 VectFull, Allocator4>& beta,
2966 Matrix<complex<float>,
2967 General, ColMajor, Allocator5>& z,
2970 #ifdef SELDON_CHECK_DIMENSIONS
2971 if (A.GetM() != B.GetM())
2972 throw WrongDim(
"GetEigenvaluesEigenvectors",
2973 "Matrix A and B must have the same size");
2977 Matrix<complex<float>, General, ColMajor> C(n,n), D(n,n);
2978 for (
int i = 0; i < n; i++)
2979 for (
int j = 0; j < n; j++)
2987 alpha.Reallocate(n);
2990 GetEigenvaluesEigenvectors(C, D, alpha, beta, z, info);
2994 template<
class Prop1,
class Prop2,
class Allocator1,
2995 class Allocator2,
class Allocator3>
2996 void GetEigenvalues(Matrix<double, Prop1, ColSymPacked, Allocator1>& A,
2997 Matrix<double, Prop2, ColSymPacked, Allocator2>& B,
2998 Vector<double, VectFull, Allocator3>& w,
3001 #ifdef SELDON_CHECK_DIMENSIONS
3002 if (A.GetM() != B.GetM())
3003 throw WrongDim(
"GetEigenvalues",
3004 "Matrix A and B must have the same size");
3009 char uplo(
'U');
char job(
'N');
3010 int lwork = 3*n; Vector<double> work(lwork);
3012 dspgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(), w.GetData(),
3013 A.GetData(), &n, work.GetData(), &info.GetInfoRef());
3015 #ifdef SELDON_LAPACK_CHECK_INFO
3016 if (info.GetInfo() != 0)
3017 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3018 "Failed to find eigenvalues ");
3024 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
3025 class Allocator3,
class Allocator4>
3026 void GetEigenvaluesEigenvectors(Matrix<
double,
3027 Prop1, ColSymPacked, Allocator1>& A,
3029 Prop2, ColSymPacked, Allocator2>& B,
3030 Vector<double, VectFull, Allocator3>& w,
3032 General, ColMajor, Allocator4>& z,
3035 #ifdef SELDON_CHECK_DIMENSIONS
3036 if (A.GetM() != B.GetM())
3037 throw WrongDim(
"GetEigenvaluesEigenvectors",
3038 "Matrix A and B must have the same size");
3043 char uplo(
'U');
char job(
'V');
int lwork = 3*n;
3044 Vector<double> work(lwork);
3047 dspgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(), w.GetData(),
3048 z.GetData(), &n, work.GetData(), &info.GetInfoRef());
3050 #ifdef SELDON_LAPACK_CHECK_INFO
3051 if (info.GetInfo() != 0)
3052 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3053 "Failed to find eigenvalues ");
3059 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
3060 class Allocator3,
class Allocator4>
3061 void GetEigenvalues(Matrix<complex<double>,
3062 Prop1, ColSymPacked, Allocator1>& A,
3063 Matrix<complex<double>,
3064 Prop2, ColSymPacked, Allocator2>& B,
3065 Vector<complex<double>, VectFull, Allocator3>& alpha,
3066 Vector<complex<double>, VectFull, Allocator4>& beta,
3069 #ifdef SELDON_CHECK_DIMENSIONS
3070 if (A.GetM() != B.GetM())
3071 throw WrongDim(
"GetEigenvalues",
3072 "Matrix A and B must have the same size");
3076 Matrix<complex<double>, General, ColMajor> C(n,n), D(n,n);
3077 for (
int i = 0; i < n; i++)
3078 for (
int j = 0; j < n; j++)
3086 alpha.Reallocate(n);
3088 GetEigenvalues(C, D, alpha, beta, info);
3092 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
3093 class Allocator3,
class Allocator4,
class Allocator5>
3094 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
3095 Prop1, ColSymPacked, Allocator1>& A,
3096 Matrix<complex<double>,
3097 Prop2, ColSymPacked, Allocator2>& B,
3098 Vector<complex<double>,
3099 VectFull, Allocator3>& alpha,
3100 Vector<complex<double>,
3101 VectFull, Allocator4>& beta,
3102 Matrix<complex<double>,
3103 General, ColMajor, Allocator5>& z,
3106 #ifdef SELDON_CHECK_DIMENSIONS
3107 if (A.GetM() != B.GetM())
3108 throw WrongDim(
"GetEigenvaluesEigenvectors",
3109 "Matrix A and B must have the same size");
3113 Matrix<complex<double>, General, ColMajor> C(n,n), D(n,n);
3114 for (
int i = 0; i < n; i++)
3115 for (
int j = 0; j < n; j++)
3123 alpha.Reallocate(n);
3126 GetEigenvaluesEigenvectors(C, D, alpha, beta, z, info);
3133 template<
class Prop1,
class Prop2,
class Allocator1,
3134 class Allocator2,
class Allocator3>
3135 void GetEigenvalues(Matrix<complex<float>,
3136 Prop1, RowHermPacked, Allocator1>& A,
3137 Matrix<complex<float>,
3138 Prop2, RowHermPacked, Allocator2>& B,
3139 Vector<float, VectFull, Allocator3>& w,
3142 #ifdef SELDON_CHECK_DIMENSIONS
3143 if (A.GetM() != B.GetM())
3144 throw WrongDim(
"GetEigenvalues",
3145 "Matrix A and B must have the same size");
3150 char uplo(
'L'), job(
'N');
3152 Vector<complex<float> > work(lwork);
3153 Vector<float> rwork(3*n);
3156 chpgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(), w.GetData(),
3157 A.GetData(), &n, work.GetData(), rwork.GetData(),
3158 &info.GetInfoRef());
3160 #ifdef SELDON_LAPACK_CHECK_INFO
3161 if (info.GetInfo() != 0)
3162 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3163 "Failed to find eigenvalues ");
3169 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
3170 class Allocator3,
class Allocator4>
3171 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
3172 Prop1, RowHermPacked, Allocator1>& A,
3173 Matrix<complex<float>,
3174 Prop2, RowHermPacked, Allocator2>& B,
3175 Vector<float, VectFull, Allocator3>& w,
3176 Matrix<complex<float>,
3177 General, RowMajor, Allocator4>& z,
3180 #ifdef SELDON_CHECK_DIMENSIONS
3181 if (A.GetM() != B.GetM())
3182 throw WrongDim(
"GetEigenvaluesEigenvectors",
3183 "Matrix A and B must have the same size");
3188 char uplo(
'L');
char job(
'V');
int lwork = 2*n;
3189 Vector<complex<float> > work(lwork);
3190 Vector<float> rwork(3*n);
3194 chpgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(), w.GetData(),
3195 z.GetData(), &n, work.GetData(), rwork.GetData(),
3196 &info.GetInfoRef());
3198 #ifdef SELDON_LAPACK_CHECK_INFO
3199 if (info.GetInfo() != 0)
3200 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3201 "Failed to find eigenvalues ");
3208 template<
class Prop1,
class Prop2,
class Allocator1,
3209 class Allocator2,
class Allocator3>
3210 void GetEigenvalues(Matrix<complex<double>,
3211 Prop1, RowHermPacked, Allocator1>& A,
3212 Matrix<complex<double>,
3213 Prop2, RowHermPacked, Allocator2>& B,
3214 Vector<double, VectFull, Allocator3>& w,
3217 #ifdef SELDON_CHECK_DIMENSIONS
3218 if (A.GetM() != B.GetM())
3219 throw WrongDim(
"GetEigenvalues",
3220 "Matrix A and B must have the same size");
3225 char uplo(
'L'), job(
'N');
3227 Vector<complex<double> > work(lwork);
3228 Vector<double> rwork(3*n);
3231 zhpgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(), w.GetData(),
3232 A.GetData(), &n, work.GetData(), rwork.GetData(),
3233 &info.GetInfoRef());
3235 #ifdef SELDON_LAPACK_CHECK_INFO
3236 if (info.GetInfo() != 0)
3237 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3238 "Failed to find eigenvalues ");
3244 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
3245 class Allocator3,
class Allocator4>
3246 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
3247 Prop1, RowHermPacked, Allocator1>& A,
3248 Matrix<complex<double>,
3249 Prop2, RowHermPacked, Allocator2>& B,
3250 Vector<double, VectFull, Allocator3>& w,
3251 Matrix<complex<double>,
3252 General, RowMajor, Allocator4>& z,
3255 #ifdef SELDON_CHECK_DIMENSIONS
3256 if (A.GetM() != B.GetM())
3257 throw WrongDim(
"GetEigenvaluesEigenvectors",
3258 "Matrix A and B must have the same size");
3263 char uplo(
'L');
char job(
'V');
int lwork = 2*n;
3264 Vector<complex<double> > work(lwork);
3265 Vector<double> rwork(3*n);
3269 zhpgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(), w.GetData(),
3270 z.GetData(), &n, work.GetData(), rwork.GetData(),
3271 &info.GetInfoRef());
3273 #ifdef SELDON_LAPACK_CHECK_INFO
3274 if (info.GetInfo() != 0)
3275 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3276 "Failed to find eigenvalues ");
3286 template<
class Prop1,
class Prop2,
class Allocator1,
3287 class Allocator2,
class Allocator3>
3288 void GetEigenvalues(Matrix<complex<float>,
3289 Prop1, ColHermPacked, Allocator1>& A,
3290 Matrix<complex<float>,
3291 Prop2, ColHermPacked, Allocator2>& B,
3292 Vector<float, VectFull, Allocator3>& w,
3295 #ifdef SELDON_CHECK_DIMENSIONS
3296 if (A.GetM() != B.GetM())
3297 throw WrongDim(
"GetEigenvalues",
3298 "Matrix A and B must have the same size");
3303 char uplo(
'U');
char job(
'N');
3305 Vector<complex<float> > work(lwork);
3306 Vector<float> rwork(3*n);
3308 chpgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(),
3309 w.GetData(), A.GetData(), &n, work.GetData(),
3310 rwork.GetData(), &info.GetInfoRef());
3312 #ifdef SELDON_LAPACK_CHECK_INFO
3313 if (info.GetInfo() != 0)
3314 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3315 "Failed to find eigenvalues ");
3321 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
3322 class Allocator3,
class Allocator4>
3323 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
3324 Prop1, ColHermPacked, Allocator1>& A,
3325 Matrix<complex<float>,
3326 Prop2, ColHermPacked, Allocator2>& B,
3327 Vector<float, VectFull, Allocator3>& w,
3328 Matrix<complex<float>,
3329 General, ColMajor, Allocator4>& z,
3332 #ifdef SELDON_CHECK_DIMENSIONS
3333 if (A.GetM() != B.GetM())
3334 throw WrongDim(
"GetEigenvaluesEigenvectors",
3335 "Matrix A and B must have the same size");
3340 char uplo(
'U');
char job(
'V');
3342 Vector<complex<float> > work(lwork);
3343 Vector<float> rwork(3*n);
3346 chpgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(), w.GetData(),
3347 z.GetData(), &n, work.GetData(), rwork.GetData(),
3348 &info.GetInfoRef());
3350 #ifdef SELDON_LAPACK_CHECK_INFO
3351 if (info.GetInfo() != 0)
3352 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3353 "Failed to find eigenvalues ");
3359 template<
class Prop1,
class Prop2,
class Allocator1,
3360 class Allocator2,
class Allocator3>
3361 void GetEigenvalues(Matrix<complex<double>,
3362 Prop1, ColHermPacked, Allocator1>& A,
3363 Matrix<complex<double>,
3364 Prop2, ColHermPacked, Allocator2>& B,
3365 Vector<double, VectFull, Allocator3>& w,
3368 #ifdef SELDON_CHECK_DIMENSIONS
3369 if (A.GetM() != B.GetM())
3370 throw WrongDim(
"GetEigenvalues",
3371 "Matrix A and B must have the same size");
3376 char uplo(
'U');
char job(
'N');
3378 Vector<complex<double> > work(lwork);
3379 Vector<double> rwork(3*n);
3381 zhpgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(),
3382 w.GetData(), A.GetData(), &n, work.GetData(),
3383 rwork.GetData(), &info.GetInfoRef());
3385 #ifdef SELDON_LAPACK_CHECK_INFO
3386 if (info.GetInfo() != 0)
3387 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3388 "Failed to find eigenvalues ");
3394 template<
class Prop1,
class Prop2,
class Allocator1,
class Allocator2,
3395 class Allocator3,
class Allocator4>
3396 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
3397 Prop1, ColHermPacked, Allocator1>& A,
3398 Matrix<complex<double>,
3399 Prop2, ColHermPacked, Allocator2>& B,
3400 Vector<double, VectFull, Allocator3>& w,
3401 Matrix<complex<double>,
3402 General, ColMajor, Allocator4>& z,
3405 #ifdef SELDON_CHECK_DIMENSIONS
3406 if (A.GetM() != B.GetM())
3407 throw WrongDim(
"GetEigenvaluesEigenvectors",
3408 "Matrix A and B must have the same size");
3413 char uplo(
'U');
char job(
'V');
3415 Vector<complex<double> > work(lwork);
3416 Vector<double> rwork(3*n);
3419 zhpgv_(&itype, &job, &uplo, &n, A.GetData(), B.GetData(), w.GetData(),
3420 z.GetData(), &n, work.GetData(), rwork.GetData(),
3421 &info.GetInfoRef());
3423 #ifdef SELDON_LAPACK_CHECK_INFO
3424 if (info.GetInfo() != 0)
3425 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3426 "Failed to find eigenvalues ");
3435 template<
class Prop1,
class Prop2,
class Allocator1,
3436 class Allocator2,
class Allocator3,
3437 class Allocator4,
class Allocator5>
3438 void GetEigenvalues(Matrix<float, Prop1, RowMajor, Allocator1>& A,
3439 Matrix<float, Prop2, RowMajor, Allocator2>& B,
3440 Vector<float, VectFull, Allocator3>& alpha_real,
3441 Vector<float, VectFull, Allocator4>& alpha_imag,
3442 Vector<float, VectFull, Allocator5>& beta,
3445 #ifdef SELDON_CHECK_DIMENSIONS
3446 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
3447 throw WrongDim(
"GetEigenvalues",
3448 "Matrix A and B must be squared");
3450 if (A.GetM() != B.GetM())
3451 throw WrongDim(
"GetEigenvalues",
3452 "Matrix A and B must have the same size");
3456 char jobvl(
'N'), jobvr(
'N');
3457 int lwork = 8*n+16; Vector<float> work(lwork);
3458 alpha_real.Reallocate(n);
3459 alpha_imag.Reallocate(n);
3461 sggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(), &n,
3462 alpha_real.GetData(), alpha_imag.GetData(), beta.GetData(),
3463 A.GetData(), &n, A.GetData(), &n,
3464 work.GetData(), &lwork, &info.GetInfoRef());
3466 #ifdef SELDON_LAPACK_CHECK_INFO
3467 if (info.GetInfo() != 0)
3468 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3469 "Failed to find eigenvalues ");
3475 template<
class Prop1,
class Prop2,
class Prop3,
class Allocator1,
3476 class Allocator2,
class Allocator3,
class Allocator4,
3477 class Allocator5,
class Allocator6>
3478 void GetEigenvaluesEigenvectors(Matrix<float, Prop1, RowMajor, Allocator1>& A,
3479 Matrix<float, Prop2, RowMajor, Allocator2>& B,
3480 Vector<float, VectFull, Allocator3>& alpha_real,
3481 Vector<float, VectFull, Allocator4>& alpha_imag,
3482 Vector<float, VectFull, Allocator5>& beta,
3483 Matrix<float, Prop3, RowMajor, Allocator6>& V,
3486 #ifdef SELDON_CHECK_DIMENSIONS
3487 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
3488 throw WrongDim(
"GetEigenvaluesEigenvectors",
3489 "Matrix A and B must be squared");
3491 if (A.GetM() != B.GetM())
3492 throw WrongDim(
"GetEigenvaluesEigenvectors",
3493 "Matrix A and B must have the same size");
3497 char jobvl(
'V'), jobvr(
'N');
3498 int lwork = 8*n+16; Vector<float> work(lwork);
3499 alpha_real.Reallocate(n);
3500 alpha_imag.Reallocate(n);
3503 sggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(), &n,
3504 alpha_real.GetData(), alpha_imag.GetData(), beta.GetData(),
3505 V.GetData(), &n, V.GetData(), &n,
3506 work.GetData(), &lwork, &info.GetInfoRef());
3509 #ifdef SELDON_LAPACK_CHECK_INFO
3510 if (info.GetInfo() != 0)
3511 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3512 "Failed to find eigenvalues ");
3521 if (alpha_real(i) == alpha_real(i+1))
3523 for (
int j = 0; j < n; j++)
3524 V(j,i+1) = -V(j,i+1);
3534 template<
class Prop1,
class Prop2,
class Allocator1,
3535 class Allocator2,
class Allocator4,
class Allocator5>
3536 void GetEigenvalues(Matrix<complex<float>, Prop1, RowMajor, Allocator1>& A,
3537 Matrix<complex<float>, Prop2, RowMajor, Allocator2>& B,
3538 Vector<complex<float>, VectFull, Allocator4>& alpha,
3539 Vector<complex<float>, VectFull, Allocator5>& beta,
3542 #ifdef SELDON_CHECK_DIMENSIONS
3543 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
3544 throw WrongDim(
"GetEigenvalues",
3545 "Matrix A and B must be squared");
3547 if (A.GetM() != B.GetM())
3548 throw WrongDim(
"GetEigenvalues",
3549 "Matrix A and B must have the same size");
3553 char jobvl(
'N'), jobvr(
'N');
int lwork = 2*n;
3554 Vector<complex<float> > work(lwork);
3555 Vector<float> rwork(8*n);
3556 alpha.Reallocate(n);
3558 cggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(), &n,
3559 alpha.GetData(), beta.GetData(), A.GetData(), &n, A.GetData(), &n,
3560 work.GetData(), &lwork, rwork.GetData(), &info.GetInfoRef());
3562 #ifdef SELDON_LAPACK_CHECK_INFO
3563 if (info.GetInfo() != 0)
3564 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3565 "Failed to find eigenvalues ");
3571 template<
class Prop1,
class Prop2,
class Prop3,
class Allocator1,
3572 class Allocator2,
class Allocator4,
3573 class Allocator5,
class Allocator6>
3574 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
3575 Prop1, RowMajor, Allocator1>& A,
3576 Matrix<complex<float>,
3577 Prop2, RowMajor, Allocator2>& B,
3578 Vector<complex<float>,
3579 VectFull, Allocator4>& alpha,
3580 Vector<complex<float>,
3581 VectFull, Allocator5>& beta,
3582 Matrix<complex<float>,
3583 Prop3, RowMajor, Allocator6>& V,
3586 #ifdef SELDON_CHECK_DIMENSIONS
3587 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
3588 throw WrongDim(
"GetEigenvaluesEigenvectors",
3589 "Matrix A and B must be squared");
3591 if (A.GetM() != B.GetM())
3592 throw WrongDim(
"GetEigenvaluesEigenvectors",
3593 "Matrix A and B must have the same size");
3597 char jobvl(
'V'), jobvr(
'N');
3598 int lwork = 2*n; Vector<complex<float> > work(lwork);
3599 Vector<float> rwork(8*n);
3600 alpha.Reallocate(n);
3603 cggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(), &n, alpha.GetData(),
3604 beta.GetData(), V.GetData(), &n, V.GetData(), &n, work.GetData(),
3605 &lwork, rwork.GetData(), &info.GetInfoRef());
3608 #ifdef SELDON_LAPACK_CHECK_INFO
3609 if (info.GetInfo() != 0)
3610 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3611 "Failed to find eigenvalues ");
3618 template<
class Prop1,
class Prop2,
class Allocator1,
3619 class Allocator2,
class Allocator3,
3620 class Allocator4,
class Allocator5>
3621 void GetEigenvalues(Matrix<double, Prop1, RowMajor, Allocator1>& A,
3622 Matrix<double, Prop2, RowMajor, Allocator2>& B,
3623 Vector<double, VectFull, Allocator3>& alpha_real,
3624 Vector<double, VectFull, Allocator4>& alpha_imag,
3625 Vector<double, VectFull, Allocator5>& beta,
3628 #ifdef SELDON_CHECK_DIMENSIONS
3629 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
3630 throw WrongDim(
"GetEigenvalues",
3631 "Matrix A and B must be squared");
3633 if (A.GetM() != B.GetM())
3634 throw WrongDim(
"GetEigenvalues",
3635 "Matrix A and B must have the same size");
3639 char jobvl(
'N'), jobvr(
'N');
3640 int lwork = 8*n+16; Vector<double> work(lwork);
3641 alpha_real.Reallocate(n);
3642 alpha_imag.Reallocate(n);
3644 dggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(), &n,
3645 alpha_real.GetData(), alpha_imag.GetData(), beta.GetData(),
3646 A.GetData(), &n, A.GetData(), &n,
3647 work.GetData(), &lwork, &info.GetInfoRef());
3649 #ifdef SELDON_LAPACK_CHECK_INFO
3650 if (info.GetInfo() != 0)
3651 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3652 "Failed to find eigenvalues ");
3658 template<
class Prop1,
class Prop2,
class Prop3,
class Allocator1,
3659 class Allocator2,
class Allocator3,
class Allocator4,
3660 class Allocator5,
class Allocator6>
3661 void GetEigenvaluesEigenvectors(Matrix<double, Prop1, RowMajor, Allocator1>& A,
3662 Matrix<double, Prop2, RowMajor, Allocator2>& B,
3663 Vector<double, VectFull, Allocator3>& alpha_real,
3664 Vector<double, VectFull, Allocator4>& alpha_imag,
3665 Vector<double, VectFull, Allocator5>& beta,
3666 Matrix<double, Prop3, RowMajor, Allocator6>& V,
3669 #ifdef SELDON_CHECK_DIMENSIONS
3670 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
3671 throw WrongDim(
"GetEigenvaluesEigenvectors",
3672 "Matrix A and B must be squared");
3674 if (A.GetM() != B.GetM())
3675 throw WrongDim(
"GetEigenvaluesEigenvectors",
3676 "Matrix A and B must have the same size");
3680 char jobvl(
'V'), jobvr(
'N');
3681 int lwork = 8*n+16; Vector<double> work(lwork);
3682 alpha_real.Reallocate(n);
3683 alpha_imag.Reallocate(n);
3686 dggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(), &n,
3687 alpha_real.GetData(), alpha_imag.GetData(), beta.GetData(),
3688 V.GetData(), &n, V.GetData(), &n,
3689 work.GetData(), &lwork, &info.GetInfoRef());
3691 #ifdef SELDON_LAPACK_CHECK_INFO
3692 if (info.GetInfo() != 0)
3693 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3694 "Failed to find eigenvalues ");
3703 if (alpha_real(i) == alpha_real(i+1))
3705 for (
int j = 0; j < n; j++)
3706 V(j,i+1) = -V(j,i+1);
3716 template<
class Prop1,
class Prop2,
class Allocator1,
3717 class Allocator2,
class Allocator4,
class Allocator5>
3718 void GetEigenvalues(Matrix<complex<double>, Prop1, RowMajor, Allocator1>& A,
3719 Matrix<complex<double>, Prop2, RowMajor, Allocator2>& B,
3720 Vector<complex<double>, VectFull, Allocator4>& alpha,
3721 Vector<complex<double>, VectFull, Allocator5>& beta,
3724 #ifdef SELDON_CHECK_DIMENSIONS
3725 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
3726 throw WrongDim(
"GetEigenvalues",
3727 "Matrix A and B must be squared");
3729 if (A.GetM() != B.GetM())
3730 throw WrongDim(
"GetEigenvalues",
3731 "Matrix A and B must have the same size");
3735 char jobvl(
'N'), jobvr(
'N');
int lwork = 2*n;
3736 Vector<complex<double> > work(lwork);
3737 Vector<double> rwork(8*n);
3738 alpha.Reallocate(n);
3740 zggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(), &n,
3741 alpha.GetData(), beta.GetData(), A.GetData(), &n, A.GetData(), &n,
3742 work.GetData(), &lwork, rwork.GetData(), &info.GetInfoRef());
3744 #ifdef SELDON_LAPACK_CHECK_INFO
3745 if (info.GetInfo() != 0)
3746 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3747 "Failed to find eigenvalues ");
3753 template<
class Prop1,
class Prop2,
class Prop3,
class Allocator1,
3754 class Allocator2,
class Allocator4,
3755 class Allocator5,
class Allocator6>
3756 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
3757 Prop1, RowMajor, Allocator1>& A,
3758 Matrix<complex<double>,
3759 Prop2, RowMajor, Allocator2>& B,
3760 Vector<complex<double>,
3761 VectFull, Allocator4>& alpha,
3762 Vector<complex<double>,
3763 VectFull, Allocator5>& beta,
3764 Matrix<complex<double>,
3765 Prop3, RowMajor, Allocator6>& V,
3768 #ifdef SELDON_CHECK_DIMENSIONS
3769 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
3770 throw WrongDim(
"GetEigenvaluesEigenvectors",
3771 "Matrix A and B must be squared");
3773 if (A.GetM() != B.GetM())
3774 throw WrongDim(
"GetEigenvaluesEigenvectors",
3775 "Matrix A and B must have the same size");
3779 char jobvl(
'V'), jobvr(
'N');
3780 int lwork = 2*n; Vector<complex<double> > work(lwork);
3781 Vector<double> rwork(8*n);
3782 alpha.Reallocate(n);
3785 zggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(), &n, alpha.GetData(),
3786 beta.GetData(), V.GetData(), &n, V.GetData(), &n, work.GetData(),
3787 &lwork, rwork.GetData(), &info.GetInfoRef());
3789 #ifdef SELDON_LAPACK_CHECK_INFO
3790 if (info.GetInfo() != 0)
3791 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3792 "Failed to find eigenvalues ");
3802 template<
class Prop1,
class Prop2,
class Allocator1,
3803 class Allocator2,
class Allocator3,
3804 class Allocator4,
class Allocator5>
3805 void GetEigenvalues(Matrix<float, Prop1, ColMajor, Allocator1>& A,
3806 Matrix<float, Prop2, ColMajor, Allocator2>& B,
3807 Vector<float, VectFull, Allocator3>& alpha_real,
3808 Vector<float, VectFull, Allocator4>& alpha_imag,
3809 Vector<float, VectFull, Allocator5>& beta,
3812 #ifdef SELDON_CHECK_DIMENSIONS
3813 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
3814 throw WrongDim(
"GetEigenvalues",
3815 "Matrix A and B must be squared");
3817 if (A.GetM() != B.GetM())
3818 throw WrongDim(
"GetEigenvalues",
3819 "Matrix A and B must have the same size");
3823 char jobvl(
'N'), jobvr(
'N');
3824 int lwork = 8*n+16; Vector<float> work(lwork);
3825 alpha_real.Reallocate(n);
3826 alpha_imag.Reallocate(n);
3829 sggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(), &n,
3830 alpha_real.GetData(), alpha_imag.GetData(), beta.GetData(),
3831 A.GetData(), &n, A.GetData(), &n,
3832 work.GetData(), &lwork, &info.GetInfoRef());
3834 #ifdef SELDON_LAPACK_CHECK_INFO
3835 if (info.GetInfo() != 0)
3836 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3837 "Failed to find eigenvalues ");
3843 template<
class Prop1,
class Prop2,
class Prop3,
class Allocator1,
3844 class Allocator2,
class Allocator3,
class Allocator4,
3845 class Allocator5,
class Allocator6>
3846 void GetEigenvaluesEigenvectors(Matrix<float, Prop1, ColMajor, Allocator1>& A,
3847 Matrix<float, Prop2, ColMajor, Allocator2>& B,
3849 VectFull, Allocator3>& alpha_real,
3851 VectFull, Allocator4>& alpha_imag,
3852 Vector<float, VectFull, Allocator5>& beta,
3853 Matrix<float, Prop3, ColMajor, Allocator6>& V,
3856 #ifdef SELDON_CHECK_DIMENSIONS
3857 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
3858 throw WrongDim(
"GetEigenvaluesEigenvectors",
3859 "Matrix A and B must be squared");
3861 if (A.GetM() != B.GetM())
3862 throw WrongDim(
"GetEigenvaluesEigenvectors",
3863 "Matrix A and B must have the same size");
3867 char jobvl(
'V'), jobvr(
'N');
3868 int lwork = 8*n+16; Vector<float> work(lwork);
3869 alpha_real.Reallocate(n);
3870 alpha_imag.Reallocate(n);
3873 sggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(),
3874 &n, alpha_real.GetData(), alpha_imag.GetData(),
3875 beta.GetData(), V.GetData(), &n, V.GetData(), &n,
3876 work.GetData(), &lwork, &info.GetInfoRef());
3878 #ifdef SELDON_LAPACK_CHECK_INFO
3879 if (info.GetInfo() != 0)
3880 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3881 "Failed to find eigenvalues ");
3887 template<
class Prop1,
class Prop2,
class Allocator1,
3888 class Allocator2,
class Allocator4,
class Allocator5>
3889 void GetEigenvalues(Matrix<complex<float>, Prop1, ColMajor, Allocator1>& A,
3890 Matrix<complex<float>, Prop2, ColMajor, Allocator2>& B,
3891 Vector<complex<float>, VectFull, Allocator4>& alpha,
3892 Vector<complex<float>, VectFull, Allocator5>& beta,
3895 #ifdef SELDON_CHECK_DIMENSIONS
3896 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
3897 throw WrongDim(
"GetEigenvalues",
3898 "Matrix A and B must be squared");
3900 if (A.GetM() != B.GetM())
3901 throw WrongDim(
"GetEigenvalues",
3902 "Matrix A and B must have the same size");
3906 char jobvl(
'N'), jobvr(
'N');
int lwork = 2*n;
3907 Vector<complex<float> > work(lwork);
3908 Vector<float> rwork(8*n);
3909 alpha.Reallocate(n);
3912 cggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(),
3913 &n, alpha.GetData(),
3914 beta.GetData(), A.GetData(), &n, A.GetData(), &n, work.GetData(),
3915 &lwork, rwork.GetData(), &info.GetInfoRef());
3917 #ifdef SELDON_LAPACK_CHECK_INFO
3918 if (info.GetInfo() != 0)
3919 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3920 "Failed to find eigenvalues ");
3926 template<
class Prop1,
class Prop2,
class Prop3,
class Allocator1,
3927 class Allocator2,
class Allocator4,
3928 class Allocator5,
class Allocator6>
3929 void GetEigenvaluesEigenvectors(Matrix<complex<float>,
3930 Prop1, ColMajor, Allocator1>& A,
3931 Matrix<complex<float>,
3932 Prop2, ColMajor, Allocator2>& B,
3933 Vector<complex<float>,
3934 VectFull, Allocator4>& alpha,
3935 Vector<complex<float>,
3936 VectFull, Allocator5>& beta,
3937 Matrix<complex<float>,
3938 Prop3, ColMajor, Allocator6>& V,
3941 #ifdef SELDON_CHECK_DIMENSIONS
3942 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
3943 throw WrongDim(
"GetEigenvaluesEigenvectors",
3944 "Matrix A and B must be squared");
3946 if (A.GetM() != B.GetM())
3947 throw WrongDim(
"GetEigenvaluesEigenvectors",
3948 "Matrix A and B must have the same size");
3952 char jobvl(
'N'), jobvr(
'V');
int lwork = 2*n;
3953 Vector<complex<float> > work(lwork);
3954 Vector<float> rwork(8*n);
3955 alpha.Reallocate(n);
3958 cggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(),
3959 &n, alpha.GetData(),
3960 beta.GetData(), V.GetData(), &n, V.GetData(), &n, work.GetData(),
3961 &lwork, rwork.GetData(), &info.GetInfoRef());
3963 #ifdef SELDON_LAPACK_CHECK_INFO
3964 if (info.GetInfo() != 0)
3965 throw LapackError(info.GetInfo(),
"GetEigenvalues",
3966 "Failed to find eigenvalues ");
3972 template<
class Prop1,
class Prop2,
class Allocator1,
3973 class Allocator2,
class Allocator3,
3974 class Allocator4,
class Allocator5>
3975 void GetEigenvalues(Matrix<double, Prop1, ColMajor, Allocator1>& A,
3976 Matrix<double, Prop2, ColMajor, Allocator2>& B,
3977 Vector<double, VectFull, Allocator3>& alpha_real,
3978 Vector<double, VectFull, Allocator4>& alpha_imag,
3979 Vector<double, VectFull, Allocator5>& beta,
3982 #ifdef SELDON_CHECK_DIMENSIONS
3983 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
3984 throw WrongDim(
"GetEigenvalues",
3985 "Matrix A and B must be squared");
3987 if (A.GetM() != B.GetM())
3988 throw WrongDim(
"GetEigenvalues",
3989 "Matrix A and B must have the same size");
3993 char jobvl(
'N'), jobvr(
'N');
3994 int lwork = 8*n+16; Vector<double> work(lwork);
3995 alpha_real.Reallocate(n);
3996 alpha_imag.Reallocate(n);
3999 dggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(), &n,
4000 alpha_real.GetData(), alpha_imag.GetData(), beta.GetData(),
4001 A.GetData(), &n, A.GetData(), &n,
4002 work.GetData(), &lwork, &info.GetInfoRef());
4004 #ifdef SELDON_LAPACK_CHECK_INFO
4005 if (info.GetInfo() != 0)
4006 throw LapackError(info.GetInfo(),
"GetEigenvalues",
4007 "Failed to find eigenvalues ");
4013 template<
class Prop1,
class Prop2,
class Prop3,
class Allocator1,
4014 class Allocator2,
class Allocator3,
class Allocator4,
4015 class Allocator5,
class Allocator6>
4016 void GetEigenvaluesEigenvectors(Matrix<double, Prop1, ColMajor, Allocator1>& A,
4017 Matrix<double, Prop2, ColMajor, Allocator2>& B,
4019 VectFull, Allocator3>& alpha_real,
4021 VectFull, Allocator4>& alpha_imag,
4022 Vector<double, VectFull, Allocator5>& beta,
4023 Matrix<double, Prop3, ColMajor, Allocator6>& V,
4026 #ifdef SELDON_CHECK_DIMENSIONS
4027 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
4028 throw WrongDim(
"GetEigenvaluesEigenvectors",
4029 "Matrix A and B must be squared");
4031 if (A.GetM() != B.GetM())
4032 throw WrongDim(
"GetEigenvaluesEigenvectors",
4033 "Matrix A and B must have the same size");
4037 char jobvl(
'V'), jobvr(
'N');
4038 int lwork = 8*n+16; Vector<double> work(lwork);
4039 alpha_real.Reallocate(n);
4040 alpha_imag.Reallocate(n);
4044 dggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(),
4045 &n, alpha_real.GetData(), alpha_imag.GetData(),
4046 beta.GetData(), V.GetData(), &n, V.GetData(), &n,
4047 work.GetData(), &lwork, &info.GetInfoRef());
4049 #ifdef SELDON_LAPACK_CHECK_INFO
4050 if (info.GetInfo() != 0)
4051 throw LapackError(info.GetInfo(),
"GetEigenvalues",
4052 "Failed to find eigenvalues ");
4058 template<
class Prop1,
class Prop2,
class Allocator1,
4059 class Allocator2,
class Allocator4,
class Allocator5>
4060 void GetEigenvalues(Matrix<complex<double>, Prop1, ColMajor, Allocator1>& A,
4061 Matrix<complex<double>, Prop2, ColMajor, Allocator2>& B,
4062 Vector<complex<double>, VectFull, Allocator4>& alpha,
4063 Vector<complex<double>, VectFull, Allocator5>& beta,
4066 #ifdef SELDON_CHECK_DIMENSIONS
4067 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
4068 throw WrongDim(
"GetEigenvalues",
4069 "Matrix A and B must be squared");
4071 if (A.GetM() != B.GetM())
4072 throw WrongDim(
"GetEigenvalues",
4073 "Matrix A and B must have the same size");
4077 char jobvl(
'N'), jobvr(
'N');
int lwork = 2*n;
4078 Vector<complex<double> > work(lwork);
4079 Vector<double> rwork(8*n);
4080 alpha.Reallocate(n);
4083 zggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(),
4084 &n, alpha.GetData(),
4085 beta.GetData(), A.GetData(), &n, A.GetData(), &n, work.GetData(),
4086 &lwork, rwork.GetData(), &info.GetInfoRef());
4088 #ifdef SELDON_LAPACK_CHECK_INFO
4089 if (info.GetInfo() != 0)
4090 throw LapackError(info.GetInfo(),
"GetEigenvalues",
4091 "Failed to find eigenvalues ");
4097 template<
class Prop1,
class Prop2,
class Prop3,
class Allocator1,
4098 class Allocator2,
class Allocator4,
4099 class Allocator5,
class Allocator6>
4100 void GetEigenvaluesEigenvectors(Matrix<complex<double>,
4101 Prop1, ColMajor, Allocator1>& A,
4102 Matrix<complex<double>,
4103 Prop2, ColMajor, Allocator2>& B,
4104 Vector<complex<double>,
4105 VectFull, Allocator4>& alpha,
4106 Vector<complex<double>,
4107 VectFull, Allocator5>& beta,
4108 Matrix<complex<double>,
4109 Prop3, ColMajor, Allocator6>& V,
4112 #ifdef SELDON_CHECK_DIMENSIONS
4113 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()) )
4114 throw WrongDim(
"GetEigenvaluesEigenvectors",
4115 "Matrix A and B must be squared");
4117 if (A.GetM() != B.GetM())
4118 throw WrongDim(
"GetEigenvaluesEigenvectors",
4119 "Matrix A and B must have the same size");
4123 char jobvl(
'N'), jobvr(
'V');
int lwork = 2*n;
4124 Vector<complex<double> > work(lwork);
4125 Vector<double> rwork(8*n);
4126 alpha.Reallocate(n);
4129 zggev_(&jobvl, &jobvr, &n, A.GetData(), &n, B.GetData(),
4130 &n, alpha.GetData(),
4131 beta.GetData(), V.GetData(), &n, V.GetData(), &n, work.GetData(),
4132 &lwork, rwork.GetData(), &info.GetInfoRef());
4134 #ifdef SELDON_LAPACK_CHECK_INFO
4135 if (info.GetInfo() != 0)
4136 throw LapackError(info.GetInfo(),
"GetEigenvalues",
4137 "Failed to find eigenvalues ");
4154 template<
class Prop1,
class Allocator1,
class Allocator2,
4155 class Allocator3,
class Allocator4>
4156 void GetSVD(Matrix<float, Prop1, RowMajor, Allocator1>& A,
4157 Vector<float, VectFull, Allocator4>& lambda,
4158 Matrix<float, General, RowMajor, Allocator2>& u,
4159 Matrix<float, General, RowMajor, Allocator3>& v,
4164 char jobl(
'A'), jobr(
'A');
4165 int lwork = max(3 * min(m, n) + max(m, n), 5 * min(m, n));
4166 Vector<float> work(lwork);
4167 lambda.Reallocate(min(m, n));
4173 sgesvd_(&jobl, &jobr, &n, &m, A.GetData(), &n, lambda.GetData(),
4174 v.GetData(), &n, u.GetData(), &m, work.GetData(),
4175 &lwork, &info.GetInfoRef());
4177 #ifdef SELDON_LAPACK_CHECK_INFO
4178 if (info.GetInfo() != 0)
4179 throw LapackError(info.GetInfo(),
"GetSVD",
4180 "Failed to find singular value decomposition");
4186 template<
class Prop1,
class Allocator1,
class Allocator2,
4187 class Allocator3,
class Allocator4>
4188 void GetSVD(Matrix<complex<float>, Prop1, RowMajor, Allocator1>& A,
4189 Vector<float, VectFull, Allocator4>& lambda,
4190 Matrix<complex<float>, General, RowMajor, Allocator2>& u,
4191 Matrix<complex<float>, General, RowMajor, Allocator3>& v,
4196 char jobl(
'A'), jobr(
'A');
4197 int lwork = 2 * min(m, n) + max(m, n);
4198 Vector<complex<float> > work(lwork);
4199 Vector<float> rwork(5 * min(m, n));
4200 lambda.Reallocate(min(m, n));
4206 cgesvd_(&jobl, &jobr, &n, &m, A.GetDataVoid(), &n, lambda.GetData(),
4207 v.GetDataVoid(), &n, u.GetDataVoid(), &m, work.GetDataVoid(),
4208 &lwork, rwork.GetData(), &info.GetInfoRef());
4210 #ifdef SELDON_LAPACK_CHECK_INFO
4211 if (info.GetInfo() != 0)
4212 throw LapackError(info.GetInfo(),
"GetSVD",
4213 "Failed to find singular value decomposition");
4219 template<
class Prop1,
class Allocator1,
class Allocator2,
4220 class Allocator3,
class Allocator4>
4221 void GetSVD(Matrix<double, Prop1, RowMajor, Allocator1>& A,
4222 Vector<double, VectFull, Allocator4>& lambda,
4223 Matrix<double, General, RowMajor, Allocator2>& u,
4224 Matrix<double, General, RowMajor, Allocator3>& v,
4229 char jobl(
'A'), jobr(
'A');
4230 int lwork = max(3 * min(m, n) + max(m, n), 5 * min(m, n));
4231 Vector<double> work(lwork);
4232 lambda.Reallocate(min(m, n));
4238 dgesvd_(&jobl, &jobr, &n, &m, A.GetData(), &n, lambda.GetData(),
4239 v.GetData(), &n, u.GetData(), &m, work.GetData(),
4240 &lwork, &info.GetInfoRef());
4242 #ifdef SELDON_LAPACK_CHECK_INFO
4243 if (info.GetInfo() != 0)
4244 throw LapackError(info.GetInfo(),
"GetSVD",
4245 "Failed to find singular value decomposition");
4251 template<
class Prop1,
class Allocator1,
class Allocator2,
4252 class Allocator3,
class Allocator4>
4253 void GetSVD(Matrix<complex<double>, Prop1, RowMajor, Allocator1>& A,
4254 Vector<double, VectFull, Allocator4>& lambda,
4255 Matrix<complex<double>, General, RowMajor, Allocator2>& u,
4256 Matrix<complex<double>, General, RowMajor, Allocator3>& v,
4261 char jobl(
'A'), jobr(
'A');
4262 int lwork = 2 * min(m, n) + max(m, n);
4263 Vector<complex<double> > work(lwork);
4264 Vector<double> rwork(5 * min(m, n));
4265 lambda.Reallocate(min(m, n));
4271 zgesvd_(&jobl, &jobr, &n, &m, A.GetDataVoid(), &n, lambda.GetData(),
4272 v.GetDataVoid(), &n, u.GetDataVoid(), &m, work.GetDataVoid(),
4273 &lwork, rwork.GetData(), &info.GetInfoRef());
4275 #ifdef SELDON_LAPACK_CHECK_INFO
4276 if (info.GetInfo() != 0)
4277 throw LapackError(info.GetInfo(),
"GetSVD",
4278 "Failed to find singular value decomposition");
4287 template<
class Prop1,
class Allocator1,
class Allocator2,
4288 class Allocator3,
class Allocator4>
4289 void GetSVD(Matrix<float, Prop1, ColMajor, Allocator1>& A,
4290 Vector<float, VectFull, Allocator4>& lambda,
4291 Matrix<float, General, ColMajor, Allocator2>& u,
4292 Matrix<float, General, ColMajor, Allocator3>& v,
4297 char jobl(
'A'), jobr(
'A');
4298 int lwork = max(3 * min(m, n) + max(m, n), 5 * min(m, n));
4299 Vector<float> work(lwork);
4300 lambda.Reallocate(min(m, n));
4306 sgesvd_(&jobl, &jobr, &m, &n, A.GetData(), &m, lambda.GetData(),
4307 u.GetData(), &m, v.GetData(), &n, work.GetData(),
4308 &lwork, &info.GetInfoRef());
4310 #ifdef SELDON_LAPACK_CHECK_INFO
4311 if (info.GetInfo() != 0)
4312 throw LapackError(info.GetInfo(),
"GetSVD",
4313 "Failed to find singular value decomposition");
4319 template<
class Prop1,
class Allocator1,
class Allocator2,
4320 class Allocator3,
class Allocator4>
4321 void GetSVD(Matrix<complex<float>, Prop1, ColMajor, Allocator1>& A,
4322 Vector<float, VectFull, Allocator4>& lambda,
4323 Matrix<complex<float>, General, ColMajor, Allocator2>& u,
4324 Matrix<complex<float>, General, ColMajor, Allocator3>& v,
4329 char jobl(
'A'), jobr(
'A');
4330 int lwork = 2 * min(m, n) + max(m, n);
4331 Vector<complex<float> > work(lwork);
4332 Vector<float> rwork(5 * min(m, n));
4333 lambda.Reallocate(min(m, n));
4339 cgesvd_(&jobl, &jobr, &m, &n, A.GetDataVoid(), &m, lambda.GetData(),
4340 u.GetDataVoid(), &m, v.GetDataVoid(), &n, work.GetDataVoid(),
4341 &lwork, rwork.GetData(), &info.GetInfoRef());
4343 #ifdef SELDON_LAPACK_CHECK_INFO
4344 if (info.GetInfo() != 0)
4345 throw LapackError(info.GetInfo(),
"GetSVD",
4346 "Failed to find singular value decomposition");
4352 template<
class Prop1,
class Allocator1,
class Allocator2,
4353 class Allocator3,
class Allocator4>
4354 void GetSVD(Matrix<double, Prop1, ColMajor, Allocator1>& A,
4355 Vector<double, VectFull, Allocator4>& lambda,
4356 Matrix<double, General, ColMajor, Allocator2>& u,
4357 Matrix<double, General, ColMajor, Allocator3>& v,
4362 char jobl(
'A'), jobr(
'A');
4363 int lwork = 10 * max(m, n);
4364 Vector<double> work(lwork);
4365 lambda.Reallocate(min(m, n));
4371 dgesvd_(&jobl, &jobr, &m, &n, A.GetData(), &m, lambda.GetData(),
4372 u.GetData(), &m, v.GetData(), &n, work.GetData(),
4373 &lwork, &info.GetInfoRef());
4375 #ifdef SELDON_LAPACK_CHECK_INFO
4376 if (info.GetInfo() != 0)
4377 throw LapackError(info.GetInfo(),
"GetSVD",
4378 "Failed to find singular value decomposition");
4384 template<
class Prop1,
class Allocator1,
class Allocator2,
4385 class Allocator3,
class Allocator4>
4386 void GetSVD(Matrix<complex<double>, Prop1, ColMajor, Allocator1>& A,
4387 Vector<double, VectFull, Allocator4>& sigma,
4388 Matrix<complex<double>, General, ColMajor, Allocator2>& u,
4389 Matrix<complex<double>, General, ColMajor, Allocator3>& v,
4394 char jobl(
'A'), jobr(
'A');
4395 int lwork = 2 * min(m, n) + max(m, n);
4396 Vector<complex<double> > work(lwork);
4397 Vector<double> rwork(5 * min(m, n));
4398 sigma.Reallocate(min(m, n));
4404 zgesvd_(&jobl, &jobr, &m, &n, A.GetDataVoid(), &m, sigma.GetData(),
4405 u.GetDataVoid(), &m, v.GetDataVoid(), &n, work.GetDataVoid(),
4406 &lwork, rwork.GetData(), &info.GetInfoRef());
4408 #ifdef SELDON_LAPACK_CHECK_INFO
4409 if (info.GetInfo() != 0)
4410 throw LapackError(info.GetInfo(),
"GetSVD",
4411 "Failed to find singular value decomposition");
4418 template<
class T,
class Prop,
class Storage,
class Allocator>
4419 void GetPseudoInverse(Matrix<T, Prop, Storage, Allocator>& A,
4420 const T& epsilon, LapackInfo& info)
4422 int m = A.GetM(), n = A.GetN();
4423 Vector<T, VectFull, Allocator> lambda;
4424 Matrix<T, Prop, Storage, Allocator> U;
4425 Matrix<T, Prop, Storage, Allocator> V;
4427 GetSVD(A, lambda, U, V);
4432 for (
int k = 0; k < min(m, n); k++)
4433 if (abs(lambda(k)) > epsilon)
4434 for (
int j = 0; j < m; j++)
4435 U(j, k) /= lambda(k);
4438 for (
int k = m; k < n; k++)
4439 for (
int j = 0; j < m; j++)
4442 MltAdd(1.0, SeldonTrans, V, SeldonTrans, U, 0.0, A);
4447 template<
class T,
class Prop,
class Storage,
class Allocator>
4448 void GetPseudoInverse(Matrix<complex<T>, Prop, Storage, Allocator>& A,
4449 const T& epsilon, LapackInfo& info)
4451 int m = A.GetM(), n = A.GetN();
4453 Matrix<complex<T>, Prop, Storage, Allocator> U;
4454 Matrix<complex<T>, Prop, Storage, Allocator> V;
4456 GetSVD(A, lambda, U, V, info);
4458 complex<T> one(1.0, 0.0), zero(0.0, 0.0);
4463 for (
int k = 0; k < min(m, n); k++)
4464 if (abs(lambda(k)) > epsilon)
4465 for (
int j = 0; j < m; j++)
4466 U(j, k) /= lambda(k);
4469 for (
int k = m; k < n; k++)
4470 for (
int j = 0; j < m; j++)
4473 MltAdd(one, SeldonConjTrans, V, SeldonConjTrans, U, zero, A);
4493 template<
class Alloc>
4498 #ifdef SELDON_CHECK_DIMENSIONS
4499 if (A.GetM() != A.GetN())
4500 throw WrongDim(
"GetHessenberg",
"Matrix must be squared");
4504 int ilo = 1, ihi = n;
4508 zgehrd_(&n, &ilo, &ihi, A.GetDataVoid(), &n, tau.GetDataVoid(),
4509 work.GetDataVoid(), &lwork, &info.GetInfoRef());
4511 #ifdef SELDON_LAPACK_CHECK_INFO
4512 if (info.GetInfo() != 0)
4513 throw LapackError(info.GetInfo(),
"GetHessenberg",
4514 "Failed to reduce A to Hessenberg form");
4519 complex<double> zero(0, 0);
4520 for (
int i = 0; i < n; i++)
4521 for (
int j = 0; j < i-1; j++)
4524 zunghr_(&n, &ilo, &ihi, Q.GetDataVoid(), &n, tau.GetDataVoid(),
4525 work.GetDataVoid(), &lwork, &info.GetInfoRef());
4527 #ifdef SELDON_LAPACK_CHECK_INFO
4528 if (info.GetInfo() != 0)
4529 throw LapackError(info.GetInfo(),
"GetHessenberg",
4530 "Failed to generate unitary matrix Q");
4545 template<
class Alloc>
4552 #ifdef SELDON_CHECK_DIMENSIONS
4553 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()))
4555 "Matrix A and B must be squared");
4557 if (A.GetM() != B.GetM())
4559 "Matrix A and B must have the same size");
4562 char compq(
'V'), compz(
'I');
4563 int n = A.GetM(), ilo = 1, ihi = n, lwork = 4 * n;
4566 zgeqrf_(&n, &n, B.GetDataVoid(), &n, tau.GetDataVoid(),
4567 work.GetDataVoid(), &lwork, &info.GetInfoRef());
4569 #ifdef SELDON_LAPACK_CHECK_INFO
4570 if (info.GetInfo() != 0)
4571 throw LapackError(info.GetInfo(),
"GetHessenberg",
4572 "Failed to compute QR factorisation of B");
4576 zungqr_(&n, &n, &n, Q.GetDataVoid(), &n, tau.GetDataVoid(),
4577 work.GetDataVoid(), &lwork, &info.GetInfoRef());
4579 #ifdef SELDON_LAPACK_CHECK_INFO
4580 if (info.GetInfo() != 0)
4581 throw LapackError(info.GetInfo(),
"GetHessenberg",
4582 "Failed to generate unitary matrix Q");
4585 char side(
'L'), trans(
'C');
4586 zunmqr_(&side, &trans, &n, &n, &n, B.GetDataVoid(), &n, tau.GetDataVoid(),
4587 A.GetDataVoid(), &n, work.GetData(), &lwork, &info.GetInfoRef());
4589 for (
int i = 0; i < n; i++)
4590 for (
int j = 0; j < i; j++)
4594 zgghrd_(&compq, &compz, &n, &ilo, &ihi, A.GetDataVoid(), &n,
4595 B.GetDataVoid(), &n, Q.GetDataVoid(), &n, Z.GetDataVoid(),
4596 &n, &info.GetInfoRef());
4598 #ifdef SELDON_LAPACK_CHECK_INFO
4599 if (info.GetInfo() != 0)
4600 throw LapackError(info.GetInfo(),
"GetHessenberg",
4601 "Failed to generate unitary matrix Z");
4616 template<
class Alloc>
4623 #ifdef SELDON_CHECK_DIMENSIONS
4624 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()))
4626 "Matrix A and B must be squared");
4628 if (A.GetM() != B.GetM())
4630 "Matrix A and B must have the same size");
4633 char compq(
'V'), compz(
'I');
4634 int n = A.GetM(), ilo = 1, ihi = n, lwork = 4*n;
4637 zgeqrf_(&n, &n, B.GetDataVoid(), &n, tau.GetDataVoid(),
4638 work.GetDataVoid(), &lwork, &info.GetInfoRef());
4640 #ifdef SELDON_LAPACK_CHECK_INFO
4641 if (info.GetInfo() != 0)
4643 "Failed to compute QR factorisation of B");
4647 zungqr_(&n, &n, &n, Q.GetDataVoid(), &n, tau.GetDataVoid(),
4648 work.GetDataVoid(), &lwork, &info.GetInfoRef());
4650 #ifdef SELDON_LAPACK_CHECK_INFO
4651 if (info.GetInfo() != 0)
4653 "Failed to generate unitary matrix Q");
4656 char side(
'L'), trans(
'C');
4657 zunmqr_(&side, &trans, &n, &n, &n, B.GetDataVoid(), &n, tau.GetDataVoid(),
4658 A.GetDataVoid(), &n, work.GetData(), &lwork, &info.GetInfoRef());
4660 for (
int i = 0; i < n; i++)
4661 for (
int j = 0; j < i; j++)
4664 zgghrd_(&compq, &compz, &n, &ilo, &ihi, A.GetDataVoid(), &n,
4665 B.GetDataVoid(), &n, Q.GetDataVoid(), &n, Z.GetDataVoid(),
4666 &n, &info.GetInfoRef());
4673 zhgeqz_(&job, &compq, &compz, &n, &ilo, &ihi, A.GetDataVoid(), &n,
4674 B.GetDataVoid(), &n, alpha.GetDataVoid(), beta.GetDataVoid(),
4675 Q.GetDataVoid(), &n, Z.GetDataVoid(), &n, work.GetDataVoid(),
4676 &lwork, rwork.GetData(), &info.GetInfoRef());
4678 #ifdef SELDON_LAPACK_CHECK_INFO
4679 if (info.GetInfo() != 0)
4681 "Failed to generate qz factorisation");
4686 template<
class Alloc>
4687 void GetHessenberg(Matrix<complex<double>, General, RowMajor, Alloc>& A,
4688 Matrix<complex<double>, General, RowMajor, Alloc>& Q,
4691 #ifdef SELDON_CHECK_DIMENSIONS
4692 if (A.GetM() != A.GetN())
4693 throw WrongDim(
"GetHessenberg",
"Matrix must be squared");
4697 int ilo = 1, ihi = n;
4698 Vector<complex<double>, VectFull, Alloc> tau(n-1);
4700 Vector<complex<double>, VectFull, Alloc> work(lwork);
4702 zgehrd_(&n, &ilo, &ihi, A.GetDataVoid(), &n, tau.GetDataVoid(),
4703 work.GetDataVoid(), &lwork, &info.GetInfoRef());
4705 #ifdef SELDON_LAPACK_CHECK_INFO
4706 if (info.GetInfo() != 0)
4707 throw LapackError(info.GetInfo(),
"GetHessenberg",
4708 "Failed to reduce A to Hessenberg form");
4713 zunghr_(&n, &ilo, &ihi, Q.GetDataVoid(), &n, tau.GetDataVoid(),
4714 work.GetDataVoid(), &lwork, &info.GetInfoRef());
4716 #ifdef SELDON_LAPACK_CHECK_INFO
4717 if (info.GetInfo() != 0)
4718 throw LapackError(info.GetInfo(),
"GetHessenberg",
4719 "Failed to generate unitary matrix Q");
4724 complex<double> zero(0, 0);
4725 for (
int i = 0; i < n; i++)
4726 for (
int j = 0; j < i-1; j++)
4731 template<
class Alloc>
4732 void GetHessenberg(Matrix<complex<double>, General, RowMajor, Alloc>& A,
4733 Matrix<complex<double>, General, RowMajor, Alloc>& B,
4734 Matrix<complex<double>, General, RowMajor, Alloc>& Q,
4735 Matrix<complex<double>, General, RowMajor, Alloc>& Z,
4738 #ifdef SELDON_CHECK_DIMENSIONS
4739 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()))
4740 throw WrongDim(
"GetHessenberg",
4741 "Matrix A and B must be squared");
4743 if (A.GetM() != B.GetM())
4744 throw WrongDim(
"GetHessenberg",
4745 "Matrix A and B must have the same size");
4748 char compq(
'V'), compz(
'I');
4749 int n = A.GetM(), ilo = 1, ihi = n, lwork = 4 * n;
4751 Vector<complex<double> > tau(n);
4752 Vector<complex<double> > work(lwork);
4753 zgeqrf_(&n, &n, B.GetDataVoid(), &n, tau.GetDataVoid(),
4754 work.GetDataVoid(), &lwork, &info.GetInfoRef());
4756 #ifdef SELDON_LAPACK_CHECK_INFO
4757 if (info.GetInfo() != 0)
4758 throw LapackError(info.GetInfo(),
"GetHessenberg",
4759 "Failed to compute QR factorisation of B");
4763 zungqr_(&n, &n, &n, Q.GetDataVoid(), &n, tau.GetDataVoid(),
4764 work.GetDataVoid(), &lwork, &info.GetInfoRef());
4766 #ifdef SELDON_LAPACK_CHECK_INFO
4767 if (info.GetInfo() != 0)
4768 throw LapackError(info.GetInfo(),
"GetHessenberg",
4769 "Failed to generate unitary matrix Q");
4772 char side(
'L'), trans(
'C');
4773 zunmqr_(&side, &trans, &n, &n, &n, B.GetDataVoid(), &n, tau.GetDataVoid(),
4774 A.GetDataVoid(), &n, work.GetData(), &lwork, &info.GetInfoRef());
4776 for (
int i = 0; i < n; i++)
4777 for (
int j = 0; j < i; j++)
4781 zgghrd_(&compq, &compz, &n, &ilo, &ihi, A.GetDataVoid(), &n,
4782 B.GetDataVoid(), &n, Q.GetDataVoid(), &n, Z.GetDataVoid(),
4783 &n, &info.GetInfoRef());
4785 #ifdef SELDON_LAPACK_CHECK_INFO
4786 if (info.GetInfo() != 0)
4787 throw LapackError(info.GetInfo(),
"GetHessenberg",
4788 "Failed to generate unitary matrix Z");
4796 template<
class Alloc>
4797 void GetQZ(Matrix<complex<double>, General, RowMajor, Alloc>& A,
4798 Matrix<complex<double>, General, RowMajor, Alloc>& B,
4799 Matrix<complex<double>, General, RowMajor, Alloc>& Q,
4800 Matrix<complex<double>, General, RowMajor, Alloc>& Z,
4803 #ifdef SELDON_CHECK_DIMENSIONS
4804 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()))
4805 throw WrongDim(
"GetQZ",
4806 "Matrix A and B must be squared");
4808 if (A.GetM() != B.GetM())
4809 throw WrongDim(
"GetQZ",
4810 "Matrix A and B must have the same size");
4813 char compq(
'V'), compz(
'I');
4814 int n = A.GetM(), ilo = 1, ihi = n, lwork = 4*n;
4816 Vector<complex<double> > tau(n);
4817 Vector<complex<double> > work(lwork);
4818 zgeqrf_(&n, &n, B.GetDataVoid(), &n, tau.GetDataVoid(),
4819 work.GetDataVoid(), &lwork, &info.GetInfoRef());
4821 #ifdef SELDON_LAPACK_CHECK_INFO
4822 if (info.GetInfo() != 0)
4823 throw LapackError(info.GetInfo(),
"GetQZ",
4824 "Failed to compute QR factorisation of B");
4828 zungqr_(&n, &n, &n, Q.GetDataVoid(), &n, tau.GetDataVoid(),
4829 work.GetDataVoid(), &lwork, &info.GetInfoRef());
4831 #ifdef SELDON_LAPACK_CHECK_INFO
4832 if (info.GetInfo() != 0)
4833 throw LapackError(info.GetInfo(),
"GetQZ",
4834 "Failed to generate unitary matrix Q");
4837 char side(
'L'), trans(
'C');
4838 zunmqr_(&side, &trans, &n, &n, &n, B.GetDataVoid(), &n, tau.GetDataVoid(),
4839 A.GetDataVoid(), &n, work.GetData(), &lwork, &info.GetInfoRef());
4841 for (
int i = 0; i < n; i++)
4842 for (
int j = 0; j < i; j++)
4846 zgghrd_(&compq, &compz, &n, &ilo, &ihi, A.GetDataVoid(), &n,
4847 B.GetDataVoid(), &n, Q.GetDataVoid(), &n, Z.GetDataVoid(),
4848 &n, &info.GetInfoRef());
4853 Vector<complex<double> > alpha(n), beta(n);
4854 Vector<double> rwork(lwork);
4855 zhgeqz_(&job, &compq, &compz, &n, &ilo, &ihi, A.GetDataVoid(), &n,
4856 B.GetDataVoid(), &n, alpha.GetDataVoid(), beta.GetDataVoid(),
4857 Q.GetDataVoid(), &n, Z.GetDataVoid(), &n, work.GetDataVoid(),
4858 &lwork, rwork.GetData(), &info.GetInfoRef());
4860 #ifdef SELDON_LAPACK_CHECK_INFO
4861 if (info.GetInfo() != 0)
4862 throw LapackError(info.GetInfo(),
"GetQZ",
4863 "Failed to generate qz factorisation");
4872 template<
class T,
class Prop,
class Storage,
class Allocator,
class Vector1>
4876 T tmp, pivot, invDiag;
4878 for (
int i = 0; i < n-1; i++)
4881 if (abs(A(i+1, i)) > abs(A(i, i)))
4884 for (
int j = i; j < n; j++)
4887 A(i, j) = A(i+1, j);
4897 invDiag = 1.0/A(i, i);
4898 pivot = A(i+1, i)*invDiag;
4901 for (
int j = i+1; j < n; j++)
4902 A(i+1, j) -= pivot*A(i, j);
4904 B(i+1) -= pivot*B(i);
4908 A(n-1, n-1) = 1.0/A(n-1, n-1);
4911 for (
int i = n-1; i >= 0; i--)
4914 for (
int j = i+1; j < n; j++)
4915 tmp -= A(i, j)*B(j);
4924 template<
class T,
class Prop,
class Storage,
class Allocator,
class Vector1>
4928 T tmp, pivot, invDiag, one, zero;
4929 SetComplexZero(zero);
4931 typename ClassComplexType<T>::Treal a1, a2, a3;
4933 for (
int i = 0; i < n-2; i++)
4937 a2 = abs(A(i+1, i));
4938 a3 = abs(A(i+2, i));
4939 if (a2 > max(a1, a3))
4942 for (
int j = i; j < n; j++)
4945 A(i, j) = A(i+1, j);
4953 else if (a3 > max(a1, a2))
4956 for (
int j = i; j < n; j++)
4959 A(i, j) = A(i+2, j);
4969 invDiag = 1.0/A(i, i);
4970 pivot = A(i+1, i)*invDiag;
4973 for (
int j = i+1; j < n; j++)
4974 A(i+1, j) -= pivot*A(i, j);
4976 B(i+1) -= pivot*B(i);
4979 pivot = A(i+2, i)*invDiag;
4981 for (
int j = i+1; j < n; j++)
4982 A(i+2, j) -= pivot*A(i, j);
4984 B(i+2) -= pivot*B(i);
4988 if (abs(A(n-1, n-2)) > abs(A(n-2, n-2)))
4990 for (
int j = n-2; j < n; j++)
4993 A(n-2, j) = A(n-1, j);
5002 invDiag = one/A(n-2, n-2);
5003 pivot = A(n-1, n-2)*invDiag;
5004 A(n-2, n-2) = invDiag;
5006 A(n-1, n-1) -= pivot*A(n-2, n-1);
5007 B(n-1) -= pivot*B(n-2);
5010 A(n-1, n-1) = one/A(n-1, n-1);
5013 for (
int i = n-1; i >= 0; i--)
5016 for (
int j = i+1; j < n; j++)
5017 tmp -= A(i, j)*B(j);
5026 template<
class Prop,
class Storage,
class Allocator>
5028 Matrix<complex<double>, Prop, Storage, Allocator>& B,
5029 Matrix<complex<double>, Prop, Storage, Allocator>& C,
5030 Matrix<complex<double>, Prop, Storage, Allocator>& D,
5031 Matrix<complex<double>, Prop, Storage, Allocator>& E)
5033 complex<double> one(1), zero(0);
5041 E(0, 0) /= A(0, 0) * conj(B(0, 0)) + C(0, 0) * conj(D(0, 0));
5050 GetQZ(D, B, Q2, Z2);
5053 MltAdd(one, SeldonConjTrans, Q1, SeldonNoTrans, E, zero, Y);
5054 MltAdd(one, SeldonNoTrans, Y, SeldonNoTrans, Q2, zero, F);
5058 Q1.Zero(); Q2.Zero(); E.Zero();
5059 complex<double> coef_b, coef_d;
5060 for (
int k = n-1; k >= 0; k--)
5064 for (
int j = 0; j < n; j++)
5067 for (
int j = k+1; j < n; j++)
5069 coef_b = conj(B(k, j));
5070 coef_d = conj(D(k, j));
5071 for (
int i = 0; i < n; i++)
5072 Yvec(i) -= coef_b * Q1(i, j) + coef_d * Q2(i, j);
5075 coef_b = conj(B(k, k)); coef_d = conj(D(k, k));
5076 for (
int i = 0; i < n; i++)
5077 for (
int j = max(0, i-1); j < n; j++)
5078 E(i, j) = coef_b * A(i, j) + coef_d * C(i, j);
5081 for (
int i = 0; i < n; i++)
5085 for (
int i = 0; i < n; i++)
5086 for (
int m = max(0, i-1); m < n; m++)
5087 Q1(i, k) += A(i, m)*Yvec(m);
5089 for (
int i = 0; i < n; i++)
5090 for (
int m = i; m < n; m++)
5091 Q2(i, k) += C(i, m)*Yvec(m);
5094 MltAdd(one, SeldonNoTrans, Y, SeldonConjTrans, Z2, zero, F);
5095 MltAdd(one, Z1, F, zero, E);
5099 template<
class Alloc>
5100 void GetHessenberg(Matrix<double, General, ColMajor, Alloc>& A,
5101 Matrix<double, General, ColMajor, Alloc>& Q,
5104 #ifdef SELDON_CHECK_DIMENSIONS
5105 if (A.GetM() != A.GetN())
5106 throw WrongDim(
"GetHessenberg",
"Matrix must be squared");
5110 int ilo = 1, ihi = n;
5111 Vector<double, VectFull, Alloc> tau(n-1);
5113 Vector<double, VectFull, Alloc> work(lwork);
5114 dgehrd_(&n, &ilo, &ihi, A.GetData(), &n, tau.GetData(),
5115 work.GetData(), &lwork, &info.GetInfoRef());
5117 #ifdef SELDON_LAPACK_CHECK_INFO
5118 if (info.GetInfo() != 0)
5119 throw LapackError(info.GetInfo(),
"GetHessenberg",
5120 "Failed to reduce A to Hessenberg form");
5126 for (
int i = 0; i < n; i++)
5127 for (
int j = 0; j < i-1; j++)
5130 dorghr_(&n, &ilo, &ihi, Q.GetData(), &n, tau.GetData(),
5131 work.GetData(), &lwork, &info.GetInfoRef());
5133 #ifdef SELDON_LAPACK_CHECK_INFO
5134 if (info.GetInfo() != 0)
5135 throw LapackError(info.GetInfo(),
"GetHessenberg",
5136 "Failed to generate unitary matrix Q");
5151 template<
class Alloc>
5158 #ifdef SELDON_CHECK_DIMENSIONS
5159 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()))
5161 "Matrix A and B must be squared");
5163 if (A.GetM() != B.GetM())
5165 "Matrix A and B must have the same size");
5168 char compq(
'V'), compz(
'I');
5169 int n = A.GetM(), ilo = 1, ihi = n, lwork = 4 * n;
5172 dgeqrf_(&n, &n, B.GetData(), &n, tau.GetData(),
5173 work.GetData(), &lwork, &info.GetInfoRef());
5175 #ifdef SELDON_LAPACK_CHECK_INFO
5176 if (info.GetInfo() != 0)
5177 throw LapackError(info.GetInfo(),
"GetHessenberg",
5178 "Failed to compute QR factorisation of B");
5182 dorgqr_(&n, &n, &n, Q.GetData(), &n, tau.GetData(),
5183 work.GetData(), &lwork, &info.GetInfoRef());
5185 char side(
'L'), trans(
'T');
5186 dormqr_(&side, &trans, &n, &n, &n, B.GetData(), &n, tau.GetData(),
5187 A.GetData(), &n, work.GetData(), &lwork, &info.GetInfoRef());
5189 #ifdef SELDON_LAPACK_CHECK_INFO
5190 if (info.GetInfo() != 0)
5191 throw LapackError(info.GetInfo(),
"GetHessenberg",
5192 "Failed to generate unitary matrix Q");
5195 for (
int i = 0; i < n; i++)
5196 for (
int j = 0; j < i; j++)
5200 dgghrd_(&compq, &compz, &n, &ilo, &ihi, A.GetData(), &n,
5201 B.GetData(), &n, Q.GetData(), &n, Z.GetData(),
5202 &n, &info.GetInfoRef());
5204 #ifdef SELDON_LAPACK_CHECK_INFO
5205 if (info.GetInfo() != 0)
5206 throw LapackError(info.GetInfo(),
"GetHessenberg",
5207 "Failed to generate unitary matrix Z");
5222 template<
class Alloc>
5229 #ifdef SELDON_CHECK_DIMENSIONS
5230 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()))
5232 "Matrix A and B must be squared");
5234 if (A.GetM() != B.GetM())
5236 "Matrix A and B must have the same size");
5239 char compq(
'V'), compz(
'I');
5240 int n = A.GetM(), ilo = 1, ihi = n, lwork = 4*n;
5243 dgeqrf_(&n, &n, B.GetData(), &n, tau.GetData(),
5244 work.GetData(), &lwork, &info.GetInfoRef());
5246 #ifdef SELDON_LAPACK_CHECK_INFO
5247 if (info.GetInfo() != 0)
5249 "Failed to compute QR factorisation of B");
5253 dorgqr_(&n, &n, &n, Q.GetData(), &n, tau.GetData(),
5254 work.GetData(), &lwork, &info.GetInfoRef());
5256 #ifdef SELDON_LAPACK_CHECK_INFO
5257 if (info.GetInfo() != 0)
5259 "Failed to generate unitary matrix Q");
5262 char side(
'L'), trans(
'T');
5263 dormqr_(&side, &trans, &n, &n, &n, B.GetData(), &n, tau.GetData(),
5264 A.GetData(), &n, work.GetData(), &lwork, &info.GetInfoRef());
5266 for (
int i = 0; i < n; i++)
5267 for (
int j = 0; j < i; j++)
5271 dgghrd_(&compq, &compz, &n, &ilo, &ihi, A.GetData(), &n,
5272 B.GetData(), &n, Q.GetData(), &n, Z.GetData(),
5273 &n, &info.GetInfoRef());
5280 dhgeqz_(&job, &compq, &compz, &n, &ilo, &ihi, A.GetData(), &n,
5281 B.GetData(), &n, alphar.GetData(), alphai.GetData(), beta.GetData(),
5282 Q.GetData(), &n, Z.GetData(), &n, work.GetData(),
5283 &lwork, &info.GetInfoRef());
5285 #ifdef SELDON_LAPACK_CHECK_INFO
5286 if (info.GetInfo() != 0)
5288 "Failed to generate qz factorisation");
5294 template<
class Alloc>
5295 void GetHessenberg(Matrix<double, General, RowMajor, Alloc>& A,
5296 Matrix<double, General, RowMajor, Alloc>& Q,
5299 #ifdef SELDON_CHECK_DIMENSIONS
5300 if (A.GetM() != A.GetN())
5301 throw WrongDim(
"GetHessenberg",
"Matrix must be squared");
5305 int ilo = 1, ihi = n;
5306 Vector<double, VectFull, Alloc> tau(n-1);
5308 Vector<double, VectFull, Alloc> work(lwork);
5310 dgehrd_(&n, &ilo, &ihi, A.GetData(), &n, tau.GetData(),
5311 work.GetData(), &lwork, &info.GetInfoRef());
5313 #ifdef SELDON_LAPACK_CHECK_INFO
5314 if (info.GetInfo() != 0)
5315 throw LapackError(info.GetInfo(),
"GetHessenberg",
5316 "Failed to reduce A to Hessenberg form");
5321 dorghr_(&n, &ilo, &ihi, Q.GetData(), &n, tau.GetData(),
5322 work.GetData(), &lwork, &info.GetInfoRef());
5324 #ifdef SELDON_LAPACK_CHECK_INFO
5325 if (info.GetInfo() != 0)
5326 throw LapackError(info.GetInfo(),
"GetHessenberg",
5327 "Failed to generate unitary matrix Q");
5333 for (
int i = 0; i < n; i++)
5334 for (
int j = 0; j < i-1; j++)
5339 template<
class Alloc>
5340 void GetHessenberg(Matrix<double, General, RowMajor, Alloc>& A,
5341 Matrix<double, General, RowMajor, Alloc>& B,
5342 Matrix<double, General, RowMajor, Alloc>& Q,
5343 Matrix<double, General, RowMajor, Alloc>& Z,
5346 #ifdef SELDON_CHECK_DIMENSIONS
5347 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()))
5348 throw WrongDim(
"GetHessenberg",
5349 "Matrix A and B must be squared");
5351 if (A.GetM() != B.GetM())
5352 throw WrongDim(
"GetHessenberg",
5353 "Matrix A and B must have the same size");
5356 char compq(
'V'), compz(
'I');
5357 int n = A.GetM(), ilo = 1, ihi = n, lwork = 4 * n;
5359 Vector<double> tau(n);
5360 Vector<double> work(lwork);
5361 dgeqrf_(&n, &n, B.GetData(), &n, tau.GetData(),
5362 work.GetData(), &lwork, &info.GetInfoRef());
5364 #ifdef SELDON_LAPACK_CHECK_INFO
5365 if (info.GetInfo() != 0)
5366 throw LapackError(info.GetInfo(),
"GetHessenberg",
5367 "Failed to compute QR factorisation of B");
5371 dorgqr_(&n, &n, &n, Q.GetData(), &n, tau.GetData(),
5372 work.GetData(), &lwork, &info.GetInfoRef());
5374 char side(
'L'), trans(
'T');
5375 dormqr_(&side, &trans, &n, &n, &n, B.GetData(), &n, tau.GetData(),
5376 A.GetData(), &n, work.GetData(), &lwork, &info.GetInfoRef());
5378 for (
int i = 0; i < n; i++)
5379 for (
int j = 0; j < i; j++)
5383 dgghrd_(&compq, &compz, &n, &ilo, &ihi, A.GetData(), &n,
5384 B.GetData(), &n, Q.GetData(), &n, Z.GetData(),
5385 &n, &info.GetInfoRef());
5387 #ifdef SELDON_LAPACK_CHECK_INFO
5388 if (info.GetInfo() != 0)
5389 throw LapackError(info.GetInfo(),
"GetHessenberg",
5390 "Failed to generate unitary matrix Z");
5399 template<
class Alloc>
5400 void GetQZ(Matrix<double, General, RowMajor, Alloc>& A,
5401 Matrix<double, General, RowMajor, Alloc>& B,
5402 Matrix<double, General, RowMajor, Alloc>& Q,
5403 Matrix<double, General, RowMajor>& Z,
5406 #ifdef SELDON_CHECK_DIMENSIONS
5407 if ((A.GetM() != A.GetN()) || (B.GetM() != B.GetN()))
5408 throw WrongDim(
"GetQZ",
5409 "Matrix A and B must be squared");
5411 if (A.GetM() != B.GetM())
5412 throw WrongDim(
"GetQZ",
5413 "Matrix A and B must have the same size");
5416 char compq(
'V'), compz(
'I');
5417 int n = A.GetM(), ilo = 1, ihi = n, lwork = 4*n;
5419 Vector<double> tau(n);
5420 Vector<double> work(lwork);
5421 dgeqrf_(&n, &n, B.GetData(), &n, tau.GetData(),
5422 work.GetData(), &lwork, &info.GetInfoRef());
5424 #ifdef SELDON_LAPACK_CHECK_INFO
5425 if (info.GetInfo() != 0)
5426 throw LapackError(info.GetInfo(),
"GetQZ",
5427 "Failed to compute QR factorisation of B");
5431 dorgqr_(&n, &n, &n, Q.GetData(), &n, tau.GetData(),
5432 work.GetData(), &lwork, &info.GetInfoRef());
5434 char side(
'L'), trans(
'T');
5435 dormqr_(&side, &trans, &n, &n, &n, B.GetData(), &n, tau.GetData(),
5436 A.GetData(), &n, work.GetData(), &lwork, &info.GetInfoRef());
5438 for (
int i = 0; i < n; i++)
5439 for (
int j = 0; j < i; j++)
5443 dgghrd_(&compq, &compz, &n, &ilo, &ihi, A.GetData(), &n,
5444 B.GetData(), &n, Q.GetData(), &n, Z.GetData(),
5445 &n, &info.GetInfoRef());
5450 Vector<double> alphar(n), alphai(n), beta(n);
5451 Vector<double> rwork(lwork);
5452 dhgeqz_(&job, &compq, &compz, &n, &ilo, &ihi, A.GetData(), &n,
5453 B.GetData(), &n, alphar.GetData(), alphai.GetData(), beta.GetData(),
5454 Q.GetData(), &n, Z.GetData(), &n, work.GetData(),
5455 &lwork, &info.GetInfoRef());
5457 #ifdef SELDON_LAPACK_CHECK_INFO
5458 if (info.GetInfo() != 0)
5459 throw LapackError(info.GetInfo(),
"GetQZ",
5460 "Failed to generate qz factorisation");
5470 template<
class Prop,
class Storage,
class Allocator>
5477 double one(1), zero(0);
5484 E(0,0) /= A(0, 0) * B(0, 0) + C(0, 0) * D(0, 0);
5493 GetQZ(D, B, Q2, Z2);
5496 MltAdd(one, SeldonTrans, Q1, SeldonNoTrans, E, zero, Y);
5497 MltAdd(one, SeldonNoTrans, Y, SeldonNoTrans, Q2, zero, F);
5502 Q1.Zero(); Q2.Zero(); E.Zero();
5503 double coef_b, coef_d, coef_bm1, coef_dm1, coef_b2, coef_d2, coef_d3;
5506 Yr.Zero(); Er.Zero();
5510 if ((k==0) || (D(k, k-1) == 0))
5516 for (
int j = 0; j < n; j++)
5519 for (
int j = k+1; j < n; j++)
5523 for (
int i = 0; i < n; i++)
5524 Yvec(i) -= coef_b * Q1(i, j) + coef_d * Q2(i, j);
5527 coef_b = B(k, k); coef_d = D(k, k);
5528 for (
int i = 0; i < n; i++)
5529 for (
int j = max(0, i-1); j < n; j++)
5530 E(i, j) = coef_b * A(i, j) + coef_d * C(i, j);
5533 for (
int i = 0; i < n; i++)
5537 for (
int i = 0; i < n; i++)
5538 for (
int m = max(0, i-1); m < n; m++)
5539 Q1(i, k) += A(i, m)*Yvec(m);
5541 for (
int i = 0; i < n; i++)
5542 for (
int m = i; m < n; m++)
5543 Q2(i, k) += C(i, m)*Yvec(m);
5552 for (
int j = 0; j < n; j++)
5554 Yr(2*j) = F(j, k-1);
5555 Yr(2*j+1) = F(j, k);
5558 for (
int j = k+1; j < n; j++)
5562 for (
int i = 0; i < n; i++)
5563 Yr(2*i) -= coef_b * Q1(i, j) + coef_d * Q2(i, j);
5567 for (
int i = 0; i < n; i++)
5568 Yr(2*i+1) -= coef_b * Q1(i, j) + coef_d * Q2(i, j);
5574 coef_bm1 = B(k-1, k-1); coef_dm1 = D(k-1, k-1);
5575 coef_b2 = B(k-1, k); coef_d2 = D(k-1, k); coef_d3 = D(k, k-1);
5576 coef_b = B(k, k); coef_d = D(k, k);
5577 for (
int i = 0; i < n; i++)
5578 for (
int j = max(0, i-1); j < n; j++)
5580 Er(2*i, 2*j) = coef_bm1 * A(i, j) + coef_dm1 * C(i, j);
5581 Er(2*i, 2*j+1) = coef_b2 * A(i, j) + coef_d2 * C(i, j);
5582 Er(2*i+1, 2*j) = coef_d3 * C(i, j);
5583 Er(2*i+1, 2*j+1) = coef_b * A(i, j) + coef_d * C(i, j);
5588 for (
int i = 0; i < n; i++)
5590 Y(i, k-1) = Yr(2*i);
5591 Y(i, k) = Yr(2*i+1);
5595 for (
int i = 0; i < n; i++)
5596 for (
int m = max(0, i-1); m < n; m++)
5597 Q1(i, k-1) += A(i, m)*Yr(2*m);
5599 for (
int i = 0; i < n; i++)
5600 for (
int m = i; m < n; m++)
5601 Q2(i, k-1) += C(i, m)*Yr(2*m);
5603 for (
int i = 0; i < n; i++)
5604 for (
int m = max(0, i-1); m < n; m++)
5605 Q1(i, k) += A(i, m)*Yr(2*m+1);
5607 for (
int i = 0; i < n; i++)
5608 for (
int m = i; m < n; m++)
5609 Q2(i, k) += C(i, m)*Yr(2*m+1);
5615 MltAdd(one, SeldonNoTrans, Y, SeldonTrans, Z2, zero, F);
5616 MltAdd(one, Z1, F, zero, E);
5626 #define SELDON_FILE_LAPACK_EIGENVALUES_CXX