Changeset 1861 for trunk/psLib/src/math/psPolynomial.c
- Timestamp:
- Sep 22, 2004, 8:12:22 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psPolynomial.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psPolynomial.c
r1859 r1861 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1. 39$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09-23 0 4:56:40$9 * @version $Revision: 1.40 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-23 06:12:22 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 1661 1661 1662 1662 /***************************************************************************** 1663 XXX: Ensure that domain[i+1] != domain[i]1664 1663 *****************************************************************************/ 1665 1664 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds, … … 1681 1680 1682 1681 tmp->domains = (float *) psAlloc((bounds->n) * sizeof(float)); 1682 1683 1683 for (i=0;i<bounds->n;i++) { 1684 1684 (tmp->domains)[i] = bounds->data.F32[i]; 1685 if (i<(bounds->n-1)) { 1686 if (FLT_EPSILON < fabs(bounds->data.F32[i+1]-bounds->data.F32[i])) { 1687 // XXX: psErrorMsg(data points must be distinct) 1688 } 1689 } 1685 1690 } 1686 1691 … … 1697 1702 1698 1703 XXX: Macro this for a few different types. 1704 1705 XXX: name since we don't take psVectors as input. 1699 1706 *****************************************************************************/ 1700 1707 int p_psVectorBinDisectF32(float *bins, … … 1867 1874 1868 1875 1869 // This is a 1876 /***************************************************************************** 1877 p_ps1DInterpolateF32(): this is the base 1-D flat memory routine to perform 1878 LaGrange interpolation. 1879 *****************************************************************************/ 1870 1880 float p_ps1DInterpolateF32(float *domain, 1871 1881 float *range, … … 1910 1920 order around the point x. 1911 1921 1912 XXX: This stuff does not work with a mask. 1922 XXX: This stuff does not currently work with a mask. 1923 1924 XXX: nobody asked for us to generate this routine. 1913 1925 *****************************************************************************/ 1914 1926 psScalar *p_psVectorInterpolate(psVector *domain, … … 1948 1960 1949 1961 1962 /***************************************************************************** 1963 psSpline1DEval(): this routine takes an existing spline of arbitrary order 1964 and an independent x value. Each determines which spline that x corresponds 1965 to by doing a bracket disection on the domains of the spline data structure 1966 (p_psVectorBinDisectF32()). Then it evaluates the spline at that x location 1967 by a call to the 1D polynomial functions. 1968 1969 XXX: SDR is silent about data types. PS_TYPE_F32 is implemented. 1970 *****************************************************************************/ 1950 1971 float psSpline1DEval(const psSpline1D *spline, 1951 1972 float x) … … 1985 2006 return(tmpVector); 1986 2007 } 1987 1988 1989 1990 /*****************************************************************************1991 psSpline1DGen(): This routine will take an existing spline data structure,1992 along with a set of data values for each of the domains, and fit splines of1993 the specified order (currently, linear only), and set the coefficients in the1994 appropriate spline polynomials. This function is not part of the API in the1995 latest SDR, but I'm guessing it will be, and I need it to generate test1996 cases, so I included it here.1997 *****************************************************************************/1998 1999 psSpline1D *psSpline1DGen(const psSpline1D *spline,2000 psVector *data)2001 {2002 int i;2003 float slope;2004 2005 psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,2006 "---- Calling psSpline1DGen()\n");2007 2008 if (data->n != (1 + spline->n)) {2009 psLogMsg(__func__, PS_LOG_WARN,2010 "data size / spline size mismatch (%d %d)\n",2011 data->n, spline->n);2012 return(NULL);2013 }2014 // XXX: verify your math2015 if (2 == (spline->spline[0])->n) {2016 for (i=0;i<spline->n;i++) {2017 slope = (data->data.F32[i+1] - data->data.F32[i]) /2018 (spline->domains[i+1] - spline->domains[i]);2019 (spline->spline[i])->coeff[0] = data->data.F32[i] -2020 (slope * spline->domains[i]);2021 //printf("HMMM (%f, %f, %f)\n", data->data.F32[i], slope, spline->domains[i]);2022 2023 (spline->spline[i])->coeff[1] = slope;2024 psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,2025 "---- spline %d coeffs are (%f, %f)\n", i,2026 (spline->spline[i])->coeff[0],2027 (spline->spline[i])->coeff[1]);2028 }2029 psTrace(".psLib.dataManip.psFunctions.psSpline1DGen", 4,2030 "---- Exiting psSpline1DGen()\n");2031 return((psSpline1D *) spline);2032 } else if (4 == (spline->spline[0])->n) {2033 psLogMsg(__func__, PS_LOG_WARN,2034 "Cubic splines have not been implemented.");2035 return(NULL);2036 } else {2037 psLogMsg(__func__, PS_LOG_WARN,2038 "Don't know how to generate %d-order splines.",2039 (spline->spline[0])->n-1);2040 return(NULL);2041 }2042 }
Note:
See TracChangeset
for help on using the changeset viewer.
