IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6226 for trunk/psLib/src/math


Ignore:
Timestamp:
Jan 27, 2006, 10:08:58 AM (21 years ago)
Author:
gusciora
Message:

I added tests for psImageSmooth, modified the psStats stuff and the Min
routines.

Location:
trunk/psLib/src/math
Files:
3 edited

Legend:

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

    r6204 r6226  
    1010 *  @author EAM, IfA
    1111 *
    12  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-01-26 21:10:22 $
     12 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-01-27 20:08:58 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    277277NOTES: EAM: this is my re-implementation of MinLM
    278278 
     279XXX: Must implement code to handle the constrain->min, ->max, ->delta members.
     280 
    279281XXX: Put the ASSERTS in.
    280282 
     
    283285     will have to convert all F32 input vectors to F64 regardless.  So,
    284286     the F64 port might be.
     287 
    285288  *****************************************************************************/
    286289psBool psMinimizeLMChi2(
     
    288291    psImage *covar,
    289292    psVector *params,
    290     const psVector *paramMask,
     293    psMinConstrain *constrain,
    291294    const psArray *x,
    292295    const psVector *y,
     
    300303    PS_ASSERT_VECTOR_NON_EMPTY(params, false);
    301304    PS_ASSERT_VECTOR_TYPE(params, PS_TYPE_F32, false);
    302     if (paramMask != NULL) {
    303         PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_U8, false);
    304         PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false);
     305    psVector *paramMask = NULL;
     306    if (constrain != NULL) {
     307        paramMask = constrain->paramMask;
     308        if (paramMask != NULL) {
     309            PS_ASSERT_VECTOR_TYPE(paramMask, PS_TYPE_U8, false);
     310            PS_ASSERT_VECTORS_SIZE_EQUAL(params, paramMask, false);
     311        }
     312        if (constrain->paramMin != NULL) {
     313            psLogMsg(__func__, PS_LOG_WARN, "WARNING: the constrain->paramMin vector is currently ignored.\n");
     314        }
     315        if (constrain->paramMax != NULL) {
     316            psLogMsg(__func__, PS_LOG_WARN, "WARNING: the constrain->paramMax vector is currently ignored.\n");
     317        }
     318        if (constrain->paramDelta != NULL) {
     319            psLogMsg(__func__, PS_LOG_WARN, "WARNING: the constrain->paramDelta vector is currently ignored.\n");
     320        }
    305321    }
    306322    PS_ASSERT_PTR_NON_NULL(x, false);
     
    592608    return( psMemGetDeallocator(ptr) == (psFreeFunc)minimizationFree );
    593609}
     610
     611
     612static void constrainFree(psMinConstrain *tmp)
     613{
     614    // There are no dynamically allocated items
     615}
     616
     617psMinConstrain* psMinConstrainAlloc()
     618{
     619    psMinConstrain *tmp = psAlloc(sizeof(psMinConstrain));
     620    tmp->paramMask = NULL;
     621    tmp->paramMax = NULL;
     622    tmp->paramMin = NULL;
     623    tmp->paramDelta = NULL;
     624
     625    return(tmp);
     626}
     627
     628bool psMemCheckConstrain(psPtr tmp)
     629{
     630    return( psMemGetDeallocator(tmp) == (psFreeFunc)constrainFree );
     631}
  • trunk/psLib/src/math/psMinimizeLMM.h

    r6185 r6226  
    88 *  @author GLG, MHPCC
    99 *
    10  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2006-01-23 20:44:29 $
     10 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2006-01-27 20:08:58 $
    1212 *
    1313 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5252psMinimization;
    5353
     54
     55/** A data structure for minimization routines.
     56 *
     57 * 
     58 */
     59typedef struct
     60{
     61    psVector *paramMask;                ///< valid / invalid parameters
     62    psVector *paramMax;                 ///< max allowed parameters
     63    psVector *paramMin;                 ///< min allowed parameters
     64    psVector *paramDelta;               ///< max allowed param swing
     65}
     66psMinConstrain;
     67
     68psMinConstrain *psMinConstrainAlloc();
     69
    5470#define P_PSMINIMIZATION_SET_MAXITER(m,val) *(int*)&m->maxIter = val
    5571        #define P_PSMINIMIZATION_SET_TOL(m,val) *(float*)&m->tol = val
    56 
    5772
    5873                /** Allocates a psMinimization structure.
     
    97112    psImage *covar,                    ///< Covariance matrix
    98113    psVector *params,                  ///< "Best Guess" for the parameters that minimize func
    99     const psVector *paramMask,         ///< Parameters to be held fixed by the minimizer
     114    psMinConstrain *constrain,         ///< Constraints on the parameters
    100115    const psArray *x,                  ///< Measurement ordinates of multiple vectors
    101116    const psVector *y,                 ///< Measurement coordinates
  • trunk/psLib/src/math/psMinimizePolyFit.c

    r6204 r6226  
    1010 *  @author EAM, IfA
    1111 *
    12  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2006-01-26 21:10:22 $
     12 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2006-01-27 20:08:58 $
    1414 *
    1515 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    10321032    psF32 minClipSigma;
    10331033    psF32 maxClipSigma;
    1034     if (isnan(stats->max) || isfinite(stats->max)) {
     1034    if (isfinite(stats->max)) {
     1035        maxClipSigma = fabs(stats->max);
     1036    } else {
    10351037        maxClipSigma = fabs(stats->clipSigma);
    1036     } else {
    1037         maxClipSigma = fabs(stats->max);
    1038     }
    1039     if (isnan(stats->min) || isfinite(stats->min)) {
     1038    }
     1039    if (isfinite(stats->min)) {
     1040        minClipSigma = fabs(stats->min);
     1041    } else {
    10401042        minClipSigma = fabs(stats->clipSigma);
    1041     } else {
    1042         minClipSigma = fabs(stats->min);
    10431043    }
    10441044
Note: See TracChangeset for help on using the changeset viewer.