开发者

Testing symmetry on symmetric matrix fails

开发者 https://www.devze.com 2023-04-11 12:32 出处:网络
I have a symmetric matrix (4x4) in memory.Unfortunately, sum( originalMatrix != t( originalMatrix ) ) = 6.So I dput that matrix and read it back into memory.Now sum( dputMa开发者_如何学Gotrix!= t( dpu

I have a symmetric matrix (4x4) in memory. Unfortunately, sum( originalMatrix != t( originalMatrix ) ) = 6. So I dput that matrix and read it back into memory. Now sum( dputMa开发者_如何学Gotrix!= t( dputMatrix) ) = 0. How is that possible and how can I test for symmetry with my in-memory matrix?

originalMatrix = ...
sum( originalMatrix != t( originalMatrix ) )  # results in 6
dput( originalMatrix )
dputMatrix = structure(c(0.00117771346463494, -1.57864028664711e-05, 0.000293652924987303, 
-9.85387333663002e-05, -1.57864028664711e-05, 0.000194782042576016, 
6.9133672862693e-05, 4.23792732612071e-05, 0.000293652924987303, 
6.9133672862693e-05, 0.00046216043028767, 2.70172523991749e-05, 
-9.85387333663002e-05, 4.23792732612071e-05, 2.70172523991749e-05, 
0.00017694896679169), .Dim = c(4L, 4L), .Dimnames = list(c("a00088630", 
"a0091n", "a01010", "a01307810"), c("a00088630", "a0091n", "a01010", 
"a01307810")))
sum( dputMatrix != t( dputMatrix ) )  # results in 0!!!


This is a manifestation of FAQ 7.31. Note that if you want to save R objects to full precision you should use save().

Tick please!

0

精彩评论

暂无评论...
验证码 换一张
取 消