Hello list,
Can someone tell me what is going on here?
running S-Plus version 6.0, rc 2 under Win 2000
First a sanity check:
> acos(1)
[1] 0
Now, I have a list of mixed size matrices. Columns of the matrices contain
contributions to the cosine of an angle of interest.
The first angle (column) represented is always zero but only a few of the
list elements exhibit the behavior shown below:
I extract column 1 from element 7.
Ord.det.ang[[7]] [[1]] [[1]] [,1]
[1] 0.007408320 0.047814659 0.005461415 0.221836193 0.453755107
0.001774110 0.068355537 0.002081798
[9] 0.025407244 0.123056085 0.026451307 0.016598225
# Sum to get the net cosine value and assign it, then examine it a
little
> test <- sum( Ord.det.ang[[7]] [[1]] [[1]] [,1] )
> test
[1] 1
> is.numeric(test)
[1] T
> is.double(test)
[1] T
> acos(test)
[1] NA
Warning messages:
NAs generated
# Multiply by a number just close enough to 1 so as not to be
effectively rounded internally and try again
> acos( 0.999999999999999 * test )
[1] 3.332001e-008
# Then, just slightly larger:
> acos(0.9999999999999999*test)
[1] NA
Warning messages:
NAs generated
# By way of contrast, using the next element in the list::
> sum(Ord.det.ang[[8]][[1]][[1]][,1])
[1] 1
> acos(sum(Ord.det.ang[[8]][[1]][[1]][,1]))
[1] 0
# Both elements7 and 8 happen to be matrices of size 12 x 13 generated in
similar fashion. Roughly 10 to 20 percent of matricesobtained turn up NAs
from acos(sum(column 1)).
Suggestions?
john
|