Changeset 2269 for trunk/psLib/src/dataManip/psMinimize.c
- Timestamp:
- Nov 2, 2004, 5:30:30 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/dataManip/psMinimize.c (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psMinimize.c
r2267 r2269 9 9 * @author GLG, MHPCC 10 10 * 11 * @version $Revision: 1.8 3$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-11-0 2 19:08:33$11 * @version $Revision: 1.84 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-11-03 03:30:30 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 61 61 returned as a psVector sums. 62 62 63 XXX: change name64 63 XXX: Use a static vector. 65 64 *****************************************************************************/ 66 void p _psBuildSums1D(double x,67 psS32 polyOrder,68 psVector* sums)65 void psBuildSums1D(double x, 66 psS32 polyOrder, 67 psVector* sums) 69 68 { 70 69 psS32 i = 0; … … 74 73 sums = psVectorAlloc(polyOrder, PS_TYPE_F64); 75 74 } 76 77 75 if (polyOrder > sums->n) { 78 76 sums = psVectorRealloc(sums, polyOrder); … … 109 107 psS32 i; 110 108 psS32 k; 111 psBool mustFreeX = false;112 109 float sig; 113 110 float p; … … 150 147 } 151 148 152 if (mustFreeX == true) {153 psFree(X);154 }155 149 psFree(u); 156 157 150 psTrace(".psLib.dataManip.CalculateSecondDerivs", 4, 158 151 "---- CalculateSecondDerivs() end ----\n"); … … 171 164 polynomials which are stored in psSpline1D. 172 165 173 XXX: check types/sizes174 166 XXX: This is F32 only 175 167 *****************************************************************************/ 168 /* 176 169 float p_psNRSpline1DEval(psSpline1D *spline, 177 170 const psVector* restrict x, … … 187 180 PS_VECTOR_CHECK_NULL(y, NAN); 188 181 PS_VECTOR_CHECK_TYPE(y, PS_TYPE_F32, NAN); 189 182 190 183 psS32 n; 191 184 psS32 klo; … … 197 190 float D; 198 191 float Y; 199 192 200 193 n = spline->n; 201 klo = p_psVectorBinDisect F32(spline->domains, (spline->n)+1, X);194 klo = p_psVectorBinDisect32(spline->domains, (spline->n)+1, X); 202 195 khi = klo + 1; 203 196 H = (spline->domains)[khi] - (spline->domains)[klo]; … … 206 199 C = ((A*A*A)-A) * (H*H/6.0); 207 200 D = ((B*B*B)-B) * (H*H/6.0); 208 201 209 202 Y = (A * y->data.F32[klo]) + 210 203 (B * y->data.F32[khi]) + 211 204 (C * (spline->p_psDeriv2)[klo]) + 212 205 (D * (spline->p_psDeriv2)[khi]); 213 206 214 207 return(Y); 215 208 } 216 209 */ 217 210 /*****************************************************************************/ 218 211 /* FUNCTION IMPLEMENTATION - PUBLIC */ … … 239 232 240 233 XXX: usage of yErr is not specified in IfA documentation. 234 241 235 XXX: Is the x argument redundant? What do we do if the x argument is 242 236 supplied, but does not equal the domains specified in mySpline? … … 414 408 /****************************************************************************** 415 409 XXX: We assume unnormalized gaussians. 416 XXX: Currently, yErr is ignored.417 410 *****************************************************************************/ 418 411 psVector *psMinimizeLMChi2Gauss1D(psImage *deriv, … … 441 434 x = ((psVector *) (coords->data[i]))->data.F32[0]; 442 435 out->data.F32[i] = psGaussian(x, mean, stdev, false); 443 // psTrace(".psLib.dataManip.psMinimize", 6,444 // "out->data.F32[%d]: (x, m, s) is (%f, %f, %f) is %f\n", i, x, mean, stdev, out->data.F32[i]);445 436 } 446 437 … … 449 440 float tmp = (x - mean) * psGaussian(x, mean, stdev, false); 450 441 deriv->data.F32[i][0] = tmp / (stdev * stdev); 451 452 442 tmp = (x - mean) * (x - mean) * 453 443 psGaussian(x, mean, stdev, 0); … … 482 472 XXX: This must work for both F32 and F64. F32 is currently implemented. 483 473 Note: since the LUD routines are only implemented in F64, then we 484 >will have to convert all F32 input vectors to F64 regardless. So,474 will have to convert all F32 input vectors to F64 regardless. So, 485 475 the F64 port might be. 486 476 *****************************************************************************/ … … 730 720 731 721 /****************************************************************************** 732 p_psVectorFitPolynomial1DCheb(): This routine will fit a Chebyshev 733 polynomial of degree myPoly to the data points (x, y) and return the 734 coefficients of thatpolynomial.722 VectorFitPolynomial1DCheb(): This routine will fit a Chebyshev polynomial of 723 degree myPoly to the data points (x, y) and return the coefficients of that 724 polynomial. 735 725 736 726 XXX: yErr is currently ignored. … … 738 728 XXX: Use private name? 739 729 *****************************************************************************/ 740 psPolynomial1D * p_psVectorFitPolynomial1DCheby(psPolynomial1D* myPoly,730 psPolynomial1D *VectorFitPolynomial1DCheby(psPolynomial1D* myPoly, 741 731 const psVector* restrict x, 742 732 const psVector* restrict y, … … 785 775 psFree(fScalar); 786 776 787 psTrace(".psLib.dataManip. p_psVectorFitPolynomial1DCheby", 6,777 psTrace(".psLib.dataManip.VectorFitPolynomial1DCheby", 6, 788 778 "(x, X, y, f(X)) is (%f, %f, %f, %f)\n", 789 779 x->data.F64[i], X, y->data.F64[i], f->data.F64[i]); … … 809 799 810 800 /****************************************************************************** 811 p_psVectorFitPolynomial1DOrd(): This routine will fit an ordinary 812 polynomial of degree myPoly to the data points (x, y) and return the 813 coefficients of thatpolynomial.801 VectorFitPolynomial1DOrd(): This routine will fit an ordinary polynomial of 802 degree myPoly to the data points (x, y) and return the coefficients of that 803 polynomial. 814 804 815 805 XXX: Use private name? 816 806 XXX: Use recycled vectors. 817 807 *****************************************************************************/ 818 psPolynomial1D* p_psVectorFitPolynomial1DOrd(psPolynomial1D* myPoly,808 psPolynomial1D* VectorFitPolynomial1DOrd(psPolynomial1D* myPoly, 819 809 const psVector* restrict x, 820 810 const psVector* restrict y, … … 833 823 psVector* xSums = NULL; 834 824 835 psTrace(".psLib.dataManip. psVectorFitPolynomial1D", 4,836 "---- psVectorFitPolynomial1D() begin ----\n");837 // printf(" psVectorFitPolynomial1D()\n");825 psTrace(".psLib.dataManip.VectorFitPolynomial1DOrd", 4, 826 "---- VectorFitPolynomial1DOrd() begin ----\n"); 827 // printf("VectorFitPolynomial1D()\n"); 838 828 // for (i=0;i<x->n;i++) { 839 829 // printf("(x, y, yErr) is (%f, %f, %f)\n", x->data.F64[i], y->data.F64[i], yErr->data.F64[i]); … … 865 855 if (yErr == NULL) { 866 856 for (i = 0; i < X->n; i++) { 867 p _psBuildSums1D(X->data.F64[i], 2 * polyOrder, xSums);857 psBuildSums1D(X->data.F64[i], 2 * polyOrder, xSums); 868 858 869 859 for (k = 0; k < polyOrder; k++) { … … 879 869 } else { 880 870 for (i = 0; i < X->n; i++) { 881 p _psBuildSums1D(X->data.F64[i], 2 * polyOrder, xSums);871 psBuildSums1D(X->data.F64[i], 2 * polyOrder, xSums); 882 872 883 873 for (k = 0; k < polyOrder; k++) { … … 916 906 psFree(xSums); 917 907 918 psTrace(".psLib.dataManip. psVectorFitPolynomial1D", 4,919 "---- psVectorFitPolynomial1D() begin ----\n");908 psTrace(".psLib.dataManip.VectorFitPolynomial1DOrd", 4, 909 "---- VectorFitPolynomial1DOrd() begin ----\n"); 920 910 return (myPoly); 921 911 } … … 962 952 PS_VECTOR_GEN_X_INDEX_STATIC_F64(x64Static, y->n); 963 953 if (myPoly->type == PS_POLYNOMIAL_CHEB) { 964 p_psNormalizeVector (x64Static);954 p_psNormalizeVectorRange(x64Static, -1.0, 1.0); 965 955 } 966 956 x64 = x64Static; … … 974 964 // Call the appropriate vector fitting routine. 975 965 if (myPoly->type == PS_POLYNOMIAL_CHEB) { 976 p_psVectorFitPolynomial1DCheby(myPoly, x64, y64, yErr64);966 VectorFitPolynomial1DCheby(myPoly, x64, y64, yErr64); 977 967 } else if (myPoly->type == PS_POLYNOMIAL_ORD) { 978 tmpPoly = p_psVectorFitPolynomial1DOrd(myPoly, x64, y64, yErr64);968 tmpPoly = VectorFitPolynomial1DOrd(myPoly, x64, y64, yErr64); 979 969 } else { 980 970 psError(__func__, "unknown polynomial type.\n");
Note:
See TracChangeset
for help on using the changeset viewer.
