Changeset 4141 for trunk/psLib/test/dataManip/tst_psMinimize06.c
- Timestamp:
- Jun 7, 2005, 1:31:32 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psMinimize06.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psMinimize06.c
r3987 r4141 15 15 16 16 /***************************************************************************** 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 17 myFunc(): 18 sum = (param[0] * x[0]) + 19 (param[1] * x[1]) + 20 ... 25 21 *****************************************************************************/ 26 ps Vector *myFunc(psImage *myDeriv,27 psVector *myParams,28 psArray *myCoords)22 psF64 myFunc(psVector *deriv, 23 psVector *params, 24 psVector *x) 29 25 { 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"); 38 29 } 39 30 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]; 87 35 } 88 36 … … 121 69 myParams->data.F32[i] = (float) i; 122 70 myParams->data.F32[i] = expectedParm[i] * 1.3; 71 myParams->data.F32[i] = 0.0; 123 72 myParams->data.F32[i] = (float) (5 + i); 124 myParams->data.F32[i] = 0.0;125 73 } 126 74
Note:
See TracChangeset
for help on using the changeset viewer.
