[Rd] NaN in crossprod

McGehee, Robert Robert.McGehee at geodecapital.com
Fri Jun 15 18:20:08 CEST 2007


Hello,
I have come across a troubling problem in which my call to crossprod
will occasionally produce NaNs.  That is, a proper matrix cross-product
will be produced except that some of the matrix elements will
arbitrarily be NaN. For my purposes, this is extremely bad. On several
different R sessions run this morning this example below may fail a few
times out of a million, though sometimes not at all.
> x <- matrix(1, 100, 100); w <- rep(1, 100)
> for(i in 1:1000000) if(any(is.na(crossprod(w,x)))) cat("!")

Unfortunately, this error has been hard to reproduce as I was finding
frequent NaNs produced an hour ago but am not finding any such cases
now. I'm using a shared network computer so it's possible the computer
was under different resource constraints when the problem occurred. I
compiled R 2.5.0 on an Intel Xeon(P4) processor running Linux
2.4.21-47.0.1 on Red Hat AS 3.0, with ATLAS 3.7.30 BLAS support.

My _guess_ is that the problem is on the ATLAS end (bug, bad
compilation, etc.), though as I can't seem to reproduce the problem in
the past hour, I'm not sure I'd even know if I had "fixed" it by using a
different version of ATLAS, or recompiling, etc. And not being quite
sure how crossprod works internally, my guess is not even an educated
one. So, lest the NaNs be a symptom of impending hardware failure, solar
flares, or even a "mis-feature" in R, I thought I'd solicit any
comments, ideas, and suggestions this group might have.

Thanks,
Robert

> R.version               _
platform       i686-pc-linux-gnu
arch           i686
os             linux-gnu
system         i686, linux-gnu
status
major          2
minor          5.0
year           2007
month          04
day            23
svn rev        41293
language       R
version.string R version 2.5.0 (2007-04-23)


Robert McGehee, CFA
Quantitative Analyst
Geode Capital Management, LLC
One Post Office Square, 28th Floor | Boston, MA | 02109
Tel: 617/392-8396    Fax:617/476-6389
mailto:robert.mcgehee at geodecapital.com



This e-mail, and any attachments hereto, are intended for us...{{dropped}}



More information about the R-devel mailing list