Changeset 1103 for trunk/psLib/test/dataManip/tst_psMinimize00.c
- Timestamp:
- Jun 25, 2004, 2:24:30 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/dataManip/tst_psMinimize00.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataManip/tst_psMinimize00.c
r1095 r1103 15 15 #define NUM_PARAMS 4 16 16 17 float *myFunc(psVector *myData,18 psVector *myParams)17 float myFunc(const psVector *restrict myData, 18 const psVector *restrict myParams) 19 19 { 20 20 float x = myData->data.F32[0]; … … 24 24 float C = myParams->data.F32[2]; 25 25 float D = myParams->data.F32[3]; 26 float *tmp = (float *) psAlloc(sizeof(float));27 26 28 *tmp = A + (B*x) + (C*y) + (D*x*y); 29 return(tmp); 27 return(A + (B*x) + (C*y) + (D*x*y)); 30 28 } 31 29 32 float *myFuncDeriv(psVector *myData,33 psVector *myParams,34 int whichParamDeriv)30 float myFuncDeriv(const psVector *restrict myData, 31 const psVector *restrict myParams, 32 int whichParamDeriv) 35 33 { 36 34 float x = myData->data.F32[0]; 37 35 float y = myData->data.F32[1]; 38 float *tmp = (float *) psAlloc(sizeof(float));36 float tmp = 0.0; 39 37 40 38 if (whichParamDeriv == 0) { 41 *tmp = 1.0;39 tmp = 1.0; 42 40 } else if (whichParamDeriv == 1) { 43 *tmp = x;41 tmp = x; 44 42 } else if (whichParamDeriv == 2) { 45 *tmp = y;43 tmp = y; 46 44 } else if (whichParamDeriv == 3) { 47 *tmp = x * y;45 tmp = x * y; 48 46 } 49 47 return(tmp); … … 66 64 int memLeaks = 0; 67 65 68 domain = psImageAlloc( NUM_DATA, DATA_WIDTH, PS_TYPE_F32);66 domain = psImageAlloc(DATA_WIDTH, NUM_DATA, PS_TYPE_F32); 69 67 data = psVectorAlloc(NUM_DATA, PS_TYPE_F32); 70 68 errors = psVectorAlloc(NUM_DATA, PS_TYPE_F32); … … 73 71 tmpVecPtr = psVectorAlloc(DATA_WIDTH, PS_TYPE_F32); 74 72 73 printf("FUCK: initialGuess->n is %d\n", initialGuess->n); 75 74 // Build the data. 76 75 initialGuess->data.F32[0] = 2.0; … … 91 90 tmpVecPtr->data.F32[i] = domain->data.F32[i][j]; 92 91 } 93 data->data.F32[i] = *myFunc(tmpVecPtr, initialGuess);92 data->data.F32[i] = myFunc(tmpVecPtr, initialGuess); 94 93 } 95 94 … … 104 103 errors, 105 104 initialGuess, 106 paramMask,105 NULL, 107 106 &chiSq); 108 107
Note:
See TracChangeset
for help on using the changeset viewer.
