Changeset 793 for trunk/psLib/src/math/psSpline.c
- Timestamp:
- May 26, 2004, 4:49:34 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psSpline.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psSpline.c
r774 r793 16 16 #include "float.h" 17 17 #include <math.h> 18 #define PI 3.14 18 #include <gsl/gsl_rng.h> 19 #include <gsl/gsl_randist.h> 19 20 /***************************************************************************** 20 21 Evaluate a non-normalized Gaussian with the given mean and sigma at the … … 31 32 32 33 if (normal == 1) { 33 tmp = 1.0 / sqrtf(2.0 * PI * (stddev * stddev));34 tmp = 1.0 / sqrtf(2.0 * M_PI * (stddev * stddev)); 34 35 return(tmp * exp(-((x-mean) * (x-mean)) / (2.0 * stddev * stddev))); 35 36 } else { … … 38 39 } 39 40 40 /* 41 /***************************************************************************** 42 psGaussianDev() 43 44 This routine creates a psVector of the specified size and type F32 45 and fils it with a random Gaussiang distribution of numbers with 46 the specified meand and sigma. This routine makes use of the GSL 47 routines for generating both uniformly distributed numbers and the 48 Gaussian distribution as well. 49 *****************************************************************************/ 41 50 psVector *psGaussianDev(float mean, 42 51 float sigma, … … 44 53 { 45 54 psVector *gauss = NULL; 46 55 const gsl_rng_type *T = NULL; 56 gsl_rng *r = NULL; 57 int i = 0; 58 47 59 gauss = psVectorAlloc(Npts, PS_TYPE_FLOAT); 48 } 49 */ 60 gsl_rng_env_setup(); 61 T = gsl_rng_default; 62 r = gsl_rng_alloc(T); 63 64 for (i = 0; i < Npts; i++) { 65 gauss->vec.f[i] = mean + gsl_ran_gaussian(r, sigma); 66 } 67 return(gauss); 68 } 69 50 70 51 71 /*****************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.
