IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 19, 2006, 8:31:17 AM (20 years ago)
Author:
magnier
Message:

added NaN checks with psAbort

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psMinimizeLMM.c

    r6526 r6901  
    1010 *  @author EAM, IfA
    1111 *
    12  *  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-03-06 20:40:50 $
     12 *  @version $Revision: 1.12 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-04-19 18:31:17 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2323#include <math.h>
    2424
     25#include "psAbort.h"
    2526#include "psMinimizeLMM.h"
    2627#include "psImage.h"
     
    177178    psF64 rcF64 = p_psMinLM_SetABX(alpha, beta, params, paramMask, x, y, dy, func);
    178179    if (isnan(rcF64)) {
    179         psError(PS_ERR_UNKNOWN, false, "p_psMinLM_SetABX() retruned a NAN.\n");
     180        psError(PS_ERR_UNKNOWN, false, "p_psMinLM_SetABX() returned a NAN.\n");
    180181        rc = false;
    181182    }
     
    184185    psBool rcBool = p_psMinLM_GuessABP(Alpha, delta, Params, alpha, beta, params, paramMask, NULL, NULL, NULL, 0.0);
    185186    if (rcBool == false) {
    186         psError(PS_ERR_UNKNOWN, false, "p_psMinLM_GuessABP() retruned FALSE.\n");
     187        psError(PS_ERR_UNKNOWN, false, "p_psMinLM_GuessABP() returned FALSE.\n");
    187188        rc = false;
    188189    }
     
    259260        delta = ymodel - y->data.F32[i];
    260261        chisq += PS_SQR(delta) * dy->data.F32[i];
     262        if (isnan(dy->data.F32[i]))
     263            psAbort ("psMinLMM", "nan in weights");
     264        if (isnan(delta))
     265            psAbort ("psMinLMM", "nan in delta");
     266        if (isnan(chisq))
     267            psAbort ("psMinLMM", "nan in chisq");
    261268
    262269        for (psS32 j = 0; j < params->n; j++) {
     
    440447        // calculate Chisq for new guess, update Alpha & Beta
    441448        Chisq = p_psMinLM_SetABX(Alpha, Beta, Params, paramMask, x, y, dy, func);
     449        if (isnan(Chisq)) {
     450            min->iter ++;
     451            lambda *= 10.0;
     452            continue;
     453        }
    442454
    443455        // XXX EAM alternate convergence criterion:
Note: See TracChangeset for help on using the changeset viewer.