IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 3, 2006, 12:05:22 PM (20 years ago)
Author:
gusciora
Message:

Misc code cleaning

File:
1 edited

Legend:

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

    r6186 r6322  
    99 *  @author GLG, MHPCC
    1010 *
    11  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-01-23 22:25:31 $
     11 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-02-03 22:05:22 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
    15  *
    16  *  XXX: must follow coding name standards on local functions.
    17  *  XXX: put local functions in front.
    1815 *
    1916 */
     
    6966/*****************************************************************************/
    7067/* GLOBAL VARIABLES                                                          */
    71 /* XXX: Do these conform to code standard?         */
    7268/*****************************************************************************/
    7369static psMinimizeChi2PowellFunc Chi2PowellFunc = NULL;
    74 static psVector *myValue;
    75 static psVector *myError;
     70static psVector *PowellValue;
     71static psVector *PowellError;
    7672/*****************************************************************************/
    7773/* FILE STATIC VARIABLES                                                     */
     
    9793Repeat this process until a local minimum is found.
    9894 
    99 XXX:
    100 new algorithm: 
     95XXX: new algorithm: 
    10196start at x=0, expand in one direction until the function
    10297decreases.  Then you have two points in the bracket.  Keep going until it
     
    10499direction.
    105100 
    106 XXX:
    107 This is F32 only.  Must add
    108 F64 support (actually, make the defaults F64,
     101XXX: This is F32 only.  Must add F64 support (actually, make the defaults F64,
    109102and convert F32 vectors to F64).
    110103 
    111 XXX:
    112 output bracket vector should be an input as well.
     104XXX: output bracket vector should be an input as well.
    113105*****************************************************************************/
    114106psVector *p_psDetermineBracket(
     
    355347 *****************************************************************************/
    356348#define PS_LINEMIN_MAX_ITERATIONS 30
    357 psF32 p_psLineMin(psMinimization *min,
    358                   psVector *params,
    359                   psVector *line,
    360                   const psVector *paramMask,
    361                   const psArray *coords,
    362                   psMinimizePowellFunc func)
     349psF32 p_psLineMin(
     350    psMinimization *min,
     351    psVector *params,
     352    psVector *line,
     353    const psVector *paramMask,
     354    const psArray *coords,
     355    psMinimizePowellFunc func)
    363356{
    364357    PS_ASSERT_PTR_NON_NULL(min, NAN);
     
    502495#define PS_MINIMIZE_POWELL_LINEMIN_ERROR_TOLERANCE 0.01
    503496
    504 bool psMinimizePowell(psMinimization *min,
    505                       psVector *params,
    506                       const psVector *paramMask,
    507                       const psArray *coords,
    508                       psMinimizePowellFunc func)
     497bool psMinimizePowell(
     498    psMinimization *min,
     499    psVector *params,
     500    const psVector *paramMask,
     501    const psArray *coords,
     502    psMinimizePowellFunc func)
    509503{
    510504    PS_ASSERT_PTR_NON_NULL(min, NULL);
     
    696690This functions uses global variables to receive the function pointer, the
    697691data values, and the data errors.
     692 
    698693XXX: This is F32 only.  Must implement F64.
    699694 *****************************************************************************/
    700 static psF32 myPowellChi2Func(const psVector *params,
    701                               const psArray *coords)
     695static psF32 myPowellChi2Func(
     696    const psVector *params,
     697    const psArray *coords)
    702698{
    703699    psTrace(__func__, 4, "---- myPowellChi2Func() begin ----\n");
    704700    PS_ASSERT_VECTOR_NON_NULL(params, NAN);
    705701    PS_ASSERT_VECTOR_NON_EMPTY(params, NAN);
    706     PS_ASSERT_VECTOR_NON_NULL(myValue, NAN);
    707     PS_ASSERT_VECTOR_NON_EMPTY(myValue, NAN);
     702    PS_ASSERT_VECTOR_NON_NULL(PowellValue, NAN);
     703    PS_ASSERT_VECTOR_NON_EMPTY(PowellValue, NAN);
    708704    PS_ASSERT_PTR_NON_NULL(coords, NAN);
    709705
     
    714710
    715711    tmp = Chi2PowellFunc(params, coords);
    716     if (myError == NULL) {
     712    if (PowellError == NULL) {
    717713        for (i=0;i<coords->n;i++) {
    718             d = (tmp->data.F32[i] - myValue->data.F32[i]);
     714            d = (tmp->data.F32[i] - PowellValue->data.F32[i]);
    719715            chi2+= d * d;
    720716        }
    721717    } else {
    722718        for (i=0;i<coords->n;i++) {
    723             d = (tmp->data.F32[i] - myValue->data.F32[i]) / myError->data.F32[i];
     719            d = (tmp->data.F32[i] - PowellValue->data.F32[i]) / PowellError->data.F32[i];
    724720            chi2+= d * d;
    725721        }
     
    741737psMinimizePowell().
    742738 *****************************************************************************/
    743 bool psMinimizeChi2Powell(psMinimization *min,
    744                           psVector *params,
    745                           const psVector *paramMask,
    746                           const psArray *coords,
    747                           const psVector *value,
    748                           const psVector *error,
    749                           psMinimizeChi2PowellFunc model)
     739bool psMinimizeChi2Powell(
     740    psMinimization *min,
     741    psVector *params,
     742    const psVector *paramMask,
     743    const psArray *coords,
     744    const psVector *value,
     745    const psVector *error,
     746    psMinimizeChi2PowellFunc model)
    750747{
    751     myValue = (psVector *) value;
    752     myError = (psVector *) error;
     748    PowellValue = (psVector *) value;
     749    PowellError = (psVector *) error;
    753750
    754751    Chi2PowellFunc = model;
Note: See TracChangeset for help on using the changeset viewer.