From thomas@biostat.washington.edu  Mon Aug 25 18:18:08 1997
From: thomas@biostat.washington.edu (Thomas Lumley)
Date: Mon, 25 Aug 1997 10:18:08 -0700 (PDT)
Subject: R-alpha: eigen and batch
In-Reply-To: <9708250742.AA12773@alpha.luc.ac.be>
Message-ID: <Pine.SUN.3.95.970825095235.1542E-100000@avon>

On Mon, 25 Aug 1997, Jim Lindsey wrote:
> 
> eigen:
>    I started looking in the eispack C code and traced down the
> problem. In three of the four Fortran calls in eigen, (ch,rs,cg but
> not rg), the same vector (vals) is used for the return eigenvalues as
> for two or three temporary workspace vectors. This is risky
> programming at any time and leads to a catastrophe with a 586 where
> several things may be calculated at the same time. 

No, this is a bug in .Fortran.  Everything sent to C or FORTRAN code is
supposed to be a *copy* of the R object.  This is because R is allowed to
move things around in memory whenever it feels the urge, but C and FORTRAN
assume things stay fixed.  Since everything is supposed to be copied there
is no harm in using multiple copies of the same thing. 

One possible source of this bug is in naoktrim in src/main/dotcode.c
which begins
static SEXP naoktrim(SEXP s, int * len, int *naok, int *dup)
{
        SEXP value;

        if(s == R_NilValue) {
                value = R_NilValue;
                *naok = 0;
                *dup = 0;
                *len = 0;
        }
but should begin
static SEXP naoktrim(SEXP s, int * len, int *naok, int *dup)
{
        SEXP value;

        if(s == R_NilValue) {
                value = R_NilValue;
                *naok = 0;
                *dup = 1;
                *len = 0;
        }


Thomas Lumley
------------------------------------------------------+------
Biostatistics		: "Never attribute to malice what  :
Uni of Washington	:  can be adequately explained by  :
Box 357232		:  incompetence" - Hanlon's Razor  :
Seattle WA 98195-7232	:				   :
------------------------------------------------------------

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


R-alpha: eigen and batch
Thomas Lumley