[Rd] bug, feature of mistery?
ligges at statistik.uni-dortmund.de
Wed May 11 08:40:02 CEST 2005
Giuseppe Ragusa wrote:
> I have two machines a linux_amd64_x86 (gentoo_amd64) and a linux_x86. Both run
> R-2.1.0. I have a very long program (hopefully will become a package)
> that works perfectly on the linux_amd_x64. Great means no error, no
> problems and results that, where the analytic solution exists,
> coincide with it. I have problem making the code run on the x64 machine. I
> am baffled. The same code on the same version of R, different arch,
> is behaving differently.
> After hour of debugging, I traced down what is triggering the error on
> the x86 machine.
> the code snippet is the following similar to:
> g <- h(d)
> f <- function( lambda )
> z <- g %*% lambda
> sum( psi(z) )
> optim( init.value, f )
> The function f() is using lexical scoping to get obtain g. The
> function psi() is a call to a wrapper function that call a (.C) C
> function doing some simple calculation on z.
- Where is *lexical* scoping involved?
- Are you really calling you code from a clean workspace?
- Why don't use pass "g" through optim() to f? Please do so, because it
might be a scoping problem.
- The .C call in psi() should not matter unless you are doing strange
things in the part you omitted (...).
> What's the problem? When f() is called, g is there, lambda is there,
> but the assignment z <- g %*% lambda results in a matrix of NaN. This
> happens from the second time f() is called, i.e. the first time f() is
> called from optim() after the C call has been made. The error is then
> that passing a NaN vector to .C results in halted execution.
> If I debug f() during the call to optim, I can without problem assign
> z the correct value, but during the execution z is matrix(NaN, nr,
> At this point I can think of the following:
> 1) the external C code has errors
> It is not a programming error, because when called from console it
> returns the right results. Also, remember, the program work on my
> other machine (the 64 bit);
> 2) R error (I do not think so)
> 3) Compiling error
> Can be the gcc is messing thing around?
> on the 32bit machine
> gcc version 3.3.5 (Gentoo Linux 3.3.5-r1, ssp-3.3.2-3, pie-126.96.36.199)
> on the 64-bit machine
> gcc version 3.4.3 20041125 (Gentoo Linux 3.4.3-r1, ssp-3.4.3-0, pie-8.7.7)
> Any help, suggestions, thoughts?
> Thank you.
> Giuseppe Ragusa
> R-devel at stat.math.ethz.ch mailing list
More information about the R-devel