Changeset 1831 for trunk/psLib/src/math/psSpline.c
- Timestamp:
- Sep 17, 2004, 3:50:45 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psSpline.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psSpline.c
r1823 r1831 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.3 6$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-09-1 7 02:14:52$9 * @version $Revision: 1.37 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-09-18 01:50:45 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 1809 1809 p_psInterpolate1D(): This routine will take as input n-element floating 1810 1810 point arrays domain and range, and the x value, assumed to lie with the 1811 domain vector. It produces as output the n-order LaGrange interpolated1811 domain vector. It produces as output the (n-1)-order LaGrange interpolated 1812 1812 value of x. 1813 1813 1814 1814 XXX: do we error check for non-distinct domain values? 1815 1815 *****************************************************************************/ 1816 float p_ps FullInterpolate1DF32(float *domain,1816 float p_ps1DFullInterpolateF32(float *domain, 1817 1817 float *range, 1818 1818 int n, … … 1822 1822 int m; 1823 1823 static psVector *p = NULL; 1824 p sVectorRecycle(p, n, PS_TYPE_F32);1824 p = psVectorRecycle(p, n, PS_TYPE_F32); 1825 1825 p_psMemSetPersistent(p, true); 1826 p_psMemSetPersistent(p->data.F32, true); 1827 1828 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4, 1829 "---- p_ps1DFullInterpolateF32() begin (%d-order at x=%f) (%d data points)----\n", n-1, x, n); 1830 1831 for (i=0;i<n;i++) { 1832 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6, 1833 "domain/range is (%f %f)\n", domain[i], range[i]); 1834 } 1835 1836 for (i=0;i<n;i++) { 1837 p->data.F32[i] = range[i]; 1838 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6, 1839 "p->data.F32[%d] is %f\n", i, p->data.F32[i]); 1840 1841 } 1826 1842 1827 1843 // From NR, during each iteration of the m loop, we are computing the 1828 1844 // p_{i ... i+m} terms. 1829 for (m= 0;m<n;m++) {1845 for (m=1;m<n;m++) { 1830 1846 for (i=0;i<n-m;i++) { 1831 if (m == 0) { 1832 p->data.F32[i] = range[i]; 1833 } else { 1834 // From NR: we are computing P_{i ... i+m} 1835 p->data.F32[i] = (((x-range[i+m]) * p->data.F32[i]) + 1836 ((range[i]-x) * p->data.F32[i+1])) / 1837 (domain[i] - domain[i+m]); 1838 } 1839 } 1840 } 1847 // From NR: we are computing P_{i ... i+m} 1848 p->data.F32[i] = (((x-domain[i+m]) * p->data.F32[i]) + 1849 ((domain[i]-x) * p->data.F32[i+1])) / 1850 (domain[i] - domain[i+m]); 1851 //printf("((%f-%f * %f) + (%f-%f * %f)) / (%f - %f)\n", x, domain[i+m], p->data.F32[i], domain[i], x, p->data.F32[i+1], domain[i], domain[i+m]); 1852 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 6, 1853 "p->data.F32[%d] is %f\n", i, p->data.F32[i]); 1854 } 1855 } 1856 psTrace(".psLib.dataManip.psFunctions.p_ps1DFullInterpolateF32", 4, 1857 "---- p_ps1DFullInterpolateF32() end ----\n"); 1858 1841 1859 return(p->data.F32[0]); 1842 1860 } … … 1844 1862 1845 1863 // This is a 1846 float p_ps Interpolate1DF32(float *domain,1864 float p_ps1DInterpolateF32(float *domain, 1847 1865 float *range, 1848 1866 int n, … … 1854 1872 int origin; 1855 1873 1874 psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4, 1875 "---- p_ps1DInterpolateF32() begin ----\n"); 1876 1856 1877 binNum = VectorBinDisectF32(domain, n, x); 1878 1857 1879 if (0 == numIntPoints%2) { 1858 1880 origin = binNum - ((numIntPoints/2) - 1); … … 1871 1893 } 1872 1894 1873 return(p_psFullInterpolate1DF32(&domain[origin], &range[origin], n, x)); 1895 psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4, 1896 "---- p_ps1DInterpolateF32() end ----\n"); 1897 return(p_ps1DFullInterpolateF32(&domain[origin], &range[origin], order+1, x)); 1874 1898 } 1875 1899 … … 1882 1906 XXX: This stuff does not work with a mask. 1883 1907 *****************************************************************************/ 1884 float p_psInterpolate1D(psVector *domain, 1885 psVector *range, 1886 int order, 1887 psScalar *x) 1888 { 1908 psScalar *p_psVectorInterpolate(psVector *domain, 1909 psVector *range, 1910 int order, 1911 psScalar *x) 1912 { 1913 psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4, 1914 "---- p_psVectorInterpolate() begin ----\n"); 1915 1889 1916 if (domain->type.type != range->type.type != x->type.type) { 1890 1917 // XXX psError … … 1898 1925 1899 1926 if (x->type.type == PS_TYPE_F32) { 1900 return(p_psInterpolate1DF32(domain->data.F32, range->data.F32, 1901 domain->n, order, x->data.F32)); 1927 psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4, 1928 "---- p_psVectorInterpolate() end ----\n"); 1929 return(psScalarAlloc(p_ps1DInterpolateF32(domain->data.F32, 1930 range->data.F32, 1931 domain->n, 1932 order, 1933 x->data.F32), PS_TYPE_F32)); 1902 1934 } else { 1903 1935 // XXX psError: type not supported 1904 1936 } 1905 1937 1906 return(-1.0); 1938 psTrace(".psLib.dataManip.psFunctions.p_psVectorInterpolate", 4, 1939 "---- p_psVectorInterpolate() end ----\n"); 1940 return(NULL); 1907 1941 } 1908 1942
Note:
See TracChangeset
for help on using the changeset viewer.
