Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

psPolynomial.h

Go to the documentation of this file.
00001 /** @file psPolynomial.h
00002  *  @brief Standard Mathematical Functions.
00003  *  @ingroup Stats
00004  *
00005  *  This file will hold the prototypes for procedures which allocate, free,
00006  *  and evaluate various polynomials.  Those polynomial structures are also
00007  *  defined here.
00008  *
00009  *  @ingroup Stats
00010  *
00011  *  @author GLG, MHPCC
00012  *
00013  *  @version $Revision: 1.1.1.1 $ $Name:  $
00014  *  @date $Date: 2005/09/14 20:42:48 $
00015  *
00016  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00017  */
00018 
00019 #ifndef PS_POLYNOMIAL_H
00020 #define PS_POLYNOMIAL_H
00021 
00022 #include <stdio.h>
00023 #include <stdbool.h>
00024 #include <float.h>
00025 #include <math.h>
00026 
00027 #include "psVector.h"
00028 #include "psScalar.h"
00029 
00030 /** \addtogroup Stats
00031  *  \{
00032  */
00033 
00034 /** Evaluate a non-normalized Gaussian with the given mean and sigma at the
00035  *  given coordianate.
00036  *
00037  *  Note that this is not a Gaussian deviate.  The evaluated Gaussian is:
00038  *        \f[ exp(-\frac{(x-mean)^2}{2\sigma^2}) \f]
00039  *
00040  *  @return float      value on the gaussian curve given the input parameters
00041  */
00042 float psGaussian(
00043     float x,                           ///< Value at which to evaluate
00044     float mean,                        ///< Mean for the Gaussian
00045     float sigma,                       ///< Standard deviation for the Gaussian
00046     bool normal                        ///< Indicates whether result should be normalized
00047 );
00048 
00049 /** Produce a vector of random numbers from a Gaussian distribution with
00050  *  the specified mean and sigma
00051  *
00052  *  @return psVector*    vector of random numbers
00053  *
00054  */
00055 psVector* p_psGaussianDev(
00056     psF32 mean,                        ///< The mean of the Gaussian
00057     psF32 sigma,                       ///< The sigma of the Gaussian
00058     psS32 Npts                         ///< The size of the vector
00059 );
00060 
00061 /** Polynomial Type.
00062  *
00063  *  Enumeration for Polynomial types.
00064  */
00065 typedef enum {
00066     PS_POLYNOMIAL_ORD,                 ///< Ordinary Polynomial
00067     PS_POLYNOMIAL_CHEB                 ///< Chebyshev Polynomial
00068 }
00069 psPolynomialType;
00070 
00071 /** One-dimensional polynomial */
00072 typedef struct
00073 {
00074     psPolynomialType type;             ///< Polynomial type
00075     int n;                             ///< Number of terms
00076     psF64 *coeff;                      ///< Coefficients
00077     psF64 *coeffErr;                   ///< Error in coefficients
00078     char *mask;                        ///< Coefficient mask
00079 }
00080 psPolynomial1D;
00081 
00082 /** Two-dimensional polynomial */
00083 typedef struct
00084 {
00085     psPolynomialType type;             ///< Polynomial type
00086     int nX;                            ///< Number of terms in x
00087     int nY;                            ///< Number of terms in y
00088     psF64 **coeff;                     ///< Coefficients
00089     psF64 **coeffErr;                  ///< Error in coefficients
00090     char **mask;                       ///< Coefficients mask
00091 }
00092 psPolynomial2D;
00093 
00094 /** Three-dimensional polynomial */
00095 typedef struct
00096 {
00097     psPolynomialType type;             ///< Polynomial type
00098     int nX;                           ///< Number of terms in x
00099     int nY;                            ///< Number of terms in y
00100     int nZ;                           ///< Number of terms in z
00101     psF64 ***coeff;                    ///< Coefficients
00102     psF64 ***coeffErr;                 ///< Error in coefficients
00103     char ***mask;                      ///< Coefficients mask
00104 }
00105 psPolynomial3D;
00106 
00107 /** Four-dimensional polynomial */
00108 typedef struct
00109 {
00110     psPolynomialType type;             ///< Polynomial type
00111     int nX;                            ///< Number of terms in x
00112     int nY;                            ///< Number of terms in y
00113     int nZ;                            ///< Number of terms in z
00114     int nT;                            ///< Number of terms in t
00115     psF64 ****coeff;                   ///< Coefficients
00116     psF64 ****coeffErr;                ///< Error in coefficients
00117     char ****mask;                     ///< Coefficients mask
00118 }
00119 psPolynomial4D;
00120 
00121 
00122 /** Allocates a psPolynomial1D structure with n terms
00123  *
00124  *  @return  psPolynomial1D*    new 1-D polynomial struct
00125  */
00126 psPolynomial1D* psPolynomial1DAlloc(
00127     int n,                             ///< Number of terms
00128     psPolynomialType type              ///< Polynomial Type
00129 );
00130 
00131 /** Allocates a 2-D polynomial structure
00132  *
00133  *  @return  psPolynomial2D*    new 2-D polynomial struct
00134  */
00135 psPolynomial2D* psPolynomial2DAlloc(
00136     int nX,                   ///< Number of terms in x
00137     int nY,                   ///< Number of terms in y
00138     psPolynomialType type              ///< Polynomial Type
00139 );
00140 
00141 /** Allocates a 3-D polynomial structure
00142  *
00143  *  @return  psPolynomial3D*    new 3-D polynomial struct
00144  */
00145 psPolynomial3D* psPolynomial3DAlloc(
00146     int nX,                            ///< Number of terms in x
00147     int nY,                            ///< Number of terms in y
00148     int nZ,                            ///< Number of terms in z
00149     psPolynomialType type              ///< Polynomial Type
00150 );
00151 
00152 /** Allocates a 4-D polynomial structure
00153  *
00154  *  @return  psPolynomial4D*    new 4-D polynomial struct
00155  */
00156 psPolynomial4D* psPolynomial4DAlloc(
00157     int nX,                            ///< Number of terms in x
00158     int nY,                            ///< Number of terms in y
00159     int nZ,                            ///< Number of terms in z
00160     int nT,                            ///< Number of terms in t
00161     psPolynomialType type              ///< Polynomial Type
00162 );
00163 
00164 /** Evaluates a 1-D polynomial at specific coordinates.
00165  *
00166  *  @return psF64    result of polynomial at given location
00167  */
00168 psF64 psPolynomial1DEval(
00169     const psPolynomial1D* poly,        ///< Coefficients for the polynomial
00170     psF64 x                            ///< location at which to evaluate
00171 );
00172 
00173 /** Evaluates a 2-D polynomial at specific coordinates.
00174  *
00175  *  @return psF64    result of polynomial at given location
00176  */
00177 psF64 psPolynomial2DEval(
00178     const psPolynomial2D* poly,        ///< Coefficients for the polynomial
00179     psF64 x,                           ///< x location at which to evaluate
00180     psF64 y                            ///< y location at which to evaluate
00181 );
00182 
00183 /** Evaluates a 3-D polynomial at specific coordinates.
00184  *
00185  *  @return psF64    result of polynomial at given location
00186  */
00187 psF64 psPolynomial3DEval(
00188     const psPolynomial3D* poly,        ///< Coefficients for the polynomial
00189     psF64 x,                           ///< x location at which to evaluate
00190     psF64 y,                           ///< y location at which to evaluate
00191     psF64 z                            ///< z location at which to evaluate
00192 );
00193 
00194 /** Evaluates a 4-D polynomial at specific coordinates.
00195  *
00196  *  @return psF64    result of polynomial at given location
00197  */
00198 psF64 psPolynomial4DEval(
00199     const psPolynomial4D* poly,        ///< Coefficients for the polynomial
00200     psF64 x,                           ///< x location at which to evaluate
00201     psF64 y,                           ///< y location at which to evaluate
00202     psF64 z,                           ///< z location at which to evaluate
00203     psF64 t                            ///< t location at which to evaluate
00204 );
00205 
00206 /** Evaluates a 1-D polynomial at specific sets of coordinates
00207  *
00208  *  @return psVector*    results of polynomials at given locations
00209  */
00210 psVector *psPolynomial1DEvalVector(
00211     const psPolynomial1D *poly,        ///< Coefficients for the polynomial
00212     const psVector *x                  ///< x locations at which to evaluate
00213 );
00214 
00215 /** Evaluates a 2-D polynomial at specific sets of coordinates
00216  *
00217  *  @return psVector*    results of polynomial at given locations
00218  */
00219 psVector *psPolynomial2DEvalVector(
00220     const psPolynomial2D *poly,        ///< Coefficients for the polynomial
00221     const psVector *x,                 ///< x locations at which to evaluate
00222     const psVector *y                  ///< y locations at which to evaluate
00223 );
00224 
00225 /** Evaluates a 3-D polynomial at specific sets of coordinates
00226  *
00227  *  @return psVector*    results of polynomial at given locations
00228  */
00229 psVector *psPolynomial3DEvalVector(
00230     const psPolynomial3D *poly,        ///< Coefficients for the polynomial
00231     const psVector *x,                 ///< x locations at which to evaluate
00232     const psVector *y,                 ///< y locations at which to evaluate
00233     const psVector *z                  ///< z locations at which to evaluate
00234 );
00235 
00236 /** Evaluates a 4-D polynomial at specific sets of coordinates
00237  *
00238  *  @return psVector*    results of polynomial at given locations
00239  */
00240 psVector *psPolynomial4DEvalVector(
00241     const psPolynomial4D *poly,        ///< Coefficients for the polynomial
00242     const psVector *x,                 ///< x locations at which to evaluate
00243     const psVector *y,                 ///< y locations at which to evaluate
00244     const psVector *z,                 ///< z locations at which to evaluate
00245     const psVector *t                  ///< t locations at which to evaluate
00246 );
00247 
00248 /** Checks the type of a particular pointer.
00249  *
00250  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00251  *
00252  *  @return bool:       True if the pointer matches a psPolynomial1D structure, false otherwise.
00253  */
00254 bool psMemCheckPolynomial1D(
00255     psPtr ptr                          ///< the pointer whose type to check
00256 );
00257 
00258 /** Checks the type of a particular pointer.
00259  *
00260  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00261  *
00262  *  @return bool:       True if the pointer matches a psPolynomial2D structure, false otherwise.
00263  */
00264 bool psMemCheckPolynomial2D(
00265     psPtr ptr                          ///< the pointer whose type to check
00266 );
00267 
00268 /** Checks the type of a particular pointer.
00269  *
00270  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00271  *
00272  *  @return bool:       True if the pointer matches a psPolynomial3D structure, false otherwise.
00273  */
00274 bool psMemCheckPolynomial3D(
00275     psPtr ptr                          ///< the pointer whose type to check
00276 );
00277 
00278 /** Checks the type of a particular pointer.
00279  *
00280  *  Uses the appropriate deallocation function in psMemBlock to check the ptr datatype.
00281  *
00282  *  @return bool:       True if the pointer matches a psPolynomial4D structure, false otherwise.
00283  */
00284 bool psMemCheckPolynomial4D(
00285     psPtr ptr                          ///< the pointer whose type to check
00286 );
00287 
00288 /** \} */ // End of MathGroup Functions
00289 
00290 #endif // #ifndef PS_POLYNOMIAL_H
00291 

Generated on Wed Sep 14 10:42:48 2005 for Pan-STARRS Foundation Library by  doxygen 1.4.2