58 const octave_idx_type&,
60 const octave_idx_type&,
const double&,
61 double*,
const octave_idx_type&,
double*,
62 const octave_idx_type&, octave_idx_type*,
63 octave_idx_type*,
double*,
double*,
64 const octave_idx_type&, octave_idx_type&
69 F77_FUNC (dseupd, DSEUPD) (
const octave_idx_type&,
71 octave_idx_type*,
double*,
double*,
72 const octave_idx_type&,
const double&,
74 const octave_idx_type&,
76 const octave_idx_type&,
const double&,
double*,
77 const octave_idx_type&,
double*,
78 const octave_idx_type&, octave_idx_type*,
79 octave_idx_type*,
double*,
double*,
80 const octave_idx_type&, octave_idx_type&
86 F77_FUNC (dnaupd, DNAUPD) (octave_idx_type&,
88 const octave_idx_type&,
90 octave_idx_type&,
const double&,
91 double*,
const octave_idx_type&,
double*,
92 const octave_idx_type&, octave_idx_type*,
93 octave_idx_type*,
double*,
double*,
94 const octave_idx_type&, octave_idx_type&
99 F77_FUNC (dneupd, DNEUPD) (
const octave_idx_type&,
101 octave_idx_type*,
double*,
double*,
102 double*,
const octave_idx_type&,
const double&,
103 const double&,
double*,
105 const octave_idx_type&,
107 octave_idx_type&,
const double&,
double*,
108 const octave_idx_type&,
double*,
109 const octave_idx_type&, octave_idx_type*,
110 octave_idx_type*,
double*,
double*,
111 const octave_idx_type&, octave_idx_type&
117 F77_FUNC (znaupd, ZNAUPD) (octave_idx_type&,
119 const octave_idx_type&,
121 const octave_idx_type&,
const double&,
122 Complex*,
const octave_idx_type&, Complex*,
123 const octave_idx_type&, octave_idx_type*,
124 octave_idx_type*, Complex*, Complex*,
125 const octave_idx_type&,
double *, octave_idx_type&
130 F77_FUNC (zneupd, ZNEUPD) (
const octave_idx_type&,
132 octave_idx_type*, Complex*, Complex*,
133 const octave_idx_type&,
const Complex&, Complex*,
135 const octave_idx_type&,
137 const octave_idx_type&,
const double&,
138 Complex*,
const octave_idx_type&, Complex*,
139 const octave_idx_type&, octave_idx_type*,
140 octave_idx_type*, Complex*, Complex*,
141 const octave_idx_type&,
double *, octave_idx_type&
148 const octave_idx_type&,
const octave_idx_type&,
149 const double&,
const double*,
150 const octave_idx_type&,
const double*,
151 const octave_idx_type&,
const double&,
double*,
152 const octave_idx_type&
158 const octave_idx_type&,
const octave_idx_type&,
159 const Complex&,
const Complex*,
160 const octave_idx_type&,
const Complex*,
161 const octave_idx_type&,
const Complex&, Complex*,
162 const octave_idx_type&
168 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
209 template <
class M,
class SM>
218 m = L.solve (m, err, rcond, 0);
222 m = U.solve (utyp, m, err, rcond, 0);
227 template <
class SM,
class M>
236 M tmp = L.solve (ltyp, m, err, rcond, 0);
242 retval.resize (n, b_nc);
246 retval.elem (static_cast<octave_idx_type>(qv[i]), j) =
254 template <
class SM,
class M>
269 retval.elem (i,j) = m.elem (static_cast<octave_idx_type>(qv[i]), j);
271 return U.solve (utyp, retval, err, rcond, 0);
296 nr, nc, 1.0, m.
data (), nr,
302 (*current_liboctave_error_handler)
303 (
"eigs: unrecoverable error in dgemv");
333 nr, nc, 1.0, m.
data (), nr,
339 (*current_liboctave_error_handler)
340 (
"eigs: unrecoverable error in zgemv");
379 permB = fact.
perm () - 1.0;
417 permB = fact.
perm () - 1.0;
450 AminusSigmaB = AminusSigmaB - sigma * tmp *
454 AminusSigmaB = AminusSigmaB - sigma *
458 AminusSigmaB = 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 = AminusSigmaB - sigmat;
499 if (
xisnan (minU) || d < minU)
502 if (
xisnan (maxU) || d > maxU)
506 double rcond = (minU / maxU);
507 volatile double rcond_plus_one = rcond + 1.0;
509 if (rcond_plus_one == 1.0 ||
xisnan (rcond))
511 (*current_liboctave_warning_handler)
512 (
"eigs: 'A - sigma*B' is singular, indicating sigma is exactly");
513 (*current_liboctave_warning_handler)
514 (
" an eigenvalue. Convergence is not guaranteed");
546 *p++ -= tmp.
xelem (static_cast<octave_idx_type>(pB[i]),
547 static_cast<octave_idx_type>(pB[j]));
550 AminusSigmaB = AminusSigmaB - tmp;
553 AminusSigmaB = AminusSigmaB - sigma * b;
563 LU fact (AminusSigmaB);
576 if (
xisnan (minU) || d < minU)
579 if (
xisnan (maxU) || d > maxU)
583 double rcond = (minU / maxU);
584 volatile double rcond_plus_one = rcond + 1.0;
586 if (rcond_plus_one == 1.0 ||
xisnan (rcond))
588 (*current_liboctave_warning_handler)
589 (
"eigs: 'A - sigma*B' is singular, indicating sigma is exactly");
590 (*current_liboctave_warning_handler)
591 (
" an eigenvalue. Convergence is not guaranteed");
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))
685 (*current_liboctave_warning_handler)
686 (
"eigs: 'A - sigma*B' is singular, indicating sigma is exactly");
687 (*current_liboctave_warning_handler)
688 (
" an eigenvalue. Convergence is not guaranteed");
720 *p++ -= tmp.
xelem (static_cast<octave_idx_type>(pB[i]),
721 static_cast<octave_idx_type>(pB[j]));
724 AminusSigmaB = AminusSigmaB - tmp;
727 AminusSigmaB = AminusSigmaB - sigma * b;
750 if (
xisnan (minU) || d < minU)
753 if (
xisnan (maxU) || d > maxU)
757 double rcond = (minU / maxU);
758 volatile double rcond_plus_one = rcond + 1.0;
760 if (rcond_plus_one == 1.0 ||
xisnan (rcond))
762 (*current_liboctave_warning_handler)
763 (
"eigs: 'A - sigma*B' is singular, indicating sigma is exactly");
764 (*current_liboctave_warning_handler)
765 (
" an eigenvalue. Convergence is not guaranteed");
778 std::ostream& os,
double tol,
bool rvec,
779 bool cholB,
int disp,
int maxit)
784 bool have_b = ! b.is_empty ();
790 if (m.rows () != m.cols ())
792 (*current_liboctave_error_handler) (
"eigs: A must be square");
795 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
797 (*current_liboctave_error_handler)
798 (
"eigs: B must be square and the same size as A");
812 (*current_liboctave_error_handler)
813 (
"eigs: n must be at least 3");
828 if (k < 1 || k > n - 2)
830 (*current_liboctave_error_handler)
831 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1-1).\n"
832 " Use 'eig (full (A))' instead");
836 if (p <= k || p >= n)
838 (*current_liboctave_error_handler)
839 (
"eigs: opts.p must be greater than k and less than n");
843 if (have_b && cholB && permB.
length () != 0)
848 (*current_liboctave_error_handler)
849 (
"eigs: permB vector invalid");
859 if (checked(bidx) || bidx < 0 ||
860 bidx >= n ||
D_NINT (bidx) != bidx)
862 (*current_liboctave_error_handler)
863 (
"eigs: permB vector invalid");
870 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA" &&
871 typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI" &&
874 (*current_liboctave_error_handler)
875 (
"eigs: unrecognized sigma value");
879 if (typ ==
"LI" || typ ==
"SI" || typ ==
"LR" || typ ==
"SR")
881 (*current_liboctave_error_handler)
882 (
"eigs: invalid sigma value for real symmetric problem");
905 (*current_liboctave_error_handler)
906 (
"eigs: The matrix B is not positive definite");
945 k, tol, presid, p, v, n, iparam,
946 ipntr, workd, workl, lwork, info
951 (*current_liboctave_error_handler)
952 (
"eigs: unrecoverable exception encountered in dsaupd");
956 if (disp > 0 && !
xisnan (workl[iptr (5)-1]))
960 os <<
"Iteration " << iter - 1 <<
961 ": a few Ritz values of the " << p <<
"-by-" <<
963 for (
int i = 0 ; i < k; i++)
964 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
976 if (ido == -1 || ido == 1 || ido == 2)
982 mtmp(i,0) = workd[i + iptr(0) - 1];
987 workd[i+iptr(1)-1] = mtmp(i,0);
990 workd + iptr(1) - 1))
997 (*current_liboctave_error_handler)
998 (
"eigs: error %d in dsaupd", info);
1033 (*current_liboctave_error_handler)
1034 (
"eigs: unrecoverable exception encountered in dseupd");
1042 if (typ !=
"SM" && typ !=
"BE")
1047 d[i] = d[k - i - 1];
1048 d[k - i - 1] = dtmp;
1054 if (typ !=
"SM" && typ !=
"BE")
1067 dtmp[j] = z[off1 + j];
1070 z[off1 + j] = z[off2 + j];
1073 z[off2 + j] = dtmp[j];
1078 eig_vec =
ltsolve (b, permB, eig_vec);
1083 (*current_liboctave_error_handler)
1084 (
"eigs: error %d in dseupd", info2);
1099 std::ostream& os,
double tol,
bool rvec,
1100 bool cholB,
int disp,
int maxit)
1105 bool have_b = ! b.is_empty ();
1106 std::string typ =
"LM";
1108 if (m.rows () != m.cols ())
1110 (*current_liboctave_error_handler) (
"eigs: A must be square");
1113 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
1115 (*current_liboctave_error_handler)
1116 (
"eigs: B must be square and the same size as A");
1136 (*current_liboctave_error_handler)
1137 (
"eigs: n must be at least 3");
1141 if (k <= 0 || k >= n - 1)
1143 (*current_liboctave_error_handler)
1144 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1-1).\n"
1145 " Use 'eig (full (A))' instead");
1160 if (p <= k || p >= n)
1162 (*current_liboctave_error_handler)
1163 (
"eigs: opts.p must be greater than k and less than n");
1167 if (have_b && cholB && permB.
length () != 0)
1170 if (permB.
length () != n)
1172 (*current_liboctave_error_handler) (
"eigs: permB vector invalid");
1182 if (checked(bidx) || bidx < 0 ||
1183 bidx >= n ||
D_NINT (bidx) != bidx)
1185 (*current_liboctave_error_handler)
1186 (
"eigs: permB vector invalid");
1238 k, tol, presid, p, v, n, iparam,
1239 ipntr, workd, workl, lwork, info
1244 (*current_liboctave_error_handler)
1245 (
"eigs: unrecoverable exception encountered in dsaupd");
1249 if (disp > 0 && !
xisnan (workl[iptr (5)-1]))
1253 os <<
"Iteration " << iter - 1 <<
1254 ": a few Ritz values of the " << p <<
"-by-" <<
1256 for (
int i = 0 ; i < k; i++)
1257 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
1269 if (ido == -1 || ido == 1 || ido == 2)
1282 tmp(i,0) = dtmp[P[i]];
1286 double *ip2 = workd+iptr(1)-1;
1288 ip2[
Q[i]] = tmp(i,0);
1294 double *ip2 = workd+iptr(2)-1;
1298 tmp(i,0) = ip2[P[i]];
1302 ip2 = workd+iptr(1)-1;
1304 ip2[
Q[i]] = tmp(i,0);
1312 workd[iptr(0) + i - 1] = workd[iptr(1) + i - 1];
1316 double *ip2 = workd+iptr(0)-1;
1320 tmp(i,0) = ip2[P[i]];
1324 ip2 = workd+iptr(1)-1;
1326 ip2[
Q[i]] = tmp(i,0);
1334 (*current_liboctave_error_handler)
1335 (
"eigs: error %d in dsaupd", info);
1365 k, tol, presid, p, v, n, iparam, ipntr, workd, workl, lwork, info2
1370 (*current_liboctave_error_handler)
1371 (
"eigs: unrecoverable exception encountered in dseupd");
1382 d[i] = d[k - i - 1];
1383 d[k - i - 1] = dtmp;
1399 dtmp[j] = z[off1 + j];
1402 z[off1 + j] = z[off2 + j];
1405 z[off2 + j] = dtmp[j];
1411 (*current_liboctave_error_handler)
1412 (
"eigs: error %d in dseupd", info2);
1422 const std::string &_typ,
double sigma,
1426 std::ostream& os,
double tol,
bool rvec,
1427 bool ,
int disp,
int maxit)
1429 std::string typ (_typ);
1430 bool have_sigma = (sigma ?
true :
false);
1445 (*current_liboctave_error_handler)
1446 (
"eigs: n must be at least 3");
1461 if (k <= 0 || k >= n - 1)
1463 (*current_liboctave_error_handler)
1464 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n"
1465 " Use 'eig (full (A))' instead");
1469 if (p <= k || p >= n)
1471 (*current_liboctave_error_handler)
1472 (
"eigs: opts.p must be greater than k and less than n");
1478 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA" &&
1479 typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI" &&
1481 (*current_liboctave_error_handler)
1482 (
"eigs: unrecognized sigma value");
1484 if (typ ==
"LI" || typ ==
"SI" || typ ==
"LR" || typ ==
"SR")
1486 (*current_liboctave_error_handler)
1487 (
"eigs: invalid sigma value for real symmetric problem");
1539 k, tol, presid, p, v, n, iparam,
1540 ipntr, workd, workl, lwork, info
1545 (*current_liboctave_error_handler)
1546 (
"eigs: unrecoverable exception encountered in dsaupd");
1550 if (disp > 0 && !
xisnan (workl[iptr (5)-1]))
1554 os <<
"Iteration " << iter - 1 <<
1555 ": a few Ritz values of the " << p <<
"-by-" <<
1557 for (
int i = 0 ; i < k; i++)
1558 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
1571 if (ido == -1 || ido == 1 || ido == 2)
1573 double *ip2 = workd + iptr(0) - 1;
1584 ip2 = workd + iptr(1) - 1;
1592 (*current_liboctave_error_handler)
1593 (
"eigs: error %d in dsaupd", info);
1623 k, tol, presid, p, v, n, iparam, ipntr, workd, workl, lwork, info2
1628 (*current_liboctave_error_handler)
1629 (
"eigs: unrecoverable exception encountered in dseupd");
1637 if (typ !=
"SM" && typ !=
"BE")
1642 d[i] = d[k - i - 1];
1643 d[k - i - 1] = dtmp;
1649 if (typ !=
"SM" && typ !=
"BE")
1662 dtmp[j] = z[off1 + j];
1665 z[off1 + j] = z[off2 + j];
1668 z[off2 + j] = dtmp[j];
1675 (*current_liboctave_error_handler)
1676 (
"eigs: error %d in dseupd", info2);
1691 std::ostream& os,
double tol,
bool rvec,
1692 bool cholB,
int disp,
int maxit)
1697 bool have_b = ! b.is_empty ();
1704 if (m.rows () != m.cols ())
1706 (*current_liboctave_error_handler) (
"eigs: A must be square");
1709 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
1711 (*current_liboctave_error_handler)
1712 (
"eigs: B must be square and the same size as A");
1726 (*current_liboctave_error_handler)
1727 (
"eigs: n must be at least 3");
1742 if (k <= 0 || k >= n - 1)
1744 (*current_liboctave_error_handler)
1745 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n"
1746 " Use 'eig (full (A))' instead");
1750 if (p <= k || p >= n)
1752 (*current_liboctave_error_handler)
1753 (
"eigs: opts.p must be greater than k and less than n");
1757 if (have_b && cholB && permB.
length () != 0)
1760 if (permB.
length () != n)
1762 (*current_liboctave_error_handler)
1763 (
"eigs: permB vector invalid");
1773 if (checked(bidx) || bidx < 0 ||
1774 bidx >= n ||
D_NINT (bidx) != bidx)
1776 (*current_liboctave_error_handler)
1777 (
"eigs: permB vector invalid");
1784 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA" &&
1785 typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI" &&
1788 (*current_liboctave_error_handler)
1789 (
"eigs: unrecognized sigma value");
1793 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
1795 (*current_liboctave_error_handler)
1796 (
"eigs: invalid sigma value for unsymmetric problem");
1808 if (permB.
length () == 0)
1819 (*current_liboctave_error_handler)
1820 (
"eigs: The matrix B is not positive definite");
1859 k, tol, presid, p, v, n, iparam,
1860 ipntr, workd, workl, lwork, info
1865 (*current_liboctave_error_handler)
1866 (
"eigs: unrecoverable exception encountered in dnaupd");
1870 if (disp > 0 && !
xisnan(workl[iptr(5)-1]))
1874 os <<
"Iteration " << iter - 1 <<
1875 ": a few Ritz values of the " << p <<
"-by-" <<
1877 for (
int i = 0 ; i < k; i++)
1878 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
1890 if (ido == -1 || ido == 1 || ido == 2)
1896 mtmp(i,0) = workd[i + iptr(0) - 1];
1901 workd[i+iptr(1)-1] = mtmp(i,0);
1904 workd + iptr(1) - 1))
1911 (*current_liboctave_error_handler)
1912 (
"eigs: error %d in dnaupd", info);
1939 Matrix eig_vec2 (n, k + 1, 0.0);
1957 (*current_liboctave_error_handler)
1958 (
"eigs: unrecoverable exception encountered in dneupd");
1971 if (dr[i] == 0.0 && di[i] == 0.0 && jj == 0)
1974 d[i-jj] =
Complex (dr[i], di[i]);
1976 if (jj == 0 && !rvec)
1984 d[i] = d[k - i - 1];
1985 d[k - i - 1] = dtmp;
2002 dtmp[j] = z[off1 + j];
2005 z[off1 + j] = z[off2 + j];
2008 z[off2 + j] = dtmp[j];
2029 Complex (z[j+off1],z[j+off2]);
2032 Complex (z[j+off1],-z[j+off2]);
2039 eig_vec =
ltsolve (
M(b), permB, eig_vec);
2044 (*current_liboctave_error_handler)
2045 (
"eigs: error %d in dneupd", info2);
2061 std::ostream& os,
double tol,
bool rvec,
2062 bool cholB,
int disp,
int maxit)
2067 bool have_b = ! b.is_empty ();
2068 std::string typ =
"LM";
2071 if (m.rows () != m.cols ())
2073 (*current_liboctave_error_handler) (
"eigs: A must be square");
2076 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
2078 (*current_liboctave_error_handler)
2079 (
"eigs: B must be square and the same size as A");
2099 (*current_liboctave_error_handler)
2100 (
"eigs: n must be at least 3");
2115 if (k <= 0 || k >= n - 1)
2117 (*current_liboctave_error_handler)
2118 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n"
2119 " Use 'eig (full (A))' instead");
2123 if (p <= k || p >= n)
2125 (*current_liboctave_error_handler)
2126 (
"eigs: opts.p must be greater than k and less than n");
2130 if (have_b && cholB && permB.
length () != 0)
2133 if (permB.
length () != n)
2135 (*current_liboctave_error_handler) (
"eigs: permB vector invalid");
2145 if (checked(bidx) || bidx < 0 ||
2146 bidx >= n ||
D_NINT (bidx) != bidx)
2148 (*current_liboctave_error_handler)
2149 (
"eigs: permB vector invalid");
2201 k, tol, presid, p, v, n, iparam,
2202 ipntr, workd, workl, lwork, info
2207 (*current_liboctave_error_handler)
2208 (
"eigs: unrecoverable exception encountered in dsaupd");
2212 if (disp > 0 && !
xisnan (workl[iptr (5)-1]))
2216 os <<
"Iteration " << iter - 1 <<
2217 ": a few Ritz values of the " << p <<
"-by-" <<
2219 for (
int i = 0 ; i < k; i++)
2220 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
2232 if (ido == -1 || ido == 1 || ido == 2)
2245 tmp(i,0) = dtmp[P[i]];
2249 double *ip2 = workd+iptr(1)-1;
2251 ip2[
Q[i]] = tmp(i,0);
2257 double *ip2 = workd+iptr(2)-1;
2261 tmp(i,0) = ip2[P[i]];
2265 ip2 = workd+iptr(1)-1;
2267 ip2[
Q[i]] = tmp(i,0);
2275 workd[iptr(0) + i - 1] = workd[iptr(1) + i - 1];
2279 double *ip2 = workd+iptr(0)-1;
2283 tmp(i,0) = ip2[P[i]];
2287 ip2 = workd+iptr(1)-1;
2289 ip2[
Q[i]] = tmp(i,0);
2297 (*current_liboctave_error_handler)
2298 (
"eigs: error %d in dsaupd", info);
2325 Matrix eig_vec2 (n, k + 1, 0.0);
2343 (*current_liboctave_error_handler)
2344 (
"eigs: unrecoverable exception encountered in dneupd");
2357 if (dr[i] == 0.0 && di[i] == 0.0 && jj == 0)
2360 d[i-jj] =
Complex (dr[i], di[i]);
2362 if (jj == 0 && !rvec)
2370 d[i] = d[k - i - 1];
2371 d[k - i - 1] = dtmp;
2388 dtmp[j] = z[off1 + j];
2391 z[off1 + j] = z[off2 + j];
2394 z[off2 + j] = dtmp[j];
2415 Complex (z[j+off1],z[j+off2]);
2418 Complex (z[j+off1],-z[j+off2]);
2427 (*current_liboctave_error_handler)
2428 (
"eigs: error %d in dneupd", info2);
2438 const std::string &_typ,
double sigmar,
2442 std::ostream& os,
double tol,
bool rvec,
2443 bool ,
int disp,
int maxit)
2445 std::string typ (_typ);
2446 bool have_sigma = (sigmar ?
true :
false);
2462 (*current_liboctave_error_handler)
2463 (
"eigs: n must be at least 3");
2478 if (k <= 0 || k >= n - 1)
2480 (*current_liboctave_error_handler)
2481 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n"
2482 " Use 'eig (full (A))' instead");
2486 if (p <= k || p >= n)
2488 (*current_liboctave_error_handler)
2489 (
"eigs: opts.p must be greater than k and less than n");
2496 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA" &&
2497 typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI" &&
2499 (*current_liboctave_error_handler)
2500 (
"eigs: unrecognized sigma value");
2502 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
2504 (*current_liboctave_error_handler)
2505 (
"eigs: invalid sigma value for unsymmetric problem");
2557 k, tol, presid, p, v, n, iparam,
2558 ipntr, workd, workl, lwork, info
2563 (*current_liboctave_error_handler)
2564 (
"eigs: unrecoverable exception encountered in dnaupd");
2568 if (disp > 0 && !
xisnan(workl[iptr(5)-1]))
2572 os <<
"Iteration " << iter - 1 <<
2573 ": a few Ritz values of the " << p <<
"-by-" <<
2575 for (
int i = 0 ; i < k; i++)
2576 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
2588 if (ido == -1 || ido == 1 || ido == 2)
2590 double *ip2 = workd + iptr(0) - 1;
2601 ip2 = workd + iptr(1) - 1;
2609 (*current_liboctave_error_handler)
2610 (
"eigs: error %d in dsaupd", info);
2637 Matrix eig_vec2 (n, k + 1, 0.0);
2655 (*current_liboctave_error_handler)
2656 (
"eigs: unrecoverable exception encountered in dneupd");
2669 if (dr[i] == 0.0 && di[i] == 0.0 && jj == 0)
2672 d[i-jj] =
Complex (dr[i], di[i]);
2674 if (jj == 0 && !rvec)
2682 d[i] = d[k - i - 1];
2683 d[k - i - 1] = dtmp;
2700 dtmp[j] = z[off1 + j];
2703 z[off1 + j] = z[off2 + j];
2706 z[off2 + j] = dtmp[j];
2727 Complex (z[j+off1],z[j+off2]);
2730 Complex (z[j+off1],-z[j+off2]);
2739 (*current_liboctave_error_handler)
2740 (
"eigs: error %d in dneupd", info2);
2756 std::ostream& os,
double tol,
bool rvec,
2757 bool cholB,
int disp,
int maxit)
2762 bool have_b = ! b.is_empty ();
2768 if (m.rows () != m.cols ())
2770 (*current_liboctave_error_handler) (
"eigs: A must be square");
2773 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
2775 (*current_liboctave_error_handler)
2776 (
"eigs: B must be square and the same size as A");
2788 cresid(i) =
Complex (rr(i),ri(i));
2794 (*current_liboctave_error_handler)
2795 (
"eigs: n must be at least 3");
2810 if (k <= 0 || k >= n - 1)
2812 (*current_liboctave_error_handler)
2813 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n"
2814 " Use 'eig (full (A))' instead");
2818 if (p <= k || p >= n)
2820 (*current_liboctave_error_handler)
2821 (
"eigs: opts.p must be greater than k and less than n");
2825 if (have_b && cholB && permB.
length () != 0)
2828 if (permB.
length () != n)
2830 (*current_liboctave_error_handler)
2831 (
"eigs: permB vector invalid");
2841 if (checked(bidx) || bidx < 0 ||
2842 bidx >= n ||
D_NINT (bidx) != bidx)
2844 (*current_liboctave_error_handler)
2845 (
"eigs: permB vector invalid");
2852 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA" &&
2853 typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI" &&
2856 (*current_liboctave_error_handler)
2857 (
"eigs: unrecognized sigma value");
2861 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
2863 (*current_liboctave_error_handler)
2864 (
"eigs: invalid sigma value for complex problem");
2876 if (permB.
length () == 0)
2887 (*current_liboctave_error_handler)
2888 (
"eigs: The matrix B is not positive definite");
2928 k, tol, presid, p, v, n, iparam,
2929 ipntr, workd, workl, lwork, rwork, info
2934 (*current_liboctave_error_handler)
2935 (
"eigs: unrecoverable exception encountered in znaupd");
2939 if (disp > 0 && !
xisnan (workl[iptr (5)-1]))
2943 os <<
"Iteration " << iter - 1 <<
2944 ": a few Ritz values of the " << p <<
"-by-" <<
2946 for (
int i = 0 ; i < k; i++)
2947 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
2959 if (ido == -1 || ido == 1 || ido == 2)
2965 mtmp(i,0) = workd[i + iptr(0) - 1];
2968 workd[i+iptr(1)-1] = mtmp(i,0);
2972 workd + iptr(1) - 1))
2979 (*current_liboctave_error_handler)
2980 (
"eigs: error %d in znaupd", info);
3012 k, tol, presid, p, v, n, iparam, ipntr, workd, workl, lwork, rwork, info2
3017 (*current_liboctave_error_handler)
3018 (
"eigs: unrecoverable exception encountered in zneupd");
3028 d[i] = d[k - i - 1];
3029 d[k - i - 1] = ctmp;
3046 ctmp[j] = z[off1 + j];
3049 z[off1 + j] = z[off2 + j];
3052 z[off2 + j] = ctmp[j];
3056 eig_vec =
ltsolve (b, permB, eig_vec);
3061 (*current_liboctave_error_handler)
3062 (
"eigs: error %d in zneupd", info2);
3078 std::ostream& os,
double tol,
bool rvec,
3079 bool cholB,
int disp,
int maxit)
3084 bool have_b = ! b.is_empty ();
3085 std::string typ =
"LM";
3087 if (m.rows () != m.cols ())
3089 (*current_liboctave_error_handler) (
"eigs: A must be square");
3092 if (have_b && (m.rows () != b.rows () || m.rows () != b.cols ()))
3094 (*current_liboctave_error_handler)
3095 (
"eigs: B must be square and the same size as A");
3113 cresid(i) =
Complex (rr(i),ri(i));
3119 (*current_liboctave_error_handler)
3120 (
"eigs: n must be at least 3");
3135 if (k <= 0 || k >= n - 1)
3137 (*current_liboctave_error_handler)
3138 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n"
3139 " Use 'eig (full (A))' instead");
3143 if (p <= k || p >= n)
3145 (*current_liboctave_error_handler)
3146 (
"eigs: opts.p must be greater than k and less than n");
3150 if (have_b && cholB && permB.
length () != 0)
3153 if (permB.
length () != n)
3155 (*current_liboctave_error_handler) (
"eigs: permB vector invalid");
3165 if (checked(bidx) || bidx < 0 ||
3166 bidx >= n ||
D_NINT (bidx) != bidx)
3168 (*current_liboctave_error_handler)
3169 (
"eigs: permB vector invalid");
3222 k, tol, presid, p, v, n, iparam,
3223 ipntr, workd, workl, lwork, rwork, info
3228 (*current_liboctave_error_handler)
3229 (
"eigs: unrecoverable exception encountered in znaupd");
3233 if (disp > 0 && !
xisnan(workl[iptr(5)-1]))
3237 os <<
"Iteration " << iter - 1 <<
3238 ": a few Ritz values of the " << p <<
"-by-" <<
3240 for (
int i = 0 ; i < k; i++)
3241 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
3253 if (ido == -1 || ido == 1 || ido == 2)
3266 tmp(i,0) = ctmp[P[i]];
3270 Complex *ip2 = workd+iptr(1)-1;
3272 ip2[
Q[i]] = tmp(i,0);
3278 Complex *ip2 = workd+iptr(2)-1;
3282 tmp(i,0) = ip2[P[i]];
3286 ip2 = workd+iptr(1)-1;
3288 ip2[
Q[i]] = tmp(i,0);
3296 workd[iptr(0) + i - 1] =
3297 workd[iptr(1) + i - 1];
3301 Complex *ip2 = workd+iptr(0)-1;
3305 tmp(i,0) = ip2[P[i]];
3309 ip2 = workd+iptr(1)-1;
3311 ip2[
Q[i]] = tmp(i,0);
3319 (*current_liboctave_error_handler)
3320 (
"eigs: error %d in dsaupd", info);
3352 k, tol, presid, p, v, n, iparam, ipntr, workd, workl, lwork, rwork, info2
3357 (*current_liboctave_error_handler)
3358 (
"eigs: unrecoverable exception encountered in zneupd");
3368 d[i] = d[k - i - 1];
3369 d[k - i - 1] = ctmp;
3386 ctmp[j] = z[off1 + j];
3389 z[off1 + j] = z[off2 + j];
3392 z[off2 + j] = ctmp[j];
3398 (*current_liboctave_error_handler)
3399 (
"eigs: error %d in zneupd", info2);
3408 const std::string &_typ,
Complex sigma,
3413 double tol,
bool rvec,
bool ,
3414 int disp,
int maxit)
3416 std::string typ (_typ);
3417 bool have_sigma = (
std::abs (sigma) ?
true :
false);
3430 cresid(i) =
Complex (rr(i),ri(i));
3436 (*current_liboctave_error_handler)
3437 (
"eigs: n must be at least 3");
3452 if (k <= 0 || k >= n - 1)
3454 (*current_liboctave_error_handler)
3455 (
"eigs: Invalid number of eigenvalues to extract (must be 0 < k < n-1).\n"
3456 " Use 'eig (full (A))' instead");
3460 if (p <= k || p >= n)
3462 (*current_liboctave_error_handler)
3463 (
"eigs: opts.p must be greater than k and less than n");
3469 if (typ !=
"LM" && typ !=
"SM" && typ !=
"LA" && typ !=
"SA" &&
3470 typ !=
"BE" && typ !=
"LR" && typ !=
"SR" && typ !=
"LI" &&
3472 (*current_liboctave_error_handler)
3473 (
"eigs: unrecognized sigma value");
3475 if (typ ==
"LA" || typ ==
"SA" || typ ==
"BE")
3477 (*current_liboctave_error_handler)
3478 (
"eigs: invalid sigma value for complex problem");
3531 k, tol, presid, p, v, n, iparam,
3532 ipntr, workd, workl, lwork, rwork, info
3537 (*current_liboctave_error_handler)
3538 (
"eigs: unrecoverable exception encountered in znaupd");
3542 if (disp > 0 && !
xisnan(workl[iptr(5)-1]))
3546 os <<
"Iteration " << iter - 1 <<
3547 ": a few Ritz values of the " << p <<
"-by-" <<
3549 for (
int i = 0 ; i < k; i++)
3550 os <<
" " << workl[iptr(5)+i-1] <<
"\n";
3562 if (ido == -1 || ido == 1 || ido == 2)
3564 Complex *ip2 = workd + iptr(0) - 1;
3575 ip2 = workd + iptr(1) - 1;
3583 (*current_liboctave_error_handler)
3584 (
"eigs: error %d in dsaupd", info);
3616 k, tol, presid, p, v, n, iparam, ipntr, workd, workl, lwork, rwork, info2
3621 (*current_liboctave_error_handler)
3622 (
"eigs: unrecoverable exception encountered in zneupd");
3632 d[i] = d[k - i - 1];
3633 d[k - i - 1] = ctmp;
3650 ctmp[j] = z[off1 + j];
3653 z[off1 + j] = z[off2 + j];
3656 z[off2 + j] = ctmp[j];
3662 (*current_liboctave_error_handler)
3663 (
"eigs: error %d in zneupd", info2);
3670 #if !defined (CXX_NEW_FRIEND_TEMPLATE_DECL)
3678 double tol = std::numeric_limits<double>::epsilon (),
3679 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3689 double tol = std::numeric_limits<double>::epsilon (),
3690 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3700 double tol = std::numeric_limits<double>::epsilon (),
3701 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3711 double tol = std::numeric_limits<double>::epsilon (),
3712 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3717 const std::string &typ,
double sigma,
3722 double tol = std::numeric_limits<double>::epsilon (),
3723 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3733 double tol = std::numeric_limits<double>::epsilon (),
3734 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3745 double tol = std::numeric_limits<double>::epsilon (),
3746 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3757 double tol = std::numeric_limits<double>::epsilon (),
3758 bool rvec =
false,
bool cholB = 0,
3759 int disp = 0,
int maxit = 300);
3770 double tol = std::numeric_limits<double>::epsilon (),
3771 bool rvec =
false,
bool cholB = 0,
3772 int disp = 0,
int maxit = 300);
3776 const std::string &_typ,
double sigma,
3781 double tol = std::numeric_limits<double>::epsilon (),
3782 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3793 double tol = std::numeric_limits<double>::epsilon (),
3794 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3807 double tol = std::numeric_limits<double>::epsilon (),
3808 bool rvec =
false,
bool cholB = 0,
int disp = 0,
3821 double tol = std::numeric_limits<double>::epsilon (),
3822 bool rvec =
false,
bool cholB = 0,
3823 int disp = 0,
int maxit = 300);
3836 double tol = std::numeric_limits<double>::epsilon (),
3837 bool rvec =
false,
bool cholB = 0,
3838 int disp = 0,
int maxit = 300);
3842 const std::string &_typ,
Complex sigma,
3847 double tol = std::numeric_limits<double>::epsilon (),
3848 bool rvec =
false,
bool cholB = 0,
3849 int disp = 0,
int maxit = 300);