Mercurial > octave-nkf
diff scripts/sparse/eigs.m @ 19630:0e1f5a750d00
maint: Periodic merge of gui-release to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 20 Jan 2015 10:24:46 -0500 |
parents | 0850b5212619 446c46af4b42 |
children | db92e7e28e1f |
line wrap: on
line diff
--- a/scripts/sparse/eigs.m Tue Jan 20 09:55:41 2015 -0500 +++ b/scripts/sparse/eigs.m Tue Jan 20 10:24:46 2015 -0500 @@ -40,7 +40,7 @@ ## Calculate a limited number of eigenvalues and eigenvectors of @var{A}, ## based on a selection criteria. The number of eigenvalues and eigenvectors to ## calculate is given by @var{k} and defaults to 6. -## +## ## By default, @code{eigs} solve the equation ## @tex ## $A \nu = \lambda \nu$, @@ -63,113 +63,113 @@ ## @ifinfo ## @code{A * v = lambda * B * v}. ## @end ifinfo -## +## ## The argument @var{sigma} determines which eigenvalues are returned. ## @var{sigma} can be either a scalar or a string. When @var{sigma} is a ## scalar, the @var{k} eigenvalues closest to @var{sigma} are returned. If ## @var{sigma} is a string, it must have one of the following values. -## +## ## @table @asis ## @item @qcode{"lm"} ## Largest Magnitude (default). -## +## ## @item @qcode{"sm"} ## Smallest Magnitude. -## +## ## @item @qcode{"la"} ## Largest Algebraic (valid only for real symmetric problems). -## +## ## @item @qcode{"sa"} ## Smallest Algebraic (valid only for real symmetric problems). -## +## ## @item @qcode{"be"} ## Both Ends, with one more from the high-end if @var{k} is odd (valid only for ## real symmetric problems). -## +## ## @item @qcode{"lr"} ## Largest Real part (valid only for complex or unsymmetric problems). -## +## ## @item @qcode{"sr"} ## Smallest Real part (valid only for complex or unsymmetric problems). -## +## ## @item @qcode{"li"} ## Largest Imaginary part (valid only for complex or unsymmetric problems). -## +## ## @item @qcode{"si"} ## Smallest Imaginary part (valid only for complex or unsymmetric problems). ## @end table -## +## ## If @var{opts} is given, it is a structure defining possible options that ## @code{eigs} should use. The fields of the @var{opts} structure are: -## +## ## @table @code ## @item issym ## If @var{af} is given, then flags whether the function @var{af} defines a ## symmetric problem. It is ignored if @var{A} is given. The default is false. -## +## ## @item isreal ## If @var{af} is given, then flags whether the function @var{af} defines a ## real problem. It is ignored if @var{A} is given. The default is true. -## +## ## @item tol ## Defines the required convergence tolerance, calculated as ## @code{tol * norm (A)}. The default is @code{eps}. -## +## ## @item maxit ## The maximum number of iterations. The default is 300. -## +## ## @item p ## The number of Lanzcos basis vectors to use. More vectors will result in ## faster convergence, but a greater use of memory. The optimal value of ## @code{p} is problem dependent and should be in the range @var{k} to @var{n}. ## The default value is @code{2 * @var{k}}. -## +## ## @item v0 ## The starting vector for the algorithm. An initial vector close to the ## final vector will speed up convergence. The default is for @sc{arpack} ## to randomly generate a starting vector. If specified, @code{v0} must be ## an @var{n}-by-1 vector where @code{@var{n} = rows (@var{A})} -## +## ## @item disp ## The level of diagnostic printout (0|1|2). If @code{disp} is 0 then ## diagnostics are disabled. The default value is 0. -## +## ## @item cholB ## Flag if @code{chol (@var{B})} is passed rather than @var{B}. The default is ## false. -## +## ## @item permB ## The permutation vector of the Cholesky@tie{}factorization of @var{B} if ## @code{cholB} is true. That is @code{chol (@var{B}(permB, permB))}. The ## default is @code{1:@var{n}}. -## +## ## @end table -## +## ## It is also possible to represent @var{A} by a function denoted @var{af}. ## @var{af} must be followed by a scalar argument @var{n} defining the length ## of the vector argument accepted by @var{af}. @var{af} can be ## a function handle, an inline function, or a string. When @var{af} is a ## string it holds the name of the function to use. -## +## ## @var{af} is a function of the form @code{y = af (x)} ## where the required return value of @var{af} is determined by ## the value of @var{sigma}. The four possible forms are -## +## ## @table @code ## @item A * x ## if @var{sigma} is not given or is a string other than "sm". -## +## ## @item A \ x ## if @var{sigma} is 0 or "sm". -## +## ## @item (A - sigma * I) \ x ## for the standard eigenvalue problem, where @code{I} is the identity matrix of ## the same size as @var{A}. -## +## ## @item (A - sigma * B) \ x ## for the general eigenvalue problem. ## @end table -## +## ## The return arguments of @code{eigs} depend on the number of return arguments ## requested. With a single return argument, a vector @var{d} of length @var{k} ## is returned containing the @var{k} eigenvalues that have been found. With @@ -178,7 +178,7 @@ ## eigenvalues themselves are returned in @var{d} in the form of a ## @var{n}-by-@var{k} matrix, where the elements on the diagonal are the ## eigenvalues. -## +## ## Given a third return argument @var{flag}, @code{eigs} returns the status ## of the convergence. If @var{flag} is 0 then all eigenvalues have converged. ## Any other value indicates a failure to converge. @@ -186,7 +186,7 @@ ## This function is based on the @sc{arpack} package, written by ## @nospell{R. Lehoucq, K. Maschhoff, D. Sorensen, and C. Yang}. For more ## information see @url{http://www.caam.rice.edu/software/ARPACK/}. -## +## ## @seealso{eig, svds} ## @end deftypefn @@ -215,7 +215,7 @@ if (rows (a) < 9) call_eig = true; endif - + if (nargin > 1 + offset) tmp = varargin{2+offset}; if (isnumeric (tmp) && isscalar (tmp) && isreal (tmp)