Changeset 4857
- Timestamp:
- Aug 23, 2005, 1:23:05 PM (21 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 5 edited
-
astro/psCoord.c (modified) (2 diffs)
-
math/psFunctions.c (modified) (6 diffs)
-
math/psRandom.c (modified) (2 diffs)
-
math/psRandom.h (modified) (3 diffs)
-
math/psStats.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/astro/psCoord.c
r4620 r4857 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.8 2$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 7-27 19:55:15 $12 * @version $Revision: 1.83 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-08-23 23:23:05 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 139 139 if the supplied psPlaneTransform transform is linear: if any of the 140 140 cooefficients of order 2 are higher are non-zero, then it is not linear. 141 142 Returns: 143 1: if linear 144 0: otherwise 145 146 XXX: This should be a psBool 141 147 *****************************************************************************/ 142 148 psS32 p_psIsProjectionLinear(psPlaneTransform *transform) -
trunk/psLib/src/math/psFunctions.c
r4581 r4857 7 7 * polynomials. It also contains a Gaussian functions. 8 8 * 9 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $10 * @date $Date: 2005-0 7-20 01:21:13$9 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2005-08-23 23:23:05 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 20 20 /* INCLUDE FILES */ 21 21 /*****************************************************************************/ 22 #include <gsl/gsl_rng.h>23 #include <gsl/gsl_randist.h>24 25 22 #include <stdio.h> 26 23 #include <stdbool.h> … … 28 25 #include <math.h> 29 26 27 #include "psRandom.h" 30 28 #include "psMemory.h" 31 29 #include "psVector.h" … … 36 34 #include "psFunctions.h" 37 35 #include "psConstants.h" 38 39 36 #include "psErrorText.h" 40 37 … … 688 685 This private routine (formerly a psLib API routine) creates a psVector of the 689 686 specified size and type F32 and fills it with a random Gaussian distribution 690 of numbers with the specified mean and sigma. This routine makes use of the 691 GSL routines for generating both uniformly distributed numbers and the 692 Gaussian distribution as well. 693 694 XXX: There is no way to seed the random generator. 687 of numbers with the specified mean and sigma. 695 688 *****************************************************************************/ 696 689 psVector* p_psGaussianDev(psF32 mean, psF32 sigma, psS32 Npts) … … 698 691 PS_ASSERT_INT_NONNEGATIVE(Npts, NULL); 699 692 700 psVector* gauss = NULL; 701 const gsl_rng_type *T = NULL; 702 gsl_rng *r = NULL; 703 psS32 i = 0; 704 705 706 gauss = psVectorAlloc(Npts, PS_TYPE_F32); 707 gauss->n = Npts; 708 gsl_rng_env_setup(); 709 T = gsl_rng_default; 710 r = gsl_rng_alloc(T); 711 712 for (i = 0; i < Npts; i++) { 713 gauss->data.F32[i] = mean + gsl_ran_gaussian(r, sigma); 714 } 715 716 // XXX: Should I free r, T as well? This is a memory leak. 693 psRandom *r = psRandomAlloc(PS_RANDOM_TAUS, p_psRandomGetSystemSeed()); 694 psVector* gauss = psVectorAlloc(Npts, PS_TYPE_F32); 695 for (psS32 i = 0; i < Npts; i++) { 696 gauss->data.F32[i] = mean + p_psRandomGaussian(r, sigma); 697 } 698 psFree(r); 699 717 700 return(gauss); 718 701 } -
trunk/psLib/src/math/psRandom.c
r4540 r4857 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 7-12 19:12:01$12 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-08-23 23:23:05 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 130 130 } 131 131 132 double p_psRandomGaussian(const psRandom *r, double sigma) 133 { 134 // Check null psRandom variable 135 if(r == NULL) { 136 psError(PS_ERR_UNEXPECTED_NULL, 137 true, 138 PS_ERRORTEXT_psRandom_NULL_RANDOM_VAR); 139 return(0); 140 } else { 141 return(gsl_ran_gaussian(r->gsl, sigma)); 142 } 143 } 144 132 145 double psRandomPoisson(const psRandom *r, double mean) 133 146 { -
trunk/psLib/src/math/psRandom.h
r4330 r4857 10 10 * @author GLG, MHPCC 11 11 * 12 * @version $Revision: 1. 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-0 6-21 03:01:37$12 * @version $Revision: 1.7 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-08-23 23:23:05 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 47 47 } 48 48 psRandom; 49 50 psU64 p_psRandomGetSystemSeed(); 49 51 50 52 /** Allocates a psRandom struct. … … 84 86 ); 85 87 88 /** Random number generator based on a Gaussian deviate, N(0,1). 89 * Uses gsl_ran_gaussian. 90 * 91 * XXX: I created this since the above psLib spec for p_psRandomGaussian 92 * had no argument for sigma. Verify that with IfA. 93 * 94 * @return double: Random number. 95 */ 96 double p_psRandomGaussian( 97 const psRandom *r, ///< psRandom struct for RNG 98 double sigma 99 ); 100 86 101 /** Random number generator based on a Poisson distribution with the given mean. 87 102 * Uses gsl_ran_poisson. -
trunk/psLib/src/math/psStats.h
r4540 r4857 14 14 * @author GLG, MHPCC 15 15 * 16 * @version $Revision: 1.4 6$ $Name: not supported by cvs2svn $17 * @date $Date: 2005-0 7-12 19:12:01$16 * @version $Revision: 1.47 $ $Name: not supported by cvs2svn $ 17 * @date $Date: 2005-08-23 23:23:05 $ 18 18 * 19 19 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 52 52 PS_STAT_USE_RANGE = 0x002000, ///< Range 53 53 PS_STAT_USE_BINSIZE = 0x004000, ///< Binsize 54 // PS_STAT_ROBUST_FOR_SAMPLE = 0x008000 ///< Robust for sample55 54 } psStatsOptions; 56 55
Note:
See TracChangeset
for help on using the changeset viewer.
