23 #if defined (HAVE_CONFIG_H)
40 #if defined (HAVE_ARPACK)
66 catch (octave::execution_exception&
e)
71 if (tmp.
length () &&
tmp(0).is_defined ())
73 if (! warned_imaginary &&
tmp(0).is_complex_type ())
75 warning (
"eigs: ignoring imaginary part returned from user-supplied function");
76 warned_imaginary =
true;
79 retval =
tmp(0).xvector_value (
"eigs: evaluation of user-supplied function failed");
106 catch (octave::execution_exception&
e)
111 if (tmp.
length () &&
tmp(0).is_defined ())
113 retval =
tmp(0).complex_vector_value (
"eigs: evaluation of user-supplied function failed");
152 #if defined (HAVE_ARPACK)
165 double sigmar, sigmai;
166 bool have_sigma =
false;
174 bool have_a_fun =
false;
175 bool a_is_complex =
false;
176 bool b_is_complex =
false;
177 bool symmetric =
false;
178 bool sym_tested =
false;
180 bool a_is_sparse =
false;
183 double tol = std::numeric_limits<double>::epsilon ();
191 warned_imaginary =
false;
199 error (
"eigs: invalid recursive call");
201 if (
args(0).is_function_handle () ||
args(0).is_inline_function ()
202 ||
args(0).is_string ())
204 if (
args(0).is_string ())
209 fname.append (fcn_name);
210 fname.append (
"(x) y = ");
215 eigs_fcn =
args(0).function_value ();
218 error (
"eigs: unknown function");
221 error (
"eigs: incorrect number of arguments");
223 n =
args(1).nint_value ();
229 if (
args(0).is_complex_type ())
231 if (
args(0).is_sparse_type ())
233 ascm = (
args(0).sparse_complex_matrix_value ());
237 acm = (
args(0).complex_matrix_value ());
244 if (
args(0).is_sparse_type ())
246 asmm = (
args(0).sparse_matrix_value ());
251 amm = (
args(0).matrix_value ());
258 if (nargin > 1 + arg_offset
259 && ! (
args(1 + arg_offset).is_real_scalar ()))
261 if (
args(1+arg_offset).is_complex_type ())
263 b_arg = 1+arg_offset;
270 b_arg = 1+arg_offset;
276 if (nargin > (1+arg_offset))
277 k =
args(1+arg_offset).nint_value ();
279 if (nargin > (2+arg_offset))
281 if (
args(2+arg_offset).is_string ())
283 typ =
args(2+arg_offset).string_value ();
286 transform (typ.begin (), typ.end (), typ.begin (), toupper);
292 sigma =
args(2+arg_offset).xcomplex_value (
"eigs: SIGMA must be a scalar or a string");
298 sigmar = sigma.real ();
299 sigmai = sigma.imag ();
301 if (nargin > (3+arg_offset))
303 if (!
args(3+arg_offset).is_map ())
304 error (
"eigs: OPTS argument must be a structure");
338 if (a_is_complex || b_is_complex)
357 if (nargin > (4+arg_offset))
358 error (
"eigs: incorrect number of arguments");
361 if (! sym_tested && ! have_a_fun)
371 if (a_is_complex || b_is_complex)
374 bscm =
args(b_arg).sparse_complex_matrix_value ();
376 bcm =
args(b_arg).complex_matrix_value ();
381 bsmm =
args(b_arg).sparse_matrix_value ();
383 bmm =
args(b_arg).matrix_value ();
389 if (! have_sigma && typ ==
"SM")
393 if (a_is_complex || b_is_complex)
407 (ascm, sigma, k, p, info, eig_vec, eig_val, bscm, permB,
412 (acm, sigma, k, p, info, eig_vec, eig_val, bcm, permB,
420 (ascm, typ, k, p, info, eig_vec, eig_val, bscm, permB,
425 (acm, typ, k, p, info, eig_vec, eig_val, bcm, permB,
435 else if (sigmai != 0.)
474 (
eigs_func, n, typ, sigmar, k, p, info, eig_vec,
481 (asmm, sigmar, k, p, info, eig_vec, eig_val, bsmm,
486 (amm, sigmar, k, p, info, eig_vec, eig_val, bmm,
494 (asmm, typ, k, p, info, eig_vec, eig_val, bsmm,
499 (amm, typ, k, p, info, eig_vec, eig_val, bmm, permB,
516 (
eigs_func, n, typ, sigmar, k, p, info, eig_vec,
523 (asmm, sigmar, k, p, info, eig_vec, eig_val, bsmm,
528 (amm, sigmar, k, p, info, eig_vec, eig_val, bmm,
536 (asmm, typ, k, p, info, eig_vec, eig_val, bsmm,
541 (amm, typ, k, p, info, eig_vec, eig_val, bmm, permB,
554 warning (
"eigs: None of the %d requested eigenvalues converged", k);
556 warning (
"eigs: Only %d of the %d requested eigenvalues converged",
559 if (! fcn_name.empty ())
566 octave_unused_parameter (
args);
567 octave_unused_parameter (
nargout);
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)
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).is_integer_type())
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)
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
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,...)
octave::unwind_protect frame
void err_user_supplied_eval(const char *name)
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)
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
double double_value(bool frc_str_conv=false) const
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
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