IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4937 for trunk/psLib/src/math


Ignore:
Timestamp:
Aug 31, 2005, 12:28:35 PM (21 years ago)
Author:
drobbin
Message:

fixed psSphere struct, changed psPolynomial to unsigned int's

Location:
trunk/psLib/src/math
Files:
2 edited

Legend:

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

    r4898 r4937  
    77*  polynomials.  It also contains a Gaussian functions.
    88*
    9 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2005-08-30 01:14:13 $
     9*  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2005-08-31 22:28:35 $
    1111*
    1212*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    709709    This routine must allocate memory for the polynomial structures.
    710710 *****************************************************************************/
    711 psPolynomial1D* psPolynomial1DAlloc(int n,
     711psPolynomial1D* psPolynomial1DAlloc(unsigned int n,
    712712                                    psPolynomialType type)
    713713{
    714714    PS_ASSERT_INT_POSITIVE(n, NULL);
    715715
    716     int i = 0;
     716    unsigned int i = 0;
    717717    psPolynomial1D* newPoly = NULL;
    718718
     
    734734}
    735735
    736 psPolynomial2D* psPolynomial2DAlloc( int nX,  int nY,
     736psPolynomial2D* psPolynomial2DAlloc( unsigned int nX,
     737                                     unsigned int nY,
    737738                                     psPolynomialType type)
    738739{
     
    740741    PS_ASSERT_INT_POSITIVE(nY, NULL);
    741742
    742     int x = 0;
    743     int y = 0;
     743    unsigned int x = 0;
     744    unsigned int y = 0;
    744745    psPolynomial2D* newPoly = NULL;
    745746
     
    770771}
    771772
    772 psPolynomial3D* psPolynomial3DAlloc( int nX,  int nY,  int nZ,
     773psPolynomial3D* psPolynomial3DAlloc( unsigned int nX,
     774                                     unsigned int nY,
     775                                     unsigned int nZ,
    773776                                     psPolynomialType type)
    774777{
     
    777780    PS_ASSERT_INT_POSITIVE(nZ, NULL);
    778781
    779     psS32 x = 0;
    780     psS32 y = 0;
    781     psS32 z = 0;
     782    unsigned int x = 0;
     783    unsigned int y = 0;
     784    unsigned int z = 0;
    782785    psPolynomial3D* newPoly = NULL;
    783786
     
    816819}
    817820
    818 psPolynomial4D* psPolynomial4DAlloc( int nX,  int nY,  int nZ,  int nT,
     821psPolynomial4D* psPolynomial4DAlloc( unsigned int nX,
     822                                     unsigned int nY,
     823                                     unsigned int nZ,
     824                                     unsigned int nT,
    819825                                     psPolynomialType type)
    820826{
     
    824830    PS_ASSERT_INT_POSITIVE(nT, NULL);
    825831
    826     psS32 x = 0;
    827     psS32 y = 0;
    828     psS32 z = 0;
    829     psS32 t = 0;
     832    unsigned int x = 0;
     833    unsigned int y = 0;
     834    unsigned int z = 0;
     835    unsigned int t = 0;
    830836    psPolynomial4D* newPoly = NULL;
    831837
     
    899905
    900906
    901 psF64 psPolynomial1DEval(const psPolynomial1D* poly, psF64 x)
     907psF64 psPolynomial1DEval(const psPolynomial1D* poly,
     908                         psF64 x)
    902909{
    903910    PS_ASSERT_POLY_NON_NULL(poly, NAN);
     
    932939}
    933940
    934 psF64 psPolynomial2DEval(const psPolynomial2D* poly, psF64 x, psF64 y)
     941psF64 psPolynomial2DEval(const psPolynomial2D* poly,
     942                         psF64 x,
     943                         psF64 y)
    935944{
    936945    PS_ASSERT_POLY_NON_NULL(poly, NAN);
     
    979988}
    980989
    981 psF64 psPolynomial3DEval(const psPolynomial3D* poly, psF64 x, psF64 y, psF64 z)
     990psF64 psPolynomial3DEval(const psPolynomial3D* poly,
     991                         psF64 x,
     992                         psF64 y,
     993                         psF64 z)
    982994{
    983995    PS_ASSERT_POLY_NON_NULL(poly, NAN);
     
    10351047}
    10361048
    1037 psF64 psPolynomial4DEval(const psPolynomial4D* poly, psF64 x, psF64 y, psF64 z, psF64 t)
     1049psF64 psPolynomial4DEval(const psPolynomial4D* poly,
     1050                         psF64 x,
     1051                         psF64 y,
     1052                         psF64 z,
     1053                         psF64 t)
    10381054{
    10391055    PS_ASSERT_POLY_NON_NULL(poly, NAN);
     
    11141130XXX: What should be the default type for knots be?  psF32 is assumed.
    11151131 *****************************************************************************/
    1116 psSpline1D *psSpline1DAlloc(int numSplines,
    1117                             int order,
     1132psSpline1D *psSpline1DAlloc(unsigned int numSplines,
     1133                            unsigned int order,
    11181134                            float min,
    11191135                            float max)
     
    11311147    //
    11321148    tmpSpline->spline = (psPolynomial1D **) psAlloc(numSplines * sizeof(psPolynomial1D *));
    1133     for (psS32 i=0;i<numSplines;i++) {
     1149    for (unsigned int i=0; i < numSplines; i++) {
    11341150        (tmpSpline->spline)[i] = psPolynomial1DAlloc(order+1, PS_POLYNOMIAL_ORD);
    11351151    }
     
    11441160    psF32 width = (max - min) / ((psF32) numSplines);
    11451161    tmpSpline->knots->data.F32[0] = min;
    1146     for (psS32 i=1;i<numSplines;i++) {
     1162    for (unsigned int i=1; i < numSplines; i++) {
    11471163        tmpSpline->knots->data.F32[i] = min + (width * (psF32) i);
    11481164    }
     
    11791195 *****************************************************************************/
    11801196psSpline1D *psSpline1DAllocGeneric(const psVector *bounds,
    1181                                    int order)
     1197                                   unsigned int order)
    11821198{
    11831199    PS_ASSERT_VECTOR_NON_NULL(bounds, NULL);
     
    11951211    //
    11961212    tmpSpline->spline = (psPolynomial1D **) psAlloc(numSplines * sizeof(psPolynomial1D *));
    1197     for (psS32 i=0;i<numSplines;i++) {
     1213    for (unsigned int i=0; i < numSplines; i++) {
    11981214        (tmpSpline->spline)[i] = psPolynomial1DAlloc(order+1, PS_POLYNOMIAL_ORD);
    11991215    }
     
    12061222    // XXX:Ensure that the knots are monotonic.
    12071223    //
    1208     for (psS32 i=0;i<bounds->n-1;i++) {
     1224    for (unsigned int i=0; i < bounds->n-1; i++) {
    12091225        if (FLT_EPSILON >= fabs(bounds->data.F32[i+1]-bounds->data.F32[i])) {
    12101226            psError(PS_ERR_UNKNOWN, true, "data points must be distinct ([%d] %f %f)\n", i, bounds->data.F32[i], bounds->data.F32[i+1]);
  • trunk/psLib/src/math/psFunctions.h

    r4898 r4937  
    1212 *  @author GLG, MHPCC
    1313 *
    14  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    15  *  @date $Date: 2005-08-30 01:14:13 $
     14 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     15 *  @date $Date: 2005-08-31 22:28:35 $
    1616 *
    1717 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    7474{
    7575    psPolynomialType type;             ///< Polynomial type
    76     int n;                             ///< Number of terms
     76    unsigned int n;                    ///< Number of terms
    7777    psF64 *coeff;                      ///< Coefficients
    7878    psF64 *coeffErr;                   ///< Error in coefficients
     
    8585{
    8686    psPolynomialType type;             ///< Polynomial type
    87     int nX;                            ///< Number of terms in x
    88     int nY;                            ///< Number of terms in y
     87    unsigned int nX;                   ///< Number of terms in x
     88    unsigned int nY;                   ///< Number of terms in y
    8989    psF64 **coeff;                     ///< Coefficients
    9090    psF64 **coeffErr;                  ///< Error in coefficients
     
    9797{
    9898    psPolynomialType type;             ///< Polynomial type
    99     int nX;                           ///< Number of terms in x
    100     int nY;                            ///< Number of terms in y
    101     int nZ;                           ///< Number of terms in z
     99    unsigned int nX;                   ///< Number of terms in x
     100    unsigned int nY;                   ///< Number of terms in y
     101    unsigned int nZ;                   ///< Number of terms in z
    102102    psF64 ***coeff;                    ///< Coefficients
    103103    psF64 ***coeffErr;                 ///< Error in coefficients
     
    110110{
    111111    psPolynomialType type;             ///< Polynomial type
    112     int nX;                            ///< Number of terms in x
    113     int nY;                            ///< Number of terms in y
    114     int nZ;                            ///< Number of terms in z
    115     int nT;                            ///< Number of terms in t
     112    unsigned int nX;                   ///< Number of terms in x
     113    unsigned int nY;                   ///< Number of terms in y
     114    unsigned int nZ;                   ///< Number of terms in z
     115    unsigned int nT;                   ///< Number of terms in t
    116116    psF64 ****coeff;                   ///< Coefficients
    117117    psF64 ****coeffErr;                ///< Error in coefficients
     
    126126 */
    127127psPolynomial1D* psPolynomial1DAlloc(
    128     int n,                             ///< Number of terms
     128    unsigned int n,                    ///< Number of terms
    129129    psPolynomialType type              ///< Polynomial Type
    130130);
     
    135135 */
    136136psPolynomial2D* psPolynomial2DAlloc(
    137     int nX,                   ///< Number of terms in x
    138     int nY,                   ///< Number of terms in y
     137    unsigned int nX,                   ///< Number of terms in x
     138    unsigned int nY,                   ///< Number of terms in y
    139139    psPolynomialType type              ///< Polynomial Type
    140140);
     
    145145 */
    146146psPolynomial3D* psPolynomial3DAlloc(
    147     int nX,                            ///< Number of terms in x
    148     int nY,                            ///< Number of terms in y
    149     int nZ,                            ///< Number of terms in z
     147    unsigned int nX,                   ///< Number of terms in x
     148    unsigned int nY,                   ///< Number of terms in y
     149    unsigned int nZ,                   ///< Number of terms in z
    150150    psPolynomialType type              ///< Polynomial Type
    151151);
     
    156156 */
    157157psPolynomial4D* psPolynomial4DAlloc(
    158     int nX,                            ///< Number of terms in x
    159     int nY,                            ///< Number of terms in y
    160     int nZ,                            ///< Number of terms in z
    161     int nT,                            ///< Number of terms in t
     158    unsigned int nX,                   ///< Number of terms in x
     159    unsigned int nY,                   ///< Number of terms in y
     160    unsigned int nZ,                   ///< Number of terms in z
     161    unsigned int nT,                   ///< Number of terms in t
    162162    psPolynomialType type              ///< Polynomial Type
    163163);
     
    212212    psPtr ptr                          ///< the pointer whose type to check
    213213);
    214 
    215 
    216214
    217215/** Evaluates a 1-D polynomial at specific coordinates.
     
    299297);
    300298
    301 
    302299/** One-Dimensional Spline */
    303300typedef struct
    304301{
    305     int n;                             ///< The number of spline pieces
     302    unsigned int n;                    ///< The number of spline pieces
    306303    psPolynomial1D **spline;           ///< An array of n pointers to the spline polynomials
    307304    psVector *knots;                   ///< The boundaries between each spline piece.  Size is n+1.
     
    319316 */
    320317psSpline1D *psSpline1DAlloc(
    321     int n,                             ///< Number of spline polynomials
    322     int order,                         ///< Order of spline polynomials
     318    unsigned int n,                             ///< Number of spline polynomials
     319    unsigned int order,                         ///< Order of spline polynomials
    323320    float min,                         ///< Lower boundary value of spline polynomials
    324321    float max                          ///< Upper boundary value of spline polynomials
     
    333330psSpline1D *psSpline1DAllocGeneric(
    334331    const psVector *bounds,            ///< Bounds for spline polynomials
    335     int order                          ///< Order of spline polynomials
     332    unsigned int order                 ///< Order of spline polynomials
    336333);
    337334
Note: See TracChangeset for help on using the changeset viewer.