From thomas@biostat.washington.edu  Mon Aug 11 18:12:49 1997
From: thomas@biostat.washington.edu (Thomas Lumley)
Date: Mon, 11 Aug 1997 10:12:49 -0700 (PDT)
Subject: R-alpha: eigen
In-Reply-To: <199708111336.PAA00446@aragorn.ci.tuwien.ac.at>
Message-ID: <Pine.SUN.3.95.970811094129.432B-100000@zen>


eigen is behaving very strangely in my copy of patch 3 (solaris 2.5.1). 
The calls to .Fortran are returning absolute rubbish and are also mutating
things that shouldn't be mutated. 

example:
> eigen(matrix(c(1,0,0,1),2))  
debug: z <- .Fortran("rs", n, n, x, values = vals, only.values == FALSE, 
        vectors = x, vals, vals, ierr = integer(1))
Browse[1]> x
     [,1] [,2]
[1,]    1    0
[2,]    0    1
Browse[1]> 
debug: if (z$ierr) stop(paste("rs returned code ", z$ierr, " in eigen"))
Browse[1]> dim(x)
[1] -1076060379  -977277476
Browse[1]> dim(z$vectors)
[1] -1076060379  -977277476
Browse[1]> dim(x)<-c(2,2)
Browse[1]> dim(x)
[1] 2 2
Browse[1]> dim(z$vectors)
[1] 2 2
Browse[1]> z$vectors
          [,1]       [,2]
[1,] 0.8506508 -0.4472136
[2,] 0.5257311  0.7236068

Not only are these clearly not the eigenvectors of the identity, but the
.Fortran routine shouldn't even have access to x.

The problems turn out to be related: when separate objects are supplied
for each argument the function works properly, ie
        z <- .Fortran("rs", n, n, x, values = vals, only.values ==  FALSE, 
		vectors = 0 * x, vals * 0, vals * 0, ierr = integer(1))

Somehow the arguments to .Fortran aren't getting properly copied.


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
Thomas Lumley