26 #if defined (HAVE_CONFIG_H)
52 #if defined (HAVE_ARPACK)
57 (*current_liboctave_warning_with_id_handler)
58 (
"Octave:convergence",
59 "eigs: 'A - sigma*B' is singular, indicating sigma is exactly "
60 "an eigenvalue so convergence is not guaranteed");
68 std::string bug_msg =
"\nThis should not happen. Please, see https://www.gnu.org/software/octave/bugs.html, and file a bug report";
73 msg =
"N must be positive";
77 msg =
"NEV must be positive";
81 msg =
"NCV-NEV >= 2 and less than or equal to N";
85 msg =
"The maximum number of Arnoldi update iterations allowed must be greater than zero";
89 msg =
"WHICH must be one of 'LM', 'SM', 'LR', 'SR', 'LI', 'SI'";
93 msg =
"BMAT must be one of 'I' or 'G'";
97 msg =
"Length of private work WORKL array is insufficient";
101 msg =
"Error return from LAPACK eigenvalue calculation";
105 if (fcn_name.compare (
"zneupd") == 0)
106 msg =
"Error return from calculation of eigenvectors. Informational error from LAPACK routine ztrevc";
107 else if (fcn_name.compare (
"dneupd") == 0)
108 msg =
"Error return from calculation of eigenvectors. Informational error from LAPACK routine dtrevc";
110 msg =
"Starting vector is zero";
115 if (fcn_name.compare (
"dneupd") == 0
116 || fcn_name.compare (
"dnaupd") == 0)
117 msg =
"IPARAM(7) must be 1,2,3,4";
118 else if (fcn_name.compare (
"zneupd") == 0
119 || fcn_name.compare (
"znaupd") == 0)
120 msg =
"IPARAM(7) must be 1,2,3";
122 msg =
"IPARAM(7) must be 1,2,3,4,5";
127 msg =
"IPARAM(7) = 1 and BMAT = 'G' are incompatible";
131 if (fcn_name.compare (
"dnaupd") == 0
132 || fcn_name.compare (
"znaupd") == 0
133 || fcn_name.compare (
"dsaupd") == 0)
134 msg = std::string (
"IPARAM(1) must be equal to 0 or 1");
135 else if (fcn_name.compare (
"dneupd") == 0
136 || fcn_name.compare (
"zneupd") == 0)
137 msg =
"HOWMNY = 'S' not yet implemented";
139 msg =
"NEV and WHICH = 'BE' are incompatible";
144 if (fcn_name.compare (
"dneupd") == 0
145 || fcn_name.compare (
"zneupd") == 0)
146 msg =
"HOWMNY must be one of 'A' or 'P' if RVEC = .true.";
147 else if (fcn_name.compare (
"dsaupd") == 0)
148 msg =
"NEV and WHICH = 'BE' are incompatible";
153 if (fcn_name.compare (
"dneupd") == 0)
154 msg =
"DNAUPD did not find any eigenvalues to sufficient accuracy.";
155 else if (fcn_name.compare (
"zneupd") == 0)
156 msg =
"ZNAUPD did not find any eigenvalues to sufficient accuracy.";
157 else if (fcn_name.compare (
"dseupd") == 0)
158 msg =
"DSAUPD did not find any eigenvalues to sufficient accuracy.";
160 msg +=
" Consider changing tolerance (TOL), maximum iterations (MAXIT), number of Lanzcos basis vectors (P), or starting vector (V0) in OPTS structure.";
165 if (fcn_name.compare (
"dseupd") == 0)
166 msg =
"HOWMNY must be one of 'A' or 'S' if RVEC = .true.";
171 if (fcn_name.compare (
"dseupd") == 0)
172 msg =
"HOWMNY = 'S' not yet implemented";
177 if (fcn_name.compare (
"dnaupd") == 0)
178 msg =
"Could not build an Arnoldi factorization. IPARAM(5) returns the size of the current Arnoldi factorization";
183 if (fcn_name.compare (
"dneupd") == 0)
184 msg =
"The Schur form computed by LAPACK routine dlahqr could not be reordered by LAPACK routine dtrsen. Re-enter subroutine DNEUPD with IPARAM(5)=NCV and increase the size of the arrays DR and DI to have dimension at least dimension NCV and allocate at least NCV columns for Z. NOTE: Not necessary if Z and V share the same space. Please notify the authors if this error occurs.";
185 else if (fcn_name.compare (
"dnaupd") == 0
186 || fcn_name.compare (
"znaupd") == 0
187 || fcn_name.compare (
"dsaupd") == 0)
188 msg =
"Maximum number of iterations taken. All possible eigenvalues of OP has been found. IPARAM(5) returns the number of wanted converged Ritz values";
189 else if (fcn_name.compare (
"znaupd") == 0)
190 msg =
"The Schur form computed by LAPACK routine csheqr could not be reordered by LAPACK routine ztrsen. Re-enter subroutine ZNEUPD with IPARAM(5)=NCV and increase the size of the array D to have dimension at least dimension NCV and allocate at least NCV columns for Z. NOTE: Not necessary if Z and V share the same space. Please notify the authors if this error occurs.";
195 if (fcn_name.compare (
"dnaupd") == 0
196 || fcn_name.compare (
"znaupd") == 0
197 || fcn_name.compare (
"dsaupd") == 0)
198 msg =
"No longer an informational error. Deprecated starting with release 2 of ARPACK.";
203 if (fcn_name.compare (
"dnaupd") == 0
204 || fcn_name.compare (
"znaupd") == 0
205 || fcn_name.compare (
"dsaupd") == 0)
206 msg =
"No shifts could be applied during a cycle of the implicitly restarted Arnoldi iteration. One possibility is to increase the size of NCV relative to NEV.";
212 if ((errnum != -9) && (errnum != -14) && (errnum != -9999))
213 msg.append (bug_msg);
218 template <
typename M,
typename SM>
220 lusolve (
const SM& L,
const SM& U,
M&
m)
228 m = L.solve (ltyp,
m, err, rcond,
nullptr);
232 m = U.solve (utyp,
m, err, rcond,
nullptr);
237 template <
typename SM,
typename M>
248 const double *qv =
Q.data ();
254 return L.solve (ltyp, retval, err, rcond,
nullptr);
257 template <
typename SM,
typename M>
267 M tmp = U.solve (utyp,
m, err, rcond,
nullptr);
269 const double *qv =
Q.data ();
273 retval.resize (
n, b_nc);
286 vector_product (
const SparseMatrix&
m,
const double *
x,
double *y)
295 y[
m.ridx (i)] +=
m.data (i) *
x[j];
301 vector_product (
const Matrix&
m,
const double *
x,
double *y)
303 F77_INT nr = octave::to_f77_int (
m.rows ());
304 F77_INT nc = octave::to_f77_int (
m.cols ());
306 F77_XFCN (dgemv, DGEMV, (F77_CONST_CHAR_ARG2 (
"N", 1),
307 nr, nc, 1.0,
m.data (), nr,
309 F77_CHAR_ARG_LEN (1)));
325 y[
m.ridx (i)] +=
m.data (i) *
x[j];
333 F77_INT nr = octave::to_f77_int (
m.rows ());
334 F77_INT nc = octave::to_f77_int (
m.cols ());
336 F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 (
"N", 1),
341 F77_CHAR_ARG_LEN (1)));
350 octave::math::chol<Matrix> fact (b, info);
357 bt = fact.chol_matrix ();
370 octave::math::sparse_chol<SparseMatrix> fact (b, info,
false);
378 permB = fact.perm () - 1.0;
387 octave::math::chol<ComplexMatrix> fact (b, info);
394 bt = fact.chol_matrix ();
408 octave::math::sparse_chol<SparseComplexMatrix> fact (b, info,
false);
416 permB = fact.perm () - 1.0;
451 AminusSigmaB -= sigma * tmp *
455 AminusSigmaB -= sigma * b.
transpose () * b;
458 AminusSigmaB -= sigma * b;
465 sigmat.xcidx (0) = 0;
468 sigmat.xdata (i) = sigma;
469 sigmat.xridx (i) = i;
470 sigmat.xcidx (i+1) = i + 1;
473 AminusSigmaB -= sigmat;
477 octave::math::sparse_lu<SparseMatrix> fact (AminusSigmaB,
Matrix (),
true);
511 double rcond = (minU / maxU);
512 volatile double rcond_plus_one = rcond + 1.0;
540 const double *pB = permB.
data ();
541 double *p = AminusSigmaB.fortran_vec ();
556 AminusSigmaB -= sigma * b;
567 octave::math::lu<Matrix> fact (AminusSigmaB);
585 double d = std::abs (U.
xelem (j, j));
593 double rcond = (minU / maxU);
594 volatile double rcond_plus_one = rcond + 1.0;
632 AminusSigmaB -= tmp * b.
hermitian () * b *
636 AminusSigmaB -= sigma * b.
hermitian () * b;
639 AminusSigmaB -= sigma * b;
646 sigmat.xcidx (0) = 0;
649 sigmat.xdata (i) = sigma;
650 sigmat.xridx (i) = i;
651 sigmat.xcidx (i+1) = i + 1;
654 AminusSigmaB -= sigmat;
658 octave::math::sparse_lu<SparseComplexMatrix> fact (AminusSigmaB,
Matrix(),
693 double rcond = (minU / maxU);
694 volatile double rcond_plus_one = rcond + 1.0;
722 const double *pB = permB.
data ();
723 Complex *p = AminusSigmaB.fortran_vec ();
738 AminusSigmaB -= sigma * b;
749 octave::math::lu<ComplexMatrix> fact (AminusSigmaB);
767 double d = std::abs (U.
xelem (j, j));
775 double rcond = (minU / maxU);
776 volatile double rcond_plus_one = rcond + 1.0;
784 template <
typename M>
791 std::ostream& os,
double tol,
bool rvec,
792 bool cholB,
int disp,
int maxit)
794 F77_INT k = octave::to_f77_int (k_arg);
795 F77_INT p = octave::to_f77_int (p_arg);
797 F77_INT n = octave::to_f77_int (
m.cols ());
799 bool have_b = ! b.isempty ();
805 if (
m.rows () !=
m.cols ())
806 (*current_liboctave_error_handler) (
"eigs: A must be square");
807 if (have_b && (
m.rows () != b.rows () ||
m.rows () != b.cols ()))
809 (
"eigs: B must be square and the same size as A");
813 std::string rand_dist = octave::rand::distribution ();
814 octave::rand::distribution (
"uniform");
816 octave::rand::distribution (rand_dist);
818 else if (
m.cols () != resid.
numel ())
819 (*current_liboctave_error_handler) (
"eigs: opts.v0 must be n-by-1");
822 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
835 if (k < 1 || k >
n - 2)
836 (*current_liboctave_error_handler)
837 (
"eigs: Invalid number of eigenvalues to extract"
838 " (must be 0 < k < n-1-1).\n"
839 " Use 'eig (full (A))' instead");
842 (*current_liboctave_error_handler)
843 (
"eigs: opts.p must be greater than k and less than or equal to n");
845 if (have_b && cholB && ! permB.
isempty ())
856 if (checked(bidx) || bidx < 0 || bidx >=
n
862 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
863 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
865 (*current_liboctave_error_handler) (
"eigs: unrecognized sigma value");
867 if (typ ==
"LI" || typ ==
"SI" || typ ==
"LR" || typ ==
"SR")
868 (*current_liboctave_error_handler)
869 (
"eigs: invalid sigma value for real symmetric problem");
888 if (! make_cholb (b, bt, permB))
889 (*current_liboctave_error_handler)
890 (
"eigs: The matrix B is not positive definite");
924 F77_INT tmp_info = octave::to_f77_int (info);
927 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
928 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
929 k, tol, presid, p, v,
n, iparam,
930 ipntr, workd, workl, lwork, tmp_info
931 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
939 os <<
"Iteration " << iter - 1 <<
940 ": a few Ritz values of the " << p <<
"-by-" <<
944 for (
F77_INT i = 0; i < k; i++)
945 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
950 for (
F77_INT i = p - k; i < p; i++)
951 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
964 if (ido == -1 || ido == 1 || ido == 2)
970 mtmp(i, 0) = workd[i + iptr(0) - 1];
972 mtmp = ltsolve (b, permB,
m * utsolve (bt, permB, mtmp));
975 workd[i+iptr(1)-1] = mtmp(i, 0);
977 else if (! vector_product (
m, workd + iptr(0) - 1,
978 workd + iptr(1) - 1))
984 (*current_liboctave_error_handler)
985 (
"eigs: error in dsaupd: %s",
1012 (rvec, F77_CONST_CHAR_ARG2 (
"A", 1), sel,
d, z,
n, sigma,
1013 F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
1014 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2), k, tol, presid, p, v,
n, iparam,
1015 ipntr, workd, workl, lwork, info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1)
1016 F77_CHAR_ARG_LEN(2));
1020 for (
F77_INT i = ip(4); i < k; i++)
1023 if (typ !=
"SM" && typ !=
"BE" && ! (typ ==
"SA" && rvec))
1025 for (
F77_INT i = 0; i < k2; i++)
1028 d[i] =
d[ip(4) - i - 1];
1029 d[ip(4) - i - 1] = dtmp;
1035 for (
F77_INT i = ip(4); i < k; i++)
1041 if (typ !=
"SM" && typ !=
"BE" && typ !=
"SA")
1045 for (
F77_INT i = 0; i < k2; i++)
1048 F77_INT off2 = (ip(4) - i - 1) *
n;
1054 dtmp[j] = z[off1 + j];
1057 z[off1 + j] = z[off2 + j];
1060 z[off2 + j] = dtmp[j];
1065 eig_vec = utsolve (bt, permB, eig_vec);
1070 (
"eigs: error in dseupd: %s",
1076 template <
typename M>
1083 std::ostream& os,
double tol,
bool rvec,
1084 bool cholB,
int disp,
int maxit)
1086 F77_INT k = octave::to_f77_int (k_arg);
1087 F77_INT p = octave::to_f77_int (p_arg);
1089 F77_INT n = octave::to_f77_int (
m.cols ());
1091 bool have_b = ! b.isempty ();
1092 std::string typ =
"LM";
1094 if (
m.rows () !=
m.cols ())
1095 (*current_liboctave_error_handler) (
"eigs: A must be square");
1096 if (have_b && (
m.rows () != b.rows () ||
m.rows () != b.cols ()))
1098 (
"eigs: B must be square and the same size as A");
1108 std::string rand_dist = octave::rand::distribution ();
1109 octave::rand::distribution (
"uniform");
1111 octave::rand::distribution (rand_dist);
1113 else if (
m.cols () != resid.
numel ())
1114 (*current_liboctave_error_handler) (
"eigs: opts.v0 must be n-by-1");
1117 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
1119 if (k <= 0 || k >=
n - 1)
1120 (*current_liboctave_error_handler)
1121 (
"eigs: Invalid number of eigenvalues to extract"
1122 " (must be 0 < k < n-1-1).\n"
1123 " Use 'eig (full (A))' instead");
1136 if (p <= k || p >
n)
1137 (*current_liboctave_error_handler)
1138 (
"eigs: opts.p must be greater than k and less than or equal to n");
1140 if (have_b && cholB && ! permB.
isempty ())
1151 if (checked(bidx) || bidx < 0 || bidx >=
n
1188 if (! LuAminusSigmaB (
m, b, cholB, permB, sigma, L, U, P,
Q,
r))
1200 F77_INT tmp_info = octave::to_f77_int (info);
1203 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
1204 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
1205 k, tol, presid, p, v,
n, iparam,
1206 ipntr, workd, workl, lwork, tmp_info
1207 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
1214 os <<
"Iteration " << iter - 1 <<
1215 ": a few Ritz values of the " << p <<
"-by-" <<
1219 for (
F77_INT i = 0; i < k; i++)
1220 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
1225 for (
F77_INT i = p - k; i < p; i++)
1226 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
1239 if (ido == -1 || ido == 1 || ido == 2)
1247 vector_product (b, workd+iptr(0)-1, dtmp);
1252 tmp(i, 0) = dtmp[P[i]] /
r(P[i]);
1254 lusolve (L, U, tmp);
1256 double *ip2 = workd+iptr(1)-1;
1258 ip2[
Q[i]] = tmp(i, 0);
1261 vector_product (b, workd+iptr(0)-1, workd+iptr(1)-1);
1264 double *ip2 = workd+iptr(2)-1;
1268 tmp(i, 0) = ip2[P[i]] /
r(P[i]);
1270 lusolve (L, U, tmp);
1272 ip2 = workd+iptr(1)-1;
1274 ip2[
Q[i]] = tmp(i, 0);
1280 double *ip2 = workd+iptr(0)-1;
1284 tmp(i, 0) = ip2[P[i]] /
r(P[i]);
1286 lusolve (L, U, tmp);
1288 ip2 = workd+iptr(1)-1;
1290 ip2[
Q[i]] = tmp(i, 0);
1296 (*current_liboctave_error_handler)
1297 (
"eigs: error in dsaupd: %s",
1324 (rvec, F77_CONST_CHAR_ARG2 (
"A", 1), sel,
d, z,
n, sigma,
1325 F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
1326 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
1327 k, tol, presid, p, v,
n, iparam, ipntr, workd, workl, lwork, info2
1328 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
1332 for (
F77_INT i = ip(4); i < k; i++)
1335 for (
F77_INT i = 0; i < k2; i++)
1338 d[i] =
d[ip(4) - i - 1];
1339 d[ip(4) - i - 1] = dtmp;
1346 for (
F77_INT i = ip(4); i < k; i++)
1352 for (
F77_INT i = 0; i < k2; i++)
1355 F77_INT off2 = (ip(4) - i - 1) *
n;
1361 dtmp[j] = z[off1 + j];
1364 z[off1 + j] = z[off2 + j];
1367 z[off2 + j] = dtmp[j];
1373 (
"eigs: error in dseupd: %s",
1379 template <
typename M>
1382 const std::string& _typ,
double sigma,
1387 std::ostream& os,
double tol,
bool rvec,
1388 bool cholB,
int disp,
int maxit)
1390 F77_INT n = octave::to_f77_int (n_arg);
1391 F77_INT k = octave::to_f77_int (k_arg);
1392 F77_INT p = octave::to_f77_int (p_arg);
1394 std::string typ (_typ);
1395 bool have_sigma = (sigma ? true :
false);
1396 bool have_b = ! b.isempty ();
1405 std::string rand_dist = octave::rand::distribution ();
1406 octave::rand::distribution (
"uniform");
1408 octave::rand::distribution (rand_dist);
1410 else if (
n != resid.
numel ())
1411 (*current_liboctave_error_handler) (
"eigs: opts.v0 must be n-by-1");
1414 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
1427 if (k <= 0 || k >=
n - 1)
1428 (*current_liboctave_error_handler)
1429 (
"eigs: Invalid number of eigenvalues to extract"
1430 " (must be 0 < k < n-1).\n"
1431 " Use 'eig (full (A))' instead");
1433 if (p <= k || p >
n)
1434 (*current_liboctave_error_handler)
1435 (
"eigs: opts.p must be greater than k and less than or equal to n");
1437 if (have_b && cholB && ! permB.
isempty ())
1448 if (checked(bidx) || bidx < 0 || bidx >=
n
1456 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
1457 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
1459 (*current_liboctave_error_handler) (
"eigs: unrecognized sigma value");
1461 if (typ ==
"LI" || typ ==
"SI" || typ ==
"LR" || typ ==
"SR")
1462 (*current_liboctave_error_handler)
1463 (
"eigs: invalid sigma value for real symmetric problem");
1465 if (typ !=
"SM" && have_b)
1477 else if (! std::abs (sigma))
1491 if (mode == 1 && have_b)
1508 if (! make_cholb (b, bt, permB))
1509 (*current_liboctave_error_handler)
1510 (
"eigs: The matrix B is not positive definite");
1544 F77_INT tmp_info = octave::to_f77_int (info);
1547 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
1548 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
1549 k, tol, presid, p, v,
n, iparam,
1550 ipntr, workd, workl, lwork, tmp_info
1551 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
1559 os <<
"Iteration " << iter - 1 <<
1560 ": a few Ritz values of the " << p <<
"-by-" <<
1564 for (
F77_INT i = 0; i < k; i++)
1565 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
1570 for (
F77_INT i = p - k; i < p; i++)
1571 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
1584 if (ido == -1 || ido == 1 || ido == 2)
1592 mtmp(i, 0) = workd[i + iptr(0) - 1];
1594 mtmp = utsolve (bt, permB, mtmp);
1600 mtmp = ltsolve (b, permB, y);
1603 workd[i+iptr(1)-1] = mtmp(i, 0);
1611 vector_product (b, workd+iptr(0)-1, dtmp);
1623 double *ip2 = workd + iptr(1) - 1;
1628 vector_product (b, workd+iptr(0)-1, workd+iptr(1)-1);
1631 double *ip2 = workd+iptr(2)-1;
1642 ip2 = workd + iptr(1) - 1;
1650 double *ip2 = workd + iptr(0) - 1;
1661 ip2 = workd + iptr(1) - 1;
1669 (*current_liboctave_error_handler)
1670 (
"eigs: error in dsaupd: %s",
1697 (rvec, F77_CONST_CHAR_ARG2 (
"A", 1), sel,
d, z,
n, sigma,
1698 F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
1699 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
1700 k, tol, presid, p, v,
n, iparam, ipntr, workd, workl, lwork, info2
1701 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
1705 for (
F77_INT i = ip(4); i < k; i++)
1708 if (mode == 3 || (mode == 1 && typ !=
"SM" && typ !=
"BE"))
1710 for (
F77_INT i = 0; i < k2; i++)
1713 d[i] =
d[ip(4) - i - 1];
1714 d[ip(4) - i - 1] = dtmp;
1720 for (
F77_INT i = ip(4); i < k; i++)
1726 if (mode == 3 || (mode == 1 && typ !=
"SM" && typ !=
"BE"))
1730 for (
F77_INT i = 0; i < k2; i++)
1733 F77_INT off2 = (ip(4) - i - 1) *
n;
1739 dtmp[j] = z[off1 + j];
1742 z[off1 + j] = z[off2 + j];
1745 z[off2 + j] = dtmp[j];
1749 eig_vec = utsolve (bt, permB, eig_vec);
1754 (
"eigs: error in dseupd: %s",
1760 template <
typename M>
1767 std::ostream& os,
double tol,
bool rvec,
1768 bool cholB,
int disp,
int maxit)
1770 F77_INT k = octave::to_f77_int (k_arg);
1771 F77_INT p = octave::to_f77_int (p_arg);
1773 F77_INT n = octave::to_f77_int (
m.cols ());
1775 bool have_b = ! b.isempty ();
1782 if (
m.rows () !=
m.cols ())
1783 (*current_liboctave_error_handler) (
"eigs: A must be square");
1784 if (have_b && (
m.rows () != b.rows () ||
m.rows () != b.cols ()))
1786 (
"eigs: B must be square and the same size as A");
1790 std::string rand_dist = octave::rand::distribution ();
1791 octave::rand::distribution (
"uniform");
1793 octave::rand::distribution (rand_dist);
1795 else if (
m.cols () != resid.
numel ())
1796 (*current_liboctave_error_handler) (
"eigs: opts.v0 must be n-by-1");
1799 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
1812 if (k <= 0 || k >=
n - 1)
1813 (*current_liboctave_error_handler)
1814 (
"eigs: Invalid number of eigenvalues to extract"
1815 " (must be 0 < k < n-1).\n"
1816 " Use 'eig (full (A))' instead");
1818 if (p <= k || p >
n)
1819 (*current_liboctave_error_handler)
1820 (
"eigs: opts.p must be greater than k and less than or equal to n");
1822 if (have_b && cholB && ! permB.
isempty ())
1833 if (checked(bidx) || bidx < 0 || bidx >=
n
1839 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
1840 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
1842 (*current_liboctave_error_handler) (
"eigs: unrecognized sigma value");
1844 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
1845 (*current_liboctave_error_handler)
1846 (
"eigs: invalid sigma value for unsymmetric problem");
1865 if (! make_cholb (b, bt, permB))
1866 (*current_liboctave_error_handler)
1867 (
"eigs: The matrix B is not positive definite");
1892 F77_INT lwork = 3 * p * (p + 2);
1901 F77_INT tmp_info = octave::to_f77_int (info);
1906 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
1907 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
1908 k, tol, presid, p, v,
n, iparam,
1909 ipntr, workd, workl, lwork, tmp_info
1910 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
1919 os <<
"Iteration " << iter - 1 <<
1920 ": a few Ritz values of the " << p <<
"-by-" <<
1924 os <<
" " << workl[iptr(5)+k] <<
"\n";
1925 for (
F77_INT i = 0; i < k; i++)
1926 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
1931 for (
F77_INT i = p - k - 1; i < p; i++)
1932 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
1945 if (ido == -1 || ido == 1 || ido == 2)
1951 mtmp(i, 0) = workd[i + iptr(0) - 1];
1953 mtmp = ltsolve (b, permB,
m * utsolve (bt, permB, mtmp));
1956 workd[i+iptr(1)-1] = mtmp(i, 0);
1958 else if (! vector_product (
m, workd + iptr(0) - 1,
1959 workd + iptr(1) - 1))
1965 (*current_liboctave_error_handler)
1966 (
"eigs: error in dnaupd: %s",
1993 Matrix eig_vec2 (
n, k + 1, 0.0);
1999 for (
F77_INT i = 0; i < k+1; i++)
2004 (rvec, F77_CONST_CHAR_ARG2 (
"A", 1), sel, dr, di, z,
n, sigmar,
2005 sigmai, workev, F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
2006 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2), k, tol, presid, p, v,
n, iparam,
2007 ipntr, workd, workl, lwork, info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1)
2008 F77_CHAR_ARG_LEN(2));
2012 if (! rvec && ip(4) > k)
2020 bool have_cplx_eig =
false;
2021 for (
F77_INT i = 0; i < ip(4); i++)
2027 have_cplx_eig =
true;
2033 for (
F77_INT i = ip(4); i < k; i++)
2039 for (
F77_INT i = ip(4); i < k; i++)
2046 for (
F77_INT i = 0; i < k2; i++)
2049 d[i] =
d[ip(4) - i - 1];
2050 d[ip(4) - i - 1] = dtmp;
2065 eig_vec(j, i) =
Complex (z[j+off1], 0.);
2072 eig_vec(j, i) =
Complex (z[j+off1], z[j+off2]);
2074 eig_vec(j, i+1) =
Complex (z[j+off1], -z[j+off2]);
2081 for (
F77_INT ii = ip(4); ii < k; ii++)
2089 for (
F77_INT ii = ip(4); ii < k; ii++)
2095 eig_vec = utsolve (bt, permB, eig_vec);
2105 (
"eigs: error in dneupd: %s",
2111 template <
typename M>
2119 std::ostream& os,
double tol,
bool rvec,
2120 bool cholB,
int disp,
int maxit)
2122 F77_INT k = octave::to_f77_int (k_arg);
2123 F77_INT p = octave::to_f77_int (p_arg);
2125 F77_INT n = octave::to_f77_int (
m.cols ());
2127 bool have_b = ! b.isempty ();
2128 std::string typ =
"LM";
2131 if (
m.rows () !=
m.cols ())
2132 (*current_liboctave_error_handler) (
"eigs: A must be square");
2133 if (have_b && (
m.rows () != b.rows () ||
m.rows () != b.cols ()))
2135 (
"eigs: B must be square and the same size as A");
2145 std::string rand_dist = octave::rand::distribution ();
2146 octave::rand::distribution (
"uniform");
2148 octave::rand::distribution (rand_dist);
2150 else if (
m.cols () != resid.
numel ())
2151 (*current_liboctave_error_handler) (
"eigs: opts.v0 must be n-by-1");
2154 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
2167 if (k <= 0 || k >=
n - 1)
2168 (*current_liboctave_error_handler)
2169 (
"eigs: Invalid number of eigenvalues to extract"
2170 " (must be 0 < k < n-1).\n"
2171 " Use 'eig (full (A))' instead");
2173 if (p <= k || p >
n)
2174 (*current_liboctave_error_handler)
2175 (
"eigs: opts.p must be greater than k and less than or equal to n");
2177 if (have_b && cholB && ! permB.
isempty ())
2188 if (checked(bidx) || bidx < 0 || bidx >=
n
2225 if (! LuAminusSigmaB (
m, b, cholB, permB, sigmar, L, U, P,
Q,
r))
2228 F77_INT lwork = 3 * p * (p + 2);
2237 F77_INT tmp_info = octave::to_f77_int (info);
2242 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
2243 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
2244 k, tol, presid, p, v,
n, iparam,
2245 ipntr, workd, workl, lwork, tmp_info
2246 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
2255 os <<
"Iteration " << iter - 1 <<
2256 ": a few Ritz values of the " << p <<
"-by-" <<
2260 os <<
" " << workl[iptr(5)+k] <<
"\n";
2261 for (
F77_INT i = 0; i < k; i++)
2262 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
2267 for (
F77_INT i = p - k - 1; i < p; i++)
2268 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
2281 if (ido == -1 || ido == 1 || ido == 2)
2289 vector_product (b, workd+iptr(0)-1, dtmp);
2294 tmp(i, 0) = dtmp[P[i]] /
r(P[i]);
2296 lusolve (L, U, tmp);
2298 double *ip2 = workd+iptr(1)-1;
2300 ip2[
Q[i]] = tmp(i, 0);
2303 vector_product (b, workd+iptr(0)-1, workd+iptr(1)-1);
2306 double *ip2 = workd+iptr(2)-1;
2310 tmp(i, 0) = ip2[P[i]] /
r(P[i]);
2312 lusolve (L, U, tmp);
2314 ip2 = workd+iptr(1)-1;
2316 ip2[
Q[i]] = tmp(i, 0);
2322 double *ip2 = workd+iptr(0)-1;
2326 tmp(i, 0) = ip2[P[i]] /
r(P[i]);
2328 lusolve (L, U, tmp);
2330 ip2 = workd+iptr(1)-1;
2332 ip2[
Q[i]] = tmp(i, 0);
2338 (*current_liboctave_error_handler)
2339 (
"eigs: error in dnaupd: %s",
2366 Matrix eig_vec2 (
n, k + 1, 0.0);
2372 for (
F77_INT i = 0; i < k+1; i++)
2377 (rvec, F77_CONST_CHAR_ARG2 (
"A", 1), sel, dr, di, z,
n, sigmar,
2378 sigmai, workev, F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
2379 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2), k, tol, presid, p, v,
n, iparam,
2380 ipntr, workd, workl, lwork, info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1)
2381 F77_CHAR_ARG_LEN(2));
2385 if (! rvec && ip(4) > k)
2393 bool have_cplx_eig =
false;
2394 for (
F77_INT i = 0; i < ip(4); i++)
2400 have_cplx_eig =
true;
2406 for (
F77_INT i = ip(4); i < k; i++)
2412 for (
F77_INT i = ip(4); i < k; i++)
2420 for (
F77_INT i = 0; i < k2; i++)
2423 d[i] =
d[ip(4) - i - 1];
2424 d[ip(4) - i - 1] = dtmp;
2439 eig_vec(j, i) =
Complex (z[j+off1], 0.);
2446 eig_vec(j, i) =
Complex (z[j+off1], z[j+off2]);
2448 eig_vec(j, i+1) =
Complex (z[j+off1], -z[j+off2]);
2455 for (
F77_INT ii = ip(4); ii < k; ii++)
2463 for (
F77_INT ii = ip(4); ii < k; ii++)
2477 (
"eigs: error in dneupd: %s",
2483 template <
typename M>
2486 const std::string& _typ,
double sigmar,
2491 std::ostream& os,
double tol,
bool rvec,
2492 bool cholB,
int disp,
int maxit)
2494 F77_INT n = octave::to_f77_int (n_arg);
2495 F77_INT k = octave::to_f77_int (k_arg);
2496 F77_INT p = octave::to_f77_int (p_arg);
2498 std::string typ (_typ);
2499 bool have_sigma = (sigmar ? true :
false);
2502 bool have_b = ! b.isempty ();
2510 std::string rand_dist = octave::rand::distribution ();
2511 octave::rand::distribution (
"uniform");
2513 octave::rand::distribution (rand_dist);
2515 else if (
n != resid.
numel ())
2516 (*current_liboctave_error_handler) (
"eigs: opts.v0 must be n-by-1");
2519 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
2532 if (k <= 0 || k >=
n - 1)
2533 (*current_liboctave_error_handler)
2534 (
"eigs: Invalid number of eigenvalues to extract"
2535 " (must be 0 < k < n-1).\n"
2536 " Use 'eig (full (A))' instead");
2538 if (p <= k || p >
n)
2539 (*current_liboctave_error_handler)
2540 (
"eigs: opts.p must be greater than k and less than or equal to n");
2542 if (have_b && cholB && ! permB.
isempty ())
2553 if (checked(bidx) || bidx < 0 || bidx >=
n
2561 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
2562 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
2564 (*current_liboctave_error_handler) (
"eigs: unrecognized sigma value");
2566 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
2567 (*current_liboctave_error_handler)
2568 (
"eigs: invalid sigma value for unsymmetric problem");
2570 if (typ !=
"SM" && have_b)
2582 else if (! std::abs (sigmar))
2596 if (mode == 1 && have_b)
2613 if (! make_cholb (b, bt, permB))
2614 (*current_liboctave_error_handler)
2615 (
"eigs: The matrix B is not positive definite");
2640 F77_INT lwork = 3 * p * (p + 2);
2649 F77_INT tmp_info = octave::to_f77_int (info);
2654 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
2655 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
2656 k, tol, presid, p, v,
n, iparam,
2657 ipntr, workd, workl, lwork, tmp_info
2658 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
2667 os <<
"Iteration " << iter - 1 <<
2668 ": a few Ritz values of the " << p <<
"-by-" <<
2672 os <<
" " << workl[iptr(5)+k] <<
"\n";
2673 for (
F77_INT i = 0; i < k; i++)
2674 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
2679 for (
F77_INT i = p - k - 1; i < p; i++)
2680 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
2693 if (ido == -1 || ido == 1 || ido == 2)
2701 mtmp(i, 0) = workd[i + iptr(0) - 1];
2703 mtmp = utsolve (bt, permB, mtmp);
2709 mtmp = ltsolve (b, permB, y);
2712 workd[i+iptr(1)-1] = mtmp(i, 0);
2720 vector_product (b, workd+iptr(0)-1, dtmp);
2732 double *ip2 = workd + iptr(1) - 1;
2737 vector_product (b, workd+iptr(0)-1, workd+iptr(1)-1);
2740 double *ip2 = workd+iptr(2)-1;
2751 ip2 = workd + iptr(1) - 1;
2759 double *ip2 = workd + iptr(0) - 1;
2770 ip2 = workd + iptr(1) - 1;
2778 (*current_liboctave_error_handler)
2779 (
"eigs: error in dnaupd: %s",
2806 Matrix eig_vec2 (
n, k + 1, 0.0);
2812 for (
F77_INT i = 0; i < k+1; i++)
2817 (rvec, F77_CONST_CHAR_ARG2 (
"A", 1), sel, dr, di, z,
n, sigmar,
2818 sigmai, workev, F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
2819 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2), k, tol, presid, p, v,
n, iparam,
2820 ipntr, workd, workl, lwork, info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1)
2821 F77_CHAR_ARG_LEN(2));
2825 if (! rvec && ip(4) > k)
2833 bool have_cplx_eig =
false;
2834 for (
F77_INT i = 0; i < ip(4); i++)
2840 have_cplx_eig =
true;
2846 for (
F77_INT i = ip(4); i < k; i++)
2852 for (
F77_INT i = ip(4); i < k; i++)
2860 for (
F77_INT i = 0; i < k2; i++)
2863 d[i] =
d[ip(4) - i - 1];
2864 d[ip(4) - i - 1] = dtmp;
2879 eig_vec(j, i) =
Complex (z[j+off1], 0.);
2886 eig_vec(j, i) =
Complex (z[j+off1], z[j+off2]);
2888 eig_vec(j, i+1) =
Complex (z[j+off1], -z[j+off2]);
2895 for (
F77_INT ii = ip(4); ii < k; ii++)
2903 for (
F77_INT ii = ip(4); ii < k; ii++)
2909 eig_vec = utsolve (bt, permB, eig_vec);
2919 (
"eigs: error in dneupd: %s",
2925 template <
typename M>
2933 std::ostream& os,
double tol,
bool rvec,
2934 bool cholB,
int disp,
int maxit)
2936 F77_INT k = octave::to_f77_int (k_arg);
2937 F77_INT p = octave::to_f77_int (p_arg);
2939 F77_INT n = octave::to_f77_int (
m.cols ());
2941 bool have_b = ! b.isempty ();
2947 if (
m.rows () !=
m.cols ())
2948 (*current_liboctave_error_handler) (
"eigs: A must be square");
2949 if (have_b && (
m.rows () != b.rows () ||
m.rows () != b.cols ()))
2951 (
"eigs: B must be square and the same size as A");
2955 std::string rand_dist = octave::rand::distribution ();
2956 octave::rand::distribution (
"uniform");
2961 cresid(i) =
Complex (rr(i), ri(i));
2962 octave::rand::distribution (rand_dist);
2964 else if (
m.cols () != cresid.
numel ())
2965 (*current_liboctave_error_handler) (
"eigs: opts.v0 must be n-by-1");
2968 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
2981 if (k <= 0 || k >=
n - 1)
2982 (*current_liboctave_error_handler)
2983 (
"eigs: Invalid number of eigenvalues to extract"
2984 " (must be 0 < k < n-1).\n"
2985 " Use 'eig (full (A))' instead");
2987 if (p <= k || p >
n)
2988 (*current_liboctave_error_handler)
2989 (
"eigs: opts.p must be greater than k and less than or equal to n");
2991 if (have_b && cholB && ! permB.
isempty ())
3002 if (checked(bidx) || bidx < 0 || bidx >=
n
3008 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
3009 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
3011 (*current_liboctave_error_handler) (
"eigs: unrecognized sigma value");
3013 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
3014 (*current_liboctave_error_handler)
3015 (
"eigs: invalid sigma value for complex problem");
3034 if (! make_cholb (b, bt, permB))
3035 (*current_liboctave_error_handler)
3036 (
"eigs: The matrix B is not positive definite");
3061 F77_INT lwork = p * (3 * p + 5);
3071 F77_INT tmp_info = octave::to_f77_int (info);
3074 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
3075 F77_CONST_CHAR_ARG2 (typ.c_str (), 2),
3079 tmp_info F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
3087 os <<
"Iteration " << iter - 1 <<
3088 ": a few Ritz values of the " << p <<
"-by-" <<
3092 for (
F77_INT i = 0; i < k; i++)
3093 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
3098 for (
F77_INT i = p - k; i < p; i++)
3099 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
3112 if (ido == -1 || ido == 1 || ido == 2)
3118 mtmp(i, 0) = workd[i + iptr(0) - 1];
3119 mtmp = ltsolve (b, permB,
m * utsolve (bt, permB, mtmp));
3121 workd[i+iptr(1)-1] = mtmp(i, 0);
3124 else if (! vector_product (
m, workd + iptr(0) - 1,
3125 workd + iptr(1) - 1))
3131 (*current_liboctave_error_handler)
3132 (
"eigs: error %" OCTAVE_IDX_TYPE_FORMAT
" in znaupd: %s",
3164 F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
3165 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
3169 info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
3173 for (
F77_INT i = ip(4); i < k; i++)
3178 for (
F77_INT i = 0; i < k2; i++)
3181 d[i] =
d[ip(4) - i - 1];
3182 d[ip(4) - i - 1] = ctmp;
3190 for (
F77_INT i = ip(4); i < k; i++)
3198 for (
F77_INT i = 0; i < k2; i++)
3201 F77_INT off2 = (ip(4) - i - 1) *
n;
3207 ctmp[j] = z[off1 + j];
3210 z[off1 + j] = z[off2 + j];
3213 z[off2 + j] = ctmp[j];
3217 eig_vec = utsolve (bt, permB, eig_vec);
3222 (
"eigs: error in zneupd: %s",
3228 template <
typename M>
3237 std::ostream& os,
double tol,
bool rvec,
3238 bool cholB,
int disp,
int maxit)
3240 F77_INT k = octave::to_f77_int (k_arg);
3241 F77_INT p = octave::to_f77_int (p_arg);
3243 F77_INT n = octave::to_f77_int (
m.cols ());
3245 bool have_b = ! b.isempty ();
3246 std::string typ =
"LM";
3248 if (
m.rows () !=
m.cols ())
3249 (*current_liboctave_error_handler) (
"eigs: A must be square");
3250 if (have_b && (
m.rows () != b.rows () ||
m.rows () != b.cols ()))
3252 (
"eigs: B must be square and the same size as A");
3262 std::string rand_dist = octave::rand::distribution ();
3263 octave::rand::distribution (
"uniform");
3268 cresid(i) =
Complex (rr(i), ri(i));
3269 octave::rand::distribution (rand_dist);
3271 else if (
m.cols () != cresid.
numel ())
3272 (*current_liboctave_error_handler) (
"eigs: opts.v0 must be n-by-1");
3275 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
3288 if (k <= 0 || k >=
n - 1)
3289 (*current_liboctave_error_handler)
3290 (
"eigs: Invalid number of eigenvalues to extract"
3291 " (must be 0 < k < n-1).\n"
3292 " Use 'eig (full (A))' instead");
3294 if (p <= k || p >
n)
3295 (*current_liboctave_error_handler)
3296 (
"eigs: opts.p must be greater than k and less than or equal to n");
3298 if (have_b && cholB && ! permB.
isempty ())
3309 if (checked(bidx) || bidx < 0 || bidx >=
n
3346 if (! LuAminusSigmaB (
m, b, cholB, permB, sigma, L, U, P,
Q,
r))
3349 F77_INT lwork = p * (3 * p + 5);
3359 F77_INT tmp_info = octave::to_f77_int (info);
3362 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
3363 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
3367 tmp_info F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
3375 os <<
"Iteration " << iter - 1 <<
3376 ": a few Ritz values of the " << p <<
"-by-" <<
3380 for (
F77_INT i = 0; i < k; i++)
3381 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
3386 for (
F77_INT i = p - k; i < p; i++)
3387 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
3400 if (ido == -1 || ido == 1 || ido == 2)
3408 vector_product (b, workd+iptr(0)-1, ctmp);
3413 tmp(i, 0) = ctmp[P[i]] /
r(P[i]);
3415 lusolve (L, U, tmp);
3417 Complex *ip2 = workd+iptr(1)-1;
3419 ip2[
Q[i]] = tmp(i, 0);
3422 vector_product (b, workd + iptr(0) - 1, workd + iptr(1) - 1);
3425 Complex *ip2 = workd+iptr(2)-1;
3429 tmp(i, 0) = ip2[P[i]] /
r(P[i]);
3431 lusolve (L, U, tmp);
3433 ip2 = workd+iptr(1)-1;
3435 ip2[
Q[i]] = tmp(i, 0);
3441 Complex *ip2 = workd+iptr(0)-1;
3445 tmp(i, 0) = ip2[P[i]] /
r(P[i]);
3447 lusolve (L, U, tmp);
3449 ip2 = workd+iptr(1)-1;
3451 ip2[
Q[i]] = tmp(i, 0);
3457 (*current_liboctave_error_handler)
3458 (
"eigs: error %" OCTAVE_IDX_TYPE_FORMAT
" in znaupd: %s",
3490 F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
3491 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
3495 info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
3499 for (
F77_INT i = ip(4); i < k; i++)
3504 for (
F77_INT i = 0; i < k2; i++)
3507 d[i] =
d[ip(4) - i - 1];
3508 d[ip(4) - i - 1] = ctmp;
3516 for (
F77_INT i = ip(4); i < k; i++)
3524 for (
F77_INT i = 0; i < k2; i++)
3527 F77_INT off2 = (ip(4) - i - 1) *
n;
3533 ctmp[j] = z[off1 + j];
3536 z[off1 + j] = z[off2 + j];
3539 z[off2 + j] = ctmp[j];
3545 (
"eigs: error in zneupd: %s",
3551 template <
typename M>
3554 const std::string& _typ,
Complex sigma,
3559 std::ostream& os,
double tol,
bool rvec,
3560 bool cholB,
int disp,
int maxit)
3562 F77_INT n = octave::to_f77_int (n_arg);
3563 F77_INT k = octave::to_f77_int (k_arg);
3564 F77_INT p = octave::to_f77_int (p_arg);
3566 std::string typ (_typ);
3567 bool have_sigma = (std::abs (sigma) ? true :
false);
3569 bool have_b = ! b.isempty ();
3577 std::string rand_dist = octave::rand::distribution ();
3578 octave::rand::distribution (
"uniform");
3583 cresid(i) =
Complex (rr(i), ri(i));
3584 octave::rand::distribution (rand_dist);
3586 else if (
n != cresid.
numel ())
3587 (*current_liboctave_error_handler) (
"eigs: opts.v0 must be n-by-1");
3590 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
3603 if (k <= 0 || k >=
n - 1)
3604 (*current_liboctave_error_handler)
3605 (
"eigs: Invalid number of eigenvalues to extract"
3606 " (must be 0 < k < n-1).\n"
3607 " Use 'eig (full (A))' instead");
3609 if (p <= k || p >
n)
3610 (*current_liboctave_error_handler)
3611 (
"eigs: opts.p must be greater than k and less than or equal to n");
3613 if (have_b && cholB && ! permB.
isempty ())
3624 if (checked(bidx) || bidx < 0 || bidx >=
n
3632 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
3633 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
3635 (*current_liboctave_error_handler) (
"eigs: unrecognized sigma value");
3637 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
3638 (*current_liboctave_error_handler)
3639 (
"eigs: invalid sigma value for complex problem");
3641 if (typ !=
"SM" && have_b)
3653 else if (! std::abs (sigma))
3667 if (mode == 1 && have_b)
3684 if (! make_cholb (b, bt, permB))
3685 (*current_liboctave_error_handler)
3686 (
"eigs: The matrix B is not positive definite");
3711 F77_INT lwork = p * (3 * p + 5);
3721 F77_INT tmp_info = octave::to_f77_int (info);
3724 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
3725 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
3729 tmp_info F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
3737 os <<
"Iteration " << iter - 1 <<
3738 ": a few Ritz values of the " << p <<
"-by-" <<
3742 for (
F77_INT i = 0; i < k; i++)
3743 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
3748 for (
F77_INT i = p - k; i < p; i++)
3749 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
3762 if (ido == -1 || ido == 1 || ido == 2)
3770 mtmp(i, 0) = workd[i + iptr(0) - 1];
3772 mtmp = utsolve (bt, permB, mtmp);
3778 mtmp = ltsolve (b, permB, y);
3781 workd[i+iptr(1)-1] = mtmp(i, 0);
3789 vector_product (b, workd+iptr(0)-1, ctmp);
3801 Complex *ip2 = workd+iptr(1)-1;
3806 vector_product (b, workd+iptr(0)-1, workd+iptr(1)-1);
3809 Complex *ip2 = workd+iptr(2)-1;
3820 ip2 = workd + iptr(1) - 1;
3828 Complex *ip2 = workd + iptr(0) - 1;
3839 ip2 = workd + iptr(1) - 1;
3847 (*current_liboctave_error_handler)
3848 (
"eigs: error %" OCTAVE_IDX_TYPE_FORMAT
" in znaupd: %s",
3880 F77_CONST_CHAR_ARG2 (&bmat, 1),
n,
3881 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
3885 info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
3889 for (
F77_INT i = ip(4); i < k; i++)
3894 for (
F77_INT i = 0; i < k2; i++)
3897 d[i] =
d[ip(4) - i - 1];
3898 d[ip(4) - i - 1] = ctmp;
3906 for (
F77_INT i = ip(4); i < k; i++)
3914 for (
F77_INT i = 0; i < k2; i++)
3917 F77_INT off2 = (ip(4) - i - 1) *
n;
3923 ctmp[j] = z[off1 + j];
3926 z[off1 + j] = z[off2 + j];
3929 z[off2 + j] = ctmp[j];
3932 eig_vec = utsolve (bt, permB, eig_vec);
3937 (
"eigs: error in zneupd: %s",
3953 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
3954 bool cholB,
int disp,
int maxit);
3962 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
3963 bool cholB,
int disp,
int maxit);
3972 bool rvec,
bool cholB,
int disp,
int maxit);
3980 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
3981 bool cholB,
int disp,
int maxit);
3989 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
3990 bool cholB,
int disp,
int maxit);
3999 bool rvec,
bool cholB,
int disp,
int maxit);
4009 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
4010 bool cholB,
int disp,
int maxit);
4018 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
4019 bool cholB,
int disp,
int maxit);
4028 bool rvec,
bool cholB,
int disp,
int maxit);
4036 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
4037 bool cholB,
int disp,
int maxit);
4045 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
4046 bool cholB,
int disp,
int maxit);
4055 std::ostream& os,
double tol,
bool rvec,
bool cholB,
int disp,
int maxit);
4066 bool rvec,
bool cholB,
int disp,
int maxit);
4075 bool rvec,
bool cholB,
int disp,
int maxit);
4084 std::ostream& os,
double tol,
bool rvec,
bool cholB,
int disp,
int maxit);
4095 double tol,
bool rvec,
bool cholB,
int disp,
int maxit);
4104 double tol,
bool rvec,
bool cholB,
int disp,
int maxit);
4114 bool cholB,
int disp,
int maxit);
T * fortran_vec()
Size of the specified dimension.
octave_idx_type rows() const
const T * data() const
Size of the specified dimension.
octave_idx_type cols() const
bool isempty() const
Size of the specified dimension.
T & xelem(octave_idx_type n)
Size of the specified dimension.
octave_idx_type numel() const
Number of elements in the array.
void resize(octave_idx_type n, const double &rfv=0)
void resize(octave_idx_type n, const Complex &rfv=Complex(0))
void resize(octave_idx_type nr, octave_idx_type nc, const Complex &rfv=Complex(0))
ComplexMatrix hermitian() const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
SparseComplexMatrix hermitian() const
SparseMatrix transpose() const
octave_idx_type * xcidx()
octave_idx_type * xridx()
Vector representing the dimensions (size) of an Array.
ColumnVector real(const ComplexColumnVector &a)
ColumnVector imag(const ComplexColumnVector &a)
template octave_idx_type EigsComplexNonSymmetricFunc< ComplexMatrix >(EigsComplexFunc fcn, octave_idx_type n, const std::string &_typ, Complex sigma, octave_idx_type k, octave_idx_type p, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const ComplexMatrix &_b, ColumnVector &permB, ComplexColumnVector &cresid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsComplexNonSymmetricMatrix< SparseComplexMatrix >(const SparseComplexMatrix &m, const std::string typ, octave_idx_type k, octave_idx_type p, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const SparseComplexMatrix &_b, ColumnVector &permB, ComplexColumnVector &cresid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsComplexNonSymmetricMatrixShift< SparseComplexMatrix >(const SparseComplexMatrix &m, Complex sigma, octave_idx_type k, octave_idx_type p, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const SparseComplexMatrix &_b, ColumnVector &permB, ComplexColumnVector &cresid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsRealSymmetricFunc< Matrix >(EigsFunc fcn, octave_idx_type n, const std::string &_typ, double sigma, octave_idx_type k, octave_idx_type p, octave_idx_type &info, Matrix &eig_vec, ColumnVector &eig_val, const Matrix &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
octave_idx_type EigsRealNonSymmetricMatrixShift(const M &m, double sigmar, octave_idx_type k_arg, octave_idx_type p_arg, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const M &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
octave_idx_type EigsRealSymmetricMatrixShift(const M &m, double sigma, octave_idx_type k_arg, octave_idx_type p_arg, octave_idx_type &info, Matrix &eig_vec, ColumnVector &eig_val, const M &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsRealNonSymmetricMatrixShift< Matrix >(const Matrix &m, double sigmar, octave_idx_type k, octave_idx_type p, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const Matrix &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
octave_idx_type EigsRealNonSymmetricMatrix(const M &m, const std::string typ, octave_idx_type k_arg, octave_idx_type p_arg, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const M &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
octave_idx_type EigsComplexNonSymmetricMatrix(const M &m, const std::string typ, octave_idx_type k_arg, octave_idx_type p_arg, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const M &_b, ColumnVector &permB, ComplexColumnVector &cresid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
octave_idx_type EigsRealSymmetricFunc(EigsFunc fcn, octave_idx_type n_arg, const std::string &_typ, double sigma, octave_idx_type k_arg, octave_idx_type p_arg, octave_idx_type &info, Matrix &eig_vec, ColumnVector &eig_val, const M &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
std::string arpack_errno2str(const octave_idx_type &errnum, const std::string &fcn_name)
template octave_idx_type EigsRealSymmetricMatrixShift< SparseMatrix >(const SparseMatrix &m, double sigma, octave_idx_type k, octave_idx_type p, octave_idx_type &info, Matrix &eig_vec, ColumnVector &eig_val, const SparseMatrix &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsRealNonSymmetricMatrixShift< SparseMatrix >(const SparseMatrix &m, double sigmar, octave_idx_type k, octave_idx_type p, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const SparseMatrix &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsComplexNonSymmetricMatrixShift< ComplexMatrix >(const ComplexMatrix &m, Complex sigma, octave_idx_type k, octave_idx_type p, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const ComplexMatrix &_b, ColumnVector &permB, ComplexColumnVector &cresid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsRealNonSymmetricFunc< SparseMatrix >(EigsFunc fcn, octave_idx_type n, const std::string &_typ, double sigmar, octave_idx_type k, octave_idx_type p, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const SparseMatrix &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsRealNonSymmetricMatrix< Matrix >(const Matrix &m, const std::string typ, octave_idx_type k, octave_idx_type p, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const Matrix &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsRealSymmetricMatrixShift< Matrix >(const Matrix &m, double sigma, octave_idx_type k, octave_idx_type p, octave_idx_type &info, Matrix &eig_vec, ColumnVector &eig_val, const Matrix &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsRealSymmetricMatrix< Matrix >(const Matrix &m, const std::string typ, octave_idx_type k, octave_idx_type p, octave_idx_type &info, Matrix &eig_vec, ColumnVector &eig_val, const Matrix &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
octave_idx_type EigsRealNonSymmetricFunc(EigsFunc fcn, octave_idx_type n_arg, const std::string &_typ, double sigmar, octave_idx_type k_arg, octave_idx_type p_arg, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const M &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
octave_idx_type EigsComplexNonSymmetricMatrixShift(const M &m, Complex sigma, octave_idx_type k_arg, octave_idx_type p_arg, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const M &_b, ColumnVector &permB, ComplexColumnVector &cresid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsRealNonSymmetricMatrix< SparseMatrix >(const SparseMatrix &m, const std::string typ, octave_idx_type k, octave_idx_type p, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const SparseMatrix &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsRealSymmetricFunc< SparseMatrix >(EigsFunc fcn, octave_idx_type n, const std::string &_typ, double sigma, octave_idx_type k, octave_idx_type p, octave_idx_type &info, Matrix &eig_vec, ColumnVector &eig_val, const SparseMatrix &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
octave_idx_type EigsRealSymmetricMatrix(const M &m, const std::string typ, octave_idx_type k_arg, octave_idx_type p_arg, octave_idx_type &info, Matrix &eig_vec, ColumnVector &eig_val, const M &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
octave_idx_type EigsComplexNonSymmetricFunc(EigsComplexFunc fcn, octave_idx_type n_arg, const std::string &_typ, Complex sigma, octave_idx_type k_arg, octave_idx_type p_arg, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const M &_b, ColumnVector &permB, ComplexColumnVector &cresid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsComplexNonSymmetricFunc< SparseComplexMatrix >(EigsComplexFunc fcn, octave_idx_type n, const std::string &_typ, Complex sigma, octave_idx_type k, octave_idx_type p, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const SparseComplexMatrix &_b, ColumnVector &permB, ComplexColumnVector &cresid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsComplexNonSymmetricMatrix< ComplexMatrix >(const ComplexMatrix &m, const std::string typ, octave_idx_type k, octave_idx_type p, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const ComplexMatrix &_b, ColumnVector &permB, ComplexColumnVector &cresid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsRealSymmetricMatrix< SparseMatrix >(const SparseMatrix &m, const std::string typ, octave_idx_type k, octave_idx_type p, octave_idx_type &info, Matrix &eig_vec, ColumnVector &eig_val, const SparseMatrix &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
template octave_idx_type EigsRealNonSymmetricFunc< Matrix >(EigsFunc fcn, octave_idx_type n, const std::string &_typ, double sigmar, octave_idx_type k, octave_idx_type p, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, const Matrix &_b, ColumnVector &permB, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool cholB, int disp, int maxit)
std::function< ColumnVector(const ColumnVector &x, int &eigs_error)> EigsFunc
std::function< ComplexColumnVector(const ComplexColumnVector &x, int &eigs_error)> EigsComplexFunc
#define F77_DBLE_CMPLX_ARG(x)
#define F77_XFCN(f, F, args)
octave_f77_int_type F77_INT
#define F77_CONST_DBLE_CMPLX_ARG(x)
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
F77_RET_T const F77_INT const F77_INT const F77_INT F77_DBLE const F77_INT F77_DBLE const F77_INT F77_DBLE * Q
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT & M
F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
F77_RET_T const F77_DBLE * x
std::complex< double > Complex
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
F77_RET_T F77_FUNC(xerbla, XERBLA)(F77_CONST_CHAR_ARG_DEF(s_arg