Changeset 3096 for trunk/psLib/src/math/psPolynomial.c
- Timestamp:
- Jan 26, 2005, 10:41:04 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psPolynomial.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psPolynomial.c
r3027 r3096 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.8 3$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-01- 17 23:25:09$9 * @version $Revision: 1.84 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-01-26 20:41:04 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 92 92 psFree(tmpSpline->p_psDeriv2); 93 93 } 94 psFree(tmpSpline-> domains);94 psFree(tmpSpline->knots); 95 95 96 96 return; … … 1833 1833 // psPolynomial1D **spline; 1834 1834 // psF32 *p_psDeriv2; 1835 // ps F32 *domains;1835 // psVector *knots; 1836 1836 //} psSpline1D; 1837 1837 1838 1838 /***************************************************************************** 1839 1839 NOTE: "n" specifies the number of spline polynomials. Therefore, there 1840 must exist n+1 points in " domains".1840 must exist n+1 points in "knots". 1841 1841 1842 1842 XXX: Ensure that domain[i+1] != domain[i] … … 1867 1867 tmp->p_psDeriv2 = NULL; 1868 1868 1869 tmp-> domains = (psF32 *) psAlloc((numSplines+1) * sizeof(psF32));1869 tmp->knots = psVectorAlloc(numSplines+1, PS_TYPE_F32); 1870 1870 width = (max - min) / ((psF32) numSplines); 1871 1871 1872 (tmp->domains)[0] = min;1872 tmp->knots->data.F32[0] = min; 1873 1873 tmpDomain = min+width; 1874 1874 for (i=1;i<numSplines+1;i++) { 1875 (tmp->domains)[i] = tmpDomain;1875 tmp->knots->data.F32[i] = tmpDomain; 1876 1876 tmpDomain+= width; 1877 1877 } 1878 (tmp->domains)[numSplines] = max;1878 tmp->knots->data.F32[numSplines] = max; 1879 1879 1880 1880 p_psMemSetDeallocator(tmp,(psFreeFcn)spline1DFree); … … 1909 1909 tmp->p_psDeriv2 = NULL; 1910 1910 1911 tmp-> domains = (psF32 *) psAlloc((bounds->n) * sizeof(psF32));1911 tmp->knots = psVectorAlloc(bounds->n, PS_TYPE_F32); 1912 1912 1913 1913 for (i=0;i<bounds->n;i++) { 1914 (tmp->domains)[i] = bounds->data.F32[i];1914 tmp->knots->data.F32[i] = bounds->data.F32[i]; 1915 1915 if (i<(bounds->n-1)) { 1916 1916 if (FLT_EPSILON >= fabs(bounds->data.F32[i+1]-bounds->data.F32[i])) { … … 2136 2136 psSpline1DEval(): this routine takes an existing spline of arbitrary order 2137 2137 and an independent x value. Each determines which spline that x corresponds 2138 to by doing a bracket disection on the domains of the spline data structure2138 to by doing a bracket disection on the knots of the spline data structure 2139 2139 (vectorBinDisectF32()). Then it evaluates the spline at that x location 2140 2140 by a call to the 1D polynomial functions. … … 2155 2155 2156 2156 n = spline->n; 2157 binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x); 2157 //XXX binNum = vectorBinDisectF32(spline->domains, (spline->n)+1, x); 2158 binNum = vectorBinDisectF32(spline->knots->data.F32, (spline->n)+1, x); 2158 2159 if (binNum < 0) { 2159 2160 psLogMsg(__func__, PS_LOG_WARN, 2160 2161 "psSpline1DEval(): x ordinate (%f) is outside the spline range (%f - %f).", 2161 x, (spline->domains)[0],2162 (spline->domains)[n-1]);2163 2164 if (x < (spline->domains)[0]) {2162 x, spline->knots->data.F32[0], 2163 spline->knots->data.F32[n-1]); 2164 2165 if (x < spline->knots->data.F32[0]) { 2165 2166 return(psPolynomial1DEval(spline->spline[0], 2166 2167 x)); 2167 } else if (x > (spline->domains)[n-1]) {2168 } else if (x > spline->knots->data.F32[n-1]) { 2168 2169 return(psPolynomial1DEval(spline->spline[n-1], 2169 2170 x));
Note:
See TracChangeset
for help on using the changeset viewer.
