IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 10, 2004, 12:26:09 PM (22 years ago)
Author:
gusciora
Message:

...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/dataManip/psMinimize.c

    r1775 r1781  
    99 *  @author George Gusciora, MHPCC
    1010 *
    11  *  @version $Revision: 1.36 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-09-10 02:52:02 $
     11 *  @version $Revision: 1.37 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-09-10 22:25:59 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    845845}
    846846/******************************************************************************
     847This routine will take an procedure which calculates an arbitrary function
     848and it's derivative and minimize it.
     849 
    847850GUS
     851 
     852XXX: Do this:
     853 After checking that all entries in the paramMask are 1 or 0, when
     854 forming the A matrix from alpha, try this:
     855 
     856     A[i][i] = (1 + lambda*paramask[i]) * alpha[i][i];
     857 
     858 
    848859 *****************************************************************************/
    849860bool psMinimizeLM(psMinimization *min,
     
    857868    psVector *perm = psVectorAlloc(params->n, PS_TYPE_F32);
    858869    psVector *newParams = psVectorAlloc(params->n, PS_TYPE_F32);
     870    psVector *origParams = psVectorAlloc(params->n, PS_TYPE_F32);
    859871    psImage *alpha = psImageAlloc(params->n, params->n, PS_TYPE_F32);
    860872    psImage *A = psImageAlloc(params->n, params->n, PS_TYPE_F32);
     
    869881    float lamda = 1.0;
    870882
     883    for (i=0;i<params->n;i++) {
     884        origParams->data.F32[i] = params->data.F32[i];
     885    }
     886
    871887    min->lastDelta = -HUGE;
    872888    min->iter = 0;
    873889    min->value = func(deriv, params, coords);
     890    for (i=0;i<params->n;i++) {
     891        if ((paramMask != NULL) &&
     892                (paramMask->data.U8[i] != 0)) {
     893            deriv->data.F32[i] = 0.0;
     894        }
     895    }
    874896
    875897    while ((min->lastDelta > min->tol) &&
     
    897919        newParams = psMatrixLUSolve(newParams, aOut, beta, perm);
    898920
     921        for (i=0;i<params->n;i++) {
     922            if ((paramMask != NULL) &&
     923                    (paramMask->data.U8[i] != 0)) {
     924                newParams->data.F32[i] = origParams->data.F32[i];
     925            }
     926        }
     927
    899928        oldValue = min->value;
    900929        newValue = func(newDeriv, newParams, coords);
     930        for (i=0;i<params->n;i++) {
     931            if ((paramMask != NULL) &&
     932                    (paramMask->data.U8[i] != 0)) {
     933                deriv->data.F32[i] = 0.0;
     934            }
     935        }
     936
    901937        if (oldValue > newValue) {
    902938            min->lastDelta = oldValue - newValue;
    903939            min->value = newValue;
    904940
     941            // No need to check the paramMask here since we already did so
     942            // before the last function evaluation.
    905943            for (i=0;i<params->n;i++) {
    906944                params->data.F32[i] = newParams->data.F32[i];
     
    918956    psFree(perm);
    919957    psFree(newParams);
     958    psFree(origParams);
    920959    psFree(alpha);
    921960    psFree(A);
     
    17691808 
    17701809The basic idea is calculate chi-squared for a set of params/coords/errors.
    1771 This functions uses globale variables to receive the function pointer, the
     1810This functions uses global variables to receive the function pointer, the
    17721811data values, and the data errors.
    17731812 *****************************************************************************/
Note: See TracChangeset for help on using the changeset viewer.