From p.dalgaard at biostat.ku.dk  Thu Apr 24 14:28:21 2003
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard BSA)
Date: Thu Apr 24 13:27:05 2003
Subject: [Rd] "LAPACK routine DGESDD gave error code -12" with Debian
	(PR#2822)
In-Reply-To: <54el3swyrk.fsf@intech19.enhanced.com>
References: <200304221807.h3MI7apD014611@pubhealth.ku.dk>
	<20030423003246.GA27400@sonny.eddelbuettel.com>
	<54el3swyrk.fsf@intech19.enhanced.com>
Message-ID: <x2u1co878q.fsf@biostat.ku.dk>

Camm Maguire <camm@enhanced.com> writes:

> 2) Given the error code, and the scaling behavior with matrix size,
>    I'd say the lwork parameter (size of the work array) passed to
>    dgesdd is not always large enough, i.e. is not scaling properly
>    with n,m.  Please see 'man dgesdd' for interpretations of the error
>    code.  It is the responsibility of the calling routine to allocate
>    and pass the work array to dgesdd.  With most lapack routines, one
>    can make a 'workspace query' call first by setting lwork to -1, or
>    some such.  check the man page for details.  This of course would
>    have to be done with each change in n,m.  Alternatively, you could
>    take the minimum workspace requirements from the manpage.  

Right, but that's actually what we do, use the workspace query. It's
all very weird, because the -12 value indicates that the lwork
parameter is wrong, but it is computed from an exactly identical call,
except lwork=-l:

        lwork = -1;

        F77_CALL(dgesdd)(CHAR(STRING_ELT(jobu, 0)),
                         &n, &p, xvals, &n, REAL(s),
                         REAL(u), &ldu,
                         REAL(v), &ldvt,
                         &tmp, &lwork, iwork, &info);
        lwork = (int) tmp;

        work = (double *) R_alloc(lwork, sizeof(double));
        F77_CALL(dgesdd)(CHAR(STRING_ELT(jobu, 0)),
                         &n, &p, xvals, &n, REAL(s),
                         REAL(u), &ldu,
                         REAL(v), &ldvt,
                         work, &lwork, iwork, &info);


Also, this must be happening in the early parts of DGESDD which seem
to be all integer storage size calculations and so shouldn't need the
BLAS. Nevertheless people are seeing different behaviour when linking
against different BLAS libraries.
 
There are a lot of calls similar to this one, though:

      WRKBL = M + M*ILAENV( 1, 'DGELQF', ' ', M, N, -1, -1 )

so whether or not the BLAS is being used is hard to tell precisely.

>    lapack is the relevant lib, so I don't know what --without-blas is
>    supposed to do.  And working under windows, while nice, doesn't
>    exactly inspire confidence :-).

--without-blas means to use generic blas routines in the R
sources?rather than any (tuned) system set.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907


[Rd] "LAPACK routine DGESDD gave error code -12" with Debian (PR#2822)
Peter Dalgaard BSA