[Rd] eigen()

Peter Dalgaard p.dalgaard at biostat.ku.dk
Tue Jan 10 14:34:10 CET 2006


Peter Dalgaard <p.dalgaard at biostat.ku.dk> writes:

> Robin Hankin <r.hankin at noc.soton.ac.uk> writes:
> 
> > Hi
> > 
> > I am having difficulty with eigen() on   R-devel_2006-01-05.tar.gz
> > 
> > Specifically,  in R-2.2.0 I get expected behaviour:
> > 
> > 
> >  > eigen(matrix(1:100,10,10),FALSE,TRUE)$values
> > [1]  5.208398e+02+0.000000e+00i -1.583980e+01+0.000000e+00i
> > [3] -4.805412e-15+0.000000e+00i  1.347691e-15+4.487511e-15i
> > [5]  1.347691e-15-4.487511e-15i -4.269863e-16+0.000000e+00i
> > [7]  1.364748e-16+0.000000e+00i -1.269735e-16+0.000000e+00i
> > [9] -1.878758e-18+5.031259e-17i -1.878758e-18-5.031259e-17i
> >  >
> > 
> > 
> > The same command gives different results in the development version:
> > 
> > 
> >  > eigen(matrix(1:100,10,10),FALSE,TRUE)$values
> > [1]  3.903094e-118 -3.903094e-118 -2.610848e-312 -2.995687e-313  
> > -2.748516e-313
> > [6] -1.073138e-314 -1.061000e-314 -1.060998e-314  4.940656e-324    
> > 0.000000e+00
> >  > R.version()
> > Error: attempt to apply non-function
> >  > R.version
> 
> Strange and semi-random results on SuSE 9.3 as well:
> 
> >  eigen(matrix(1:100,10,10))$values
>  [1] -5.393552e+194   3.512001e-68   0.000000e+00   0.000000e+00   0.000000e+00
>  [6]   0.000000e+00   0.000000e+00   0.000000e+00   0.000000e+00   0.000000e+00
> >  eigen(matrix(1:100,10,10))$values
>  [1]  1.526259e-311 -1.041529e-311  1.181720e-313   0.000000e+00   0.000000e+00
>  [6]   0.000000e+00   0.000000e+00   0.000000e+00   0.000000e+00   0.000000e+00
> >  eigen(matrix(1:100,10,10))$values
>  [1] -9.338774e+93  0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00
>  [6]  0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00
> >  eigen(matrix(1:100,10,10))$values
>  [1]  5.4e-311+ 0.0e+00i -2.5e-311+3.7e-311i -2.5e-311-3.7e-311i
>  [4]  2.5e-312+ 0.0e+00i -2.4e-312+ 0.0e+00i  3.2e-317+ 0.0e+00i
>  [7]   0.0e+00+ 0.0e+00i   0.0e+00+ 0.0e+00i   0.0e+00+ 0.0e+00i
> [10]   0.0e+00+ 0.0e+00i


On closer inspection:

> eigen(matrix(as.numeric(1:100),10),FALSE,TRUE)
$values
 [1]  5.208398e+02+0.000000e+00i -1.583980e+01+0.000000e+00i
 [3]  9.895951e-15+3.370683e-15i  9.895951e-15-3.370683e-15i
 [5] -7.018984e-15+2.881924e-15i -7.018984e-15-2.881924e-15i
 [7] -7.978136e-16+2.629350e-15i -7.978136e-16-2.629350e-15i
 [9]  1.818143e-16+6.007106e-16i  1.818143e-16-6.007106e-16i

$vectors
NULL


I.e. there's a bug in that eigen() doesn't check the storage mode, but
there's also a simple workaround.

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)                  FAX: (+45) 35327907



More information about the R-devel mailing list