Changeset 2204 for trunk/psLib/src/math/psPolynomial.c
- Timestamp:
- Oct 26, 2004, 2:57:34 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psPolynomial.c (modified) (57 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psPolynomial.c
r2197 r2204 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1.5 3$ $Name: not supported by cvs2svn $10 * @date $Date: 2004-10-2 6 21:24:42$9 * @version $Revision: 1.54 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2004-10-27 00:57:31 $ 11 11 * 12 12 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 50 50 \ 51 51 if (IN->type.type == PS_TYPE_F64) { \ 52 for ( inti=0;i<IN->n;i++) { \52 for (psS32 i=0;i<IN->n;i++) { \ 53 53 OUT->data.F32[i] = (float) (IN->data.F64[i]); \ 54 54 } \ … … 69 69 \ 70 70 if (IN->type.type == PS_TYPE_F32) { \ 71 for ( inti=0;i<IN->n;i++) { \71 for (psS32 i=0;i<IN->n;i++) { \ 72 72 OUT->data.F64[i] = (float) (IN->data.F32[i]); \ 73 73 } \ … … 117 117 outer coefficients of the Chebyshev polynomials. 118 118 *****************************************************************************/ 119 static psPolynomial1D **CreateChebyshevPolys( intmaxChebyPoly)119 static psPolynomial1D **CreateChebyshevPolys(psS32 maxChebyPoly) 120 120 { 121 121 psPolynomial1D **chebPolys = NULL; 122 inti = 0;123 intj = 0;122 psS32 i = 0; 123 psS32 j = 0; 124 124 125 125 chebPolys = (psPolynomial1D **) psAlloc(maxChebyPoly * sizeof(psPolynomial1D *)); … … 153 153 evaluated Gaussian is: \f[ exp(-\frac{(x-mean)^2}{2\sigma^2}) \f] 154 154 *****************************************************************************/ 155 float psGaussian(float x, float mean, float sigma, bool normal)155 float psGaussian(float x, float mean, float sigma, psBool normal) 156 156 { 157 157 float tmp = 1.0; … … 185 185 NOTE: XXX: There is no way to seed the random generator. 186 186 *****************************************************************************/ 187 psVector* psGaussianDev(float mean, float sigma, intNpts)187 psVector* psGaussianDev(float mean, float sigma, psS32 Npts) 188 188 { 189 189 psVector* gauss = NULL; 190 190 const gsl_rng_type *T = NULL; 191 191 gsl_rng *r = NULL; 192 inti = 0;192 psS32 i = 0; 193 193 194 194 gauss = psVectorAlloc(Npts, PS_TYPE_F32); … … 209 209 This routine must allocate memory for the polynomial structures. 210 210 *****************************************************************************/ 211 psPolynomial1D* psPolynomial1DAlloc( intn,211 psPolynomial1D* psPolynomial1DAlloc(psS32 n, 212 212 psPolynomialType type) 213 213 { 214 inti = 0;214 psS32 i = 0; 215 215 psPolynomial1D* newPoly = NULL; 216 216 … … 232 232 } 233 233 234 psPolynomial2D* psPolynomial2DAlloc( int nX, intnY,234 psPolynomial2D* psPolynomial2DAlloc(psS32 nX, psS32 nY, 235 235 psPolynomialType type) 236 236 { 237 intx = 0;238 inty = 0;237 psS32 x = 0; 238 psS32 y = 0; 239 239 psPolynomial2D* newPoly = NULL; 240 240 … … 265 265 } 266 266 267 psPolynomial3D* psPolynomial3DAlloc( int nX, int nY, intnZ,267 psPolynomial3D* psPolynomial3DAlloc(psS32 nX, psS32 nY, psS32 nZ, 268 268 psPolynomialType type) 269 269 { 270 intx = 0;271 inty = 0;272 intz = 0;270 psS32 x = 0; 271 psS32 y = 0; 272 psS32 z = 0; 273 273 psPolynomial3D* newPoly = NULL; 274 274 … … 307 307 } 308 308 309 psPolynomial4D* psPolynomial4DAlloc( int nW, int nX, int nY, intnZ,309 psPolynomial4D* psPolynomial4DAlloc(psS32 nW, psS32 nX, psS32 nY, psS32 nZ, 310 310 psPolynomialType type) 311 311 { 312 intw = 0;313 intx = 0;314 inty = 0;315 intz = 0;312 psS32 w = 0; 313 psS32 x = 0; 314 psS32 y = 0; 315 psS32 z = 0; 316 316 psPolynomial4D* newPoly = NULL; 317 317 … … 367 367 static void polynomial2DFree(psPolynomial2D* myPoly) 368 368 { 369 intx = 0;369 psS32 x = 0; 370 370 371 371 for (x = 0; x < myPoly->nX; x++) { … … 381 381 static void polynomial3DFree(psPolynomial3D* myPoly) 382 382 { 383 intx = 0;384 inty = 0;383 psS32 x = 0; 384 psS32 y = 0; 385 385 386 386 for (x = 0; x < myPoly->nX; x++) { … … 402 402 static void polynomial4DFree(psPolynomial4D* myPoly) 403 403 { 404 intw = 0;405 intx = 0;406 inty = 0;404 psS32 w = 0; 405 psS32 x = 0; 406 psS32 y = 0; 407 407 408 408 for (w = 0; w < myPoly->nW; w++) { … … 434 434 float p_psOrdPolynomial1DEval(float x, const psPolynomial1D* myPoly) 435 435 { 436 intloop_x = 0;436 psS32 loop_x = 0; 437 437 float polySum = 0.0; 438 438 float xSum = 1.0; … … 478 478 { 479 479 psVector *d; 480 intn;481 inti;480 psS32 n; 481 psS32 i; 482 482 float tmp; 483 483 … … 500 500 /* 501 501 502 intn;503 inti;502 psS32 n; 503 psS32 i; 504 504 float tmp; 505 505 psPolynomial1D **chebPolys = NULL; … … 537 537 psVector *tmp; 538 538 psVector *myX; 539 inti;539 psS32 i; 540 540 541 541 PS_CONVERT_VECTOR_F32(x, myX); … … 555 555 float p_psOrdPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly) 556 556 { 557 intloop_x = 0;558 intloop_y = 0;557 psS32 loop_x = 0; 558 psS32 loop_y = 0; 559 559 float polySum = 0.0; 560 560 float xSum = 1.0; … … 577 577 float p_psChebPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly) 578 578 { 579 intloop_x = 0;580 intloop_y = 0;581 inti = 0;579 psS32 loop_x = 0; 580 psS32 loop_y = 0; 581 psS32 i = 0; 582 582 float polySum = 0.0; 583 583 psPolynomial1D* *chebPolys = NULL; 584 intmaxChebyPoly = 0;584 psS32 maxChebyPoly = 0; 585 585 586 586 // Determine how many Chebyshev polynomials … … 628 628 psVector *myX; 629 629 psVector *myY; 630 inti;631 intvecLen=x->n;630 psS32 i; 631 psS32 vecLen=x->n; 632 632 633 633 PS_CONVERT_VECTOR_F32(x, myX); … … 658 658 float p_psOrdPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly) 659 659 { 660 intloop_x = 0;661 intloop_y = 0;662 intloop_z = 0;660 psS32 loop_x = 0; 661 psS32 loop_y = 0; 662 psS32 loop_z = 0; 663 663 float polySum = 0.0; 664 664 float xSum = 1.0; … … 686 686 float p_psChebPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly) 687 687 { 688 intloop_x = 0;689 intloop_y = 0;690 intloop_z = 0;691 inti = 0;688 psS32 loop_x = 0; 689 psS32 loop_y = 0; 690 psS32 loop_z = 0; 691 psS32 i = 0; 692 692 float polySum = 0.0; 693 693 psPolynomial1D* *chebPolys = NULL; 694 intmaxChebyPoly = 0;694 psS32 maxChebyPoly = 0; 695 695 696 696 // Determine how many Chebyshev polynomials … … 746 746 psVector *myY; 747 747 psVector *myZ; 748 inti;749 intvecLen=x->n;748 psS32 i; 749 psS32 vecLen=x->n; 750 750 751 751 PS_CONVERT_VECTOR_F32(x, myX); … … 787 787 float p_psOrdPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly) 788 788 { 789 intloop_w = 0;790 intloop_x = 0;791 intloop_y = 0;792 intloop_z = 0;789 psS32 loop_w = 0; 790 psS32 loop_x = 0; 791 psS32 loop_y = 0; 792 psS32 loop_z = 0; 793 793 float polySum = 0.0; 794 794 float wSum = 1.0; … … 821 821 float p_psChebPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly) 822 822 { 823 intloop_w = 0;824 intloop_x = 0;825 intloop_y = 0;826 intloop_z = 0;827 inti = 0;823 psS32 loop_w = 0; 824 psS32 loop_x = 0; 825 psS32 loop_y = 0; 826 psS32 loop_z = 0; 827 psS32 i = 0; 828 828 float polySum = 0.0; 829 829 psPolynomial1D* *chebPolys = NULL; 830 intmaxChebyPoly = 0;830 psS32 maxChebyPoly = 0; 831 831 832 832 // Determine how many Chebyshev polynomials … … 890 890 psVector *myY; 891 891 psVector *myZ; 892 inti;893 intvecLen=x->n;892 psS32 i; 893 psS32 vecLen=x->n; 894 894 895 895 PS_CONVERT_VECTOR_F32(w, myW); … … 936 936 937 937 938 psDPolynomial1D* psDPolynomial1DAlloc( intn,938 psDPolynomial1D* psDPolynomial1DAlloc(psS32 n, 939 939 psPolynomialType type) 940 940 { 941 inti = 0;941 psS32 i = 0; 942 942 psDPolynomial1D* newPoly = NULL; 943 943 … … 959 959 } 960 960 961 psDPolynomial2D* psDPolynomial2DAlloc( int nX, intnY,961 psDPolynomial2D* psDPolynomial2DAlloc(psS32 nX, psS32 nY, 962 962 psPolynomialType type) 963 963 { 964 intx = 0;965 inty = 0;964 psS32 x = 0; 965 psS32 y = 0; 966 966 psDPolynomial2D* newPoly = NULL; 967 967 … … 992 992 } 993 993 994 psDPolynomial3D* psDPolynomial3DAlloc( int nX, int nY, intnZ,994 psDPolynomial3D* psDPolynomial3DAlloc(psS32 nX, psS32 nY, psS32 nZ, 995 995 psPolynomialType type) 996 996 { 997 intx = 0;998 inty = 0;999 intz = 0;997 psS32 x = 0; 998 psS32 y = 0; 999 psS32 z = 0; 1000 1000 psDPolynomial3D* newPoly = NULL; 1001 1001 … … 1034 1034 } 1035 1035 1036 psDPolynomial4D* psDPolynomial4DAlloc( int nW, int nX, int nY, intnZ,1036 psDPolynomial4D* psDPolynomial4DAlloc(psS32 nW, psS32 nX, psS32 nY, psS32 nZ, 1037 1037 psPolynomialType type) 1038 1038 { 1039 intw = 0;1040 intx = 0;1041 inty = 0;1042 intz = 0;1039 psS32 w = 0; 1040 psS32 x = 0; 1041 psS32 y = 0; 1042 psS32 z = 0; 1043 1043 psDPolynomial4D* newPoly = NULL; 1044 1044 … … 1094 1094 static void dPolynomial2DFree(psDPolynomial2D* myPoly) 1095 1095 { 1096 intx = 0;1096 psS32 x = 0; 1097 1097 1098 1098 for (x = 0; x < myPoly->nX; x++) { … … 1108 1108 static void dPolynomial3DFree(psDPolynomial3D* myPoly) 1109 1109 { 1110 intx = 0;1111 inty = 0;1110 psS32 x = 0; 1111 psS32 y = 0; 1112 1112 1113 1113 for (x = 0; x < myPoly->nX; x++) { … … 1129 1129 static void dPolynomial4DFree(psDPolynomial4D* myPoly) 1130 1130 { 1131 intw = 0;1132 intx = 0;1133 inty = 0;1131 psS32 w = 0; 1132 psS32 x = 0; 1133 psS32 y = 0; 1134 1134 1135 1135 for (w = 0; w < myPoly->nW; w++) { … … 1159 1159 double p_psDOrdPolynomial1DEval(double x, const psDPolynomial1D* myPoly) 1160 1160 { 1161 intloop_x = 0;1161 psS32 loop_x = 0; 1162 1162 double polySum = 0.0; 1163 1163 double xSum = 1.0; … … 1183 1183 { 1184 1184 psVector *d; 1185 intn;1186 inti;1185 psS32 n; 1186 psS32 i; 1187 1187 double tmp; 1188 1188 … … 1222 1222 psVector *tmp; 1223 1223 psVector *myX; 1224 inti;1224 psS32 i; 1225 1225 1226 1226 PS_CONVERT_VECTOR_F64(x, myX); … … 1241 1241 double p_psDOrdPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly) 1242 1242 { 1243 intloop_x = 0;1244 intloop_y = 0;1243 psS32 loop_x = 0; 1244 psS32 loop_y = 0; 1245 1245 double polySum = 0.0; 1246 1246 double xSum = 1.0; … … 1263 1263 double p_psDChebPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly) 1264 1264 { 1265 intloop_x = 0;1266 intloop_y = 0;1267 inti = 0;1265 psS32 loop_x = 0; 1266 psS32 loop_y = 0; 1267 psS32 i = 0; 1268 1268 double polySum = 0.0; 1269 1269 psPolynomial1D* *chebPolys = NULL; 1270 intmaxChebyPoly = 0;1270 psS32 maxChebyPoly = 0; 1271 1271 1272 1272 // Determine how many Chebyshev polynomials … … 1314 1314 psVector *myX; 1315 1315 psVector *myY; 1316 inti;1317 intvecLen=x->n;1316 psS32 i; 1317 psS32 vecLen=x->n; 1318 1318 1319 1319 PS_CONVERT_VECTOR_F64(x, myX); … … 1344 1344 double p_psDOrdPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly) 1345 1345 { 1346 intloop_x = 0;1347 intloop_y = 0;1348 intloop_z = 0;1346 psS32 loop_x = 0; 1347 psS32 loop_y = 0; 1348 psS32 loop_z = 0; 1349 1349 double polySum = 0.0; 1350 1350 double xSum = 1.0; … … 1372 1372 double p_psDChebPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly) 1373 1373 { 1374 intloop_x = 0;1375 intloop_y = 0;1376 intloop_z = 0;1377 inti = 0;1374 psS32 loop_x = 0; 1375 psS32 loop_y = 0; 1376 psS32 loop_z = 0; 1377 psS32 i = 0; 1378 1378 double polySum = 0.0; 1379 1379 psPolynomial1D* *chebPolys = NULL; 1380 intmaxChebyPoly = 0;1380 psS32 maxChebyPoly = 0; 1381 1381 1382 1382 // Determine how many Chebyshev polynomials … … 1432 1432 psVector *myY; 1433 1433 psVector *myZ; 1434 inti;1435 intvecLen=x->n;1434 psS32 i; 1435 psS32 vecLen=x->n; 1436 1436 1437 1437 PS_CONVERT_VECTOR_F64(x, myX); … … 1475 1475 double p_psDOrdPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly) 1476 1476 { 1477 intloop_w = 0;1478 intloop_x = 0;1479 intloop_y = 0;1480 intloop_z = 0;1477 psS32 loop_w = 0; 1478 psS32 loop_x = 0; 1479 psS32 loop_y = 0; 1480 psS32 loop_z = 0; 1481 1481 double polySum = 0.0; 1482 1482 double wSum = 1.0; … … 1509 1509 double p_psDChebPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly) 1510 1510 { 1511 intloop_w = 0;1512 intloop_x = 0;1513 intloop_y = 0;1514 intloop_z = 0;1515 inti = 0;1511 psS32 loop_w = 0; 1512 psS32 loop_x = 0; 1513 psS32 loop_y = 0; 1514 psS32 loop_z = 0; 1515 psS32 i = 0; 1516 1516 double polySum = 0.0; 1517 1517 psPolynomial1D* *chebPolys = NULL; 1518 intmaxChebyPoly = 0;1518 psS32 maxChebyPoly = 0; 1519 1519 1520 1520 // Determine how many Chebyshev polynomials … … 1578 1578 psVector *myY; 1579 1579 psVector *myZ; 1580 inti;1581 intvecLen=x->n;1580 psS32 i; 1581 psS32 vecLen=x->n; 1582 1582 1583 1583 PS_CONVERT_VECTOR_F64(w, myW); … … 1624 1624 1625 1625 //typedef struct { 1626 // intn;1626 // psS32 n; 1627 1627 // psPolynomial1D **spline; 1628 1628 // float *p_psDeriv2; … … 1636 1636 XXX: Ensure that domain[i+1] != domain[i] 1637 1637 *****************************************************************************/ 1638 psSpline1D *psSpline1DAlloc( intnumSplines,1639 intorder,1638 psSpline1D *psSpline1DAlloc(psS32 numSplines, 1639 psS32 order, 1640 1640 float min, 1641 1641 float max) 1642 1642 { 1643 1643 psSpline1D *tmp = NULL; 1644 inti;1644 psS32 i; 1645 1645 float tmpDomain; 1646 1646 float width; … … 1677 1677 1678 1678 // XXX: Have Robert put the dealocator in the memory file. 1679 intp_psSpline1DFree(psSpline1D *tmpSpline)1680 { 1681 inti;1679 psS32 p_psSpline1DFree(psSpline1D *tmpSpline) 1680 { 1681 psS32 i; 1682 1682 1683 1683 if (tmpSpline == NULL) { … … 1704 1704 *****************************************************************************/ 1705 1705 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds, 1706 intorder)1706 psS32 order) 1707 1707 { 1708 1708 psSpline1D *tmp = NULL; 1709 inti;1710 intnumSplines;1709 psS32 i; 1710 psS32 numSplines; 1711 1711 1712 1712 tmp = (psSpline1D *) psAlloc(sizeof(psSpline1D)); … … 1746 1746 XXX: name since we don't take psVectors as input. 1747 1747 *****************************************************************************/ 1748 intp_psVectorBinDisectF32(float *bins,1749 intnumBins,1750 float x)1751 { 1752 intmin;1753 intmax;1754 intmid;1748 psS32 p_psVectorBinDisectF32(float *bins, 1749 psS32 numBins, 1750 float x) 1751 { 1752 psS32 min; 1753 psS32 max; 1754 psS32 mid; 1755 1755 1756 1756 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4, … … 1800 1800 p_psVectorBinDisectS32(): integer version of above. 1801 1801 *****************************************************************************/ 1802 int p_psVectorBinDisectS32(int*bins,1803 intnumBins,1804 intx)1805 { 1806 intmin;1807 intmax;1808 intmid;1802 psS32 p_psVectorBinDisectS32(psS32 *bins, 1803 psS32 numBins, 1804 psS32 x) 1805 { 1806 psS32 min; 1807 psS32 max; 1808 psS32 mid; 1809 1809 1810 1810 psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4, … … 1848 1848 p_psVectorBinDisect(): A wrapper to the above p_psVectorBinDisect(). 1849 1849 *****************************************************************************/ 1850 intp_psVectorBinDisect(psVector *bins,1851 psScalar *x)1850 psS32 p_psVectorBinDisect(psVector *bins, 1851 psScalar *x) 1852 1852 { 1853 1853 if (x->type.type != bins->type.type) { … … 1877 1877 float p_ps1DFullInterpolateF32(float *domain, 1878 1878 float *range, 1879 intn,1879 psS32 n, 1880 1880 float x) 1881 1881 { 1882 inti;1883 intm;1882 psS32 i; 1883 psS32 m; 1884 1884 static psVector *p = NULL; 1885 1885 p = psVectorRecycle(p, n, PS_TYPE_F32); … … 1937 1937 float p_ps1DInterpolateF32(float *domain, 1938 1938 float *range, 1939 intn,1940 intorder,1939 psS32 n, 1940 psS32 order, 1941 1941 float x) 1942 1942 { 1943 intbinNum;1944 intnumIntPoints = order+1;1945 intorigin;1943 psS32 binNum; 1944 psS32 numIntPoints = order+1; 1945 psS32 origin; 1946 1946 1947 1947 psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4, … … 1987 1987 psScalar *p_psVectorInterpolate(psVector *domain, 1988 1988 psVector *range, 1989 intorder,1989 psS32 order, 1990 1990 psScalar *x) 1991 1991 { … … 2065 2065 float x) 2066 2066 { 2067 intbinNum;2068 intn;2067 psS32 binNum; 2068 psS32 n; 2069 2069 2070 2070 n = spline->n; … … 2091 2091 const psSpline1D *spline) 2092 2092 { 2093 inti;2093 psS32 i; 2094 2094 psVector *tmpVector; 2095 2095
Note:
See TracChangeset
for help on using the changeset viewer.
