23 #if defined (HAVE_CONFIG_H) 44 #if defined (HAVE_ARPACK) 70 catch (octave::execution_exception&
e)
75 if (
tmp.length () &&
tmp(0).is_defined ())
79 warning (
"eigs: ignoring imaginary part returned from user-supplied function");
83 retval =
tmp(0).xvector_value (
"eigs: evaluation of user-supplied function failed");
110 catch (octave::execution_exception&
e)
115 if (
tmp.length () &&
tmp(0).is_defined ())
117 retval =
tmp(0).complex_vector_value (
"eigs: evaluation of user-supplied function failed");
156 #if defined (HAVE_ARPACK) 158 int nargin = args.length ();
169 double sigmar, sigmai;
170 bool have_sigma =
false;
178 bool have_a_fun =
false;
179 bool a_is_complex =
false;
180 bool b_is_complex =
false;
181 bool symmetric =
false;
182 bool sym_tested =
false;
184 bool a_is_sparse =
false;
187 double tol = std::numeric_limits<double>::epsilon ();
203 error (
"eigs: invalid recursive call");
205 if (args(0).is_function_handle () || args(0).is_inline_function ()
206 || args(0).is_string ())
208 if (args(0).is_string ())
213 fname.append (fcn_name);
214 fname.append (
"(x) y = ");
222 error (
"eigs: unknown function");
225 error (
"eigs: incorrect number of arguments");
227 n = args(1).nint_value ();
233 if (args(0).iscomplex ())
235 if (args(0).issparse ())
237 ascm = (args(0).sparse_complex_matrix_value ());
241 acm = (args(0).complex_matrix_value ());
248 if (args(0).issparse ())
250 asmm = (args(0).sparse_matrix_value ());
255 amm = (args(0).matrix_value ());
262 if (
nargin > 1 + arg_offset
263 && ! (args(1 + arg_offset).is_real_scalar ()))
265 if (args(1+arg_offset).iscomplex ())
267 b_arg = 1+arg_offset;
274 b_arg = 1+arg_offset;
280 if (
nargin > (1+arg_offset))
281 k = args(1+arg_offset).nint_value ();
283 if (
nargin > (2+arg_offset))
285 if (args(2+arg_offset).is_string ())
287 typ = args(2+arg_offset).string_value ();
290 transform (typ.begin (), typ.end (), typ.begin (), toupper);
296 sigma = args(2+arg_offset).xcomplex_value (
"eigs: SIGMA must be a scalar or a string");
302 sigmar = sigma.real ();
303 sigmai = sigma.imag ();
305 if (
nargin > (3+arg_offset))
307 if (! args(3+arg_offset).
isstruct ())
308 error (
"eigs: OPTS argument must be a structure");
310 octave_scalar_map map = args(3+arg_offset).xscalar_map_value (
"eigs: OPTS argument must be a scalar structure");
316 if (
tmp.is_defined () && ! sym_tested)
318 symmetric =
tmp.double_value () != 0.;
324 if (
tmp.is_defined () && have_a_fun)
325 a_is_complex = ! (
tmp.double_value () != 0.);
328 if (
tmp.is_defined ())
329 tol =
tmp.double_value ();
332 if (
tmp.is_defined ())
333 maxit =
tmp.nint_value ();
336 if (
tmp.is_defined ())
337 p =
tmp.nint_value ();
340 if (
tmp.is_defined ())
342 if (a_is_complex || b_is_complex)
349 if (
tmp.is_defined ())
353 if (
tmp.is_defined ())
354 cholB =
tmp.double_value () != 0.;
357 if (
tmp.is_defined ())
361 if (
nargin > (4+arg_offset))
362 error (
"eigs: incorrect number of arguments");
365 if (! sym_tested && ! have_a_fun)
375 if (a_is_complex || b_is_complex)
378 bscm = args(b_arg).sparse_complex_matrix_value ();
380 bcm = args(b_arg).complex_matrix_value ();
385 bsmm = args(b_arg).sparse_matrix_value ();
387 bmm = args(b_arg).matrix_value ();
393 if (! have_sigma && typ ==
"SM")
397 if (a_is_complex || b_is_complex)
411 (ascm, sigma,
k,
p, info, eig_vec, eig_val, bscm, permB,
416 (acm, sigma,
k,
p, info, eig_vec, eig_val, bcm, permB,
424 (ascm, typ,
k,
p, info, eig_vec, eig_val, bscm, permB,
429 (acm, typ,
k,
p, info, eig_vec, eig_val, bcm, permB,
439 else if (sigmai != 0.)
485 (asmm, sigmar,
k,
p, info, eig_vec, eig_val, bsmm,
490 (amm, sigmar,
k,
p, info, eig_vec, eig_val, bmm,
498 (asmm, typ,
k,
p, info, eig_vec, eig_val, bsmm,
503 (amm, typ,
k,
p, info, eig_vec, eig_val, bmm, permB,
527 (asmm, sigmar,
k,
p, info, eig_vec, eig_val, bsmm,
532 (amm, sigmar,
k,
p, info, eig_vec, eig_val, bmm,
540 (asmm, typ,
k,
p, info, eig_vec, eig_val, bsmm,
545 (amm, typ,
k,
p, info, eig_vec, eig_val, bmm, permB,
559 "eigs: None of the %d requested eigenvalues converged",
k);
562 "eigs: Only %d of the %d requested eigenvalues converged",
565 if (! fcn_name.empty ())
576 octave_unused_parameter (interp);
577 octave_unused_parameter (args);
578 octave_unused_parameter (
nargout);
OCTINTERP_API octave_value_list feval(const std::string &name, const octave_value_list &args=octave_value_list(), int nargout=0)
void warning_with_id(const char *id, const char *fmt,...)
scalar structure containing the one value The second produces an empty struct array with one field and no values since being passed an empty cell array of struct array values When the value is a cell array containing a single entry this becomes a scalar struct with that single entry as the value of the field That single entry happens to be an empty cell array Finally if the value is a non scalar cell array then ode isstruct
octave_idx_type EigsRealSymmetricFunc(EigsFunc fun, octave_idx_type n_arg, const std::string &_typ, double sigma, octave_idx_type k_arg, octave_idx_type p_arg, 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 EigsRealNonSymmetricMatrix(const M &m, const std::string typ, octave_idx_type k_arg, octave_idx_type p_arg, 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 EigsComplexNonSymmetricMatrixShift(const M &m, Complex sigma, octave_idx_type k_arg, octave_idx_type p_arg, 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)
OCTINTERP_API void print_usage(void)
void error(const char *fmt,...)
ColumnVector eigs_func(const ColumnVector &x, int &eigs_error)
std::string unique_symbol_name(const std::string &basename)
Cell getfield(const std::string &key) const
#define DEFMETHOD_DLD(name, interp_name, args_name, nargout_name, doc)
Macro to define an at run time dynamically loadable builtin method.
octave_idx_type EigsRealNonSymmetricMatrixShift(const M &m, double sigmar, octave_idx_type k_arg, octave_idx_type p_arg, 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)
nd deftypefn *std::string name
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 EigsRealNonSymmetricFunc(EigsFunc fun, octave_idx_type n_arg, const std::string &_typ, double sigmar, octave_idx_type k_arg, octave_idx_type p_arg, 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 EigsRealSymmetricMatrix(const M &m, const std::string typ, octave_idx_type k_arg, octave_idx_type p_arg, 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_arg, octave_idx_type p_arg, 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)
void warning(const char *fmt,...)
octave::unwind_protect frame
bool issymmetric(void) const
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_arg, octave_idx_type p_arg, 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_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
octave_idx_type EigsComplexNonSymmetricFunc(EigsComplexFunc fun, octave_idx_type n_arg, const std::string &_typ, Complex sigma, octave_idx_type k_arg, octave_idx_type p_arg, octave_idx_type &info, ComplexMatrix &eig_vec, ComplexColumnVector &eig_val, ComplexColumnVector &cresid, std::ostream &os, double tol, bool rvec, bool, int disp, int maxit)
bool issymmetric(void) 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)
void clear_function(const std::string &name)
static octave_function * eigs_fcn
std::complex< double > Complex
virtual octave_function * function_value(bool silent=false)
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 const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T const F77_DBLE * x