IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6431


Ignore:
Timestamp:
Feb 15, 2006, 10:01:04 PM (20 years ago)
Author:
magnier
Message:

added correct constraint handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psLib/src/math/psMinimizeLMM.c

    r6346 r6431  
    1010 *  @author EAM, IfA
    1111 *
    12  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-02-07 23:14:21 $
     12 *  @version $Revision: 1.5.6.1 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-02-16 08:01:04 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    301301NOTES: EAM: this is my re-implementation of MinLM
    302302 
    303 XXX: Must implement code to handle the constrain->min, ->max, ->delta members.
     303XXX: EAM : constraints added 2006.02.15
    304304 
    305305XXX: Put the ASSERTS in.
     
    328328    PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false);
    329329    psVector *paramMask = NULL;
     330    psVector *paramDelta = NULL;
     331    psVector *paramMin = NULL;
     332    psVector *paramMax = NULL;
    330333    if (constrain != NULL) {
     334        // XXX EAM : fill out the asserts
     335        paramDelta = constrain->paramDelta;
     336        paramMin = constrain->paramMin;
     337        paramMax = constrain->paramMax;
    331338        paramMask = constrain->paramMask;
    332339        if (paramMask != NULL) {
    333340            PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_U8, false);
    334341            PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false);
    335         }
    336         if (constrain->paramMin != NULL) {
    337             psLogMsg(__func__, PS_LOG_WARN, "WARNING: the constrain->paramMin vector is currently ignored.\n");
    338         }
    339         if (constrain->paramMax != NULL) {
    340             psLogMsg(__func__, PS_LOG_WARN, "WARNING: the constrain->paramMax vector is currently ignored.\n");
    341         }
    342         if (constrain->paramDelta != NULL) {
    343             psLogMsg(__func__, PS_LOG_WARN, "WARNING: the constrain->paramDelta vector is currently ignored.\n");
    344342        }
    345343    }
     
    373371    psF64 Chisq = 0.0;
    374372    psF64 lambda = 0.001;
    375     // XXX: Code this properly.  Don't use mustFree00.
    376     psBool mustFree00 = false;
    377     psVector *beta_lim = NULL;
    378     psVector *param_min = NULL;
    379     psVector *param_max = NULL;
    380 
    381     // if we are provided a covar image, we expect to find these three vectors in first three rows
    382     if (covar != NULL) {
    383         mustFree00 = true;
    384         beta_lim  = psVectorAlloc(params->n, PS_TYPE_F32);
    385         param_min = psVectorAlloc(params->n, PS_TYPE_F32);
    386         param_max = psVectorAlloc(params->n, PS_TYPE_F32);
    387         for (int i = 0; i < params->n; i++) {
    388             beta_lim->data.F32[i] = covar->data.F64[0][i];
    389             param_min->data.F32[i] = covar->data.F64[1][i];
    390             param_max->data.F32[i] = covar->data.F64[2][i];
    391         }
    392         psImageRecycle(covar, params->n, params->n, PS_TYPE_F64);
    393     }
    394373
    395374    // why is this needed here??? the initial guess on params is provided by the user
     
    431410        // set a new guess for Alpha, Beta, Params
    432411        p_psMinLM_GuessABP(Alpha, Beta, Params, alpha, beta, params, paramMask,
    433                            beta_lim, param_min, param_max, lambda);
     412                           paramDelta, paramMin, paramMax, lambda);
    434413
    435414        // measure linear model prediction
     
    488467    if (covar != NULL) {
    489468        p_psMinLM_GuessABP(covar, Beta, Params, alpha, beta, params, paramMask,
    490                            beta_lim, param_min, param_max, 0.0);
     469                           paramDelta, paramMin, paramMax, 0.0);
    491470    }
    492471
     
    499478    if (yWt == NULL) {
    500479        psFree(dy);
    501     }
    502     if (mustFree00 == true) {
    503         psFree(beta_lim);
    504         psFree(param_min);
    505         psFree(param_max);
    506480    }
    507481    if (min->iter == min->maxIter) {
Note: See TracChangeset for help on using the changeset viewer.