[R] Matrix multiplication gives different results some of the times (NaN)

Ben Bolker bbolker at gmail.com
Tue Sep 13 13:40:37 CEST 2011


Xavier Fernández i Marín <xfim.ll <at> gmail.com> writes:

> Rolf Turner vas escriure el dia dt, 13 set 2011:
> 

  [snip]

> > This sort of thing should not/does not/cannot happen under
> > ``normal circumstances''.  There has to be something wrong
> > somewhere in your setup.  Either your hardware or your software
> > is flaky in some way.
> > 
> > I.e. it is not an "R problem".
> > 
> > How you track down the flakiness is unfortunately way beyond me.
> 
> Ok, thank you. 
> 
> More elements: In python the same algorithm does not show this strange
> behaviour.
> 
> Any other clue?

  You mentioned that you had compiled R yourself.
Can you replicate this with a stock R binary, i.e. from a 
Red Hat or Ubuntu repository?  If not, can you give details of
your compilation setup, especially if you are using a specialized
or optimized linear algebra library (BLAS)?

  Are you using your own compiled, dynamically loaded code elsewhere
in the same session that might be trashing memory?

  These details of the CRAN test platforms might be helpful:

http://cran.r-project.org/web/checks/check_flavors.html

  It's quite a bit of work, but you can try valgrind (see section
4.3.2 of the R extensions manual).

  The reason for everyone's skepticism is that matrix multiplication
is a *very* basic part of R, tested at least thousands and possibly
millions of times a day by thousands of users on all different platforms --
so it's surprising that it is failing for you.

  Ben Bolker



More information about the R-help mailing list