[R] Communative Matrix Multiplcation
Martin Maechler
maechler at stat.math.ethz.ch
Thu Aug 16 14:37:59 CEST 2012
> Thanks to you both. I'm not sure all.equal() was right for this situation, is it? If the differences were to the right of the decimal and differed as a function of precision, then I see all.equal() being the right function. But, the differences in the reproducible code were to the left of the decimal, but a lot, so I thought identical was perhaps better.
You are right that the difference was dramatic, and hence your
posting was well in place, well, would have, iff it had been
earlier, when that version of Matrix was current
(... looking it
up: the next version after the one you used, was
0.999375-47, CRAN-released: 2011-02-23;
and there were *many* releases since, notably 1.0-0 & 1.0-1
the latter released 2011-10-18.)
However, using identical() for comparisons of the results of
double precision computations is almost always "wrong", in
principle: identical() very often can give FALSE notably from
such simple changes as algebraical shuffling (commutative,
associative, distributive laws), and indeed these things are
covered by the BFMFAQ (By Far Most Frequently Asked Question) 7.31.
> Martin, there seem to be some issues with calculations in the
> updated Matrix package. I'll send an email to matrix
> authors. It seems some calculations that were almost
> instantaneous with older versions are now causing R to
> hang. I'll provide reproducible examples.
Thank you in advance!
Martin
> ________________________________________
> From: Martin Maechler [maechler at stat.math.ethz.ch]
> Sent: Thursday, August 16, 2012 3:42 AM
> To: David Reiner
> Cc: Doran, Harold; 'r-help at r-project.org'
> Subject: Re: [R] Communative Matrix Multiplcation
> >>>>> David Reiner <David.Reiner at xrtrading.com>
> >>>>> on Wed, 15 Aug 2012 09:59:10 -0500 writes:
> > As a mathematician, I have to correct the subject line
> > to 'Distributive Matrix operations' -- David
> Yes, indeed;
> that was *really* disturbing to me as well, about this thread!
> {in addition to the fact that he should have used all.equal()
> and not identical() as someone had pointed out already ..}
> And at last: Yes, some of the methods for Diagonal() matrices in the
> 'Matrix' package did have bugs, in earlier versions.
> NOTE: You can (and often should) update packages also if for
> some reason you cannot update your version of R!
> Martin Maechler, ETH Zurich
> ....
> ....
> >>
> >> On 14-08-2012, at 19:26, Doran, Harold wrote:
> >>
> >> >
> >> > I'm not seeing why the following occurs:
> >> >
> >> > T1 <- (A1 - A2) %*% D
> >> > T2 <- (A1 %*% D) - (A2 %*% D)
> >> > identical(T1, T2)
> >> [1] FALSE
> >>
More information about the R-help
mailing list