Changeset 2433 for trunk/psLib/src/math/psRandom.c
- Timestamp:
- Nov 24, 2004, 11:59:43 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/math/psRandom.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/math/psRandom.c
r2432 r2433 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $13 * @date $Date: 2004-11-24 2 0:55:01$12 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2004-11-24 21:59:43 $ 14 14 * 15 15 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 20 20 #include <float.h> 21 21 #include <math.h> 22 #include <gsl/gsl_rng.h> 23 #include <gsl/gsl_randist.h> 22 24 25 #include "psMemory.h" 23 26 #include "psRandom.h" 24 27 #include "psScalar.h" 28 #include "psError.h" 29 #include "psTrace.h" 30 #include "psLogMsg.h" 31 #include "psConstants.h" 32 #include "psDataManipErrors.h" 25 33 26 34 /* … … 39 47 psU64 seed) 40 48 { 49 gsl_rng *r = NULL; 50 psRandom *myRNG = (psRandom *) psAlloc(sizeof(psRandom)); 51 52 switch (type) { 53 case PS_RANDOM_TAUS: 54 r = gsl_rng_alloc(gsl_rng_taus); 55 myRNG->gsl = r; 56 return(myRNG); 57 58 default: 59 psError(PS_ERR_UNEXPECTED_NULL, 60 true, 61 PS_ERRORTEXT_psRandom_UNKNOWN_RANDFOM_NUMBER_GENERATOR_TYPE); 62 } 41 63 return(NULL); 42 64 } … … 44 66 void psRandomReset(psRandom *rand, 45 67 psU64 seed) 46 {} 68 { 69 gsl_rng_set(rand->gsl, seed); 70 } 47 71 48 72 psF64 psRandomUniform(const psRandom *r) 49 73 { 50 return( 0.0);74 return(gsl_rng_uniform(r->gsl)); 51 75 } 52 76 53 77 psF64 psRandomGaussian(const psRandom *r) 54 78 { 55 return(0.0); 79 // XXX: What should sigma be? 80 return(gsl_ran_gaussian(r->gsl, 1.0)); 56 81 } 57 82 58 83 psF64 psRandomPoisson(const psRandom *r, psF64 mean) 59 84 { 60 return( 0.0);85 return((psF64) gsl_ran_poisson(r->gsl, mean)); 61 86 }
Note:
See TracChangeset
for help on using the changeset viewer.
