Mantis - ALGLIB
Viewing Issue Advanced Details
293 Linear algebra crash always 2010-02-07 22:26 2010-02-08 10:38
wvd_vegt  
SergeyB  
normal  
resolved 2.3.0  
no change required  
none    
none  
C#
0000293: SVD Algorithhm crashes on array bounds
Hi,

When i try to run an SVD the routine crashes on an array index out of bounds in

Test method LsaTest.LsaTests.TestDecompose threw exception: System.IndexOutOfRangeException: De index ligt buiten de matrixgrenzen..

The error comes from the loop

                for(i_=1; i_<=nmip1;i_++)
                {
                    t[i_] = a[i,i_+i1_];
                }

where the i_ index runs from 0 to 25 (in the alglib svd test code) where the array is only 25 elements and start at 0 (so the index should run from 0..24).
Callstack:

alglib.lq.lqdecomposition(Double[,]& a, Int32 m, Int32 n, Double[]& tau) in Alglib\lq.cs: line 285

alglib.svd.svddecomposition(Double[,] a, Int32 m, Int32 n, Int32 uneeded, Int32 vtneeded, Int32 additionalmemory, Double[]& w, Double[,]& u, Double[,]& vt) in
Alglib\svd.cs: line 517

--<rest is from my test probject.
Lsa.NET.Lsa.Decompose() in C:\Documents and Settings\veg\Mijn documenten\Visual Studio 2008\Projects\Lsa\lsa\Lsa.cs: line 942
LsaTest.LsaTests.TestDecompose() in C:\Documents and Settings\veg\Mijn documenten\Visual Studio 2008\Projects\Lsa\lsatest\LsaTests.cs: line 175


As you can see I compiled and ran a vs2k8 unit test (copied the code from the alglib test into it).
Issue History
2010-02-07 22:26 wvd_vegt New Issue
2010-02-07 22:26 wvd_vegt Programming language => C#
2010-02-08 10:30 SergeyB Status new => assigned
2010-02-08 10:30 SergeyB Assigned To => SergeyB
2010-02-08 10:33 SergeyB Category Statistics => Linear algebra
2010-02-08 10:38 SergeyB Note Added: 0000045
2010-02-08 10:38 SergeyB Status assigned => resolved
2010-02-08 10:38 SergeyB Resolution open => no change required

Notes
(0000045)
SergeyB   
2010-02-08 10:38   
It is not a bug.

alglib.svd.svddecomposition is an obsolete routine which uses old 1-based notation from LAPACK. It accepts matrix with [1..N,1..N] numeration, not with [0..N-1,0..N-1] indexes. It was left for backward compatibility, new users should use rmatrixsvd which uses modern 0-based array indexes.

P.S. looks like it is better to purge it from next release...