Boost logo

Ublas :

From: Kresimir Fresl (fresl_at_[hidden])
Date: 2008-03-15 04:03:50


Nico Galoppo wrote:

> Upon calling the lapack gesvd in numeric/bindings/lapack/gesvd.cpp,
> with JobU = 'O', I'm getting an assertion error on line 418:
>
> 417 assert ((jobu == 'N' && traits::leading_dimension (u) >= 1)
> 418 || (jobu == 'O' && traits::leading_dimension (u) >= 1)
> 419 || (jobu == 'A' && traits::leading_dimension (u) >= m)
> 420 || (jobu == 'S' && traits::leading_dimension (u) >= m));
>
> I don't understand why this assertion is correct. jobu == 'O' means
> that the left-hand vectors should be written to input matrix A, not to
> u, hence, the u input to gesvd should essentially be able to be a null
> pointer (or zero-size matrix).
>
> Am I missing something?

This is the requirement in the "original" LAPACK xgesvd.

DGESVD subroutine is in http://www.netlib.org/lapack/double/dgesvd.f
declared as:

       SUBROUTINE DGESVD( JOBU, JOBVT, M, N, A, LDA, S, U, LDU, VT, LDVT,
      $ WORK, LWORK, INFO )
* ..
* .. Scalar Arguments ..
       CHARACTER JOBU, JOBVT
       INTEGER INFO, LDA, LDU, LDVT, LWORK, M, N
* ..
* .. Array Arguments ..
       DOUBLE PRECISION A( LDA, * ), S( * ), U( LDU, * ),
      $ VT( LDVT, * ), WORK( * )

Description of the arguments says:

* U (output) DOUBLE PRECISION array, dimension (LDU,UCOL)
* (LDU,M) if JOBU = 'A' or (LDU,min(M,N)) if JOBU = 'S'.
* If JOBU = 'A', U contains the M-by-M orthogonal matrix U;
* if JOBU = 'S', U contains the first min(m,n) columns of U
* (the left singular vectors, stored columnwise);
* if JOBU = 'N' or 'O', U is not referenced.
*
* LDU (input) INTEGER
* The leading dimension of the array U. LDU >= 1; if
* JOBU = 'S' or 'A', LDU >= M.

And there is a check later in the code:

       ELSE IF( LDU.LT.1 .OR. ( WNTUAS .AND. LDU.LT.M ) ) THEN
          INFO = -9

Regards,

fres