59 const octave_idx_type&,
61 const octave_idx_type&,
const double&,
62 double*,
const octave_idx_type&,
double*,
63 const octave_idx_type&, octave_idx_type*,
64 octave_idx_type*,
double*,
double*,
65 const octave_idx_type&, octave_idx_type&
70 F77_FUNC (dseupd, DSEUPD) (
const octave_idx_type&,
72 octave_idx_type*,
double*,
double*,
73 const octave_idx_type&,
const double&,
75 const octave_idx_type&,
77 const octave_idx_type&,
const double&,
double*,
78 const octave_idx_type&,
double*,
79 const octave_idx_type&, octave_idx_type*,
80 octave_idx_type*,
double*,
double*,
81 const octave_idx_type&, octave_idx_type&
87 F77_FUNC (dnaupd, DNAUPD) (octave_idx_type&,
89 const octave_idx_type&,
91 octave_idx_type&,
const double&,
92 double*,
const octave_idx_type&,
double*,
93 const octave_idx_type&, octave_idx_type*,
94 octave_idx_type*,
double*,
double*,
95 const octave_idx_type&, octave_idx_type&
100 F77_FUNC (dneupd, DNEUPD) (
const octave_idx_type&,
102 octave_idx_type*,
double*,
double*,
103 double*,
const octave_idx_type&,
const double&,
104 const double&,
double*,
106 const octave_idx_type&,
108 octave_idx_type&,
const double&,
double*,
109 const octave_idx_type&,
double*,
110 const octave_idx_type&, octave_idx_type*,
111 octave_idx_type*,
double*,
double*,
112 const octave_idx_type&, octave_idx_type&
118 F77_FUNC (znaupd, ZNAUPD) (octave_idx_type&,
120 const octave_idx_type&,
122 const octave_idx_type&,
const double&,
123 Complex*,
const octave_idx_type&, Complex*,
124 const octave_idx_type&, octave_idx_type*,
125 octave_idx_type*, Complex*, Complex*,
126 const octave_idx_type&,
double *, octave_idx_type&
131 F77_FUNC (zneupd, ZNEUPD) (
const octave_idx_type&,
133 octave_idx_type*, Complex*, Complex*,
134 const octave_idx_type&,
const Complex&, Complex*,
136 const octave_idx_type&,
138 const octave_idx_type&,
const double&,
139 Complex*,
const octave_idx_type&, Complex*,
140 const octave_idx_type&, octave_idx_type*,
141 octave_idx_type*, Complex*, Complex*,
142 const octave_idx_type&,
double *, octave_idx_type&
149 const octave_idx_type&,
const octave_idx_type&,
150 const double&,
const double*,
151 const octave_idx_type&,
const double*,
152 const octave_idx_type&,
const double&,
double*,
153 const octave_idx_type&
159 const octave_idx_type&,
const octave_idx_type&,
160 const Complex&,
const Complex*,
161 const octave_idx_type&,
const Complex*,
162 const octave_idx_type&,
const Complex&, Complex*,
163 const octave_idx_type&
169 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
213 (*current_liboctave_warning_with_id_handler)
214 (
"Octave:convergence",
215 "eigs: 'A - sigma*B' is singular, indicating sigma is exactly "
216 "an eigenvalue so convergence is not guaranteed");
219 template <
class M,
class SM>
228 m = L.solve (m, err, rcond, 0);
232 m = U.solve (utyp, m, err, rcond, 0);
237 template <
class SM,
class M>
246 M tmp = L.solve (ltyp, m, err, rcond, 0);
252 retval.resize (n, b_nc);
256 retval.elem (static_cast<octave_idx_type>(qv[i]), j) =
264 template <
class SM,
class M>
279 retval.elem (i,j) = m.elem (static_cast<octave_idx_type>(qv[i]), j);
281 return U.solve (utyp, retval, err, rcond, 0);
306 nr, nc, 1.0, m.
data (), nr,
312 (*current_liboctave_error_handler)
313 (
"eigs: unrecoverable error in dgemv");
343 nr, nc, 1.0, m.
data (), nr,
349 (*current_liboctave_error_handler)
350 (
"eigs: unrecoverable error in zgemv");
389 permB = fact.
perm () - 1.0;
427 permB = fact.
perm () - 1.0;
460 AminusSigmaB = AminusSigmaB - sigma * tmp *
464 AminusSigmaB = AminusSigmaB - sigma *
468 AminusSigmaB = AminusSigmaB - sigma * b;
475 sigmat.
xcidx (0) = 0;
478 sigmat.
xdata (i) = sigma;
479 sigmat.
xridx (i) = i;
480 sigmat.
xcidx (i+1) = i + 1;
483 AminusSigmaB = AminusSigmaB - sigmat;
509 if (
xisnan (minU) || d < minU)
512 if (
xisnan (maxU) || d > maxU)
516 double rcond = (minU / maxU);
517 volatile double rcond_plus_one = rcond + 1.0;
519 if (rcond_plus_one == 1.0 ||
xisnan (rcond))
551 *p++ -= tmp.
xelem (static_cast<octave_idx_type>(pB[i]),
552 static_cast<octave_idx_type>(pB[j]));
555 AminusSigmaB = AminusSigmaB - tmp;
558 AminusSigmaB = AminusSigmaB - sigma * b;
568 LU fact (AminusSigmaB);
581 if (
xisnan (minU) || d < minU)
584 if (
xisnan (maxU) || d > maxU)
588 double rcond = (minU / maxU);
589 volatile double rcond_plus_one = rcond + 1.0;
591 if (rcond_plus_one == 1.0 ||
xisnan (rcond))
625 AminusSigmaB = AminusSigmaB - tmp * b.
hermitian () * b *
629 AminusSigmaB = AminusSigmaB - sigma * b.
hermitian () * b;
632 AminusSigmaB = AminusSigmaB - sigma * b;
639 sigmat.
xcidx (0) = 0;
642 sigmat.
xdata (i) = sigma;
643 sigmat.
xridx (i) = i;
644 sigmat.
xcidx (i+1) = i + 1;
647 AminusSigmaB = AminusSigmaB - sigmat;
673 if (
xisnan (minU) || d < minU)
676 if (
xisnan (maxU) || d > maxU)
680 double rcond = (minU / maxU);
681 volatile double rcond_plus_one = rcond + 1.0;
683 if (rcond_plus_one == 1.0 ||
xisnan (rcond))
715 *p++ -= tmp.
xelem (static_cast<octave_idx_type>(pB[i]),
716 static_cast<octave_idx_type>(pB[j]));
719 AminusSigmaB = AminusSigmaB - tmp;
722 AminusSigmaB = AminusSigmaB - sigma * b;
745 if (
xisnan (minU) || d < minU)
748 if (
xisnan (maxU) || d > maxU)
752 double rcond = (minU / maxU);
753 volatile double rcond_plus_one = rcond + 1.0;
755 if (rcond_plus_one == 1.0 ||
xisnan (rcond))
768 std::ostream& os,
double tol,
bool rvec,
769 bool cholB,
int disp,
int maxit)
774 bool have_b = ! b.is_empty ();
780 if (m.rows () != m.cols ())
782 (*current_liboctave_error_handler) (
"eigs: A must be square");
785 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
787 (*current_liboctave_error_handler)
788 (
"eigs: B must be square and the same size as A");
802 (*current_liboctave_error_handler)
803 (
"eigs: n must be at least 3");
818 if (k < 1 || k > n - 2)
820 (*current_liboctave_error_handler)
821 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1-1).\n"
822 " Use 'eig (full (A))' instead");
826 if (p <= k || p >= n)
828 (*current_liboctave_error_handler)
829 (
"eigs: opts.p must be greater than k and less than n");
833 if (have_b && cholB && permB.
length () != 0)
838 (*current_liboctave_error_handler)
839 (
"eigs: permB vector invalid");
849 if (checked(bidx) || bidx < 0 || bidx >= n
852 (*current_liboctave_error_handler)
853 (
"eigs: permB vector invalid");
860 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
861 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
864 (*current_liboctave_error_handler)
865 (
"eigs: unrecognized sigma value");
869 if (typ ==
"LI" || typ ==
"SI" || typ ==
"LR" || typ ==
"SR")
871 (*current_liboctave_error_handler)
872 (
"eigs: invalid sigma value for real symmetric problem");
895 (*current_liboctave_error_handler)
896 (
"eigs: The matrix B is not positive definite");
935 k, tol, presid, p, v, n, iparam,
936 ipntr, workd, workl, lwork, info
941 (*current_liboctave_error_handler)
942 (
"eigs: unrecoverable exception encountered in dsaupd");
946 if (disp > 0 && !
xisnan (workl[iptr (5)-1]))
950 os <<
"Iteration " << iter - 1 <<
951 ": a few Ritz values of the " << p <<
"-by-" <<
953 for (
int i = 0 ; i < k; i++)
954 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
966 if (ido == -1 || ido == 1 || ido == 2)
972 mtmp(i,0) = workd[i + iptr(0) - 1];
977 workd[i+iptr(1)-1] = mtmp(i,0);
980 workd + iptr(1) - 1))
987 (*current_liboctave_error_handler)
988 (
"eigs: error %d in dsaupd", info);
1023 (*current_liboctave_error_handler)
1024 (
"eigs: unrecoverable exception encountered in dseupd");
1032 if (typ !=
"SM" && typ !=
"BE")
1037 d[i] = d[k - i - 1];
1038 d[k - i - 1] = dtmp;
1044 if (typ !=
"SM" && typ !=
"BE")
1057 dtmp[j] = z[off1 + j];
1060 z[off1 + j] = z[off2 + j];
1063 z[off2 + j] = dtmp[j];
1068 eig_vec =
ltsolve (b, permB, eig_vec);
1073 (*current_liboctave_error_handler)
1074 (
"eigs: error %d in dseupd", info2);
1089 std::ostream& os,
double tol,
bool rvec,
1090 bool cholB,
int disp,
int maxit)
1095 bool have_b = ! b.is_empty ();
1096 std::string typ =
"LM";
1098 if (m.rows () != m.cols ())
1100 (*current_liboctave_error_handler) (
"eigs: A must be square");
1103 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
1105 (*current_liboctave_error_handler)
1106 (
"eigs: B must be square and the same size as A");
1126 (*current_liboctave_error_handler)
1127 (
"eigs: n must be at least 3");
1131 if (k <= 0 || k >= n - 1)
1133 (*current_liboctave_error_handler)
1134 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1-1).\n"
1135 " Use 'eig (full (A))' instead");
1150 if (p <= k || p >= n)
1152 (*current_liboctave_error_handler)
1153 (
"eigs: opts.p must be greater than k and less than n");
1157 if (have_b && cholB && permB.
length () != 0)
1160 if (permB.
length () != n)
1162 (*current_liboctave_error_handler) (
"eigs: permB vector invalid");
1172 if (checked(bidx) || bidx < 0 || bidx >= n
1173 ||
D_NINT (bidx) != bidx)
1175 (*current_liboctave_error_handler)
1176 (
"eigs: permB vector invalid");
1228 k, tol, presid, p, v, n, iparam,
1229 ipntr, workd, workl, lwork, info
1234 (*current_liboctave_error_handler)
1235 (
"eigs: unrecoverable exception encountered in dsaupd");
1239 if (disp > 0 && !
xisnan (workl[iptr (5)-1]))
1243 os <<
"Iteration " << iter - 1 <<
1244 ": a few Ritz values of the " << p <<
"-by-" <<
1246 for (
int i = 0 ; i < k; i++)
1247 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
1259 if (ido == -1 || ido == 1 || ido == 2)
1272 tmp(i,0) = dtmp[P[i]];
1276 double *ip2 = workd+iptr(1)-1;
1278 ip2[
Q[i]] = tmp(i,0);
1284 double *ip2 = workd+iptr(2)-1;
1288 tmp(i,0) = ip2[P[i]];
1292 ip2 = workd+iptr(1)-1;
1294 ip2[
Q[i]] = tmp(i,0);
1302 workd[iptr(0) + i - 1] = workd[iptr(1) + i - 1];
1306 double *ip2 = workd+iptr(0)-1;
1310 tmp(i,0) = ip2[P[i]];
1314 ip2 = workd+iptr(1)-1;
1316 ip2[
Q[i]] = tmp(i,0);
1324 (*current_liboctave_error_handler)
1325 (
"eigs: error %d in dsaupd", info);
1355 k, tol, presid, p, v, n, iparam, ipntr, workd, workl, lwork, info2
1360 (*current_liboctave_error_handler)
1361 (
"eigs: unrecoverable exception encountered in dseupd");
1372 d[i] = d[k - i - 1];
1373 d[k - i - 1] = dtmp;
1389 dtmp[j] = z[off1 + j];
1392 z[off1 + j] = z[off2 + j];
1395 z[off2 + j] = dtmp[j];
1401 (*current_liboctave_error_handler)
1402 (
"eigs: error %d in dseupd", info2);
1412 const std::string &_typ,
double sigma,
1416 std::ostream& os,
double tol,
bool rvec,
1417 bool ,
int disp,
int maxit)
1419 std::string typ (_typ);
1420 bool have_sigma = (sigma ?
true :
false);
1435 (*current_liboctave_error_handler)
1436 (
"eigs: n must be at least 3");
1451 if (k <= 0 || k >= n - 1)
1453 (*current_liboctave_error_handler)
1454 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n"
1455 " Use 'eig (full (A))' instead");
1459 if (p <= k || p >= n)
1461 (*current_liboctave_error_handler)
1462 (
"eigs: opts.p must be greater than k and less than n");
1468 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
1469 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
1471 (*current_liboctave_error_handler)
1472 (
"eigs: unrecognized sigma value");
1474 if (typ ==
"LI" || typ ==
"SI" || typ ==
"LR" || typ ==
"SR")
1476 (*current_liboctave_error_handler)
1477 (
"eigs: invalid sigma value for real symmetric problem");
1529 k, tol, presid, p, v, n, iparam,
1530 ipntr, workd, workl, lwork, info
1535 (*current_liboctave_error_handler)
1536 (
"eigs: unrecoverable exception encountered in dsaupd");
1540 if (disp > 0 && !
xisnan (workl[iptr (5)-1]))
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";
1561 if (ido == -1 || ido == 1 || ido == 2)
1563 double *ip2 = workd + iptr(0) - 1;
1574 ip2 = workd + iptr(1) - 1;
1582 (*current_liboctave_error_handler)
1583 (
"eigs: error %d in dsaupd", info);
1613 k, tol, presid, p, v, n, iparam, ipntr, workd, workl, lwork, info2
1618 (*current_liboctave_error_handler)
1619 (
"eigs: unrecoverable exception encountered in dseupd");
1627 if (typ !=
"SM" && typ !=
"BE")
1632 d[i] = d[k - i - 1];
1633 d[k - i - 1] = dtmp;
1639 if (typ !=
"SM" && typ !=
"BE")
1652 dtmp[j] = z[off1 + j];
1655 z[off1 + j] = z[off2 + j];
1658 z[off2 + j] = dtmp[j];
1665 (*current_liboctave_error_handler)
1666 (
"eigs: error %d in dseupd", info2);
1681 std::ostream& os,
double tol,
bool rvec,
1682 bool cholB,
int disp,
int maxit)
1687 bool have_b = ! b.is_empty ();
1694 if (m.rows () != m.cols ())
1696 (*current_liboctave_error_handler) (
"eigs: A must be square");
1699 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
1701 (*current_liboctave_error_handler)
1702 (
"eigs: B must be square and the same size as A");
1716 (*current_liboctave_error_handler)
1717 (
"eigs: n must be at least 3");
1732 if (k <= 0 || k >= n - 1)
1734 (*current_liboctave_error_handler)
1735 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n"
1736 " Use 'eig (full (A))' instead");
1740 if (p <= k || p >= n)
1742 (*current_liboctave_error_handler)
1743 (
"eigs: opts.p must be greater than k and less than n");
1747 if (have_b && cholB && permB.
length () != 0)
1750 if (permB.
length () != n)
1752 (*current_liboctave_error_handler)
1753 (
"eigs: permB vector invalid");
1763 if (checked(bidx) || bidx < 0 || bidx >= n
1764 ||
D_NINT (bidx) != bidx)
1766 (*current_liboctave_error_handler)
1767 (
"eigs: permB vector invalid");
1774 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
1775 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
1778 (*current_liboctave_error_handler)
1779 (
"eigs: unrecognized sigma value");
1783 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
1785 (*current_liboctave_error_handler)
1786 (
"eigs: invalid sigma value for unsymmetric problem");
1798 if (permB.
length () == 0)
1809 (*current_liboctave_error_handler)
1810 (
"eigs: The matrix B is not positive definite");
1849 k, tol, presid, p, v, n, iparam,
1850 ipntr, workd, workl, lwork, info
1855 (*current_liboctave_error_handler)
1856 (
"eigs: unrecoverable exception encountered in dnaupd");
1860 if (disp > 0 && !
xisnan(workl[iptr(5)-1]))
1864 os <<
"Iteration " << iter - 1 <<
1865 ": a few Ritz values of the " << p <<
"-by-" <<
1867 for (
int i = 0 ; i < k; i++)
1868 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
1880 if (ido == -1 || ido == 1 || ido == 2)
1886 mtmp(i,0) = workd[i + iptr(0) - 1];
1891 workd[i+iptr(1)-1] = mtmp(i,0);
1894 workd + iptr(1) - 1))
1901 (*current_liboctave_error_handler)
1902 (
"eigs: error %d in dnaupd", info);
1929 Matrix eig_vec2 (n, k + 1, 0.0);
1947 (*current_liboctave_error_handler)
1948 (
"eigs: unrecoverable exception encountered in dneupd");
1961 if (dr[i] == 0.0 && di[i] == 0.0 && jj == 0)
1964 d[i-jj] =
Complex (dr[i], di[i]);
1966 if (jj == 0 && !rvec)
1974 d[i] = d[k - i - 1];
1975 d[k - i - 1] = dtmp;
1992 dtmp[j] = z[off1 + j];
1995 z[off1 + j] = z[off2 + j];
1998 z[off2 + j] = dtmp[j];
2019 Complex (z[j+off1],z[j+off2]);
2022 Complex (z[j+off1],-z[j+off2]);
2029 eig_vec =
ltsolve (
M(b), permB, eig_vec);
2034 (*current_liboctave_error_handler)
2035 (
"eigs: error %d in dneupd", info2);
2051 std::ostream& os,
double tol,
bool rvec,
2052 bool cholB,
int disp,
int maxit)
2057 bool have_b = ! b.is_empty ();
2058 std::string typ =
"LM";
2061 if (m.rows () != m.cols ())
2063 (*current_liboctave_error_handler) (
"eigs: A must be square");
2066 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
2068 (*current_liboctave_error_handler)
2069 (
"eigs: B must be square and the same size as A");
2089 (*current_liboctave_error_handler)
2090 (
"eigs: n must be at least 3");
2105 if (k <= 0 || k >= n - 1)
2107 (*current_liboctave_error_handler)
2108 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n"
2109 " Use 'eig (full (A))' instead");
2113 if (p <= k || p >= n)
2115 (*current_liboctave_error_handler)
2116 (
"eigs: opts.p must be greater than k and less than n");
2120 if (have_b && cholB && permB.
length () != 0)
2123 if (permB.
length () != n)
2125 (*current_liboctave_error_handler) (
"eigs: permB vector invalid");
2135 if (checked(bidx) || bidx < 0 || bidx >= n
2136 ||
D_NINT (bidx) != bidx)
2138 (*current_liboctave_error_handler)
2139 (
"eigs: permB vector invalid");
2191 k, tol, presid, p, v, n, iparam,
2192 ipntr, workd, workl, lwork, info
2197 (*current_liboctave_error_handler)
2198 (
"eigs: unrecoverable exception encountered in dsaupd");
2202 if (disp > 0 && !
xisnan (workl[iptr (5)-1]))
2206 os <<
"Iteration " << iter - 1 <<
2207 ": a few Ritz values of the " << p <<
"-by-" <<
2209 for (
int i = 0 ; i < k; i++)
2210 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
2222 if (ido == -1 || ido == 1 || ido == 2)
2235 tmp(i,0) = dtmp[P[i]];
2239 double *ip2 = workd+iptr(1)-1;
2241 ip2[
Q[i]] = tmp(i,0);
2247 double *ip2 = workd+iptr(2)-1;
2251 tmp(i,0) = ip2[P[i]];
2255 ip2 = workd+iptr(1)-1;
2257 ip2[
Q[i]] = tmp(i,0);
2265 workd[iptr(0) + i - 1] = workd[iptr(1) + i - 1];
2269 double *ip2 = workd+iptr(0)-1;
2273 tmp(i,0) = ip2[P[i]];
2277 ip2 = workd+iptr(1)-1;
2279 ip2[
Q[i]] = tmp(i,0);
2287 (*current_liboctave_error_handler)
2288 (
"eigs: error %d in dsaupd", info);
2315 Matrix eig_vec2 (n, k + 1, 0.0);
2333 (*current_liboctave_error_handler)
2334 (
"eigs: unrecoverable exception encountered in dneupd");
2347 if (dr[i] == 0.0 && di[i] == 0.0 && jj == 0)
2350 d[i-jj] =
Complex (dr[i], di[i]);
2352 if (jj == 0 && !rvec)
2360 d[i] = d[k - i - 1];
2361 d[k - i - 1] = dtmp;
2378 dtmp[j] = z[off1 + j];
2381 z[off1 + j] = z[off2 + j];
2384 z[off2 + j] = dtmp[j];
2405 Complex (z[j+off1],z[j+off2]);
2408 Complex (z[j+off1],-z[j+off2]);
2417 (*current_liboctave_error_handler)
2418 (
"eigs: error %d in dneupd", info2);
2428 const std::string &_typ,
double sigmar,
2432 std::ostream& os,
double tol,
bool rvec,
2433 bool ,
int disp,
int maxit)
2435 std::string typ (_typ);
2436 bool have_sigma = (sigmar ?
true :
false);
2452 (*current_liboctave_error_handler)
2453 (
"eigs: n must be at least 3");
2468 if (k <= 0 || k >= n - 1)
2470 (*current_liboctave_error_handler)
2471 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n"
2472 " Use 'eig (full (A))' instead");
2476 if (p <= k || p >= n)
2478 (*current_liboctave_error_handler)
2479 (
"eigs: opts.p must be greater than k and less than n");
2486 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
2487 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
2489 (*current_liboctave_error_handler)
2490 (
"eigs: unrecognized sigma value");
2492 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
2494 (*current_liboctave_error_handler)
2495 (
"eigs: invalid sigma value for unsymmetric problem");
2547 k, tol, presid, p, v, n, iparam,
2548 ipntr, workd, workl, lwork, info
2553 (*current_liboctave_error_handler)
2554 (
"eigs: unrecoverable exception encountered in dnaupd");
2558 if (disp > 0 && !
xisnan(workl[iptr(5)-1]))
2562 os <<
"Iteration " << iter - 1 <<
2563 ": a few Ritz values of the " << p <<
"-by-" <<
2565 for (
int i = 0 ; i < k; i++)
2566 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
2578 if (ido == -1 || ido == 1 || ido == 2)
2580 double *ip2 = workd + iptr(0) - 1;
2591 ip2 = workd + iptr(1) - 1;
2599 (*current_liboctave_error_handler)
2600 (
"eigs: error %d in dsaupd", info);
2627 Matrix eig_vec2 (n, k + 1, 0.0);
2645 (*current_liboctave_error_handler)
2646 (
"eigs: unrecoverable exception encountered in dneupd");
2659 if (dr[i] == 0.0 && di[i] == 0.0 && jj == 0)
2662 d[i-jj] =
Complex (dr[i], di[i]);
2664 if (jj == 0 && !rvec)
2672 d[i] = d[k - i - 1];
2673 d[k - i - 1] = dtmp;
2690 dtmp[j] = z[off1 + j];
2693 z[off1 + j] = z[off2 + j];
2696 z[off2 + j] = dtmp[j];
2717 Complex (z[j+off1],z[j+off2]);
2720 Complex (z[j+off1],-z[j+off2]);
2729 (*current_liboctave_error_handler)
2730 (
"eigs: error %d in dneupd", info2);
2746 std::ostream& os,
double tol,
bool rvec,
2747 bool cholB,
int disp,
int maxit)
2752 bool have_b = ! b.is_empty ();
2758 if (m.rows () != m.cols ())
2760 (*current_liboctave_error_handler) (
"eigs: A must be square");
2763 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
2765 (*current_liboctave_error_handler)
2766 (
"eigs: B must be square and the same size as A");
2778 cresid(i) =
Complex (rr(i),ri(i));
2784 (*current_liboctave_error_handler)
2785 (
"eigs: n must be at least 3");
2800 if (k <= 0 || k >= n - 1)
2802 (*current_liboctave_error_handler)
2803 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n"
2804 " Use 'eig (full (A))' instead");
2808 if (p <= k || p >= n)
2810 (*current_liboctave_error_handler)
2811 (
"eigs: opts.p must be greater than k and less than n");
2815 if (have_b && cholB && permB.
length () != 0)
2818 if (permB.
length () != n)
2820 (*current_liboctave_error_handler)
2821 (
"eigs: permB vector invalid");
2831 if (checked(bidx) || bidx < 0 || bidx >= n
2832 ||
D_NINT (bidx) != bidx)
2834 (*current_liboctave_error_handler)
2835 (
"eigs: permB vector invalid");
2842 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
2843 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
2846 (*current_liboctave_error_handler)
2847 (
"eigs: unrecognized sigma value");
2851 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
2853 (*current_liboctave_error_handler)
2854 (
"eigs: invalid sigma value for complex problem");
2866 if (permB.
length () == 0)
2877 (*current_liboctave_error_handler)
2878 (
"eigs: The matrix B is not positive definite");
2918 k, tol, presid, p, v, n, iparam,
2919 ipntr, workd, workl, lwork, rwork, info
2924 (*current_liboctave_error_handler)
2925 (
"eigs: unrecoverable exception encountered in znaupd");
2929 if (disp > 0 && !
xisnan (workl[iptr (5)-1]))
2933 os <<
"Iteration " << iter - 1 <<
2934 ": a few Ritz values of the " << p <<
"-by-" <<
2936 for (
int i = 0 ; i < k; i++)
2937 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
2949 if (ido == -1 || ido == 1 || ido == 2)
2955 mtmp(i,0) = workd[i + iptr(0) - 1];
2958 workd[i+iptr(1)-1] = mtmp(i,0);
2962 workd + iptr(1) - 1))
2969 (*current_liboctave_error_handler)
2970 (
"eigs: error %d in znaupd", info);
3002 k, tol, presid, p, v, n, iparam, ipntr, workd, workl, lwork, rwork, info2
3007 (*current_liboctave_error_handler)
3008 (
"eigs: unrecoverable exception encountered in zneupd");
3018 d[i] = d[k - i - 1];
3019 d[k - i - 1] = ctmp;
3036 ctmp[j] = z[off1 + j];
3039 z[off1 + j] = z[off2 + j];
3042 z[off2 + j] = ctmp[j];
3046 eig_vec =
ltsolve (b, permB, eig_vec);
3051 (*current_liboctave_error_handler)
3052 (
"eigs: error %d in zneupd", info2);
3068 std::ostream& os,
double tol,
bool rvec,
3069 bool cholB,
int disp,
int maxit)
3074 bool have_b = ! b.is_empty ();
3075 std::string typ =
"LM";
3077 if (m.rows () != m.cols ())
3079 (*current_liboctave_error_handler) (
"eigs: A must be square");
3082 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
3084 (*current_liboctave_error_handler)
3085 (
"eigs: B must be square and the same size as A");
3103 cresid(i) =
Complex (rr(i),ri(i));
3109 (*current_liboctave_error_handler)
3110 (
"eigs: n must be at least 3");
3125 if (k <= 0 || k >= n - 1)
3127 (*current_liboctave_error_handler)
3128 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n"
3129 " Use 'eig (full (A))' instead");
3133 if (p <= k || p >= n)
3135 (*current_liboctave_error_handler)
3136 (
"eigs: opts.p must be greater than k and less than n");
3140 if (have_b && cholB && permB.
length () != 0)
3143 if (permB.
length () != n)
3145 (*current_liboctave_error_handler) (
"eigs: permB vector invalid");
3155 if (checked(bidx) || bidx < 0 || bidx >= n
3156 ||
D_NINT (bidx) != bidx)
3158 (*current_liboctave_error_handler)
3159 (
"eigs: permB vector invalid");
3212 k, tol, presid, p, v, n, iparam,
3213 ipntr, workd, workl, lwork, rwork, info
3218 (*current_liboctave_error_handler)
3219 (
"eigs: unrecoverable exception encountered in znaupd");
3223 if (disp > 0 && !
xisnan(workl[iptr(5)-1]))
3227 os <<
"Iteration " << iter - 1 <<
3228 ": a few Ritz values of the " << p <<
"-by-" <<
3230 for (
int i = 0 ; i < k; i++)
3231 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
3243 if (ido == -1 || ido == 1 || ido == 2)
3256 tmp(i,0) = ctmp[P[i]];
3260 Complex *ip2 = workd+iptr(1)-1;
3262 ip2[
Q[i]] = tmp(i,0);
3268 Complex *ip2 = workd+iptr(2)-1;
3272 tmp(i,0) = ip2[P[i]];
3276 ip2 = workd+iptr(1)-1;
3278 ip2[
Q[i]] = tmp(i,0);
3286 workd[iptr(0) + i - 1] =
3287 workd[iptr(1) + i - 1];
3291 Complex *ip2 = workd+iptr(0)-1;
3295 tmp(i,0) = ip2[P[i]];
3299 ip2 = workd+iptr(1)-1;
3301 ip2[
Q[i]] = tmp(i,0);
3309 (*current_liboctave_error_handler)
3310 (
"eigs: error %d in dsaupd", info);
3342 k, tol, presid, p, v, n, iparam, ipntr, workd, workl, lwork, rwork, info2
3347 (*current_liboctave_error_handler)
3348 (
"eigs: unrecoverable exception encountered in zneupd");
3358 d[i] = d[k - i - 1];
3359 d[k - i - 1] = ctmp;
3376 ctmp[j] = z[off1 + j];
3379 z[off1 + j] = z[off2 + j];
3382 z[off2 + j] = ctmp[j];
3388 (*current_liboctave_error_handler)
3389 (
"eigs: error %d in zneupd", info2);
3398 const std::string &_typ,
Complex sigma,
3403 double tol,
bool rvec,
bool ,
3404 int disp,
int maxit)
3406 std::string typ (_typ);
3407 bool have_sigma = (
std::abs (sigma) ?
true :
false);
3420 cresid(i) =
Complex (rr(i),ri(i));
3426 (*current_liboctave_error_handler)
3427 (
"eigs: n must be at least 3");
3442 if (k <= 0 || k >= n - 1)
3444 (*current_liboctave_error_handler)
3445 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n"
3446 " Use 'eig (full (A))' instead");
3450 if (p <= k || p >= n)
3452 (*current_liboctave_error_handler)
3453 (
"eigs: opts.p must be greater than k and less than n");
3459 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA"
3460 && typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI"
3462 (*current_liboctave_error_handler)
3463 (
"eigs: unrecognized sigma value");
3465 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
3467 (*current_liboctave_error_handler)
3468 (
"eigs: invalid sigma value for complex problem");
3521 k, tol, presid, p, v, n, iparam,
3522 ipntr, workd, workl, lwork, rwork, info
3527 (*current_liboctave_error_handler)
3528 (
"eigs: unrecoverable exception encountered in znaupd");
3532 if (disp > 0 && !
xisnan(workl[iptr(5)-1]))
3536 os <<
"Iteration " << iter - 1 <<
3537 ": a few Ritz values of the " << p <<
"-by-" <<
3539 for (
int i = 0 ; i < k; i++)
3540 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
3552 if (ido == -1 || ido == 1 || ido == 2)
3554 Complex *ip2 = workd + iptr(0) - 1;
3565 ip2 = workd + iptr(1) - 1;
3573 (*current_liboctave_error_handler)
3574 (
"eigs: error %d in dsaupd", info);
3606 k, tol, presid, p, v, n, iparam, ipntr, workd, workl, lwork, rwork, info2
3611 (*current_liboctave_error_handler)
3612 (
"eigs: unrecoverable exception encountered in zneupd");
3622 d[i] = d[k - i - 1];
3623 d[k - i - 1] = ctmp;
3640 ctmp[j] = z[off1 + j];
3643 z[off1 + j] = z[off2 + j];
3646 z[off2 + j] = ctmp[j];
3652 (*current_liboctave_error_handler)
3653 (
"eigs: error %d in zneupd", info2);
3660 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
3668 double tol = std::numeric_limits<double>::epsilon (),
3669 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3679 double tol = std::numeric_limits<double>::epsilon (),
3680 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3690 double tol = std::numeric_limits<double>::epsilon (),
3691 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3701 double tol = std::numeric_limits<double>::epsilon (),
3702 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3707 const std::string &typ,
double sigma,
3712 double tol = std::numeric_limits<double>::epsilon (),
3713 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3723 double tol = std::numeric_limits<double>::epsilon (),
3724 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3735 double tol = std::numeric_limits<double>::epsilon (),
3736 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3747 double tol = std::numeric_limits<double>::epsilon (),
3748 bool rvec =
false,
bool cholB = 0,
3749 int disp = 0,
int maxit = 300);
3760 double tol = std::numeric_limits<double>::epsilon (),
3761 bool rvec =
false,
bool cholB = 0,
3762 int disp = 0,
int maxit = 300);
3766 const std::string &_typ,
double sigma,
3771 double tol = std::numeric_limits<double>::epsilon (),
3772 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3783 double tol = std::numeric_limits<double>::epsilon (),
3784 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3797 double tol = std::numeric_limits<double>::epsilon (),
3798 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3811 double tol = std::numeric_limits<double>::epsilon (),
3812 bool rvec =
false,
bool cholB = 0,
3813 int disp = 0,
int maxit = 300);
3826 double tol = std::numeric_limits<double>::epsilon (),
3827 bool rvec =
false,
bool cholB = 0,
3828 int disp = 0,
int maxit = 300);
3832 const std::string &_typ,
Complex sigma,
3837 double tol = std::numeric_limits<double>::epsilon (),
3838 bool rvec =
false,
bool cholB = 0,
3839 int disp = 0,
int maxit = 300);
octave_idx_type * xridx(void)
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
#define F77_CHAR_ARG_LEN(l)
void resize(octave_idx_type n, const Complex &rfv=Complex(0))
ColumnVector perm(void) const
octave_idx_type rows(void) const
const octave_idx_type * col_perm(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
ComplexColumnVector(* EigsComplexFunc)(const ComplexColumnVector &x, int &eigs_error)
static ComplexMatrix ltsolve(const SparseComplexMatrix &, const ColumnVector &, const ComplexMatrix &)
const octave_idx_type * row_perm(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)
F77_RET_T F77_FUNC(dsaupd, DSAUPD)(octave_idx_type &
F77_RET_T const octave_idx_type const octave_idx_type const octave_idx_type const double const double octave_idx_type & M
ColumnVector(* EigsFunc)(const ColumnVector &x, int &eigs_error)
octave_idx_type * xcidx(void)
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)
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)
Matrix chol_matrix(void) const
octave_idx_type rows(void) const
F77_RET_T const double const double double * 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)
#define F77_CONST_CHAR_ARG2(x, l)
static octave_idx_type lusolve(const SparseMatrix &, const SparseMatrix &, Matrix &)
ComplexMatrix hermitian(void) const
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)
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
SparseMatrix L(void) const
F77_RET_T const octave_idx_type const octave_idx_type const double double const octave_idx_type double const octave_idx_type octave_idx_type octave_idx_type double double const octave_idx_type octave_idx_type &F77_CHAR_ARG_LEN_DECL F77_CHAR_ARG_LEN_DECL
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)
OCTAVE_API double D_NINT(double x)
octave_idx_type P(void) const
ComplexMatrix chol_matrix(void) const
T & xelem(octave_idx_type n)
F77_RET_T F77_CONST_CHAR_ARG_DECL
octave_idx_type length(void) const
Number of elements in the array.
SparseComplexMatrix L(void) const
octave_idx_type * ridx(void)
bool is_empty(void) const
octave_idx_type P(void) const
void resize(octave_idx_type nr, octave_idx_type nc, const Complex &rfv=Complex(0))
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)
static ComplexMatrix utsolve(const SparseComplexMatrix &, const ColumnVector &, const ComplexMatrix &)
ColumnVector perm(void) const
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
static std::string distribution(void)
F77_RET_T const octave_idx_type const octave_idx_type const octave_idx_type double const octave_idx_type double const octave_idx_type double * Q
ColumnVector imag(const ComplexColumnVector &a)
std::complex< double > Complex
const T * fortran_vec(void) const
octave_idx_type cols(void) const
F77_RET_T const double * x
void resize(octave_idx_type n, const double &rfv=0)