IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 26, 2004, 2:57:34 PM (22 years ago)
Author:
desonia
Message:

converted native C types to ps Types, where practical.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psPolynomial.c

    r2197 r2204  
    77 *  polynomials.  It also contains a Gaussian functions.
    88 *
    9  *  @version $Revision: 1.53 $ $Name: not supported by cvs2svn $
    10  *  @date $Date: 2004-10-26 21:24:42 $
     9 *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
     10 *  @date $Date: 2004-10-27 00:57:31 $
    1111 *
    1212 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    5050    \
    5151    if (IN->type.type == PS_TYPE_F64) { \
    52         for (int i=0;i<IN->n;i++) { \
     52        for (psS32 i=0;i<IN->n;i++) { \
    5353            OUT->data.F32[i] = (float) (IN->data.F64[i]); \
    5454        } \
     
    6969    \
    7070    if (IN->type.type == PS_TYPE_F32) { \
    71         for (int i=0;i<IN->n;i++) { \
     71        for (psS32 i=0;i<IN->n;i++) { \
    7272            OUT->data.F64[i] = (float) (IN->data.F32[i]); \
    7373        } \
     
    117117outer coefficients of the Chebyshev polynomials.
    118118 *****************************************************************************/
    119 static psPolynomial1D **CreateChebyshevPolys(int maxChebyPoly)
     119static psPolynomial1D **CreateChebyshevPolys(psS32 maxChebyPoly)
    120120{
    121121    psPolynomial1D **chebPolys = NULL;
    122     int i = 0;
    123     int j = 0;
     122    psS32 i = 0;
     123    psS32 j = 0;
    124124
    125125    chebPolys = (psPolynomial1D **) psAlloc(maxChebyPoly * sizeof(psPolynomial1D *));
     
    153153    evaluated Gaussian is: \f[ exp(-\frac{(x-mean)^2}{2\sigma^2}) \f]
    154154 *****************************************************************************/
    155 float psGaussian(float x, float mean, float sigma, bool normal)
     155float psGaussian(float x, float mean, float sigma, psBool normal)
    156156{
    157157    float tmp = 1.0;
     
    185185 NOTE: XXX: There is no way to seed the random generator.
    186186 *****************************************************************************/
    187 psVector* psGaussianDev(float mean, float sigma, int Npts)
     187psVector* psGaussianDev(float mean, float sigma, psS32 Npts)
    188188{
    189189    psVector* gauss = NULL;
    190190    const gsl_rng_type *T = NULL;
    191191    gsl_rng *r = NULL;
    192     int i = 0;
     192    psS32 i = 0;
    193193
    194194    gauss = psVectorAlloc(Npts, PS_TYPE_F32);
     
    209209    This routine must allocate memory for the polynomial structures.
    210210 *****************************************************************************/
    211 psPolynomial1D* psPolynomial1DAlloc(int n,
     211psPolynomial1D* psPolynomial1DAlloc(psS32 n,
    212212                                    psPolynomialType type)
    213213{
    214     int i = 0;
     214    psS32 i = 0;
    215215    psPolynomial1D* newPoly = NULL;
    216216
     
    232232}
    233233
    234 psPolynomial2D* psPolynomial2DAlloc(int nX, int nY,
     234psPolynomial2D* psPolynomial2DAlloc(psS32 nX, psS32 nY,
    235235                                    psPolynomialType type)
    236236{
    237     int x = 0;
    238     int y = 0;
     237    psS32 x = 0;
     238    psS32 y = 0;
    239239    psPolynomial2D* newPoly = NULL;
    240240
     
    265265}
    266266
    267 psPolynomial3D* psPolynomial3DAlloc(int nX, int nY, int nZ,
     267psPolynomial3D* psPolynomial3DAlloc(psS32 nX, psS32 nY, psS32 nZ,
    268268                                    psPolynomialType type)
    269269{
    270     int x = 0;
    271     int y = 0;
    272     int z = 0;
     270    psS32 x = 0;
     271    psS32 y = 0;
     272    psS32 z = 0;
    273273    psPolynomial3D* newPoly = NULL;
    274274
     
    307307}
    308308
    309 psPolynomial4D* psPolynomial4DAlloc(int nW, int nX, int nY, int nZ,
     309psPolynomial4D* psPolynomial4DAlloc(psS32 nW, psS32 nX, psS32 nY, psS32 nZ,
    310310                                    psPolynomialType type)
    311311{
    312     int w = 0;
    313     int x = 0;
    314     int y = 0;
    315     int z = 0;
     312    psS32 w = 0;
     313    psS32 x = 0;
     314    psS32 y = 0;
     315    psS32 z = 0;
    316316    psPolynomial4D* newPoly = NULL;
    317317
     
    367367static void polynomial2DFree(psPolynomial2D* myPoly)
    368368{
    369     int x = 0;
     369    psS32 x = 0;
    370370
    371371    for (x = 0; x < myPoly->nX; x++) {
     
    381381static void polynomial3DFree(psPolynomial3D* myPoly)
    382382{
    383     int x = 0;
    384     int y = 0;
     383    psS32 x = 0;
     384    psS32 y = 0;
    385385
    386386    for (x = 0; x < myPoly->nX; x++) {
     
    402402static void polynomial4DFree(psPolynomial4D* myPoly)
    403403{
    404     int w = 0;
    405     int x = 0;
    406     int y = 0;
     404    psS32 w = 0;
     405    psS32 x = 0;
     406    psS32 y = 0;
    407407
    408408    for (w = 0; w < myPoly->nW; w++) {
     
    434434float p_psOrdPolynomial1DEval(float x, const psPolynomial1D* myPoly)
    435435{
    436     int loop_x = 0;
     436    psS32 loop_x = 0;
    437437    float polySum = 0.0;
    438438    float xSum = 1.0;
     
    478478{
    479479    psVector *d;
    480     int n;
    481     int i;
     480    psS32 n;
     481    psS32 i;
    482482    float tmp;
    483483
     
    500500    /*
    501501
    502     int n;
    503     int i;
     502    psS32 n;
     503    psS32 i;
    504504    float tmp;
    505505    psPolynomial1D **chebPolys = NULL;
     
    537537    psVector *tmp;
    538538    psVector *myX;
    539     int i;
     539    psS32 i;
    540540
    541541    PS_CONVERT_VECTOR_F32(x, myX);
     
    555555float p_psOrdPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
    556556{
    557     int loop_x = 0;
    558     int loop_y = 0;
     557    psS32 loop_x = 0;
     558    psS32 loop_y = 0;
    559559    float polySum = 0.0;
    560560    float xSum = 1.0;
     
    577577float p_psChebPolynomial2DEval(float x, float y, const psPolynomial2D* myPoly)
    578578{
    579     int loop_x = 0;
    580     int loop_y = 0;
    581     int i = 0;
     579    psS32 loop_x = 0;
     580    psS32 loop_y = 0;
     581    psS32 i = 0;
    582582    float polySum = 0.0;
    583583    psPolynomial1D* *chebPolys = NULL;
    584     int maxChebyPoly = 0;
     584    psS32 maxChebyPoly = 0;
    585585
    586586    // Determine how many Chebyshev polynomials
     
    628628    psVector *myX;
    629629    psVector *myY;
    630     int i;
    631     int vecLen=x->n;
     630    psS32 i;
     631    psS32 vecLen=x->n;
    632632
    633633    PS_CONVERT_VECTOR_F32(x, myX);
     
    658658float p_psOrdPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
    659659{
    660     int loop_x = 0;
    661     int loop_y = 0;
    662     int loop_z = 0;
     660    psS32 loop_x = 0;
     661    psS32 loop_y = 0;
     662    psS32 loop_z = 0;
    663663    float polySum = 0.0;
    664664    float xSum = 1.0;
     
    686686float p_psChebPolynomial3DEval(float x, float y, float z, const psPolynomial3D* myPoly)
    687687{
    688     int loop_x = 0;
    689     int loop_y = 0;
    690     int loop_z = 0;
    691     int i = 0;
     688    psS32 loop_x = 0;
     689    psS32 loop_y = 0;
     690    psS32 loop_z = 0;
     691    psS32 i = 0;
    692692    float polySum = 0.0;
    693693    psPolynomial1D* *chebPolys = NULL;
    694     int maxChebyPoly = 0;
     694    psS32 maxChebyPoly = 0;
    695695
    696696    // Determine how many Chebyshev polynomials
     
    746746    psVector *myY;
    747747    psVector *myZ;
    748     int i;
    749     int vecLen=x->n;
     748    psS32 i;
     749    psS32 vecLen=x->n;
    750750
    751751    PS_CONVERT_VECTOR_F32(x, myX);
     
    787787float p_psOrdPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
    788788{
    789     int loop_w = 0;
    790     int loop_x = 0;
    791     int loop_y = 0;
    792     int loop_z = 0;
     789    psS32 loop_w = 0;
     790    psS32 loop_x = 0;
     791    psS32 loop_y = 0;
     792    psS32 loop_z = 0;
    793793    float polySum = 0.0;
    794794    float wSum = 1.0;
     
    821821float p_psChebPolynomial4DEval(float w, float x, float y, float z, const psPolynomial4D* myPoly)
    822822{
    823     int loop_w = 0;
    824     int loop_x = 0;
    825     int loop_y = 0;
    826     int loop_z = 0;
    827     int i = 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;
    828828    float polySum = 0.0;
    829829    psPolynomial1D* *chebPolys = NULL;
    830     int maxChebyPoly = 0;
     830    psS32 maxChebyPoly = 0;
    831831
    832832    // Determine how many Chebyshev polynomials
     
    890890    psVector *myY;
    891891    psVector *myZ;
    892     int i;
    893     int vecLen=x->n;
     892    psS32 i;
     893    psS32 vecLen=x->n;
    894894
    895895    PS_CONVERT_VECTOR_F32(w, myW);
     
    936936
    937937
    938 psDPolynomial1D* psDPolynomial1DAlloc(int n,
     938psDPolynomial1D* psDPolynomial1DAlloc(psS32 n,
    939939                                      psPolynomialType type)
    940940{
    941     int i = 0;
     941    psS32 i = 0;
    942942    psDPolynomial1D* newPoly = NULL;
    943943
     
    959959}
    960960
    961 psDPolynomial2D* psDPolynomial2DAlloc(int nX, int nY,
     961psDPolynomial2D* psDPolynomial2DAlloc(psS32 nX, psS32 nY,
    962962                                      psPolynomialType type)
    963963{
    964     int x = 0;
    965     int y = 0;
     964    psS32 x = 0;
     965    psS32 y = 0;
    966966    psDPolynomial2D* newPoly = NULL;
    967967
     
    992992}
    993993
    994 psDPolynomial3D* psDPolynomial3DAlloc(int nX, int nY, int nZ,
     994psDPolynomial3D* psDPolynomial3DAlloc(psS32 nX, psS32 nY, psS32 nZ,
    995995                                      psPolynomialType type)
    996996{
    997     int x = 0;
    998     int y = 0;
    999     int z = 0;
     997    psS32 x = 0;
     998    psS32 y = 0;
     999    psS32 z = 0;
    10001000    psDPolynomial3D* newPoly = NULL;
    10011001
     
    10341034}
    10351035
    1036 psDPolynomial4D* psDPolynomial4DAlloc(int nW, int nX, int nY, int nZ,
     1036psDPolynomial4D* psDPolynomial4DAlloc(psS32 nW, psS32 nX, psS32 nY, psS32 nZ,
    10371037                                      psPolynomialType type)
    10381038{
    1039     int w = 0;
    1040     int x = 0;
    1041     int y = 0;
    1042     int z = 0;
     1039    psS32 w = 0;
     1040    psS32 x = 0;
     1041    psS32 y = 0;
     1042    psS32 z = 0;
    10431043    psDPolynomial4D* newPoly = NULL;
    10441044
     
    10941094static void dPolynomial2DFree(psDPolynomial2D* myPoly)
    10951095{
    1096     int x = 0;
     1096    psS32 x = 0;
    10971097
    10981098    for (x = 0; x < myPoly->nX; x++) {
     
    11081108static void dPolynomial3DFree(psDPolynomial3D* myPoly)
    11091109{
    1110     int x = 0;
    1111     int y = 0;
     1110    psS32 x = 0;
     1111    psS32 y = 0;
    11121112
    11131113    for (x = 0; x < myPoly->nX; x++) {
     
    11291129static void dPolynomial4DFree(psDPolynomial4D* myPoly)
    11301130{
    1131     int w = 0;
    1132     int x = 0;
    1133     int y = 0;
     1131    psS32 w = 0;
     1132    psS32 x = 0;
     1133    psS32 y = 0;
    11341134
    11351135    for (w = 0; w < myPoly->nW; w++) {
     
    11591159double p_psDOrdPolynomial1DEval(double x, const psDPolynomial1D* myPoly)
    11601160{
    1161     int loop_x = 0;
     1161    psS32 loop_x = 0;
    11621162    double polySum = 0.0;
    11631163    double xSum = 1.0;
     
    11831183{
    11841184    psVector *d;
    1185     int n;
    1186     int i;
     1185    psS32 n;
     1186    psS32 i;
    11871187    double tmp;
    11881188
     
    12221222    psVector *tmp;
    12231223    psVector *myX;
    1224     int i;
     1224    psS32 i;
    12251225
    12261226    PS_CONVERT_VECTOR_F64(x, myX);
     
    12411241double p_psDOrdPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
    12421242{
    1243     int loop_x = 0;
    1244     int loop_y = 0;
     1243    psS32 loop_x = 0;
     1244    psS32 loop_y = 0;
    12451245    double polySum = 0.0;
    12461246    double xSum = 1.0;
     
    12631263double p_psDChebPolynomial2DEval(double x, double y, const psDPolynomial2D* myPoly)
    12641264{
    1265     int loop_x = 0;
    1266     int loop_y = 0;
    1267     int i = 0;
     1265    psS32 loop_x = 0;
     1266    psS32 loop_y = 0;
     1267    psS32 i = 0;
    12681268    double polySum = 0.0;
    12691269    psPolynomial1D* *chebPolys = NULL;
    1270     int maxChebyPoly = 0;
     1270    psS32 maxChebyPoly = 0;
    12711271
    12721272    // Determine how many Chebyshev polynomials
     
    13141314    psVector *myX;
    13151315    psVector *myY;
    1316     int i;
    1317     int vecLen=x->n;
     1316    psS32 i;
     1317    psS32 vecLen=x->n;
    13181318
    13191319    PS_CONVERT_VECTOR_F64(x, myX);
     
    13441344double p_psDOrdPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
    13451345{
    1346     int loop_x = 0;
    1347     int loop_y = 0;
    1348     int loop_z = 0;
     1346    psS32 loop_x = 0;
     1347    psS32 loop_y = 0;
     1348    psS32 loop_z = 0;
    13491349    double polySum = 0.0;
    13501350    double xSum = 1.0;
     
    13721372double p_psDChebPolynomial3DEval(double x, double y, double z, const psDPolynomial3D* myPoly)
    13731373{
    1374     int loop_x = 0;
    1375     int loop_y = 0;
    1376     int loop_z = 0;
    1377     int i = 0;
     1374    psS32 loop_x = 0;
     1375    psS32 loop_y = 0;
     1376    psS32 loop_z = 0;
     1377    psS32 i = 0;
    13781378    double polySum = 0.0;
    13791379    psPolynomial1D* *chebPolys = NULL;
    1380     int maxChebyPoly = 0;
     1380    psS32 maxChebyPoly = 0;
    13811381
    13821382    // Determine how many Chebyshev polynomials
     
    14321432    psVector *myY;
    14331433    psVector *myZ;
    1434     int i;
    1435     int vecLen=x->n;
     1434    psS32 i;
     1435    psS32 vecLen=x->n;
    14361436
    14371437    PS_CONVERT_VECTOR_F64(x, myX);
     
    14751475double p_psDOrdPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
    14761476{
    1477     int loop_w = 0;
    1478     int loop_x = 0;
    1479     int loop_y = 0;
    1480     int loop_z = 0;
     1477    psS32 loop_w = 0;
     1478    psS32 loop_x = 0;
     1479    psS32 loop_y = 0;
     1480    psS32 loop_z = 0;
    14811481    double polySum = 0.0;
    14821482    double wSum = 1.0;
     
    15091509double p_psDChebPolynomial4DEval(double w, double x, double y, double z, const psDPolynomial4D* myPoly)
    15101510{
    1511     int loop_w = 0;
    1512     int loop_x = 0;
    1513     int loop_y = 0;
    1514     int loop_z = 0;
    1515     int i = 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;
    15161516    double polySum = 0.0;
    15171517    psPolynomial1D* *chebPolys = NULL;
    1518     int maxChebyPoly = 0;
     1518    psS32 maxChebyPoly = 0;
    15191519
    15201520    // Determine how many Chebyshev polynomials
     
    15781578    psVector *myY;
    15791579    psVector *myZ;
    1580     int i;
    1581     int vecLen=x->n;
     1580    psS32 i;
     1581    psS32 vecLen=x->n;
    15821582
    15831583    PS_CONVERT_VECTOR_F64(w, myW);
     
    16241624
    16251625//typedef struct {
    1626 //    int n;
     1626//    psS32 n;
    16271627//    psPolynomial1D **spline;
    16281628//    float *p_psDeriv2;
     
    16361636XXX: Ensure that domain[i+1] != domain[i]
    16371637 *****************************************************************************/
    1638 psSpline1D *psSpline1DAlloc(int numSplines,
    1639                             int order,
     1638psSpline1D *psSpline1DAlloc(psS32 numSplines,
     1639                            psS32 order,
    16401640                            float min,
    16411641                            float max)
    16421642{
    16431643    psSpline1D *tmp = NULL;
    1644     int i;
     1644    psS32 i;
    16451645    float tmpDomain;
    16461646    float width;
     
    16771677
    16781678// XXX: Have Robert put the dealocator in the memory file.
    1679 int p_psSpline1DFree(psSpline1D *tmpSpline)
    1680 {
    1681     int i;
     1679psS32 p_psSpline1DFree(psSpline1D *tmpSpline)
     1680{
     1681    psS32 i;
    16821682
    16831683    if (tmpSpline == NULL) {
     
    17041704 *****************************************************************************/
    17051705psSpline1D *psSpline1DAllocGeneric(const psVector *bounds,
    1706                                    int order)
     1706                                   psS32 order)
    17071707{
    17081708    psSpline1D *tmp = NULL;
    1709     int i;
    1710     int numSplines;
     1709    psS32 i;
     1710    psS32 numSplines;
    17111711
    17121712    tmp = (psSpline1D *) psAlloc(sizeof(psSpline1D));
     
    17461746XXX: name since we don't take psVectors as input.
    17471747 *****************************************************************************/
    1748 int p_psVectorBinDisectF32(float *bins,
    1749                            int numBins,
    1750                            float x)
    1751 {
    1752     int min;
    1753     int max;
    1754     int mid;
     1748psS32 p_psVectorBinDisectF32(float *bins,
     1749                             psS32 numBins,
     1750                             float x)
     1751{
     1752    psS32 min;
     1753    psS32 max;
     1754    psS32 mid;
    17551755
    17561756    psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectF32", 4,
     
    18001800p_psVectorBinDisectS32(): integer version of above.
    18011801 *****************************************************************************/
    1802 int p_psVectorBinDisectS32(int *bins,
    1803                            int numBins,
    1804                            int x)
    1805 {
    1806     int min;
    1807     int max;
    1808     int mid;
     1802psS32 p_psVectorBinDisectS32(psS32 *bins,
     1803                             psS32 numBins,
     1804                             psS32 x)
     1805{
     1806    psS32 min;
     1807    psS32 max;
     1808    psS32 mid;
    18091809
    18101810    psTrace(".psLib.dataManip.psFunctions.p_psVectorBinDisectS32", 4,
     
    18481848p_psVectorBinDisect(): A wrapper to the above p_psVectorBinDisect().
    18491849 *****************************************************************************/
    1850 int p_psVectorBinDisect(psVector *bins,
    1851                         psScalar *x)
     1850psS32 p_psVectorBinDisect(psVector *bins,
     1851                          psScalar *x)
    18521852{
    18531853    if (x->type.type != bins->type.type) {
     
    18771877float p_ps1DFullInterpolateF32(float *domain,
    18781878                               float *range,
    1879                                int n,
     1879                               psS32 n,
    18801880                               float x)
    18811881{
    1882     int i;
    1883     int m;
     1882    psS32 i;
     1883    psS32 m;
    18841884    static psVector *p = NULL;
    18851885    p = psVectorRecycle(p, n, PS_TYPE_F32);
     
    19371937float p_ps1DInterpolateF32(float *domain,
    19381938                           float *range,
    1939                            int n,
    1940                            int order,
     1939                           psS32 n,
     1940                           psS32 order,
    19411941                           float x)
    19421942{
    1943     int binNum;
    1944     int numIntPoints = order+1;
    1945     int origin;
     1943    psS32 binNum;
     1944    psS32 numIntPoints = order+1;
     1945    psS32 origin;
    19461946
    19471947    psTrace(".psLib.dataManip.psFunctions.p_ps1DInterpolateF32", 4,
     
    19871987psScalar *p_psVectorInterpolate(psVector *domain,
    19881988                                psVector *range,
    1989                                 int order,
     1989                                psS32 order,
    19901990                                psScalar *x)
    19911991{
     
    20652065                     float x)
    20662066{
    2067     int binNum;
    2068     int n;
     2067    psS32 binNum;
     2068    psS32 n;
    20692069
    20702070    n = spline->n;
     
    20912091                               const psSpline1D *spline)
    20922092{
    2093     int i;
     2093    psS32 i;
    20942094    psVector *tmpVector;
    20952095
Note: See TracChangeset for help on using the changeset viewer.