IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 7, 2005, 1:31:32 PM (21 years ago)
Author:
gusciora
Message:

I basically added comments noting missed areas of test coverage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/dataManip/tst_psMinimize06.c

    r3987 r4141  
    1515
    1616/*****************************************************************************
    17 myFunc(): This routine subtracts the associate value in expectedParm[] from
    18 each parameter and then squares it, then sums that for all parameters, then
    19 adds MIN_VALUE to it.  The minimum for this function will be MIN_VALUE, and
    20 will occur when each parameter equals the associated value in expectedParm[].
    21  
    22 This procedure ignores the coordinates, other than to ensure that they were
    23 passed correctly from psMinimizePowell().
    24  
     17myFunc():
     18    sum = (param[0] * x[0]) +
     19          (param[1] * x[1]) +
     20          ...
    2521 *****************************************************************************/
    26 psVector *myFunc(psImage *myDeriv,
    27                  psVector *myParams,
    28                  psArray *myCoords)
     22psF64 myFunc(psVector *deriv,
     23             psVector *params,
     24             psVector *x)
    2925{
    30     psVector *sum = psVectorAlloc(myCoords->n, PS_TYPE_F32);
    31     psS32 i;
    32     psS32 j;
    33 
    34 
    35     if (myDeriv == NULL) {
    36         myDeriv = psImageAlloc(myParams->n, myCoords->n, PS_TYPE_F32);
    37         psError(PS_ERR_UNKNOWN, true, "myDeriv is NULL.\n");
     26    if ((deriv == NULL) ||
     27            (params == NULL)) {
     28        psError(PS_ERR_UNKNOWN, true, "deriv or params is NULL.\n");
    3829    }
    3930
    40     for (i=0;i<N;i++) {
    41         sum->data.F32[i] = MIN_VALUE;
    42         for (j=0;j<NUM_PARAMS;j++) {
    43             sum->data.F32[i]+= (myParams->data.F32[j] - expectedParm[j]) *
    44                                (myParams->data.F32[j] - expectedParm[j]);
    45 
    46             myDeriv->data.F32[i][j] = (2.0 * myParams->data.F32[j]) -
    47                                       (2.0 * expectedParm[j]);
    48         }
    49     }
    50 
    51     return(sum);
    52 }
    53 
    54 /*****************************************************************************
    55 myFuncEAM(): This routine subtracts the associate value in expectedParm[] from
    56 each parameter and then squares it, then sums that for all parameters, then
    57 adds MIN_VALUE to it.  The minimum for this function will be MIN_VALUE, and
    58 will occur when each parameter equals the associated value in expectedParm[].
    59  
    60 This procedure ignores the coordinates, other than to ensure that they were
    61 passed correctly from psMinimizePowell().
    62  
    63  *****************************************************************************/
    64 psVector *myFuncEAM(psImage *myDeriv,
    65                     psVector *myParams,
    66                     psArray *myCoords)
    67 {
    68     psVector *sum = psVectorAlloc(myCoords->n, PS_TYPE_F32);
    69     psS32 i;
    70     psS32 j;
    71 
    72 
    73     if (myDeriv == NULL) {
    74         myDeriv = psImageAlloc(myParams->n, myCoords->n, PS_TYPE_F32);
    75         psError(PS_ERR_UNKNOWN, true, "myDeriv is NULL.\n");
    76     }
    77 
    78     for (i=0;i<N;i++) {
    79         sum->data.F32[i] = MIN_VALUE;
    80         for (j=0;j<NUM_PARAMS;j++) {
    81             sum->data.F32[i]+= (myParams->data.F32[j] - expectedParm[j]) *
    82                                (myParams->data.F32[j] - expectedParm[j]);
    83 
    84             myDeriv->data.F32[i][j] = (2.0 * myParams->data.F32[j]) -
    85                                       (2.0 * expectedParm[j]);
    86         }
     31    psF64 sum = 0.0;
     32    for (psS32 i=0 ; i < params->n ; i++) {
     33        sum += (params->data.F32[i] * x->data.F32[i]);
     34        deriv->data.F32[i] = params->data.F32[i];
    8735    }
    8836
     
    12169        myParams->data.F32[i] = (float) i;
    12270        myParams->data.F32[i] = expectedParm[i] * 1.3;
     71        myParams->data.F32[i] = 0.0;
    12372        myParams->data.F32[i] = (float) (5 + i);
    124         myParams->data.F32[i] = 0.0;
    12573    }
    12674
Note: See TracChangeset for help on using the changeset viewer.