68 if (tmp.
length () && tmp(0).is_defined ())
70 if (! warned_imaginary && tmp(0).is_complex_type ())
72 warning (
"eigs: ignoring imaginary part returned from user-supplied function");
73 warned_imaginary =
true;
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 ();
190 warned_imaginary =
false;
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");