IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1423


Ignore:
Timestamp:
Aug 9, 2004, 11:23:09 AM (22 years ago)
Author:
Paul Price
Message:

Added splines and evaluation of vectors for polynomials.
Also made polynomials ordinary or Chebyshev (psPolynomialType).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/pslib/include/psFunctions.h

    r1089 r1423  
    2626/************************************************************************************************************/
    2727
     28/** Type of polynomial */
     29typedef enum {
     30    PS_POLYNOMIAL_ORD,                  ///< Ordinary polynomial
     31    PS_POLYNOMIAL_CHEB                  ///< Chebyshev polynomial
     32} psPolynomialType;
     33
     34/************************************************************************************************************/
     35
    2836/** one-dimensional polynomial */
    2937typedef struct {
     38    psPolynomialType type;              ///< Polynomial type
    3039    int n;                              ///< Number of terms
    3140    float *restrict coeff;              ///< Coefficients
     
    3645/** Two-dimensional polynomial */
    3746typedef struct {
     47    psPolynomialType type;              ///< Polynomial type
    3848    int nX, nY;                         ///< Number of terms in x and y
    3949    float *restrict *restrict coeff;    ///< Coefficients
     
    4454/** Three-dimensional polynomial */
    4555typedef struct {
     56    psPolynomialType type;              ///< Polynomial type
    4657    int nX, nY, nZ;                     ///< Number of terms in x, y and z
    4758    float *restrict *restrict *restrict coeff; ///< Coefficients
     
    5263/** Four-dimensional polynomial */
    5364typedef struct {
     65    psPolynomialType type;              ///< Polynomial type
    5466    int nW, nX, nY, nZ;                 ///< Number of terms in w, x, y and z
    5567    float *restrict *restrict *restrict *restrict coeff; ///< Coefficients
     
    6678/** Constructor */
    6779psPolynomial1D *psPolynomial1DAlloc(int n ///< Number of terms
     80                                    psPolynomialType type ///< Polynomial type
    6881                                    );
    6982/** Constructor */
    7083psPolynomial2D *psPolynomial2DAlloc(int nX, int nY ///< Number of terms in x and y
     84                                    psPolynomialType type ///< Polynomial type
    7185                                    );
    7286/** Constructor */
    7387psPolynomial3D *psPolynomial3DAlloc(int nX, int nY, int nZ ///< Number of terms in x, y and z
     88                                    psPolynomialType type ///< Polynomial type
    7489                                    );
    7590/** Constructor */
    7691psPolynomial4D *psPolynomial4DAlloc(int nW, int nX, int nY, int nZ ///< Number of terms in w, x, y and z
     92                                    psPolynomialType type ///< Polynomial type
    7793                                    );
    7894
     
    121137                   );
    122138
     139/** Evaluate 1D polynomial: vector input */
     140psVector *
     141psPolynomial1DEvalVector(psVector *x,   ///< Value at which to evaluate
     142                         const psPolynomial1D *restrict myPoly ///< Coefficients for the polynomial
     143                         );
     144
     145/** Evaluate 2D polynomial: vector input */
     146psVector *
     147psPolynomial2DEvalVector(psVector *x,   ///< Value x at which to evaluate
     148                         psVector *y,   ///< Value y at which to evaluate
     149                         const psPolynomial2D *restrict myPoly ///< Coefficients for the polynomial
     150                         );
     151
     152/** Evaluate 3D polynomial: vector input */
     153psVector *
     154psPolynomial3DEvalVector(psVector *x,   ///< Value x at which to evaluate
     155                         psVector *y,   ///< Value y at which to evaluate
     156                         psVector *z,   ///< Value z at which to evaluate
     157                         const psPolynomial3D *restrict myPoly ///< Coefficients for the polynomial
     158                         );
     159
     160/** Evaluate 4D polynomial: vector input */
     161psVector *
     162psPolynomial4DEvalVector(psVector *w,   ///< Value w at which to evaluate
     163                         psVector *x,   ///< Value x at which to evaluate
     164                         psVector *y,   ///< Value y at which to evaluate
     165                         psVector *z,   ///< Value z at which to evaluate
     166                         const psPolynomial4D *restrict myPoly ///< Coefficients for the polynomial
     167                         );
     168
     169
    123170/* \} */ // End of MathGroup Functions
    124171
     
    129176/** Double-precision one-dimensional polynomial */
    130177typedef struct {
     178    psPolynomialType type;              ///< Polynomial type
    131179    int n;                              ///< Number of terms
    132180    double *restrict coeff;             ///< Coefficients
     
    137185/** Double-precision two-dimensional polynomial */
    138186typedef struct {
     187    psPolynomialType type;              ///< Polynomial type
    139188    int nX, nY;                         ///< Number of terms in x and y
    140189    double *restrict *restrict coeff;   ///< Coefficients
     
    145194/** Double-precision three-dimensional polynomial */
    146195typedef struct {
     196    psPolynomialType type;              ///< Polynomial type
    147197    int nX, nY, nZ;                     ///< Number of terms in x, y and z
    148198    double *restrict *restrict *restrict coeff; ///< Coefficients
     
    153203/** Double-precision four-dimensional polynomial */
    154204typedef struct {
     205    psPolynomialType type;              ///< Polynomial type
    155206    int nW, nX, nY, nZ;                 ///< Number of terms in w, x, y and z
    156207    double *restrict *restrict *restrict *restrict coeff; ///< Coefficients
     
    165216
    166217/** Constructor */
    167 psDPolynomial1D *psDPolynomial1DAlloc(int n ///< Number of terms
    168     );
     218psDPolynomial1D *psDPolynomial1DAlloc(int n, ///< Number of terms
     219                                      psPolynomialType type ///< Polynomial type
     220                                      );
    169221/** Constructor */
    170222psDPolynomial2D *psDPolynomial2DAlloc(int nX, int nY ///< Number of terms in x and y
    171     );
     223                                      psPolynomialType type ///< Polynomial type
     224                                      );
    172225/** Constructor */
    173226psDPolynomial3D *psDPolynomial3DAlloc(int nX, int nY, int nZ ///< Number of terms in x, y and z
    174     );
     227                                      psPolynomialType type ///< Polynomial type
     228                                      );
    175229/** Constructor */
    176230psDPolynomial4D *psDPolynomial4DAlloc(int nW, int nX, int nY, int nZ ///< Number of terms in w, x, y and z
    177     );
     231                                      psPolynomialType type ///< Polynomial type
     232                                      );
    178233
    179234
     
    222277                    );
    223278
     279/** Evaluate 1D polynomial: vector input */
     280psVector *
     281psDPolynomial1DEvalVector(psVector *x,  ///< Value at which to evaluate
     282                          const psDPolynomial1D *restrict myPoly ///< Coefficients for the polynomial
     283                          );
     284
     285/** Evaluate 2D polynomial: vector input */
     286psVector *
     287psDPolynomial2DEvalVector(psVector *x,  ///< Value x at which to evaluate
     288                          psVector *y,  ///< Value y at which to evaluate
     289                          const psDPolynomial2D *restrict myPoly ///< Coefficients for the polynomial
     290                          );
     291
     292/** Evaluate 3D polynomial: vector input */
     293psVector *
     294psDPolynomial3DEvalVector(psVector *x,  ///< Value x at which to evaluate
     295                          psVector *y,  ///< Value y at which to evaluate
     296                          psVector *z,  ///< Value z at which to evaluate
     297                          const psDPolynomial3D *restrict myPoly ///< Coefficients for the polynomial
     298                          );
     299
     300/** Evaluate 4D polynomial: vector input */
     301psVector *
     302psDPolynomial4DEvalVector(psVector *w,  ///< Value w at which to evaluate
     303                          psVector *x,  ///< Value x at which to evaluate
     304                          psVector *y,  ///< Value y at which to evaluate
     305                          psVector *z,  ///< Value z at which to evaluate
     306                          const psDPolynomial4D *restrict myPoly ///< Coefficients for the polynomial
     307                          );
     308
    224309/* \} */ // End of MathGroup Functions
    225310
     311/************************************************************************************************************/
     312
     313/* Splines */
     314
     315/** A 1D cubic-spline */
     316typedef struct {
     317    int n;                              ///< Number of spline pieces
     318    psPolynomial1D *spline;             ///< Array of n splines
     319    float *domains;                     ///< The boundaries between each spline piece.  Size is n+1.
     320} psSpline1D;
     321
     322/** Functions **************************************************************/
     323/** \addtogroup MathGroup Math Utilities
     324 *  \{
     325 */
     326
     327/** Constructors */
     328psSpline1D *psSpline1DAlloc(int n,      ///< Number of spline pieces
     329                            int order,  ///< Order of spline pieces
     330                            float min,  ///< Minimum data value
     331                            float max   ///< Maximum data value
     332                            );
     333psSpline1D *psSpline1DAllocGeneric(const psVector *bounds ///< Boundaries between each spline piece.  Number
     334                                                          ///< of spline pieces can hence be inferred.
     335                                   int order    ///< Order of spline pieces
     336                                   );
     337/** Destructor */
     338void psSpline1DFree(psSpline1D *mySpline ///< Spline to destroy
     339                    );
     340/** Evaluator */
     341float psSpline1DEval(float x,           ///< Coordinate at which to evaluate
     342                     const psSpline1D *spline ///< Spline to evaluate
     343                     );
     344
     345/** Evaluator: vector version */
     346psVector *psSpline1DEvalVector(psVector *x, ///< Coordinates at which to evaluate
     347                               const psSpline1D *spline ///< Spline to evaluate
     348                               );
     349
    226350#endif
Note: See TracChangeset for help on using the changeset viewer.