eigs fails with small matrices
Reported by Atri Bhattacharya
BUG DESCRIPTION:
----------------
eigs(A) fails where A is a matrix with less than 7 rows and columns if it is symmetric or less than 8 rows and columns if it is asymmetric. For example:
=======================================================
-->A = rand(7,7);
-->eigs(A)
!--error 999
eigs: Wrong value for input argument #3: For real non symmetric or complex problems, k must be an integer in the range 1 to N - 2.
at line 111 of function eigs called by :
eigs(A)
-->A = rand(6,6);
-->eigs(A + A')
!--error 999
eigs: Wrong value for input argument #3: For real symmetric problems, k must be an integer in the range 1 to N - 1.
at line 111 of function eigs called by :
eigs(A + A')
=======================================================
My guess is the error stems from line 64 in share/scilab/modules/arnoldi/macros/eigs.sci, where nev is set to: min(size(A, "r"), 6).
I modify the eigs function with the following patch:
-----------------------
--- /usr/share/scilab/modules/arnoldi/macros/eigs.sci 2014-06-20 20:39:06.456291171 -0700
+++ eigs2/eigs2.sci 2014-06-21 00:24:55.102864697 -0700
@@ -7,7 +7,7 @@
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
@@ -61,7 +61,11 @@
if(typeof(varargin(1)) <> "function")
select rhs
case 1
- nev = min(size(A, "r"), 6);
+ if(isequal(varargin(1), varargin(1)'))
+ nev = min(size(A, "r") - 1, 6);
+ else
+ nev = min(size(A, "r") - 2, 6);
+ end
case 2
nev = min(size(A, "r"), 6);
B = varargin(2);
------------------------
eigs now works with matrices of smaller dimensions, returning the N - 2 or N - 1 largest eigenvalues as appropriate for an asymmetric or symmetric matrix respectively.