IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 28, 2005, 4:13:54 PM (21 years ago)
Author:
gusciora
Message:

I added EAM's new version of LM minimization.

File:
1 edited

Legend:

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

    r4859 r5175  
    77#include <math.h>
    88#define NUM_ITERATIONS 100
    9 #define ERR_TOL 0.0
     9#define ERR_TOL 0.1
    1010#define NUM_DATA_POINTS 20
    1111#define NUM_PARAMS 5
     
    4545}
    4646
    47 
    4847psS32 t01()
    4948{
     
    6362        ((psVector *) (myCoords->data[i]))->data.F32[0] = (float) (i+10);
    6463        ((psVector *) (myCoords->data[i]))->data.F32[1] = (float) (i+3);
    65         /*
    66                 printf("x[%d] is vector (%f, %f)\n", i, ((psVector *) (myCoords->data[i]))->data.F32[0],
    67                                                         ((psVector *) (myCoords->data[i]))->data.F32[1]);
    68         */
     64        psTrace(__func__, 5, "x[%d] is vector (%f, %f)\n", i, ((psVector *) (myCoords->data[i]))->data.F32[0],
     65                ((psVector *) (myCoords->data[i]))->data.F32[1]);
    6966        y->data.F32[i] = (float) i;
    7067    }
     
    7471    }
    7572
    76     psMinimizeLMChi2(min,
    77                      myCovar,
    78                      myParams,
    79                      NULL,
    80                      myCoords,
    81                      y,
    82                      NULL,
    83                      (psMinimizeLMChi2Func) myFunc);
     73    psBool rc = psMinimizeLMChi2(min,
     74                                 NULL,
     75                                 myParams,
     76                                 NULL,
     77                                 myCoords,
     78                                 y,
     79                                 NULL,
     80                                 (psMinimizeLMChi2Func) myFunc);
     81    if (rc == false) {
     82        printf("TEST ERROR: psMinimizeLMChi2() returned FALSE.\n");
     83        fflush(stdout);
     84        testStatus = false;
     85    } else {
     86        printf("\nThe value of the function at the minimum is %f\n", min->value);
     87        for (psS32 i=0;i<NUM_DATA_POINTS;i++) {
     88            printf("The minimum for data point %d: %f\n", i, myFunc(myDerivs, myParams, (psVector *) myCoords->data[i]));
     89            fflush(stdout);
     90        }
    8491
    85     printf("\nThe value of the function at the minimum is %f\n", min->value);
    86     for (psS32 i=0;i<NUM_DATA_POINTS;i++) {
    87         printf("The minimum for data point %d: %f\n", i, myFunc(myDerivs, myParams, (psVector *) myCoords->data[i]));
    88     }
    89 
    90     for (psS32 i=0;i<NUM_PARAMS;i++) {
    91         printf("Parameter %d at the minimum is %f (expected: %f)\n", i,
    92                myParams->data.F32[i], expectedParm[i]);
     92        for (psS32 i=0;i<NUM_PARAMS;i++) {
     93            printf("Parameter %d at the minimum is %f (expected: %f)\n", i,
     94                   myParams->data.F32[i], expectedParm[i]);
     95            fflush(stdout);
     96        }
    9397    }
    9498
     
    99103    psFree(myCoords);
    100104    psFree(y);
    101 
    102105    psMemCheckCorruption(1);
    103     psS32 memLeaks = psMemCheckLeaks(currentId,NULL,NULL,false);
     106    psS32 memLeaks = psMemCheckLeaks(currentId, NULL, NULL, false);
    104107    if (0 != memLeaks) {
     108        printf("TEST ERROR: Memory Leaks! (%d leaks).\n", memLeaks);
     109        fflush(stdout);
     110        // XXX: This is causing a seg fault
    105111        psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks);
    106112    }
     
    108114}
    109115
     116
     117
    110118psS32 main()
    111119{
    112120    psLogSetFormat("HLNM");
     121    psTraceSetDestination(1);
     122    psTraceSetLevel(".", 0);
     123    psTraceSetLevel(__func__, 10);
     124    psTraceSetLevel("t01", 10);
     125    psTraceSetLevel("psMinimizeLMChi2_OLD", 10);
     126    psTraceSetLevel("psMinimizeLMChi2", 10);
     127    psTraceSetLevel("psMinimizeGaussNewtonDelta", 0);
     128    psTraceSetLevel("psMinimizeGaussNewtonDelta_EAM", 0);
     129    psTraceSetLevel("p_psMinLM_GuessABP", 0);
     130    psTraceSetLevel("p_psMinLM_GuessABP_EAM", 0);
     131    psTraceSetLevel("p_psMinLM_SetABX", 0);
     132    psTraceSetLevel("psGaussJordan", 0);
     133    psTraceSetLevel("psMinimizationAlloc", 0);
     134    psTraceSetLevel("psMemCheckMinimization", 0);
     135    psTraceSetLevel("p_psDetermineBracket", 0);
     136    psTraceSetLevel("p_psDetermineBracket2", 0);
     137    psTraceSetLevel("p_psLineMin", 0);
     138    psTraceSetLevel("psMinimizePowell", 0);
     139    psTraceSetLevel("myPowellChi2Func", 0);
     140    psTraceSetLevel("psMinimizeChi2Powell", 0);
     141    psTraceSetLevel("BuildSums1D", 0);
     142    psTraceSetLevel("BuildSums2D", 0);
     143    psTraceSetLevel("Polynomial2DEvalVectorD", 0);
     144    psTraceSetLevel("vectorFitPolynomial1DCheby", 0);
     145    psTraceSetLevel("VectorFitPolynomial1DOrd", 0);
     146    psTraceSetLevel("psVectorFitPolynomial1D", 0);
     147    psTraceSetLevel("psVectorClipFitPolynomial1D", 0);
     148
     149    psTrace(__func__, 2, "Calling new psMinimize().\n");
    113150    t01();
     151    printf("DONE\n");
     152    fflush(stdout);
    114153}
     154//is the way
     155
Note: See TracChangeset for help on using the changeset viewer.