From goran.brostrom at umu.se  Thu Feb  9 16:00:15 2017
From: goran.brostrom at umu.se (=?UTF-8?Q?G=c3=b6ran_Brostr=c3=b6m?=)
Date: Thu, 9 Feb 2017 16:00:15 +0100
Subject: [Rd] Ancient C /Fortran code linpack error
Message-ID: <7240dae6-2dc9-88ec-c9c8-f552fc1c2dd5@umu.se>

In my package 'glmmML' I'm using old C code and linpack in the 
optimizing procedure. Specifically, one part of the code looks like this:

     F77_CALL(dpoco)(*hessian, &bdim, &bdim, &rcond, work, info);
     if (*info == 0){
         F77_CALL(dpodi)(*hessian, &bdim, &bdim, det, &job);
         ........

This usually works OK, but with an ill-conditioned data set (from a user 
of glmmML) it happened that the hessian was all nan. However, dpoco 
returned *info = 0 (no error!) and then the call to dpodi hanged R!

I googled for C and nan and found a work-around: Change 'if ...' to

    if (*info == 0 & (hessian[0][0] == hessian[0][0])){

which works as a test of hessian[0][0] (not) being NaN.

I'm using the .C interface for calling C code.

Any thoughts on how to best handle the situation? Is this a bug in 
dpoco? Is there a simple way to test for any NaNs in a vector?

G?ran Brostr?m

PS. Yes, I will switch to .Call! Soon...



[Rd] Ancient C /Fortran code linpack error
=?UTF-8?Q?G=c3=b6ran_Brostr=c3=b6m?=