23 #if defined (HAVE_CONFIG_H)
48 #if defined (HAVE_ARPACK)
53 (*current_liboctave_warning_with_id_handler)
54 (
"Octave:convergence",
55 "eigs: 'A - sigma*B' is singular, indicating sigma is exactly "
56 "an eigenvalue so convergence is not guaranteed");
59 template <
typename M,
typename SM>
68 m = L.solve (m, err, rcond, 0);
72 m = U.solve (utyp, m, err, rcond, 0);
77 template <
typename SM,
typename M>
86 M tmp = L.solve (ltyp, m, err, rcond, 0);
92 retval.resize (n, b_nc);
96 retval.elem (static_cast<octave_idx_type>(qv[
i]), j) =
104 template <
typename SM,
typename M>
119 retval.elem (
i,j) = m.elem (static_cast<octave_idx_type>(qv[
i]), j);
121 return U.solve (utyp, retval, err, rcond, 0);
145 F77_XFCN (dgemv, DGEMV, (F77_CONST_CHAR_ARG2 (
"N", 1),
146 nr, nc, 1.0, m.
data (), nr,
148 F77_CHAR_ARG_LEN (1)));
151 (*current_liboctave_error_handler) (
"eigs: unrecoverable error in dgemv");
178 F77_XFCN (zgemv, ZGEMV, (F77_CONST_CHAR_ARG2 (
"N", 1),
183 F77_CHAR_ARG_LEN (1)));
186 (*current_liboctave_error_handler) (
"eigs: unrecoverable error in zgemv");
223 permB = fact.
perm () - 1.0;
261 permB = fact.
perm () - 1.0;
294 AminusSigmaB -= sigma * tmp *
301 AminusSigmaB -= sigma *
b;
308 sigmat.
xcidx (0) = 0;
316 AminusSigmaB -= sigmat;
349 double rcond = (minU / maxU);
350 volatile double rcond_plus_one = rcond + 1.0;
384 *p++ -= tmp.
xelem (static_cast<octave_idx_type>(pB[
i]),
385 static_cast<octave_idx_type>(pB[j]));
391 AminusSigmaB -= sigma *
b;
421 double rcond = (minU / maxU);
422 volatile double rcond_plus_one = rcond + 1.0;
458 AminusSigmaB -= tmp * b.
hermitian () * b *
465 AminusSigmaB -= sigma *
b;
472 sigmat.
xcidx (0) = 0;
480 AminusSigmaB -= sigmat;
513 double rcond = (minU / maxU);
514 volatile double rcond_plus_one = rcond + 1.0;
548 *p++ -= tmp.
xelem (static_cast<octave_idx_type>(pB[
i]),
549 static_cast<octave_idx_type>(pB[j]));
555 AminusSigmaB -= sigma *
b;
585 double rcond = (minU / maxU);
586 volatile double rcond_plus_one = rcond + 1.0;
594 template <
typename M>
601 std::ostream& os,
double tol,
bool rvec,
602 bool cholB,
int disp,
int maxit)
607 bool have_b = ! b.is_empty ();
613 if (m.rows () != m.cols ())
615 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
616 (*current_liboctave_error_handler)
617 (
"eigs: B must be square and the same size as A");
628 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
641 if (k < 1 || k > n - 2)
642 (*current_liboctave_error_handler)
643 (
"eigs: Invalid number of eigenvalues to extract"
644 " (must be 0 < k < n-1-1).\n"
645 " Use 'eig (full (A))' instead");
647 if (p <= k || p >= n)
648 (*current_liboctave_error_handler)
649 (
"eigs: opts.p must be greater than k and less than n");
651 if (have_b && cholB && ! permB.
is_empty ())
654 if (permB.
numel () != n)
662 if (checked(bidx) || bidx < 0 || bidx >= n
668 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
669 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
671 (*current_liboctave_error_handler) (
"eigs: unrecognized sigma value");
673 if (typ ==
"LI" || typ ==
"SI" || typ ==
"LR" || typ ==
"SR")
674 (*current_liboctave_error_handler)
675 (
"eigs: invalid sigma value for real symmetric problem");
695 (*current_liboctave_error_handler)
696 (
"eigs: The matrix B is not positive definite");
731 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
732 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
733 k, tol, presid,
p, v, n, iparam,
734 ipntr, workd, workl, lwork, info
735 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
738 (*current_liboctave_error_handler)
739 (
"eigs: unrecoverable exception encountered in dsaupd");
745 os <<
"Iteration " << iter - 1 <<
746 ": a few Ritz values of the " << p <<
"-by-" <<
748 for (
int i = 0 ;
i <
k;
i++)
749 os <<
" " << workl[iptr(5)+
i-1] <<
"\n";
761 if (ido == -1 || ido == 1 || ido == 2)
767 mtmp(
i,0) = workd[
i + iptr(0) - 1];
772 workd[
i+iptr(1)-1] = mtmp(
i,0);
775 workd + iptr(1) - 1))
781 (*current_liboctave_error_handler)
782 (
"eigs: error %d in dsaupd", info);
808 (rvec, F77_CONST_CHAR_ARG2 (
"A", 1), sel,
d, z, n, sigma,
809 F77_CONST_CHAR_ARG2 (&bmat, 1), n,
810 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
k, tol, presid,
p, v, n, iparam,
811 ipntr, workd, workl, lwork, info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1)
812 F77_CHAR_ARG_LEN(2));
815 (*current_liboctave_error_handler)
816 (
"eigs: unrecoverable exception encountered in dseupd");
821 if (typ !=
"SM" && typ !=
"BE")
833 if (typ !=
"SM" && typ !=
"BE")
846 dtmp[j] = z[off1 + j];
849 z[off1 + j] = z[off2 + j];
852 z[off2 + j] = dtmp[j];
857 eig_vec =
ltsolve (b, permB, eig_vec);
866 template <
typename M>
873 std::ostream& os,
double tol,
bool rvec,
874 bool cholB,
int disp,
int maxit)
879 bool have_b = ! b.is_empty ();
882 if (m.rows () != m.cols ())
884 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
885 (*current_liboctave_error_handler)
886 (
"eigs: B must be square and the same size as A");
903 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
905 if (k <= 0 || k >= n - 1)
906 (*current_liboctave_error_handler)
907 (
"eigs: Invalid number of eigenvalues to extract"
908 " (must be 0 < k < n-1-1).\n"
909 " Use 'eig (full (A))' instead");
922 if (p <= k || p >= n)
923 (*current_liboctave_error_handler)
924 (
"eigs: opts.p must be greater than k and less than n");
926 if (have_b && cholB && ! permB.
is_empty ())
929 if (permB.
numel () != n)
937 if (checked(bidx) || bidx < 0 || bidx >= n
986 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
987 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
988 k, tol, presid,
p, v, n, iparam,
989 ipntr, workd, workl, lwork, info
990 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
993 (*current_liboctave_error_handler)
994 (
"eigs: unrecoverable exception encountered in dsaupd");
1000 os <<
"Iteration " << iter - 1 <<
1001 ": a few Ritz values of the " << p <<
"-by-" <<
1003 for (
int i = 0 ;
i <
k;
i++)
1004 os <<
" " << workl[iptr(5)+
i-1] <<
"\n";
1016 if (ido == -1 || ido == 1 || ido == 2)
1033 double *ip2 = workd+iptr(1)-1;
1041 double *ip2 = workd+iptr(2)-1;
1049 ip2 = workd+iptr(1)-1;
1059 workd[iptr(0) +
i - 1] = workd[iptr(1) +
i - 1];
1063 double *ip2 = workd+iptr(0)-1;
1071 ip2 = workd+iptr(1)-1;
1080 (*current_liboctave_error_handler)
1081 (
"eigs: error %d in dsaupd", info);
1107 (rvec, F77_CONST_CHAR_ARG2 (
"A", 1), sel,
d, z, n, sigma,
1108 F77_CONST_CHAR_ARG2 (&bmat, 1), n,
1109 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
1110 k, tol, presid,
p, v, n, iparam, ipntr, workd, workl, lwork, info2
1111 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
1114 (*current_liboctave_error_handler)
1115 (
"eigs: unrecoverable exception encountered in dseupd");
1123 d[
i] = d[k -
i - 1];
1124 d[k -
i - 1] = dtmp;
1140 dtmp[j] = z[off1 + j];
1143 z[off1 + j] = z[off2 + j];
1146 z[off2 + j] = dtmp[j];
1162 std::ostream& os,
double tol,
bool rvec,
1163 bool ,
int disp,
int maxit)
1166 bool have_sigma = (sigma ?
true :
false);
1180 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
1193 if (k <= 0 || k >= n - 1)
1194 (*current_liboctave_error_handler)
1195 (
"eigs: Invalid number of eigenvalues to extract"
1196 " (must be 0 < k < n-1).\n"
1197 " Use 'eig (full (A))' instead");
1199 if (p <= k || p >= n)
1200 (*current_liboctave_error_handler)
1201 (
"eigs: opts.p must be greater than k and less than n");
1205 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
1206 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
1208 (*current_liboctave_error_handler) (
"eigs: unrecognized sigma value");
1210 if (typ ==
"LI" || typ ==
"SI" || typ ==
"LR" || typ ==
"SR")
1211 (*current_liboctave_error_handler)
1212 (
"eigs: invalid sigma value for real symmetric problem");
1260 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
1261 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
1262 k, tol, presid,
p, v, n, iparam,
1263 ipntr, workd, workl, lwork, info
1264 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
1267 (*current_liboctave_error_handler)
1268 (
"eigs: unrecoverable exception encountered in dsaupd");
1274 os <<
"Iteration " << iter - 1 <<
1275 ": a few Ritz values of the " << p <<
"-by-" <<
1277 for (
int i = 0 ;
i <
k;
i++)
1278 os <<
" " << workl[iptr(5)+
i-1] <<
"\n";
1290 if (ido == -1 || ido == 1 || ido == 2)
1292 double *ip2 = workd + iptr(0) - 1;
1303 ip2 = workd + iptr(1) - 1;
1310 (*current_liboctave_error_handler)
1311 (
"eigs: error %d in dsaupd", info);
1337 (rvec, F77_CONST_CHAR_ARG2 (
"A", 1), sel,
d, z, n, sigma,
1338 F77_CONST_CHAR_ARG2 (&bmat, 1), n,
1339 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
1340 k, tol, presid,
p, v, n, iparam, ipntr, workd, workl, lwork, info2
1341 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
1344 (*current_liboctave_error_handler)
1345 (
"eigs: unrecoverable exception encountered in dseupd");
1350 if (typ !=
"SM" && typ !=
"BE")
1355 d[
i] = d[k -
i - 1];
1356 d[k -
i - 1] = dtmp;
1362 if (typ !=
"SM" && typ !=
"BE")
1375 dtmp[j] = z[off1 + j];
1378 z[off1 + j] = z[off2 + j];
1381 z[off2 + j] = dtmp[j];
1392 template <
typename M>
1399 std::ostream& os,
double tol,
bool rvec,
1400 bool cholB,
int disp,
int maxit)
1405 bool have_b = ! b.is_empty ();
1412 if (m.rows () != m.cols ())
1414 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
1415 (*current_liboctave_error_handler)
1416 (
"eigs: B must be square and the same size as A");
1427 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
1440 if (k <= 0 || k >= n - 1)
1441 (*current_liboctave_error_handler)
1442 (
"eigs: Invalid number of eigenvalues to extract"
1443 " (must be 0 < k < n-1).\n"
1444 " Use 'eig (full (A))' instead");
1446 if (p <= k || p >= n)
1447 (*current_liboctave_error_handler)
1448 (
"eigs: opts.p must be greater than k and less than n");
1450 if (have_b && cholB && ! permB.
is_empty ())
1453 if (permB.
numel () != n)
1461 if (checked(bidx) || bidx < 0 || bidx >= n
1467 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
1468 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
1470 (*current_liboctave_error_handler) (
"eigs: unrecognized sigma value");
1472 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
1473 (*current_liboctave_error_handler)
1474 (
"eigs: invalid sigma value for unsymmetric problem");
1494 (*current_liboctave_error_handler)
1495 (
"eigs: The matrix B is not positive definite");
1530 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
1531 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
1532 k, tol, presid,
p, v, n, iparam,
1533 ipntr, workd, workl, lwork, info
1534 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
1537 (*current_liboctave_error_handler)
1538 (
"eigs: unrecoverable exception encountered in dnaupd");
1544 os <<
"Iteration " << iter - 1 <<
1545 ": a few Ritz values of the " << p <<
"-by-" <<
1547 for (
int i = 0 ;
i <
k;
i++)
1548 os <<
" " << workl[iptr(5)+
i-1] <<
"\n";
1560 if (ido == -1 || ido == 1 || ido == 2)
1566 mtmp(
i,0) = workd[
i + iptr(0) - 1];
1571 workd[
i+iptr(1)-1] = mtmp(
i,0);
1574 workd + iptr(1) - 1))
1580 (*current_liboctave_error_handler)
1581 (
"eigs: error %d in dnaupd", info);
1607 Matrix eig_vec2 (n, k + 1, 0.0);
1617 (rvec, F77_CONST_CHAR_ARG2 (
"A", 1), sel, dr, di, z, n, sigmar,
1618 sigmai, workev, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
1619 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
k, tol, presid,
p, v, n, iparam,
1620 ipntr, workd, workl, lwork, info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1)
1621 F77_CHAR_ARG_LEN(2));
1624 (*current_liboctave_error_handler)
1625 (
"eigs: unrecoverable exception encountered in dneupd");
1635 if (dr[
i] == 0.0 && di[
i] == 0.0 && jj == 0)
1640 if (jj == 0 && ! rvec)
1648 d[
i] = d[k -
i - 1];
1649 d[k -
i - 1] = dtmp;
1666 dtmp[j] = z[off1 + j];
1669 z[off1 + j] = z[off2 + j];
1672 z[off2 + j] = dtmp[j];
1693 Complex (z[j+off1],z[j+off2]);
1696 Complex (z[j+off1],-z[j+off2]);
1703 eig_vec =
ltsolve (
M(b), permB, eig_vec);
1712 template <
typename M>
1720 std::ostream& os,
double tol,
bool rvec,
1721 bool cholB,
int disp,
int maxit)
1726 bool have_b = ! b.is_empty ();
1730 if (m.rows () != m.cols ())
1732 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
1733 (*current_liboctave_error_handler)
1734 (
"eigs: B must be square and the same size as A");
1751 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
1764 if (k <= 0 || k >= n - 1)
1765 (*current_liboctave_error_handler)
1766 (
"eigs: Invalid number of eigenvalues to extract"
1767 " (must be 0 < k < n-1).\n"
1768 " Use 'eig (full (A))' instead");
1770 if (p <= k || p >= n)
1771 (*current_liboctave_error_handler)
1772 (
"eigs: opts.p must be greater than k and less than n");
1774 if (have_b && cholB && ! permB.
is_empty ())
1777 if (permB.
numel () != n)
1785 if (checked(bidx) || bidx < 0 || bidx >= n
1834 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
1835 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
1836 k, tol, presid,
p, v, n, iparam,
1837 ipntr, workd, workl, lwork, info
1838 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
1841 (*current_liboctave_error_handler)
1842 (
"eigs: unrecoverable exception encountered in dsaupd");
1848 os <<
"Iteration " << iter - 1 <<
1849 ": a few Ritz values of the " << p <<
"-by-" <<
1851 for (
int i = 0 ;
i <
k;
i++)
1852 os <<
" " << workl[iptr(5)+
i-1] <<
"\n";
1864 if (ido == -1 || ido == 1 || ido == 2)
1881 double *ip2 = workd+iptr(1)-1;
1889 double *ip2 = workd+iptr(2)-1;
1897 ip2 = workd+iptr(1)-1;
1907 workd[iptr(0) +
i - 1] = workd[iptr(1) +
i - 1];
1911 double *ip2 = workd+iptr(0)-1;
1919 ip2 = workd+iptr(1)-1;
1928 (*current_liboctave_error_handler)
1929 (
"eigs: error %d in dsaupd", info);
1955 Matrix eig_vec2 (n, k + 1, 0.0);
1965 (rvec, F77_CONST_CHAR_ARG2 (
"A", 1), sel, dr, di, z, n, sigmar,
1966 sigmai, workev, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
1967 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
k, tol, presid,
p, v, n, iparam,
1968 ipntr, workd, workl, lwork, info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1)
1969 F77_CHAR_ARG_LEN(2));
1972 (*current_liboctave_error_handler)
1973 (
"eigs: unrecoverable exception encountered in dneupd");
1983 if (dr[
i] == 0.0 && di[
i] == 0.0 && jj == 0)
1988 if (jj == 0 && ! rvec)
1996 d[
i] = d[k -
i - 1];
1997 d[k -
i - 1] = dtmp;
2014 dtmp[j] = z[off1 + j];
2017 z[off1 + j] = z[off2 + j];
2020 z[off2 + j] = dtmp[j];
2041 Complex (z[j+off1],z[j+off2]);
2044 Complex (z[j+off1],-z[j+off2]);
2063 std::ostream& os,
double tol,
bool rvec,
2064 bool ,
int disp,
int maxit)
2067 bool have_sigma = (sigmar ?
true :
false);
2082 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
2095 if (k <= 0 || k >= n - 1)
2096 (*current_liboctave_error_handler)
2097 (
"eigs: Invalid number of eigenvalues to extract"
2098 " (must be 0 < k < n-1).\n"
2099 " Use 'eig (full (A))' instead");
2101 if (p <= k || p >= n)
2102 (*current_liboctave_error_handler)
2103 (
"eigs: opts.p must be greater than k and less than n");
2107 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
2108 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
2110 (*current_liboctave_error_handler) (
"eigs: unrecognized sigma value");
2112 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
2113 (*current_liboctave_error_handler)
2114 (
"eigs: invalid sigma value for unsymmetric problem");
2162 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
2163 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
2164 k, tol, presid,
p, v, n, iparam,
2165 ipntr, workd, workl, lwork, info
2166 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
2169 (*current_liboctave_error_handler)
2170 (
"eigs: unrecoverable exception encountered in dnaupd");
2176 os <<
"Iteration " << iter - 1 <<
2177 ": a few Ritz values of the " << p <<
"-by-" <<
2179 for (
int i = 0 ;
i <
k;
i++)
2180 os <<
" " << workl[iptr(5)+
i-1] <<
"\n";
2192 if (ido == -1 || ido == 1 || ido == 2)
2194 double *ip2 = workd + iptr(0) - 1;
2205 ip2 = workd + iptr(1) - 1;
2212 (*current_liboctave_error_handler)
2213 (
"eigs: error %d in dsaupd", info);
2239 Matrix eig_vec2 (n, k + 1, 0.0);
2249 (rvec, F77_CONST_CHAR_ARG2 (
"A", 1), sel, dr, di, z, n, sigmar,
2250 sigmai, workev, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
2251 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
k, tol, presid,
p, v, n, iparam,
2252 ipntr, workd, workl, lwork, info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1)
2253 F77_CHAR_ARG_LEN(2));
2256 (*current_liboctave_error_handler)
2257 (
"eigs: unrecoverable exception encountered in dneupd");
2267 if (dr[
i] == 0.0 && di[
i] == 0.0 && jj == 0)
2272 if (jj == 0 && ! rvec)
2280 d[
i] = d[k -
i - 1];
2281 d[k -
i - 1] = dtmp;
2298 dtmp[j] = z[off1 + j];
2301 z[off1 + j] = z[off2 + j];
2304 z[off2 + j] = dtmp[j];
2325 Complex (z[j+off1],z[j+off2]);
2328 Complex (z[j+off1],-z[j+off2]);
2341 template <
typename M>
2349 std::ostream& os,
double tol,
bool rvec,
2350 bool cholB,
int disp,
int maxit)
2355 bool have_b = ! b.is_empty ();
2361 if (m.rows () != m.cols ())
2363 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
2364 (*current_liboctave_error_handler)
2365 (
"eigs: B must be square and the same size as A");
2380 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
2393 if (k <= 0 || k >= n - 1)
2394 (*current_liboctave_error_handler)
2395 (
"eigs: Invalid number of eigenvalues to extract"
2396 " (must be 0 < k < n-1).\n"
2397 " Use 'eig (full (A))' instead");
2399 if (p <= k || p >= n)
2400 (*current_liboctave_error_handler)
2401 (
"eigs: opts.p must be greater than k and less than n");
2403 if (have_b && cholB && ! permB.
is_empty ())
2406 if (permB.
numel () != n)
2414 if (checked(bidx) || bidx < 0 || bidx >= n
2420 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
2421 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
2423 (*current_liboctave_error_handler) (
"eigs: unrecognized sigma value");
2425 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
2426 (*current_liboctave_error_handler)
2427 (
"eigs: invalid sigma value for complex problem");
2447 (*current_liboctave_error_handler)
2448 (
"eigs: The matrix B is not positive definite");
2484 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
2485 F77_CONST_CHAR_ARG2 (typ.c_str (), 2),
2490 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
2493 (*current_liboctave_error_handler)
2494 (
"eigs: unrecoverable exception encountered in znaupd");
2500 os <<
"Iteration " << iter - 1 <<
2501 ": a few Ritz values of the " << p <<
"-by-" <<
2503 for (
int i = 0 ;
i <
k;
i++)
2504 os <<
" " << workl[iptr(5)+
i-1] <<
"\n";
2516 if (ido == -1 || ido == 1 || ido == 2)
2522 mtmp(
i,0) = workd[
i + iptr(0) - 1];
2525 workd[
i+iptr(1)-1] = mtmp(
i,0);
2529 workd + iptr(1) - 1))
2535 (*current_liboctave_error_handler)
2536 (
"eigs: error %d in znaupd", info);
2567 F77_CONST_CHAR_ARG2 (&bmat, 1), n,
2568 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
2572 info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
2575 (*current_liboctave_error_handler)
2576 (
"eigs: unrecoverable exception encountered in zneupd");
2584 d[
i] = d[k -
i - 1];
2585 d[k -
i - 1] = ctmp;
2602 ctmp[j] = z[off1 + j];
2605 z[off1 + j] = z[off2 + j];
2608 z[off2 + j] = ctmp[j];
2612 eig_vec =
ltsolve (b, permB, eig_vec);
2621 template <
typename M>
2630 std::ostream& os,
double tol,
bool rvec,
2631 bool cholB,
int disp,
int maxit)
2636 bool have_b = ! b.is_empty ();
2639 if (m.rows () != m.cols ())
2641 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
2642 (*current_liboctave_error_handler)
2643 (
"eigs: B must be square and the same size as A");
2664 (*current_liboctave_error_handler) (
"eigs: n must be at least 3");
2677 if (k <= 0 || k >= n - 1)
2678 (*current_liboctave_error_handler)
2679 (
"eigs: Invalid number of eigenvalues to extract"
2680 " (must be 0 < k < n-1).\n"
2681 " Use 'eig (full (A))' instead");
2683 if (p <= k || p >= n)
2684 (*current_liboctave_error_handler)
2685 (
"eigs: opts.p must be greater than k and less than n");
2687 if (have_b && cholB && ! permB.
is_empty ())
2690 if (permB.
numel () != n)
2698 if (checked(bidx) || bidx < 0 || bidx >= n
2748 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
2749 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
2753 info F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
2756 (*current_liboctave_error_handler)
2757 (
"eigs: unrecoverable exception encountered in znaupd");
2763 os <<
"Iteration " << iter - 1 <<
2764 ": a few Ritz values of the " << p <<
"-by-" <<
2766 for (
int i = 0 ;
i <
k;
i++)
2767 os <<
" " << workl[iptr(5)+
i-1] <<
"\n";
2779 if (ido == -1 || ido == 1 || ido == 2)
2796 Complex *ip2 = workd+iptr(1)-1;
2804 Complex *ip2 = workd+iptr(2)-1;
2812 ip2 = workd+iptr(1)-1;
2822 workd[iptr(0) +
i - 1] =
2823 workd[iptr(1) +
i - 1];
2827 Complex *ip2 = workd+iptr(0)-1;
2835 ip2 = workd+iptr(1)-1;
2844 (*current_liboctave_error_handler)
2845 (
"eigs: error %d in dsaupd", info);
2876 F77_CONST_CHAR_ARG2 (&bmat, 1), n,
2877 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
2881 info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
2884 (*current_liboctave_error_handler)
2885 (
"eigs: unrecoverable exception encountered in zneupd");
2893 d[
i] = d[k -
i - 1];
2894 d[k -
i - 1] = ctmp;
2911 ctmp[j] = z[off1 + j];
2914 z[off1 + j] = z[off2 + j];
2917 z[off2 + j] = ctmp[j];
2923 (
"eigs: error %d in zneupd", info2);
2935 double tol,
bool rvec,
bool ,
2936 int disp,
int maxit)
2939 bool have_sigma = (
std::abs (sigma) ?
true :
false);
2957 (*current_liboctave_error_handler)
2958 (
"eigs: n must be at least 3");
2971 if (k <= 0 || k >= n - 1)
2972 (*current_liboctave_error_handler)
2973 (
"eigs: Invalid number of eigenvalues to extract"
2974 " (must be 0 < k < n-1).\n"
2975 " Use 'eig (full (A))' instead");
2977 if (p <= k || p >= n)
2978 (*current_liboctave_error_handler)
2979 (
"eigs: opts.p must be greater than k and less than n");
2983 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
2984 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
2986 (*current_liboctave_error_handler) (
"eigs: unrecognized sigma value");
2988 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
2989 (*current_liboctave_error_handler)
2990 (
"eigs: invalid sigma value for complex problem");
3039 (ido, F77_CONST_CHAR_ARG2 (&bmat, 1), n,
3040 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
3044 info F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
3047 (*current_liboctave_error_handler)
3048 (
"eigs: unrecoverable exception encountered in znaupd");
3054 os <<
"Iteration " << iter - 1 <<
3055 ": a few Ritz values of the " << p <<
"-by-" <<
3057 for (
int i = 0 ;
i <
k;
i++)
3058 os <<
" " << workl[iptr(5)+
i-1] <<
"\n";
3070 if (ido == -1 || ido == 1 || ido == 2)
3072 Complex *ip2 = workd + iptr(0) - 1;
3083 ip2 = workd + iptr(1) - 1;
3090 (*current_liboctave_error_handler)
3091 (
"eigs: error %d in dsaupd", info);
3122 F77_CONST_CHAR_ARG2 (&bmat, 1), n,
3123 F77_CONST_CHAR_ARG2 ((typ.c_str ()), 2),
3127 info2 F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(1) F77_CHAR_ARG_LEN(2));
3130 (*current_liboctave_error_handler)
3131 (
"eigs: unrecoverable exception encountered in zneupd");
3139 d[
i] = d[k -
i - 1];
3140 d[k -
i - 1] = ctmp;
3157 ctmp[j] = z[off1 + j];
3160 z[off1 + j] = z[off2 + j];
3163 z[off2 + j] = ctmp[j];
3183 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
3184 bool cholB,
int disp,
int maxit);
3192 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
3193 bool cholB,
int disp,
int maxit);
3201 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
3202 bool cholB,
int disp,
int maxit);
3210 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
3211 bool cholB,
int disp,
int maxit);
3221 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
3222 bool cholB,
int disp,
int maxit);
3230 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
3231 bool cholB,
int disp,
int maxit);
3239 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
3240 bool cholB,
int disp,
int maxit);
3248 ColumnVector& resid, std::ostream& os,
double tol,
bool rvec,
3249 bool cholB,
int disp,
int maxit);
3260 bool rvec,
bool cholB,
int disp,
int maxit);
3269 bool rvec,
bool cholB,
int disp,
int maxit);
3280 double tol,
bool rvec,
bool cholB,
int disp,
int maxit);
3289 double tol,
bool rvec,
bool cholB,
int disp,
int maxit);
octave_idx_type * xridx(void)
octave_idx_type P(void) const
octave_idx_type EigsComplexNonSymmetricMatrixShift(const M &m, Complex sigma, octave_idx_type k, octave_idx_type p, 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)
bool is_empty(void) const
static bool make_cholb(Matrix &b, Matrix &bt, ColumnVector &permB)
octave_idx_type cols(void) const
void resize(octave_idx_type n, const Complex &rfv=Complex(0))
octave_idx_type rows(void) const
octave_idx_type EigsRealSymmetricFunc(EigsFunc fun, 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, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool, int disp, int maxit)
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
SparseMatrix transpose(void) const
octave_idx_type EigsRealNonSymmetricFunc(EigsFunc fun, 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, ColumnVector &resid, std::ostream &os, double tol, bool rvec, bool, int disp, int maxit)
octave_idx_type numel(void) const
Number of elements in the array.
ColumnVector(* EigsFunc)(const ColumnVector &x, int &eigs_error)
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
OCTAVE_NORETURN liboctave_error_handler current_liboctave_error_handler
#define F77_DBLE_CMPLX_ARG(x)
RowVector perm(void) const
octave_idx_type * xcidx(void)
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)
PermMatrix transpose(void) const
octave_idx_type EigsRealNonSymmetricMatrix(const M &m, const std::string typ, octave_idx_type k, octave_idx_type p, 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)
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)
octave_idx_type * cidx(void)
static bool vector_product(const SparseMatrix &m, const double *x, double *y)
static Array< double > vector(octave_idx_type n, double a=1.0)
int f77_exception_encountered
#define F77_XFCN(f, F, args)
static void warn_convergence(void)
const octave_idx_type * col_perm(void) const
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)
octave_idx_type rows(void) const
F77_RET_T const F77_INT const F77_INT const F77_INT const F77_DBLE const F77_DBLE F77_INT & M
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 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)
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
static bool LuAminusSigmaB(const SparseMatrix &m, const SparseMatrix &b, bool cholB, const ColumnVector &permB, double sigma, SparseMatrix &L, SparseMatrix &U, octave_idx_type *P, octave_idx_type *Q)
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)
ComplexMatrix hermitian(void) const
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)
const octave_idx_type * row_perm(void) const
nd deftypefn *octave_map m
octave_idx_type EigsRealSymmetricMatrix(const M &m, const std::string typ, octave_idx_type k, octave_idx_type p, 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 EigsComplexNonSymmetricMatrix(const M &m, const std::string typ, octave_idx_type k, octave_idx_type p, 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 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)
const T * data(void) const
octave_idx_type EigsRealNonSymmetricMatrixShift(const M &m, double sigmar, octave_idx_type k, octave_idx_type p, 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)
Matrix transpose(void) const
F77_RET_T F77_FUNC(xstopx, XSTOPX) const
static M ltsolve(const SM &L, const ColumnVector &Q, const M &m)
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)
SparseComplexMatrix hermitian(void) const
octave_idx_type EigsComplexNonSymmetricFunc(EigsComplexFunc fun, 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, ComplexColumnVector &cresid, std::ostream &os, double tol, bool rvec, bool, int disp, int maxit)
T & xelem(octave_idx_type n)
#define F77_CONST_DBLE_CMPLX_ARG(x)
octave_idx_type * ridx(void)
bool is_empty(void) const
void resize(octave_idx_type nr, octave_idx_type nc, const Complex &rfv=Complex(0))
static octave_idx_type lusolve(const SM &L, const SM &U, M &m)
octave_idx_type EigsRealSymmetricMatrixShift(const M &m, double sigma, octave_idx_type k, octave_idx_type p, 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)
=val(i)}if ode{val(i)}occurs in table i
OCTAVE_EXPORT octave_value_list return the value of the option it must match the dimension of the state and the relative tolerance must also be a vector of the same length tem it must match the dimension of the state and the absolute tolerance must also be a vector of the same length The local error test applied at each integration step is xample roup abs(local error in x(i))<
ComplexColumnVector(* EigsComplexFunc)(const ComplexColumnVector &x, int &eigs_error)
the element is set to zero In other the statement xample y
OCTAVE_EXPORT octave_value_list or N dimensional array whose elements are all equal to the IEEE symbol NaN(Not a Number).NaN is the result of operations which do not produce a well defined 0 result.Common operations which produce a NaN are arithmetic with infinity ex($\infty-\infty $)
static M utsolve(const SM &U, const ColumnVector &Q, const M &m)
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
static std::string distribution(void)
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)
OCTAVE_EXPORT octave_value_list error nd deftypefn *const octave_scalar_map err
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)
std::complex< double > Complex
const T * fortran_vec(void) const
octave_idx_type cols(void) const
Vector representing the dimensions (size) of an Array.
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)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE * x
void resize(octave_idx_type n, const double &rfv=0)
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
T chol_matrix(void) const