Changeset 5175 for trunk/psLib/test/math/tst_psMinimize06.c
- Timestamp:
- Sep 28, 2005, 4:13:54 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/math/tst_psMinimize06.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/math/tst_psMinimize06.c
r4859 r5175 7 7 #include <math.h> 8 8 #define NUM_ITERATIONS 100 9 #define ERR_TOL 0. 09 #define ERR_TOL 0.1 10 10 #define NUM_DATA_POINTS 20 11 11 #define NUM_PARAMS 5 … … 45 45 } 46 46 47 48 47 psS32 t01() 49 48 { … … 63 62 ((psVector *) (myCoords->data[i]))->data.F32[0] = (float) (i+10); 64 63 ((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]); 69 66 y->data.F32[i] = (float) i; 70 67 } … … 74 71 } 75 72 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 } 84 91 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 } 93 97 } 94 98 … … 99 103 psFree(myCoords); 100 104 psFree(y); 101 102 105 psMemCheckCorruption(1); 103 psS32 memLeaks = psMemCheckLeaks(currentId, NULL,NULL,false);106 psS32 memLeaks = psMemCheckLeaks(currentId, NULL, NULL, false); 104 107 if (0 != memLeaks) { 108 printf("TEST ERROR: Memory Leaks! (%d leaks).\n", memLeaks); 109 fflush(stdout); 110 // XXX: This is causing a seg fault 105 111 psAbort(__func__,"Memory Leaks! (%d leaks)", memLeaks); 106 112 } … … 108 114 } 109 115 116 117 110 118 psS32 main() 111 119 { 112 120 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"); 113 150 t01(); 151 printf("DONE\n"); 152 fflush(stdout); 114 153 } 154 //is the way 155
Note:
See TracChangeset
for help on using the changeset viewer.
