Skip to content
Prev 19042 / 63424 Next

eigen()

On 10 Jan 2006, at 14:14, Peter Dalgaard wrote:
For everyone's entertainment, here's an example where the analytic  
solution
is known.

fact 1:  the first eigenvalue of a magic square is equal to its constant
fact 2: the sum of the other eigenvalues of a magic square is zero
fact 3: the constant of a magic square of order 10 is 505.

R-2.2.0:

 > library(magic)
 > round(Re(eigen(magic(10),F,T)$values))
[1]  505  170 -170 -105  105   -3    3    0    0    0
 >

answers as expected.


R-devel:



 > a <- structure(c(68, 66, 92, 90, 16, 14, 37, 38, 41, 43, 65, 67, 89,
91, 13, 15, 40, 39, 44, 42, 96, 94, 20, 18, 24, 22, 45, 46, 69,
71, 93, 95, 17, 19, 21, 23, 48, 47, 72, 70, 4, 2, 28, 26, 49,
50, 76, 74, 97, 99, 1, 3, 25, 27, 52, 51, 73, 75, 100, 98, 32,
30, 56, 54, 80, 78, 81, 82, 5, 7, 29, 31, 53, 55, 77, 79, 84,
83, 8, 6, 60, 58, 64, 62, 88, 86, 9, 10, 33, 35, 57, 59, 61,
63, 85, 87, 12, 11, 36, 34), .Dim = c(10, 10))

[no magic package!  it fails R CMD check !]

 > round(Re(eigen(magic(10),F,T)$values))
[1] 7.544456e+165  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
 >


not as expected.



--
Robin Hankin
Uncertainty Analyst
National Oceanography Centre, Southampton
European Way, Southampton SO14 3ZH, UK
  tel  023-8059-7743