26 #if defined (HAVE_CONFIG_H)
41 (*current_liboctave_error_handler)
42 (
"EIG: matrix contains Inf or NaN values");
51 (*current_liboctave_error_handler) (
"EIG requires square matrix");
62 double *pwi =
wi.fortran_vec ();
79 double *pscale =
scale.fortran_vec ();
91 F77_XFCN (dgeevx, DGEEVX, (F77_CONST_CHAR_ARG2 (balance ?
"B" :
"N", 1),
92 F77_CONST_CHAR_ARG2 (calc_lev ?
"V" :
"N", 1),
93 F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
94 F77_CONST_CHAR_ARG2 (
"N", 1),
95 n, tmp_data,
n, pwr, pwi, pvl,
96 n, pvr,
n, ilo, ihi, pscale,
97 abnrm, prconde, prcondv, &dummy_work,
98 lwork, &dummy_iwork, info
102 F77_CHAR_ARG_LEN (1)));
105 (*current_liboctave_error_handler) (
"dgeevx workspace query failed");
107 lwork =
static_cast<F77_INT> (dummy_work);
111 F77_XFCN (dgeevx, DGEEVX, (F77_CONST_CHAR_ARG2 (balance ?
"B" :
"N", 1),
112 F77_CONST_CHAR_ARG2 (calc_lev ?
"V" :
"N", 1),
113 F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
114 F77_CONST_CHAR_ARG2 (
"N", 1),
115 n, tmp_data,
n, pwr, pwi, pvl,
116 n, pvr,
n, ilo, ihi, pscale,
117 abnrm, prconde, prcondv, pwork,
118 lwork, &dummy_iwork, info
122 F77_CHAR_ARG_LEN (1)));
125 (*current_liboctave_error_handler) (
"unrecoverable error in dgeevx");
128 (*current_liboctave_error_handler) (
"dgeevx failed to converge");
138 if (
wi.elem (j) == 0.0)
141 for (
F77_INT i = 0; i < nvr; i++)
144 for (
F77_INT i = 0; i < nvl; i++)
150 (*current_liboctave_error_handler) (
"EIG: internal error");
155 for (
F77_INT i = 0; i < nvr; i++)
157 double real_part = vr.
elem (i, j);
158 double imag_part = vr.
elem (i, j+1);
163 for (
F77_INT i = 0; i < nvl; i++)
165 double real_part = vl.
elem (i, j);
166 double imag_part = vl.
elem (i, j+1);
184 (*current_liboctave_error_handler) (
"EIG requires square matrix");
197 F77_XFCN (dsyev, DSYEV, (F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
198 F77_CONST_CHAR_ARG2 (
"U", 1),
199 n, tmp_data,
n, pwr, &dummy_work, lwork, info
201 F77_CHAR_ARG_LEN (1)));
204 (*current_liboctave_error_handler) (
"dsyev workspace query failed");
206 lwork =
static_cast<F77_INT> (dummy_work);
210 F77_XFCN (dsyev, DSYEV, (F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
211 F77_CONST_CHAR_ARG2 (
"U", 1),
212 n, tmp_data,
n, pwr, pwork, lwork, info
214 F77_CHAR_ARG_LEN (1)));
217 (*current_liboctave_error_handler) (
"unrecoverable error in dsyev");
220 (*current_liboctave_error_handler) (
"dsyev failed to converge");
233 (*current_liboctave_error_handler)
234 (
"EIG: matrix contains Inf or NaN values");
243 (*current_liboctave_error_handler) (
"EIG requires square matrix");
272 double *pscale =
scale.fortran_vec ();
282 F77_XFCN (zgeevx, ZGEEVX, (F77_CONST_CHAR_ARG2 (balance ?
"B" :
"N", 1),
283 F77_CONST_CHAR_ARG2 (calc_lev ?
"V" :
"N", 1),
284 F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
285 F77_CONST_CHAR_ARG2 (
"N", 1),
289 pscale, abnrm, prconde, prcondv,
295 F77_CHAR_ARG_LEN (1)));
298 (*current_liboctave_error_handler) (
"zgeevx workspace query failed");
300 lwork =
static_cast<F77_INT> (dummy_work.real ());
304 F77_XFCN (zgeevx, ZGEEVX, (F77_CONST_CHAR_ARG2 (balance ?
"B" :
"N", 1),
305 F77_CONST_CHAR_ARG2 (calc_lev ?
"V" :
"N", 1),
306 F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
307 F77_CONST_CHAR_ARG2 (
"N", 1),
311 pscale, abnrm, prconde, prcondv,
316 F77_CHAR_ARG_LEN (1)));
319 (*current_liboctave_error_handler) (
"unrecoverable error in zgeevx");
322 (*current_liboctave_error_handler) (
"zgeevx failed to converge");
338 (*current_liboctave_error_handler) (
"EIG requires square matrix");
355 F77_XFCN (zheev, ZHEEV, (F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
356 F77_CONST_CHAR_ARG2 (
"U", 1),
361 F77_CHAR_ARG_LEN (1)));
364 (*current_liboctave_error_handler) (
"zheev workspace query failed");
366 lwork =
static_cast<F77_INT> (dummy_work.real ());
370 F77_XFCN (zheev, ZHEEV, (F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
371 F77_CONST_CHAR_ARG2 (
"U", 1),
375 F77_CHAR_ARG_LEN (1)));
378 (*current_liboctave_error_handler) (
"unrecoverable error in zheev");
381 (*current_liboctave_error_handler) (
"zheev failed to converge");
395 (*current_liboctave_error_handler)
396 (
"EIG: matrix contains Inf or NaN values");
404 if (
n != a_nc || nb != b_nc)
405 (*current_liboctave_error_handler) (
"EIG requires square matrix");
408 (*current_liboctave_error_handler) (
"EIG requires same size matrices");
417 F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 (
"L", 1),
420 F77_CHAR_ARG_LEN (1)));
452 F77_XFCN (dggev, DGGEV, (F77_CONST_CHAR_ARG2 (calc_lev ?
"V" :
"N", 1),
453 F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
454 n, atmp_data,
n, btmp_data,
n,
457 &dummy_work, lwork, info
459 F77_CHAR_ARG_LEN (1)));
462 (*current_liboctave_error_handler) (
"dggev workspace query failed");
464 lwork =
static_cast<F77_INT> (dummy_work);
468 F77_XFCN (dggev, DGGEV, (F77_CONST_CHAR_ARG2 (calc_lev ?
"V" :
"N", 1),
469 F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
470 n, atmp_data,
n, btmp_data,
n,
475 F77_CHAR_ARG_LEN (1)));
478 (*current_liboctave_error_handler) (
"unrecoverable error in dggev");
481 (*current_liboctave_error_handler) (
"dggev failed to converge");
492 if (ai.
elem (j) == 0.0)
495 for (
F77_INT i = 0; i < nvr; i++)
497 for (
F77_INT i = 0; i < nvl; i++)
503 (*current_liboctave_error_handler) (
"EIG: internal error");
510 for (
F77_INT i = 0; i < nvr; i++)
512 double real_part = vr.
elem (i, j);
513 double imag_part = vr.
elem (i, j+1);
517 for (
F77_INT i = 0; i < nvl; i++)
519 double real_part = vl.
elem (i, j);
520 double imag_part = vl.
elem (i, j+1);
541 if (
n != a_nc || nb != b_nc)
542 (*current_liboctave_error_handler) (
"EIG requires square matrix");
545 (*current_liboctave_error_handler) (
"EIG requires same size matrices");
561 F77_XFCN (dsygv, DSYGV, (1, F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
562 F77_CONST_CHAR_ARG2 (
"U", 1),
565 pwr, &dummy_work, lwork, info
567 F77_CHAR_ARG_LEN (1)));
570 (*current_liboctave_error_handler) (
"dsygv workspace query failed");
572 lwork =
static_cast<F77_INT> (dummy_work);
576 F77_XFCN (dsygv, DSYGV, (1, F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
577 F77_CONST_CHAR_ARG2 (
"U", 1),
580 pwr, pwork, lwork, info
582 F77_CHAR_ARG_LEN (1)));
585 (*current_liboctave_error_handler) (
"unrecoverable error in dsygv");
588 (*current_liboctave_error_handler) (
"dsygv failed to converge");
599 bool calc_lev,
bool force_qz)
602 (*current_liboctave_error_handler)
603 (
"EIG: matrix contains Inf or NaN values");
611 if (
n != a_nc || nb != b_nc)
612 (*current_liboctave_error_handler) (
"EIG requires square matrix");
615 (*current_liboctave_error_handler) (
"EIG requires same size matrices");
624 F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 (
"L", 1),
627 F77_CHAR_ARG_LEN (1)));
660 F77_XFCN (zggev, ZGGEV, (F77_CONST_CHAR_ARG2 (calc_lev ?
"V" :
"N", 1),
661 F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
671 F77_CHAR_ARG_LEN (1)));
674 (*current_liboctave_error_handler) (
"zggev workspace query failed");
676 lwork =
static_cast<F77_INT> (dummy_work.real ());
680 F77_XFCN (zggev, ZGGEV, (F77_CONST_CHAR_ARG2 (calc_lev ?
"V" :
"N", 1),
681 F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
690 F77_CHAR_ARG_LEN (1)));
693 (*current_liboctave_error_handler) (
"unrecoverable error in zggev");
696 (*current_liboctave_error_handler) (
"zggev failed to converge");
711 bool calc_rev,
bool calc_lev)
719 if (
n != a_nc || nb != b_nc)
720 (*current_liboctave_error_handler) (
"EIG requires square matrix");
723 (*current_liboctave_error_handler) (
"EIG requires same size matrices");
743 F77_XFCN (zhegv, ZHEGV, (1, F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
744 F77_CONST_CHAR_ARG2 (
"U", 1),
750 F77_CHAR_ARG_LEN (1)));
753 (*current_liboctave_error_handler) (
"zhegv workspace query failed");
755 lwork =
static_cast<F77_INT> (dummy_work.real ());
759 F77_XFCN (zhegv, ZHEGV, (1, F77_CONST_CHAR_ARG2 (calc_rev ?
"V" :
"N", 1),
760 F77_CONST_CHAR_ARG2 (
"U", 1),
765 F77_CHAR_ARG_LEN (1)));
768 (*current_liboctave_error_handler) (
"unrecoverable error in zhegv");
771 (*current_liboctave_error_handler) (
"zhegv failed to converge");
T & elem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type cols(void) const
octave_idx_type rows(void) const
const T * fortran_vec(void) const
Size of the specified dimension.
void resize(octave_idx_type n, const Complex &rfv=Complex(0))
bool ishermitian(void) const
void resize(octave_idx_type nr, octave_idx_type nc, const Complex &rfv=Complex(0))
bool any_element_is_inf_or_nan(void) const
octave_idx_type hermitian_init(const ComplexMatrix &a, bool calc_rev, bool calc_lev)
ComplexColumnVector lambda
friend class ComplexMatrix
octave_idx_type init(const Matrix &a, bool calc_rev, bool calc_lev, bool balance)
octave_idx_type symmetric_init(const Matrix &a, bool calc_rev, bool calc_lev)
bool issymmetric(void) const
bool any_element_is_inf_or_nan(void) const
Vector representing the dimensions (size) of an Array.
#define F77_DBLE_CMPLX_ARG(x)
#define F77_XFCN(f, F, args)
octave_f77_int_type F77_INT
void scale(Matrix &m, double x, double y, double z)
std::complex< double > Complex