Changeset 1859
- Timestamp:
- Sep 22, 2004, 6:56:41 PM (22 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 8 edited
-
dataManip/psFunctions.c (modified) (13 diffs)
-
dataManip/psFunctions.h (modified) (3 diffs)
-
dataManip/psMinimize.c (modified) (22 diffs)
-
math/psMinimize.c (modified) (22 diffs)
-
math/psPolynomial.c (modified) (13 diffs)
-
math/psPolynomial.h (modified) (3 diffs)
-
math/psSpline.c (modified) (13 diffs)
-
math/psSpline.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/dataManip/psFunctions.c
r1846 r1859 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.3 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09-2 2 01:30:21$9 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-23 04:56:40 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 467 467 for (loop_x = 0; loop_x < myPoly->n; loop_x++) { 468 468 if (myPoly->mask[loop_x] == 0) { 469 psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 10, 470 "polysum+= sum*coeff [%f+= (%f * %f)\n", polySum, xSum, myPoly->coeff[loop_x]); 469 471 polySum += xSum * myPoly->coeff[loop_x]; 470 472 xSum *= x; … … 1687 1689 1688 1690 /***************************************************************************** 1689 VectorBinDisectF32(): This is a private function which takes as input a1691 p_psVectorBinDisectF32(): This is a private function which takes as input a 1690 1692 vector of floating point data as well as a single floating point values. 1691 1693 The input vector values are assumed to be non-decreasing (v[i-1] <= v[j] for … … 1696 1698 XXX: Macro this for a few different types. 1697 1699 *****************************************************************************/ 1698 int VectorBinDisectF32(float *bins,1699 int numBins,1700 float x)1700 int p_psVectorBinDisectF32(float *bins, 1701 int numBins, 1702 float x) 1701 1703 { 1702 1704 int min; … … 1704 1706 int mid; 1705 1707 1706 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectF32", 4,1707 "---- Calling VectorBinDisectF32(%f)\n", x);1708 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4, 1709 "---- Calling p_psVectorBinDisectF32(%f)\n", x); 1708 1710 1709 1711 if ((x < bins[0]) || 1710 1712 (x > bins[numBins-1])) { 1711 1713 psLogMsg(__func__, PS_LOG_WARN, 1712 " VectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",1714 "p_psVectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).", 1713 1715 x, bins[0], bins[numBins-1]); 1714 1716 return(-1); … … 1720 1722 1721 1723 while (min != max) { 1722 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectF32", 4,1724 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4, 1723 1725 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n", 1724 1726 min, mid, max, x, bins[mid]); 1725 1727 1726 1728 if (x == bins[mid]) { 1727 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectF32", 4,1728 "---- Exiting VectorBinDisectF32(): bin %d\n", mid);1729 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4, 1730 "---- Exiting p_psVectorBinDisectF32(): bin %d\n", mid); 1729 1731 return(mid); 1730 1732 } else if (x < bins[mid]) { … … 1736 1738 } 1737 1739 1738 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectF32", 4,1739 "---- Exiting VectorBinDisectF32(): bin %d\n", min);1740 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4, 1741 "---- Exiting p_psVectorBinDisectF32(): bin %d\n", min); 1740 1742 return(min); 1741 1743 } 1742 1744 1743 1745 /***************************************************************************** 1744 VectorBinDisectS32(): integer version of above.1746 p_psVectorBinDisectS32(): integer version of above. 1745 1747 *****************************************************************************/ 1746 int VectorBinDisectS32(int *bins,1747 int numBins,1748 int x)1748 int p_psVectorBinDisectS32(int *bins, 1749 int numBins, 1750 int x) 1749 1751 { 1750 1752 int min; … … 1752 1754 int mid; 1753 1755 1754 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectS32", 4,1755 "---- Calling VectorBinDisectS32(%f)\n", x);1756 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4, 1757 "---- Calling p_psVectorBinDisectS32(%f)\n", x); 1756 1758 1757 1759 if ((x < bins[0]) || 1758 1760 (x > bins[numBins-1])) { 1759 1761 psLogMsg(__func__, PS_LOG_WARN, 1760 " VectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).",1762 "p_psVectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).", 1761 1763 x, bins[0], bins[numBins-1]); 1762 1764 return(-1); … … 1768 1770 1769 1771 while (min != max) { 1770 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectS32", 4,1772 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4, 1771 1773 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n", 1772 1774 min, mid, max, x, bins[mid]); 1773 1775 1774 1776 if (x == bins[mid]) { 1775 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectS32", 4,1776 "---- Exiting VectorBinDisectS32(): bin %d\n", min);1777 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4, 1778 "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min); 1777 1779 return(min); 1778 1780 } else if (x < bins[mid]) { … … 1784 1786 } 1785 1787 1786 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectS32", 4,1787 "---- Exiting VectorBinDisectS32(): bin %d\n", min);1788 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4, 1789 "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min); 1788 1790 return(min); 1789 1791 } 1790 1792 1791 1793 /***************************************************************************** 1792 p_psVectorBinDisect(): A wrapper to the above VectorBinDisect().1794 p_psVectorBinDisect(): A wrapper to the above p_psVectorBinDisect(). 1793 1795 *****************************************************************************/ 1794 1796 int p_psVectorBinDisect(psVector *bins, … … 1801 1803 1802 1804 if (x->type.type == PS_TYPE_S32) { 1803 return( VectorBinDisectS32(bins->data.S32, bins->n, x->data.S32));1805 return(p_psVectorBinDisectS32(bins->data.S32, bins->n, x->data.S32)); 1804 1806 } else if (x->type.type == PS_TYPE_F32) { 1805 return( VectorBinDisectF32(bins->data.F32, bins->n, x->data.F32));1807 return(p_psVectorBinDisectF32(bins->data.F32, bins->n, x->data.F32)); 1806 1808 } else { 1807 1809 // XXX: Generate error message. … … 1879 1881 "---- p_ps1DInterpolateF32() begin ----\n"); 1880 1882 1881 binNum = VectorBinDisectF32(domain, n, x);1883 binNum = p_psVectorBinDisectF32(domain, n, x); 1882 1884 1883 1885 if (0 == numIntPoints%2) { … … 1953 1955 1954 1956 n = spline->n; 1955 binNum = VectorBinDisectF32(spline->domains, (spline->n)+1, x);1957 binNum = p_psVectorBinDisectF32(spline->domains, (spline->n)+1, x); 1956 1958 if (binNum == -1) { 1957 1959 psLogMsg(__func__, PS_LOG_WARN, -
trunk/psLib/src/dataManip/psFunctions.h
r1846 r1859 12 12 * @author George Gusciora, MHPCC 13 13 * 14 * @version $Revision: 1.2 4$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-09-2 2 01:30:21 $14 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-09-23 04:56:41 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 407 407 psVector *data); 408 408 409 int p_psVectorBinDisectF32(float *bins, 410 int numBins, 411 float x); 412 413 int p_psVectorBinDisectS32(int *bins, 414 int numBins, 415 int x); 416 409 417 int p_psVectorBinDisect(psVector *bins, 410 418 psScalar *x); … … 415 423 psScalar *x); 416 424 425 float p_psNRSpline1DEval(psSpline1D *spline, 426 const psVector* restrict x, 427 const psVector* restrict y, 428 float X); 429 417 430 /* \} */// End of MathGroup Functions 418 431 -
trunk/psLib/src/dataManip/psMinimize.c
r1848 r1859 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.4 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09-2 2 02:42:49$11 * @version $Revision: 1.45 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-09-23 04:56:41 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 43 43 #include "psMinimize.h" 44 44 #include "psMatrix.h" 45 #include "ps Trace.h"45 #include "psConstants.h" 46 46 47 47 /*****************************************************************************/ 48 48 /* DEFINE STATEMENTS */ 49 49 /*****************************************************************************/ 50 51 #define MAX_LMM_ITERATIONS 10052 #define MAX_MINIMIZE_ITERATIONS 10053 50 54 51 /** Preprocessor macro to generate error on a NULL 1DPolynomial */ … … 96 93 /* GLOBAL VARIABLES */ 97 94 /*****************************************************************************/ 98 99 95 static psMinimizeChi2PowellFunc Chi2PowellFunc = NULL; 100 96 //static psMinimizePowellFunc PowellFunc = NULL; … … 116 112 input parameter "x" between 0 and input parameter polyOrder. The result is 117 113 returned as a psVector sums. 114 115 XXX: change name 118 116 *****************************************************************************/ 119 void p_psBuildSums1D(double x, int polyOrder, psVector* sums) 117 void p_psBuildSums1D(double x, 118 int polyOrder, 119 psVector* sums) 120 120 { 121 121 int i = 0; … … 148 148 149 149 /***************************************************************************** 150 151 150 CalculateSecondDerivs(): Given a set of x/y vectors corresponding to a 152 tabulated function at n points, this routine calcu altes the second151 tabulated function at n points, this routine calculates the second 153 152 derivatives of the interpolating cubic splines at those n points. 154 153 155 154 The first and second derivatives at the endpoints, undefined in the SDR, are 156 here defined to be 0.0. 157 158 XXX: This algorithm is very similar to that inNumerical Recipes.155 here defined to be 0.0. They can be modified via ypo and yp1. 156 157 XXX: This algorithm is derived from the Numerical Recipes. 159 158 *****************************************************************************/ 160 159 float *CalculateSecondDerivs(const psVector* restrict x, ///< Ordinates (or NULL to just use the indices) … … 174 173 float *X = (float *) & (x->data.F32[0]); 175 174 float *Y = (float *) & (y->data.F32[0]); 175 float qn; 176 176 177 177 if (x == NULL) { … … 183 183 } 184 184 185 // XXX: The first and second derivatives at the endpoints, undefined in 186 // the SDR, are here defined to be 0.0. 187 u[0]= 0.0; 188 u[n-1]= 0.0; 189 derivs2[0] = 0.0; 190 derivs2[n-1] = 0.0; 185 // XXX: The second derivatives at the endpoints, undefined in the SDR, 186 // are set in psConstants.h: LEFT_SPLINE_DERIV, RIGHT_SPLINE_DERIV. 187 derivs2[0] = -0.5; 188 u[0]= (3.0/(X[1]-X[0])) * ((Y[1]-Y[0])/(X[1]-X[0]) - LEFT_SPLINE_DERIV); 191 189 192 190 for (i=1;i<=(n-2);i++) { … … 194 192 p = sig * derivs2[i-1] + 2.0; 195 193 derivs2[i] = (sig - 1.0) / p; 196 u[i] = ( Y[i+1] - Y[i])/(X[i+1]-X[i]) - (Y[i]-Y[i-1])/(X[i]-X[i-1]);197 u[i] = ( 6.0 * u[i] / (X[i+1] - X[i-1]) - sig * u[i-1]) / p;194 u[i] = ((Y[i+1] - Y[i])/(X[i+1]-X[i])) - ((Y[i]-Y[i-1])/(X[i]-X[i-1])); 195 u[i] = ((6.0 * u[i] / (X[i+1] - X[i-1])) - (sig * u[i-1])) / p; 198 196 199 197 psTrace(".psLib.dataManip.CalculateSecondDerivs", 6, … … 205 203 } 206 204 205 qn = 0.5; 206 u[n-1] = (3.0/(X[n-1]-X[n-2])) * (RIGHT_SPLINE_DERIV - (Y[n-1]-Y[n-2])/(X[n-1]-X[n-2])); 207 derivs2[n-1] = (u[n-1] - (qn * u[n-2])) / ((qn * derivs2[n-2]) + 1.0); 208 207 209 for (k=(n-2);k>=0;k--) { 208 210 derivs2[k] = derivs2[k] * derivs2[k+1] + u[k]; 211 209 212 psTrace(".psLib.dataManip.CalculateSecondDerivs", 6, 210 213 "derivs2[%d] is %f\n", k, derivs2[k]); 211 214 } 215 212 216 if (mustFreeX == true) { 213 217 psFree(X); … … 224 228 /* FUNCTION IMPLEMENTATION - PUBLIC */ 225 229 /*****************************************************************************/ 226 227 228 230 229 231 /***************************************************************************** … … 238 240 (3) ((((A*A*A)-A) * mySpline->p_psDeriv2[0]) * H^2)/6.0 + 239 241 (4) ((((B*B*B)-B) * mySpline->p_psDeriv2[1]) * H^2)/6.0 240 Where 241 H = x[1]-x[0], A = (x[1]-x)/H, B = (x-x[0])/H 242 Where: 243 H = x[1]-x[0] 244 A = (x[1]-x)/H 245 B = (x-x[0])/H 242 246 The bulk of the code in this routine is the expansion of the above equation 243 into a polynomial in terms of x. This gets pretty complicated. 247 into a polynomial in terms of x, and then saving the coefficients of the 248 powers of x in the spline polynomials. This gets pretty complicated. 244 249 245 250 XXX: usage of yErr is not specified in IfA documentation. … … 262 267 } 263 268 mySpline->p_psDeriv2 = CalculateSecondDerivs(x, y); 269 for (i=0;i<y->n;i++) 270 psTrace(".psLib.dataManip.psVectorFitSpline1D", 6, 271 "Second deriv[%d] is %f\n", i, mySpline->p_psDeriv2[i]); 264 272 265 273 for (i=0;i<numSplines;i++) { … … 271 279 // 272 280 // From (1) 273 (mySpline->spline[i])->coeff[0] = y->data.F32[i] * (x->data.F32[i+1]/H);281 (mySpline->spline[i])->coeff[0] = (y->data.F32[i] * x->data.F32[i+1]/H); 274 282 // From (2) 275 ((mySpline->spline[i])->coeff[0])-= ( y->data.F32[i+1] * x->data.F32[i]/H);283 ((mySpline->spline[i])->coeff[0])-= ((y->data.F32[i+1] * x->data.F32[i])/H); 276 284 // From (3) 277 285 tmp = (x->data.F32[i+1] * x->data.F32[i+1] * x->data.F32[i+1]) / (H * H * H); … … 289 297 // 290 298 // From (1) 291 (mySpline->spline[i])->coeff[1] = - ((mySpline->p_psDeriv2)[i]) / H;299 (mySpline->spline[i])->coeff[1] = -(y->data.F32[i]) / H; 292 300 // From (2) 293 ( mySpline->spline[i])->coeff[1]-= ((mySpline->p_psDeriv2)[i+1]) / H;301 ((mySpline->spline[i])->coeff[1])+= (y->data.F32[i+1] / H); 294 302 // From (3) 295 tmp = - (x->data.F32[i+1] * x->data.F32[i+1]) / (H * H * H);303 tmp = -3.0 * (x->data.F32[i+1] * x->data.F32[i+1]) / (H * H * H); 296 304 tmp+= (1.0 / H); 297 305 tmp*= ((mySpline->p_psDeriv2)[i]) * H * H / 6.0; 298 ( mySpline->spline[i])->coeff[1]+= tmp;306 ((mySpline->spline[i])->coeff[1])+= tmp; 299 307 // From (4) 300 tmp = (x->data.F32[i] +x->data.F32[i]) / (H * H * H);308 tmp = 3.0 * (x->data.F32[i] * x->data.F32[i]) / (H * H * H); 301 309 tmp-= (1.0 / H); 302 310 tmp*= ((mySpline->p_psDeriv2)[i+1]) * H * H / 6.0; 303 ( mySpline->spline[i])->coeff[1]+= tmp;311 ((mySpline->spline[i])->coeff[1])+= tmp; 304 312 305 313 // … … 307 315 // 308 316 // From (3) 309 (mySpline->spline[i])->coeff[2] = ((mySpline->p_psDeriv2)[i]) * 3.0 * x->data.F32[i+1] / 6.0;317 (mySpline->spline[i])->coeff[2] = ((mySpline->p_psDeriv2)[i]) * 3.0 * x->data.F32[i+1] / (6.0 * H); 310 318 // From (4) 311 ( mySpline->spline[i])->coeff[2]-= ((mySpline->p_psDeriv2)[i+1]) * 3.0 * x->data.F32[i] / 6.0;319 ((mySpline->spline[i])->coeff[2])-= (((mySpline->p_psDeriv2)[i+1]) * 3.0 * x->data.F32[i] / (6.0 * H)); 312 320 313 321 // … … 317 325 (mySpline->spline[i])->coeff[3] = -((mySpline->p_psDeriv2)[i]) / (6.0 * H); 318 326 // From (4) 319 ( mySpline->spline[i])->coeff[3]+= ((mySpline->p_psDeriv2)[i+1]) / (6.0 * H);327 ((mySpline->spline[i])->coeff[3])+= ((mySpline->p_psDeriv2)[i+1]) / (6.0 * H); 320 328 321 329 psTrace(".psLib.dataManip.psMinimizeLMChi2", 6, … … 334 342 return(mySpline); 335 343 } 344 345 /****************************************************************************** 346 p_psNRSpline1DEval(): This routine does NR-style evaluation of cubic splines. 347 It takes advantage of the 2nd derivatives of the cubic splines, which are 348 stored in the psSPline1D data structure, and computes the interpolated value 349 directly, without computing (or using) the interpolating cubic spline 350 polynomial. 351 352 This routine is here mostly for a sanity check on the psLib function 353 evalSpline() which computes the interpolated value based on the cubic spline 354 polynomials which are stored in psSpline1D. 355 *****************************************************************************/ 356 float p_psNRSpline1DEval(psSpline1D *spline, 357 const psVector* restrict x, 358 const psVector* restrict y, 359 float X) 360 { 361 int n; 362 int klo; 363 int khi; 364 float H; 365 float A; 366 float B; 367 float C; 368 float D; 369 float Y; 370 371 n = spline->n; 372 klo = p_psVectorBinDisectF32(spline->domains, (spline->n)+1, X); 373 khi = klo + 1; 374 H = (spline->domains)[khi] - (spline->domains)[klo]; 375 A = ((spline->domains)[khi] - X) / H; 376 B = (X - (spline->domains)[klo]) / H; 377 C = ((A*A*A)-A) * (H*H/6.0); 378 D = ((B*B*B)-B) * (H*H/6.0); 379 380 Y = (A * y->data.F32[klo]) + 381 (B * y->data.F32[khi]) + 382 (C * (spline->p_psDeriv2)[klo]) + 383 (D * (spline->p_psDeriv2)[khi]); 384 385 return(Y); 386 } 387 336 388 337 389 /****************************************************************************** … … 687 739 } 688 740 689 690 #define STEP_SIZE 0.10691 741 /****************************************************************************** 692 This routine takes as input an arbitrary function, and the parameter to 693 vary, and the line along which it must vary. This function produces as 694 output a bracket [a, b, c] such that 742 p_psDetermineBracket(): This routine takes as input an arbitrary function, 743 and the parameter to vary, and the line along which it must vary. This 744 function produces as output a bracket [a, b, c] such that 745 695 746 f(param + b * line) is less than f(param + a * line) and 696 747 f(param + c * line). … … 700 751 smaller/larger than b. Repeat this process until a local minimum is 701 752 found. 753 754 702 755 *****************************************************************************/ 703 756 psVector *p_psDetermineBracket(psVector *params, … … 719 772 float new_cDir = 0.0; 720 773 psVector *bracket = psVectorAlloc(3, PS_TYPE_F32); 721 float stepSize = STEP_SIZE;774 float stepSize = DETERMINE_BRACKET_STEP_SIZE; 722 775 psVector *tmp = NULL; 723 776 int i = 0; … … 869 922 return(NULL); 870 923 } 871 872 873 874 875 876 877 878 879 880 881 882 924 883 925 /****************************************************************************** … … 1061 1103 1062 1104 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1105 /****************************************************************************** 1077 1106 This routine must minimize a possibly multi-dimensional function. The -
trunk/psLib/src/math/psMinimize.c
r1848 r1859 9 9 * @author George Gusciora, MHPCC 10 10 * 11 * @version $Revision: 1.4 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2004-09-2 2 02:42:49$11 * @version $Revision: 1.45 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2004-09-23 04:56:41 $ 13 13 * 14 14 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 43 43 #include "psMinimize.h" 44 44 #include "psMatrix.h" 45 #include "ps Trace.h"45 #include "psConstants.h" 46 46 47 47 /*****************************************************************************/ 48 48 /* DEFINE STATEMENTS */ 49 49 /*****************************************************************************/ 50 51 #define MAX_LMM_ITERATIONS 10052 #define MAX_MINIMIZE_ITERATIONS 10053 50 54 51 /** Preprocessor macro to generate error on a NULL 1DPolynomial */ … … 96 93 /* GLOBAL VARIABLES */ 97 94 /*****************************************************************************/ 98 99 95 static psMinimizeChi2PowellFunc Chi2PowellFunc = NULL; 100 96 //static psMinimizePowellFunc PowellFunc = NULL; … … 116 112 input parameter "x" between 0 and input parameter polyOrder. The result is 117 113 returned as a psVector sums. 114 115 XXX: change name 118 116 *****************************************************************************/ 119 void p_psBuildSums1D(double x, int polyOrder, psVector* sums) 117 void p_psBuildSums1D(double x, 118 int polyOrder, 119 psVector* sums) 120 120 { 121 121 int i = 0; … … 148 148 149 149 /***************************************************************************** 150 151 150 CalculateSecondDerivs(): Given a set of x/y vectors corresponding to a 152 tabulated function at n points, this routine calcu altes the second151 tabulated function at n points, this routine calculates the second 153 152 derivatives of the interpolating cubic splines at those n points. 154 153 155 154 The first and second derivatives at the endpoints, undefined in the SDR, are 156 here defined to be 0.0. 157 158 XXX: This algorithm is very similar to that inNumerical Recipes.155 here defined to be 0.0. They can be modified via ypo and yp1. 156 157 XXX: This algorithm is derived from the Numerical Recipes. 159 158 *****************************************************************************/ 160 159 float *CalculateSecondDerivs(const psVector* restrict x, ///< Ordinates (or NULL to just use the indices) … … 174 173 float *X = (float *) & (x->data.F32[0]); 175 174 float *Y = (float *) & (y->data.F32[0]); 175 float qn; 176 176 177 177 if (x == NULL) { … … 183 183 } 184 184 185 // XXX: The first and second derivatives at the endpoints, undefined in 186 // the SDR, are here defined to be 0.0. 187 u[0]= 0.0; 188 u[n-1]= 0.0; 189 derivs2[0] = 0.0; 190 derivs2[n-1] = 0.0; 185 // XXX: The second derivatives at the endpoints, undefined in the SDR, 186 // are set in psConstants.h: LEFT_SPLINE_DERIV, RIGHT_SPLINE_DERIV. 187 derivs2[0] = -0.5; 188 u[0]= (3.0/(X[1]-X[0])) * ((Y[1]-Y[0])/(X[1]-X[0]) - LEFT_SPLINE_DERIV); 191 189 192 190 for (i=1;i<=(n-2);i++) { … … 194 192 p = sig * derivs2[i-1] + 2.0; 195 193 derivs2[i] = (sig - 1.0) / p; 196 u[i] = ( Y[i+1] - Y[i])/(X[i+1]-X[i]) - (Y[i]-Y[i-1])/(X[i]-X[i-1]);197 u[i] = ( 6.0 * u[i] / (X[i+1] - X[i-1]) - sig * u[i-1]) / p;194 u[i] = ((Y[i+1] - Y[i])/(X[i+1]-X[i])) - ((Y[i]-Y[i-1])/(X[i]-X[i-1])); 195 u[i] = ((6.0 * u[i] / (X[i+1] - X[i-1])) - (sig * u[i-1])) / p; 198 196 199 197 psTrace(".psLib.dataManip.CalculateSecondDerivs", 6, … … 205 203 } 206 204 205 qn = 0.5; 206 u[n-1] = (3.0/(X[n-1]-X[n-2])) * (RIGHT_SPLINE_DERIV - (Y[n-1]-Y[n-2])/(X[n-1]-X[n-2])); 207 derivs2[n-1] = (u[n-1] - (qn * u[n-2])) / ((qn * derivs2[n-2]) + 1.0); 208 207 209 for (k=(n-2);k>=0;k--) { 208 210 derivs2[k] = derivs2[k] * derivs2[k+1] + u[k]; 211 209 212 psTrace(".psLib.dataManip.CalculateSecondDerivs", 6, 210 213 "derivs2[%d] is %f\n", k, derivs2[k]); 211 214 } 215 212 216 if (mustFreeX == true) { 213 217 psFree(X); … … 224 228 /* FUNCTION IMPLEMENTATION - PUBLIC */ 225 229 /*****************************************************************************/ 226 227 228 230 229 231 /***************************************************************************** … … 238 240 (3) ((((A*A*A)-A) * mySpline->p_psDeriv2[0]) * H^2)/6.0 + 239 241 (4) ((((B*B*B)-B) * mySpline->p_psDeriv2[1]) * H^2)/6.0 240 Where 241 H = x[1]-x[0], A = (x[1]-x)/H, B = (x-x[0])/H 242 Where: 243 H = x[1]-x[0] 244 A = (x[1]-x)/H 245 B = (x-x[0])/H 242 246 The bulk of the code in this routine is the expansion of the above equation 243 into a polynomial in terms of x. This gets pretty complicated. 247 into a polynomial in terms of x, and then saving the coefficients of the 248 powers of x in the spline polynomials. This gets pretty complicated. 244 249 245 250 XXX: usage of yErr is not specified in IfA documentation. … … 262 267 } 263 268 mySpline->p_psDeriv2 = CalculateSecondDerivs(x, y); 269 for (i=0;i<y->n;i++) 270 psTrace(".psLib.dataManip.psVectorFitSpline1D", 6, 271 "Second deriv[%d] is %f\n", i, mySpline->p_psDeriv2[i]); 264 272 265 273 for (i=0;i<numSplines;i++) { … … 271 279 // 272 280 // From (1) 273 (mySpline->spline[i])->coeff[0] = y->data.F32[i] * (x->data.F32[i+1]/H);281 (mySpline->spline[i])->coeff[0] = (y->data.F32[i] * x->data.F32[i+1]/H); 274 282 // From (2) 275 ((mySpline->spline[i])->coeff[0])-= ( y->data.F32[i+1] * x->data.F32[i]/H);283 ((mySpline->spline[i])->coeff[0])-= ((y->data.F32[i+1] * x->data.F32[i])/H); 276 284 // From (3) 277 285 tmp = (x->data.F32[i+1] * x->data.F32[i+1] * x->data.F32[i+1]) / (H * H * H); … … 289 297 // 290 298 // From (1) 291 (mySpline->spline[i])->coeff[1] = - ((mySpline->p_psDeriv2)[i]) / H;299 (mySpline->spline[i])->coeff[1] = -(y->data.F32[i]) / H; 292 300 // From (2) 293 ( mySpline->spline[i])->coeff[1]-= ((mySpline->p_psDeriv2)[i+1]) / H;301 ((mySpline->spline[i])->coeff[1])+= (y->data.F32[i+1] / H); 294 302 // From (3) 295 tmp = - (x->data.F32[i+1] * x->data.F32[i+1]) / (H * H * H);303 tmp = -3.0 * (x->data.F32[i+1] * x->data.F32[i+1]) / (H * H * H); 296 304 tmp+= (1.0 / H); 297 305 tmp*= ((mySpline->p_psDeriv2)[i]) * H * H / 6.0; 298 ( mySpline->spline[i])->coeff[1]+= tmp;306 ((mySpline->spline[i])->coeff[1])+= tmp; 299 307 // From (4) 300 tmp = (x->data.F32[i] +x->data.F32[i]) / (H * H * H);308 tmp = 3.0 * (x->data.F32[i] * x->data.F32[i]) / (H * H * H); 301 309 tmp-= (1.0 / H); 302 310 tmp*= ((mySpline->p_psDeriv2)[i+1]) * H * H / 6.0; 303 ( mySpline->spline[i])->coeff[1]+= tmp;311 ((mySpline->spline[i])->coeff[1])+= tmp; 304 312 305 313 // … … 307 315 // 308 316 // From (3) 309 (mySpline->spline[i])->coeff[2] = ((mySpline->p_psDeriv2)[i]) * 3.0 * x->data.F32[i+1] / 6.0;317 (mySpline->spline[i])->coeff[2] = ((mySpline->p_psDeriv2)[i]) * 3.0 * x->data.F32[i+1] / (6.0 * H); 310 318 // From (4) 311 ( mySpline->spline[i])->coeff[2]-= ((mySpline->p_psDeriv2)[i+1]) * 3.0 * x->data.F32[i] / 6.0;319 ((mySpline->spline[i])->coeff[2])-= (((mySpline->p_psDeriv2)[i+1]) * 3.0 * x->data.F32[i] / (6.0 * H)); 312 320 313 321 // … … 317 325 (mySpline->spline[i])->coeff[3] = -((mySpline->p_psDeriv2)[i]) / (6.0 * H); 318 326 // From (4) 319 ( mySpline->spline[i])->coeff[3]+= ((mySpline->p_psDeriv2)[i+1]) / (6.0 * H);327 ((mySpline->spline[i])->coeff[3])+= ((mySpline->p_psDeriv2)[i+1]) / (6.0 * H); 320 328 321 329 psTrace(".psLib.dataManip.psMinimizeLMChi2", 6, … … 334 342 return(mySpline); 335 343 } 344 345 /****************************************************************************** 346 p_psNRSpline1DEval(): This routine does NR-style evaluation of cubic splines. 347 It takes advantage of the 2nd derivatives of the cubic splines, which are 348 stored in the psSPline1D data structure, and computes the interpolated value 349 directly, without computing (or using) the interpolating cubic spline 350 polynomial. 351 352 This routine is here mostly for a sanity check on the psLib function 353 evalSpline() which computes the interpolated value based on the cubic spline 354 polynomials which are stored in psSpline1D. 355 *****************************************************************************/ 356 float p_psNRSpline1DEval(psSpline1D *spline, 357 const psVector* restrict x, 358 const psVector* restrict y, 359 float X) 360 { 361 int n; 362 int klo; 363 int khi; 364 float H; 365 float A; 366 float B; 367 float C; 368 float D; 369 float Y; 370 371 n = spline->n; 372 klo = p_psVectorBinDisectF32(spline->domains, (spline->n)+1, X); 373 khi = klo + 1; 374 H = (spline->domains)[khi] - (spline->domains)[klo]; 375 A = ((spline->domains)[khi] - X) / H; 376 B = (X - (spline->domains)[klo]) / H; 377 C = ((A*A*A)-A) * (H*H/6.0); 378 D = ((B*B*B)-B) * (H*H/6.0); 379 380 Y = (A * y->data.F32[klo]) + 381 (B * y->data.F32[khi]) + 382 (C * (spline->p_psDeriv2)[klo]) + 383 (D * (spline->p_psDeriv2)[khi]); 384 385 return(Y); 386 } 387 336 388 337 389 /****************************************************************************** … … 687 739 } 688 740 689 690 #define STEP_SIZE 0.10691 741 /****************************************************************************** 692 This routine takes as input an arbitrary function, and the parameter to 693 vary, and the line along which it must vary. This function produces as 694 output a bracket [a, b, c] such that 742 p_psDetermineBracket(): This routine takes as input an arbitrary function, 743 and the parameter to vary, and the line along which it must vary. This 744 function produces as output a bracket [a, b, c] such that 745 695 746 f(param + b * line) is less than f(param + a * line) and 696 747 f(param + c * line). … … 700 751 smaller/larger than b. Repeat this process until a local minimum is 701 752 found. 753 754 702 755 *****************************************************************************/ 703 756 psVector *p_psDetermineBracket(psVector *params, … … 719 772 float new_cDir = 0.0; 720 773 psVector *bracket = psVectorAlloc(3, PS_TYPE_F32); 721 float stepSize = STEP_SIZE;774 float stepSize = DETERMINE_BRACKET_STEP_SIZE; 722 775 psVector *tmp = NULL; 723 776 int i = 0; … … 869 922 return(NULL); 870 923 } 871 872 873 874 875 876 877 878 879 880 881 882 924 883 925 /****************************************************************************** … … 1061 1103 1062 1104 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1105 /****************************************************************************** 1077 1106 This routine must minimize a possibly multi-dimensional function. The -
trunk/psLib/src/math/psPolynomial.c
r1846 r1859 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.3 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09-2 2 01:30:21$9 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-23 04:56:40 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 467 467 for (loop_x = 0; loop_x < myPoly->n; loop_x++) { 468 468 if (myPoly->mask[loop_x] == 0) { 469 psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 10, 470 "polysum+= sum*coeff [%f+= (%f * %f)\n", polySum, xSum, myPoly->coeff[loop_x]); 469 471 polySum += xSum * myPoly->coeff[loop_x]; 470 472 xSum *= x; … … 1687 1689 1688 1690 /***************************************************************************** 1689 VectorBinDisectF32(): This is a private function which takes as input a1691 p_psVectorBinDisectF32(): This is a private function which takes as input a 1690 1692 vector of floating point data as well as a single floating point values. 1691 1693 The input vector values are assumed to be non-decreasing (v[i-1] <= v[j] for … … 1696 1698 XXX: Macro this for a few different types. 1697 1699 *****************************************************************************/ 1698 int VectorBinDisectF32(float *bins,1699 int numBins,1700 float x)1700 int p_psVectorBinDisectF32(float *bins, 1701 int numBins, 1702 float x) 1701 1703 { 1702 1704 int min; … … 1704 1706 int mid; 1705 1707 1706 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectF32", 4,1707 "---- Calling VectorBinDisectF32(%f)\n", x);1708 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4, 1709 "---- Calling p_psVectorBinDisectF32(%f)\n", x); 1708 1710 1709 1711 if ((x < bins[0]) || 1710 1712 (x > bins[numBins-1])) { 1711 1713 psLogMsg(__func__, PS_LOG_WARN, 1712 " VectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",1714 "p_psVectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).", 1713 1715 x, bins[0], bins[numBins-1]); 1714 1716 return(-1); … … 1720 1722 1721 1723 while (min != max) { 1722 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectF32", 4,1724 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4, 1723 1725 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n", 1724 1726 min, mid, max, x, bins[mid]); 1725 1727 1726 1728 if (x == bins[mid]) { 1727 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectF32", 4,1728 "---- Exiting VectorBinDisectF32(): bin %d\n", mid);1729 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4, 1730 "---- Exiting p_psVectorBinDisectF32(): bin %d\n", mid); 1729 1731 return(mid); 1730 1732 } else if (x < bins[mid]) { … … 1736 1738 } 1737 1739 1738 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectF32", 4,1739 "---- Exiting VectorBinDisectF32(): bin %d\n", min);1740 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4, 1741 "---- Exiting p_psVectorBinDisectF32(): bin %d\n", min); 1740 1742 return(min); 1741 1743 } 1742 1744 1743 1745 /***************************************************************************** 1744 VectorBinDisectS32(): integer version of above.1746 p_psVectorBinDisectS32(): integer version of above. 1745 1747 *****************************************************************************/ 1746 int VectorBinDisectS32(int *bins,1747 int numBins,1748 int x)1748 int p_psVectorBinDisectS32(int *bins, 1749 int numBins, 1750 int x) 1749 1751 { 1750 1752 int min; … … 1752 1754 int mid; 1753 1755 1754 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectS32", 4,1755 "---- Calling VectorBinDisectS32(%f)\n", x);1756 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4, 1757 "---- Calling p_psVectorBinDisectS32(%f)\n", x); 1756 1758 1757 1759 if ((x < bins[0]) || 1758 1760 (x > bins[numBins-1])) { 1759 1761 psLogMsg(__func__, PS_LOG_WARN, 1760 " VectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).",1762 "p_psVectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).", 1761 1763 x, bins[0], bins[numBins-1]); 1762 1764 return(-1); … … 1768 1770 1769 1771 while (min != max) { 1770 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectS32", 4,1772 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4, 1771 1773 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n", 1772 1774 min, mid, max, x, bins[mid]); 1773 1775 1774 1776 if (x == bins[mid]) { 1775 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectS32", 4,1776 "---- Exiting VectorBinDisectS32(): bin %d\n", min);1777 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4, 1778 "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min); 1777 1779 return(min); 1778 1780 } else if (x < bins[mid]) { … … 1784 1786 } 1785 1787 1786 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectS32", 4,1787 "---- Exiting VectorBinDisectS32(): bin %d\n", min);1788 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4, 1789 "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min); 1788 1790 return(min); 1789 1791 } 1790 1792 1791 1793 /***************************************************************************** 1792 p_psVectorBinDisect(): A wrapper to the above VectorBinDisect().1794 p_psVectorBinDisect(): A wrapper to the above p_psVectorBinDisect(). 1793 1795 *****************************************************************************/ 1794 1796 int p_psVectorBinDisect(psVector *bins, … … 1801 1803 1802 1804 if (x->type.type == PS_TYPE_S32) { 1803 return( VectorBinDisectS32(bins->data.S32, bins->n, x->data.S32));1805 return(p_psVectorBinDisectS32(bins->data.S32, bins->n, x->data.S32)); 1804 1806 } else if (x->type.type == PS_TYPE_F32) { 1805 return( VectorBinDisectF32(bins->data.F32, bins->n, x->data.F32));1807 return(p_psVectorBinDisectF32(bins->data.F32, bins->n, x->data.F32)); 1806 1808 } else { 1807 1809 // XXX: Generate error message. … … 1879 1881 "---- p_ps1DInterpolateF32() begin ----\n"); 1880 1882 1881 binNum = VectorBinDisectF32(domain, n, x);1883 binNum = p_psVectorBinDisectF32(domain, n, x); 1882 1884 1883 1885 if (0 == numIntPoints%2) { … … 1953 1955 1954 1956 n = spline->n; 1955 binNum = VectorBinDisectF32(spline->domains, (spline->n)+1, x);1957 binNum = p_psVectorBinDisectF32(spline->domains, (spline->n)+1, x); 1956 1958 if (binNum == -1) { 1957 1959 psLogMsg(__func__, PS_LOG_WARN, -
trunk/psLib/src/math/psPolynomial.h
r1846 r1859 12 12 * @author George Gusciora, MHPCC 13 13 * 14 * @version $Revision: 1.2 4$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-09-2 2 01:30:21 $14 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-09-23 04:56:41 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 407 407 psVector *data); 408 408 409 int p_psVectorBinDisectF32(float *bins, 410 int numBins, 411 float x); 412 413 int p_psVectorBinDisectS32(int *bins, 414 int numBins, 415 int x); 416 409 417 int p_psVectorBinDisect(psVector *bins, 410 418 psScalar *x); … … 415 423 psScalar *x); 416 424 425 float p_psNRSpline1DEval(psSpline1D *spline, 426 const psVector* restrict x, 427 const psVector* restrict y, 428 float X); 429 417 430 /* \} */// End of MathGroup Functions 418 431 -
trunk/psLib/src/math/psSpline.c
r1846 r1859 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.3 8$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09-2 2 01:30:21$9 * @version $Revision: 1.39 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-23 04:56:40 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 467 467 for (loop_x = 0; loop_x < myPoly->n; loop_x++) { 468 468 if (myPoly->mask[loop_x] == 0) { 469 psTrace(".psLib.dataManip.psFunctions.p_psOrdPolynomial1DEval", 10, 470 "polysum+= sum*coeff [%f+= (%f * %f)\n", polySum, xSum, myPoly->coeff[loop_x]); 469 471 polySum += xSum * myPoly->coeff[loop_x]; 470 472 xSum *= x; … … 1687 1689 1688 1690 /***************************************************************************** 1689 VectorBinDisectF32(): This is a private function which takes as input a1691 p_psVectorBinDisectF32(): This is a private function which takes as input a 1690 1692 vector of floating point data as well as a single floating point values. 1691 1693 The input vector values are assumed to be non-decreasing (v[i-1] <= v[j] for … … 1696 1698 XXX: Macro this for a few different types. 1697 1699 *****************************************************************************/ 1698 int VectorBinDisectF32(float *bins,1699 int numBins,1700 float x)1700 int p_psVectorBinDisectF32(float *bins, 1701 int numBins, 1702 float x) 1701 1703 { 1702 1704 int min; … … 1704 1706 int mid; 1705 1707 1706 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectF32", 4,1707 "---- Calling VectorBinDisectF32(%f)\n", x);1708 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4, 1709 "---- Calling p_psVectorBinDisectF32(%f)\n", x); 1708 1710 1709 1711 if ((x < bins[0]) || 1710 1712 (x > bins[numBins-1])) { 1711 1713 psLogMsg(__func__, PS_LOG_WARN, 1712 " VectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).",1714 "p_psVectorBinDisectF32(): ordinate %f is outside vector range (%f - %f).", 1713 1715 x, bins[0], bins[numBins-1]); 1714 1716 return(-1); … … 1720 1722 1721 1723 while (min != max) { 1722 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectF32", 4,1724 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4, 1723 1725 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n", 1724 1726 min, mid, max, x, bins[mid]); 1725 1727 1726 1728 if (x == bins[mid]) { 1727 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectF32", 4,1728 "---- Exiting VectorBinDisectF32(): bin %d\n", mid);1729 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4, 1730 "---- Exiting p_psVectorBinDisectF32(): bin %d\n", mid); 1729 1731 return(mid); 1730 1732 } else if (x < bins[mid]) { … … 1736 1738 } 1737 1739 1738 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectF32", 4,1739 "---- Exiting VectorBinDisectF32(): bin %d\n", min);1740 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4, 1741 "---- Exiting p_psVectorBinDisectF32(): bin %d\n", min); 1740 1742 return(min); 1741 1743 } 1742 1744 1743 1745 /***************************************************************************** 1744 VectorBinDisectS32(): integer version of above.1746 p_psVectorBinDisectS32(): integer version of above. 1745 1747 *****************************************************************************/ 1746 int VectorBinDisectS32(int *bins,1747 int numBins,1748 int x)1748 int p_psVectorBinDisectS32(int *bins, 1749 int numBins, 1750 int x) 1749 1751 { 1750 1752 int min; … … 1752 1754 int mid; 1753 1755 1754 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectS32", 4,1755 "---- Calling VectorBinDisectS32(%f)\n", x);1756 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4, 1757 "---- Calling p_psVectorBinDisectS32(%f)\n", x); 1756 1758 1757 1759 if ((x < bins[0]) || 1758 1760 (x > bins[numBins-1])) { 1759 1761 psLogMsg(__func__, PS_LOG_WARN, 1760 " VectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).",1762 "p_psVectorBinDisectS32(): ordinate %f is outside vector range (%f - %f).", 1761 1763 x, bins[0], bins[numBins-1]); 1762 1764 return(-1); … … 1768 1770 1769 1771 while (min != max) { 1770 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectS32", 4,1772 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4, 1771 1773 "(min, mid, max) is (%d, %d, %d): (x, bins) is (%f, %f)\n", 1772 1774 min, mid, max, x, bins[mid]); 1773 1775 1774 1776 if (x == bins[mid]) { 1775 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectS32", 4,1776 "---- Exiting VectorBinDisectS32(): bin %d\n", min);1777 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4, 1778 "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min); 1777 1779 return(min); 1778 1780 } else if (x < bins[mid]) { … … 1784 1786 } 1785 1787 1786 psTrace(".psLib.dataManip.psFunctions. VectorBinDisectS32", 4,1787 "---- Exiting VectorBinDisectS32(): bin %d\n", min);1788 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4, 1789 "---- Exiting p_psVectorBinDisectS32(): bin %d\n", min); 1788 1790 return(min); 1789 1791 } 1790 1792 1791 1793 /***************************************************************************** 1792 p_psVectorBinDisect(): A wrapper to the above VectorBinDisect().1794 p_psVectorBinDisect(): A wrapper to the above p_psVectorBinDisect(). 1793 1795 *****************************************************************************/ 1794 1796 int p_psVectorBinDisect(psVector *bins, … … 1801 1803 1802 1804 if (x->type.type == PS_TYPE_S32) { 1803 return( VectorBinDisectS32(bins->data.S32, bins->n, x->data.S32));1805 return(p_psVectorBinDisectS32(bins->data.S32, bins->n, x->data.S32)); 1804 1806 } else if (x->type.type == PS_TYPE_F32) { 1805 return( VectorBinDisectF32(bins->data.F32, bins->n, x->data.F32));1807 return(p_psVectorBinDisectF32(bins->data.F32, bins->n, x->data.F32)); 1806 1808 } else { 1807 1809 // XXX: Generate error message. … … 1879 1881 "---- p_ps1DInterpolateF32() begin ----\n"); 1880 1882 1881 binNum = VectorBinDisectF32(domain, n, x);1883 binNum = p_psVectorBinDisectF32(domain, n, x); 1882 1884 1883 1885 if (0 == numIntPoints%2) { … … 1953 1955 1954 1956 n = spline->n; 1955 binNum = VectorBinDisectF32(spline->domains, (spline->n)+1, x);1957 binNum = p_psVectorBinDisectF32(spline->domains, (spline->n)+1, x); 1956 1958 if (binNum == -1) { 1957 1959 psLogMsg(__func__, PS_LOG_WARN, -
trunk/psLib/src/math/psSpline.h
r1846 r1859 12 12 * @author George Gusciora, MHPCC 13 13 * 14 * @version $Revision: 1.2 4$ $Name: not supported by cvs2svn $15 * @date $Date: 2004-09-2 2 01:30:21 $14 * @version $Revision: 1.25 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2004-09-23 04:56:41 $ 16 16 * 17 17 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 407 407 psVector *data); 408 408 409 int p_psVectorBinDisectF32(float *bins, 410 int numBins, 411 float x); 412 413 int p_psVectorBinDisectS32(int *bins, 414 int numBins, 415 int x); 416 409 417 int p_psVectorBinDisect(psVector *bins, 410 418 psScalar *x); … … 415 423 psScalar *x); 416 424 425 float p_psNRSpline1DEval(psSpline1D *spline, 426 const psVector* restrict x, 427 const psVector* restrict y, 428 float X); 429 417 430 /* \} */// End of MathGroup Functions 418 431
Note:
See TracChangeset
for help on using the changeset viewer.
