|Re: [eigen] Bug in SVD applied to specific matrix sizes|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
On 15 Mar, Jens Andersen wrote:
> I have stumbled upon a bug in SVD when applying it to certain matrix sizes.
> The particular problem occured when doing a simple four-point Direct
> Linear Transform in reduced form, providing a matrix of size 8x9.
> In this case an attempt to set a value to an index out of bounds, in
> the array m_sigma.
> The particular code is shown here:
> // Set up the final bidiagonal matrix or order p.
> int p = std::min(n,m+1);
> if (nct < n)
> m_sigma[nct] = matA(nct,nct);
> if (m < p)
> m_sigma[p-1] = 0.0;
> m_sigma has size m, whereas p is set to n=m+1. In this particular case
> m_sigma will be set, but m_sigma's highest index is 7.
> A quick test shows that this will consistently happen whenever the
> number of columns is greater than the number of rows.
> Unfortunately I don't know enough of Eigen's internal to create a
> reasonable fix.
As a workaround (not more) you can compute the SVD of the transposed
matrix. If A^T has the SVD V*Sigma*U^T then A itself has the SVD
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany