Changeset 1464 for trunk/psLib/src/math/psPolynomial.h
- Timestamp:
- Aug 10, 2004, 4:37:55 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psPolynomial.h (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psPolynomial.h
r1441 r1464 13 13 * @author George Gusciora, MHPCC 14 14 * 15 * @version $Revision: 1.1 8$ $Name: not supported by cvs2svn $16 * @date $Date: 2004-08- 09 23:40:55$15 * @version $Revision: 1.19 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2004-08-11 02:35:58 $ 17 17 * 18 18 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 31 31 32 32 /** Evaluate a non-normalized Gaussian with the given mean and sigma at the 33 given coordianate. Note that this is not a Gaussian deviate. The 34 evaluated Gaussian is: \f[ exp(-\frac{(x-mean)^2}{2\sigma^2}) \f] */ 35 36 float psGaussian(float x, ///< Value at which to evaluate 37 float mean, ///< Mean for the Gaussian 38 float stddev, ///< Standard deviation for the Gaussian 39 bool normal ///< Indicates whether result should be normalized 40 ); 33 * given coordianate. 34 * 35 * Note that this is not a Gaussian deviate. The evaluated Gaussian is: 36 * \f[ exp(-\frac{(x-mean)^2}{2\sigma^2}) \f] 37 * 38 * @return float value on the gaussian curve given the input parameters 39 */ 40 float psGaussian( 41 float x, ///< Value at which to evaluate 42 float mean, ///< Mean for the Gaussian 43 float stddev, ///< Standard deviation for the Gaussian 44 bool normal ///< Indicates whether result should be normalized 45 ); 41 46 42 47 /** Produce a vector of random numbers from a Gaussian distribution with 43 the specified mean and sigma */ 44 psVector* psGaussianDev(float mean, ///< The mean of the Gaussian 45 float sigma, ///< The sigma of the Gaussian 46 int Npts); ///< The size of the vector 48 * the specified mean and sigma 49 * 50 * @return psVector* vector of random numbers 51 * 52 */ 53 psVector* psGaussianDev( 54 float mean, ///< The mean of the Gaussian 55 float sigma, ///< The sigma of the Gaussian 56 int Npts ///< The size of the vector 57 ); 47 58 48 59 /** One-dimensional polynomial */ 49 60 typedef struct 50 61 { 51 int n; ///< Number of terms52 float *coeff; ///< Coefficients53 float *coeffErr; ///< Error in coefficients54 char *mask; ///< Coefficient mask62 int n; ///< Number of terms 63 float *coeff; ///< Coefficients 64 float *coeffErr; ///< Error in coefficients 65 char *mask; ///< Coefficient mask 55 66 } 56 67 psPolynomial1D; … … 59 70 typedef struct 60 71 { 61 int nX ,62 nY; ///< Number of terms in x andy63 float **coeff; ///< Coefficients64 float **coeffErr; ///< Error in coefficients65 char **mask; ///< Coefficients mask72 int nX; ///< Number of terms in x 73 int nY; ///< Number of terms in y 74 float **coeff; ///< Coefficients 75 float **coeffErr; ///< Error in coefficients 76 char **mask; ///< Coefficients mask 66 77 } 67 78 psPolynomial2D; … … 70 81 typedef struct 71 82 { 72 int nX ,73 nY,74 nZ; ///< Number of terms in x, y andz75 float ***coeff; ///< Coefficients76 float ***coeffErr; ///< Error in coefficients77 char ***mask; ///< Coefficients mask83 int nX; ///< Number of terms in x 84 int nY; ///< Number of terms in y 85 int nZ; ///< Number of terms in z 86 float ***coeff; ///< Coefficients 87 float ***coeffErr; ///< Error in coefficients 88 char ***mask; ///< Coefficients mask 78 89 } 79 90 psPolynomial3D; … … 82 93 typedef struct 83 94 { 84 int nW ,85 nX,86 nY,87 nZ; ///< Number of terms in w, x, y andz88 float ****coeff; ///< Coefficients89 float ****coeffErr; ///< Error in coefficients90 char ****mask; ///< Coefficients mask95 int nW; ///< Number of terms in w 96 int nX; ///< Number of terms in x 97 int nY; ///< Number of terms in y 98 int nZ; ///< Number of terms in z 99 float ****coeff; ///< Coefficients 100 float ****coeffErr; ///< Error in coefficients 101 char ****mask; ///< Coefficients mask 91 102 } 92 103 psPolynomial4D; 93 104 94 /** Functions **************************************************************/ 95 96 /** Constructor */ 97 psPolynomial1D* psPolynomial1DAlloc(int n ///< Number of terms 98 ); 99 100 /** Constructor */ 101 psPolynomial2D* psPolynomial2DAlloc(int nX, int nY ///< Number of terms in x and y 102 ); 103 104 /** Constructor */ 105 psPolynomial3D* psPolynomial3DAlloc(int nX, int nY, int nZ ///< Number of terms in x, y and z 106 ); 107 108 /** Constructor */ 109 psPolynomial4D* psPolynomial4DAlloc(int nW, int nX, int nY, int nZ ///< Number of terms in w, x, y and 110 // z 111 ); 112 113 /** Evaluate 1D polynomial */ 114 float psPolynomial1DEval(float x, ///< Value at which to evaluate 115 const psPolynomial1D* myPoly ///< Coefficients for the polynomial 116 ); 117 118 /** Evaluate 2D polynomial */ 119 float psPolynomial2DEval(float x, ///< Value x at which to evaluate 120 float y, ///< Value y at which to evaluate 121 const psPolynomial2D* myPoly ///< Coefficients for the polynomial 122 ); 123 124 /** Evaluate 3D polynomial */ 125 float psPolynomial3DEval(float x, ///< Value x at which to evaluate 126 float y, ///< Value y at which to evaluate 127 float z, ///< Value z at which to evaluate 128 const psPolynomial3D* myPoly ///< Coefficients for the polynomial 129 ); 130 131 /** Evaluate 4D polynomial */ 132 float psPolynomial4DEval(float w, ///< Value w at which to evaluate 133 float x, ///< Value x at which to evaluate 134 float y, ///< Value y at which to evaluate 135 float z, ///< Value z at which to evaluate 136 const psPolynomial4D* myPoly ///< Coefficients for the polynomial 137 ); 105 106 /** Allocates a psPolynomial1D structure with n terms 107 * 108 * @return psPolynomial1D* new 1-D polynomial struct 109 */ 110 psPolynomial1D* psPolynomial1DAlloc( 111 int n ///< Number of terms 112 ); 113 114 /** Allocates a 2-D polynomial structure 115 * 116 * @return psPolynomial2D* new 2-D polynomial struct 117 */ 118 psPolynomial2D* psPolynomial2DAlloc( 119 int nX, ///< Number of terms in x 120 int nY ///< Number of terms in y 121 ); 122 123 /** Allocates a 3-D polynomial structure 124 * 125 * @return psPolynomial3D* new 3-D polynomial struct 126 */ 127 psPolynomial3D* psPolynomial3DAlloc( 128 int nX, ///< Number of terms in x 129 int nY, ///< Number of terms in y 130 int nZ ///< Number of terms in z 131 ); 132 133 /** Allocates a 4-D polynomial structure 134 * 135 * @return psPolynomial4D* new 4-D polynomial struct 136 */ 137 psPolynomial4D* psPolynomial4DAlloc( 138 int nW, ///< Number of terms in w 139 int nX, ///< Number of terms in x 140 int nY, ///< Number of terms in y 141 int nZ ///< Number of terms in z 142 ); 143 144 /** Evaluates a 1-D polynomial at specific coordinates. 145 * 146 * @return float result of polynomial at given location 147 */ 148 float psPolynomial1DEval( 149 float x, ///< location at which to evaluate 150 const psPolynomial1D* myPoly ///< Coefficients for the polynomial 151 ); 152 153 /** Evaluates a 2-D polynomial at specific coordinates. 154 * 155 * @return float result of polynomial at given location 156 */ 157 float psPolynomial2DEval( 158 float x, ///< x location at which to evaluate 159 float y, ///< y location at which to evaluate 160 const psPolynomial2D* myPoly ///< Coefficients for the polynomial 161 ); 162 163 /** Evaluates a 3-D polynomial at specific coordinates. 164 * 165 * @return float result of polynomial at given location 166 */ 167 float psPolynomial3DEval( 168 float x, ///< x location at which to evaluate 169 float y, ///< y location at which to evaluate 170 float z, ///< z location at which to evaluate 171 const psPolynomial3D* myPoly ///< Coefficients for the polynomial 172 ); 173 174 /** Evaluates a 4-D polynomial at specific coordinates. 175 * 176 * @return float result of polynomial at given location 177 */ 178 float psPolynomial4DEval( 179 float w, ///< w location at which to evaluate 180 float x, ///< x location at which to evaluate 181 float y, ///< y location at which to evaluate 182 float z, ///< z location at which to evaluate 183 const psPolynomial4D* myPoly ///< Coefficients for the polynomial 184 ); 138 185 139 186 /*****************************************************************************/ … … 144 191 typedef struct 145 192 { 146 int n; ///< Number of terms147 double *coeff; ///< Coefficients148 double *coeffErr; ///< Error in coefficients149 char *mask; ///< Coefficient mask193 int n; ///< Number of terms 194 double *coeff; ///< Coefficients 195 double *coeffErr; ///< Error in coefficients 196 char *mask; ///< Coefficient mask 150 197 } 151 198 psDPolynomial1D; … … 154 201 typedef struct 155 202 { 156 int nX ,157 nY; ///< Number of terms in x andy158 double **coeff; ///< Coefficients159 double **coeffErr; ///< Error in coefficients160 char **mask; ///< Coefficients mask203 int nX; ///< Number of terms in x 204 int nY; ///< Number of terms in y 205 double **coeff; ///< Coefficients 206 double **coeffErr; ///< Error in coefficients 207 char **mask; ///< Coefficients mask 161 208 } 162 209 psDPolynomial2D; … … 165 212 typedef struct 166 213 { 167 int nX ,168 nY,169 nZ; ///< Number of terms in x, y andz170 double ***coeff; ///< Coefficients171 double ***coeffErr; ///< Error in coefficients172 char ***mask; ///< Coefficient mask214 int nX; ///< Number of terms in x 215 int nY; ///< Number of terms in y 216 int nZ; ///< Number of terms in z 217 double ***coeff; ///< Coefficients 218 double ***coeffErr; ///< Error in coefficients 219 char ***mask; ///< Coefficient mask 173 220 } 174 221 psDPolynomial3D; … … 177 224 typedef struct 178 225 { 179 int nW ,180 nX,181 nY,182 nZ; ///< Number of terms in w, x, y andz183 double ****coeff; ///< Coefficients184 double ****coeffErr; ///< Error in coefficients185 char ****mask; ///< Coefficients mask226 int nW; ///< Number of terms in w 227 int nX; ///< Number of terms in x 228 int nY; ///< Number of terms in y 229 int nZ; ///< Number of terms in z 230 double ****coeff; ///< Coefficients 231 double ****coeffErr; ///< Error in coefficients 232 char ****mask; ///< Coefficients mask 186 233 } 187 234 psDPolynomial4D; 188 235 189 /** Constructor */ 190 psDPolynomial1D* psDPolynomial1DAlloc(int n ///< Number of terms 191 ); 192 193 /** Constructor */ 194 psDPolynomial2D* psDPolynomial2DAlloc(int nX, int nY ///< Number of terms in x and y 195 ); 196 197 /** Constructor */ 198 psDPolynomial3D* psDPolynomial3DAlloc(int nX, int nY, int nZ ///< Number of terms in x, y and z 199 ); 200 201 /** Constructor */ 202 psDPolynomial4D* psDPolynomial4DAlloc(int nW, int nX, int nY, int nZ ///< Number of terms in w, x, y and 203 // z 204 ); 205 206 /** Evaluate 1D polynomial (double precision) */ 207 double psDPolynomial1DEval(double x, ///< Value at which to evaluate 208 const psDPolynomial1D* myPoly ///< Coefficients for the polynomial 209 ); 210 211 /** Evaluate 2D polynomial (double precision) */ 212 double psDPolynomial2DEval(double x, ///< Value x at which to evaluate 213 double y, ///< Value y at which to evaluate 214 const psDPolynomial2D* myPoly ///< Coefficients for the polynomial 215 ); 216 217 /** Evaluate 3D polynomial (double precision) */ 218 double psDPolynomial3DEval(double x, ///< Value x at which to evaluate 219 double y, ///< Value y at which to evaluate 220 double z, ///< Value z at which to evaluate 221 const psDPolynomial3D* myPoly ///< Coefficients for the polynomial 222 ); 223 224 /** Evaluate 4D polynomial (double precision) */ 225 double psDPolynomial4DEval(double w, ///< Value w at which to evaluate 226 double x, ///< Value x at which to evaluate 227 double y, ///< Value y at which to evaluate 228 double z, ///< Value z at which to evaluate 229 const psDPolynomial4D* myPoly ///< Coefficients for the polynomial 230 ); 236 /** Allocates a double-precision 1-D polynomial structure with n terms 237 * 238 * @return psPolynomial1D* new double-precision 1-D polynomial struct 239 */ 240 psDPolynomial1D* psDPolynomial1DAlloc( 241 int n ///< Number of terms 242 ); 243 244 /** Allocates a double-precision 2-D polynomial structure 245 * 246 * @return psPolynomial2D* new double-precision 2-D polynomial struct 247 */ 248 psDPolynomial2D* psDPolynomial2DAlloc( 249 int nX, ///< Number of terms in x 250 int nY ///< Number of terms in y 251 ); 252 253 /** Allocates a double-precision 3-D polynomial structure 254 * 255 * @return psPolynomial3D* new double-precision 3-D polynomial struct 256 */ 257 psDPolynomial3D* psDPolynomial3DAlloc( 258 int nX, ///< Number of terms in x 259 int nY, ///< Number of terms in y 260 int nZ ///< Number of terms in z 261 ); 262 263 /** Allocates a double-precision 4-D polynomial structure 264 * 265 * @return psPolynomial4D* new double-precision 4-D polynomial struct 266 */ 267 psDPolynomial4D* psDPolynomial4DAlloc( 268 int nW, ///< Number of terms in w 269 int nX, ///< Number of terms in x 270 int nY, ///< Number of terms in y 271 int nZ ///< Number of terms in z 272 ); 273 274 /** Evaluates a double-precision 1-D polynomial at specific coordinates. 275 * 276 * @return float result of polynomial at given location 277 */ 278 double psDPolynomial1DEval( 279 double x, ///< Value at which to evaluate 280 const psDPolynomial1D* myPoly ///< Coefficients for the polynomial 281 ); 282 283 /** Evaluates a double-precision 2-D polynomial at specific coordinates. 284 * 285 * @return float result of polynomial at given location 286 */ 287 double psDPolynomial2DEval( 288 double x, ///< Value x at which to evaluate 289 double y, ///< Value y at which to evaluate 290 const psDPolynomial2D* myPoly ///< Coefficients for the polynomial 291 ); 292 293 /** Evaluates a double-precision 3-D polynomial at specific coordinates. 294 * 295 * @return float result of polynomial at given location 296 */ 297 double psDPolynomial3DEval( 298 double x, ///< Value x at which to evaluate 299 double y, ///< Value y at which to evaluate 300 double z, ///< Value z at which to evaluate 301 const psDPolynomial3D* myPoly ///< Coefficients for the polynomial 302 ); 303 304 /** Evaluates a double-precision 4-D polynomial at specific coordinates. 305 * 306 * @return float result of polynomial at given location 307 */ 308 double psDPolynomial4DEval( 309 double w, ///< Value w at which to evaluate 310 double x, ///< Value x at which to evaluate 311 double y, ///< Value y at which to evaluate 312 double z, ///< Value z at which to evaluate 313 const psDPolynomial4D* myPoly ///< Coefficients for the polynomial 314 ); 231 315 232 316 /* \} */// End of MathGroup Functions
Note:
See TracChangeset
for help on using the changeset viewer.
