68 if (tmp.
length () && tmp(0).is_defined ())
72 warning (
"eigs: ignoring imaginary part returned from user-supplied function");
112 if (tmp.
length () && tmp(0).is_defined ())
134 @deftypefn {Loadable Function} {@var{d} =} __eigs__ (@var{A})\n\
135 @deftypefnx {Loadable Function} {@var{d} =} __eigs__ (@var{A}, @var{k})\n\
136 @deftypefnx {Loadable Function} {@var{d} =} __eigs__ (@var{A}, @var{k}, @var{sigma})\n\
137 @deftypefnx {Loadable Function} {@var{d} =} __eigs__ (@var{A}, @var{k}, @var{sigma}, @var{opts})\n\
138 @deftypefnx {Loadable Function} {@var{d} =} __eigs__ (@var{A}, @var{B})\n\
139 @deftypefnx {Loadable Function} {@var{d} =} __eigs__ (@var{A}, @var{B}, @var{k})\n\
140 @deftypefnx {Loadable Function} {@var{d} =} __eigs__ (@var{A}, @var{B}, @var{k}, @var{sigma})\n\
141 @deftypefnx {Loadable Function} {@var{d} =} __eigs__ (@var{A}, @var{B}, @var{k}, @var{sigma}, @var{opts})\n\
142 @deftypefnx {Loadable Function} {@var{d} =} __eigs__ (@var{af}, @var{n})\n\
143 @deftypefnx {Loadable Function} {@var{d} =} __eigs__ (@var{af}, @var{n}, @var{B})\n\
144 @deftypefnx {Loadable Function} {@var{d} =} __eigs__ (@var{af}, @var{n}, @var{k})\n\
145 @deftypefnx {Loadable Function} {@var{d} =} __eigs__ (@var{af}, @var{n}, @var{B}, @var{k})\n\
146 @deftypefnx {Loadable Function} {@var{d} =} __eigs__ (@var{af}, @var{n}, @var{k}, @var{sigma})\n\
147 @deftypefnx {Loadable Function} {@var{d} =} __eigs__ (@var{af}, @var{n}, @var{B}, @var{k}, @var{sigma})\n\
148 @deftypefnx {Loadable Function} {@var{d} =} __eigs__ (@var{af}, @var{n}, @var{k}, @var{sigma}, @var{opts})\n\
149 @deftypefnx {Loadable Function} {@var{d} =} __eigs__ (@var{af}, @var{n}, @var{B}, @var{k}, @var{sigma}, @var{opts})\n\
150 @deftypefnx {Loadable Function} {[@var{V}, @var{d}] =} __eigs__ (@var{A}, @dots{})\n\
151 @deftypefnx {Loadable Function} {[@var{V}, @var{d}] =} __eigs__ (@var{af}, @var{n}, @dots{})\n\
152 @deftypefnx {Loadable Function} {[@var{V}, @var{d}, @var{flag}] =} __eigs__ (@var{A}, @dots{})\n\
153 @deftypefnx {Loadable Function} {[@var{V}, @var{d}, @var{flag}] =} __eigs__ (@var{af}, @var{n}, @dots{})\n\
154 Undocumented internal function.\n\
159 int nargin = args.
length ();
160 std::string fcn_name;
164 double sigmar, sigmai;
165 bool have_sigma =
false;
166 std::string typ =
"LM";
173 bool have_a_fun =
false;
174 bool a_is_complex =
false;
175 bool b_is_complex =
false;
176 bool symmetric =
false;
177 bool sym_tested =
false;
179 bool a_is_sparse =
false;
182 double tol = std::numeric_limits<double>::epsilon ();
199 error (
"eigs: invalid recursive call");
200 if (fcn_name.length ())
207 else if (args(0).is_function_handle () || args(0).is_inline_function ()
208 || args(0).is_string ())
210 if (args(0).is_string ())
212 std::string name = args(0).string_value ();
213 std::string fname =
"function y = ";
215 fname.append (fcn_name);
216 fname.append (
"(x) y = ");
225 error (
"eigs: unknown function");
231 error (
"eigs: incorrect number of arguments");
236 n = args(1).nint_value ();
243 if (args(0).is_complex_type ())
245 if (args(0).is_sparse_type ())
247 ascm = (args(0).sparse_complex_matrix_value ());
251 acm = (args(0).complex_matrix_value ());
258 if (args(0).is_sparse_type ())
260 asmm = (args(0).sparse_matrix_value ());
265 amm = (args(0).matrix_value ());
274 && ! (args(1 + arg_offset).is_real_scalar ()))
276 if (args(1+arg_offset).is_complex_type ())
278 b_arg = 1+arg_offset;
285 b_arg = 1+arg_offset;
292 k = args(1+arg_offset).nint_value ();
296 if (args(2+arg_offset).is_string ())
298 typ = args(2+arg_offset).string_value ();
301 transform (typ.begin (), typ.end (), typ.begin (), toupper);
307 sigma = args(2+arg_offset).complex_value ();
313 error (
"eigs: SIGMA must be a scalar or a string");
324 if (args(3+arg_offset).is_map ())
360 if (a_is_complex || b_is_complex)
380 error (
"eigs: OPTS argument must be a scalar structure");
386 error (
"eigs: OPTS argument must be a structure");
391 if (nargin > (4+arg_offset))
393 error (
"eigs: incorrect number of arguments");
398 if (!sym_tested && !have_a_fun)
408 if (a_is_complex || b_is_complex)
411 bscm = args(b_arg).sparse_complex_matrix_value ();
413 bcm = args(b_arg).complex_matrix_value ();
418 bsmm = args(b_arg).sparse_matrix_value ();
420 bmm = args(b_arg).matrix_value ();
432 if (a_is_complex || b_is_complex)
447 (ascm, sigma, k, p, info, eig_vec, eig_val, bscm, permB,
452 (acm, sigma, k, p, info, eig_vec, eig_val, bcm, permB,
460 (ascm, typ, k, p, info, eig_vec, eig_val, bscm, permB,
465 (acm, typ, k, p, info, eig_vec, eig_val, bcm, permB,
474 retval(2) =
double (info);
479 else if (sigmai != 0.)
508 retval(2) =
double (info);
522 (
eigs_func, n, typ, sigmar, k, p, info, eig_vec,
529 (asmm, sigmar, k, p, info, eig_vec, eig_val, bsmm,
534 (amm, sigmar, k, p, info, eig_vec, eig_val, bmm,
542 (asmm, typ, k, p, info, eig_vec, eig_val, bsmm,
547 (amm, typ, k, p, info, eig_vec, eig_val, bmm, permB,
556 retval(2) =
double (info);
568 (
eigs_func, n, typ, sigmar, k, p, info, eig_vec,
575 (asmm, sigmar, k, p, info, eig_vec, eig_val, bsmm,
580 (amm, sigmar, k, p, info, eig_vec, eig_val, bmm,
588 (asmm, typ, k, p, info, eig_vec, eig_val, bsmm,
593 (amm, typ, k, p, info, eig_vec, eig_val, bmm, permB,
602 retval(2) =
double (info);
610 warning (
"eigs: None of the %d requested eigenvalues converged", k);
612 warning (
"eigs: Only %d of the %d requested eigenvalues converged",
616 if (! fcn_name.empty ())
619 error (
"eigs: not available in this version of Octave");
bool is_symmetric(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)
virtual octave_value_list do_multi_index_op(int nargout, const octave_value_list &idx)
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)
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)
OCTINTERP_API void print_usage(void)
octave_idx_type length(void) const
bool is_defined(void) const
void error(const char *fmt,...)
ColumnVector eigs_func(const ColumnVector &x, int &eigs_error)
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)
bool is_symmetric(void) const
Array< Complex > complex_vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
std::string unique_symbol_name(const std::string &basename)
void clear_function(const std::string &nm)
ComplexColumnVector eigs_complex_func(const ComplexColumnVector &x, int &eigs_error)
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)
int nint_value(bool frc_str_conv=false) const
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)
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)
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)
void warning(const char *fmt,...)
static bool warned_imaginary
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)
Array< double > vector_value(bool frc_str_conv=false, bool frc_vec_conv=false) const
octave_function * extract_function(const octave_value &arg, const std::string &warn_for, const std::string &fname, const std::string &header, const std::string &trailer)
ColumnVector transform(const Matrix &m, double x, double y, double z)
ColumnVector imag(const ComplexColumnVector &a)
octave_value getfield(const std::string &key) const
#define DEFUN_DLD(name, args_name, nargout_name, doc)
static octave_function * eigs_fcn
std::complex< double > Complex
virtual octave_function * function_value(bool silent=false)
ColumnVector real(const ComplexColumnVector &a)
double double_value(bool frc_str_conv=false) const
void gripe_user_supplied_eval(const char *name)
F77_RET_T const double * x