IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 4857


Ignore:
Timestamp:
Aug 23, 2005, 1:23:05 PM (21 years ago)
Author:
gusciora
Message:

Eliminated gsl calls in psFunctions.c.

Location:
trunk/psLib/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/astro/psCoord.c

    r4620 r4857  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.82 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-07-27 19:55:15 $
     12*  @version $Revision: 1.83 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-08-23 23:23:05 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    139139if the supplied psPlaneTransform transform is linear: if any of the
    140140cooefficients of order 2 are higher are non-zero, then it is not linear.
     141 
     142Returns:
     143    1: if linear
     144    0: otherwise
     145 
     146XXX: This should be a psBool
    141147 *****************************************************************************/
    142148psS32 p_psIsProjectionLinear(psPlaneTransform *transform)
  • trunk/psLib/src/math/psFunctions.c

    r4581 r4857  
    77*  polynomials.  It also contains a Gaussian functions.
    88*
    9 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    10 *  @date $Date: 2005-07-20 01:21:13 $
     9*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     10*  @date $Date: 2005-08-23 23:23:05 $
    1111*
    1212*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2020/*  INCLUDE FILES                                                            */
    2121/*****************************************************************************/
    22 #include <gsl/gsl_rng.h>
    23 #include <gsl/gsl_randist.h>
    24 
    2522#include <stdio.h>
    2623#include <stdbool.h>
     
    2825#include <math.h>
    2926
     27#include "psRandom.h"
    3028#include "psMemory.h"
    3129#include "psVector.h"
     
    3634#include "psFunctions.h"
    3735#include "psConstants.h"
    38 
    3936#include "psErrorText.h"
    4037
     
    688685 This private routine (formerly a psLib API routine) creates a psVector of the
    689686 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.
    695688 *****************************************************************************/
    696689psVector* p_psGaussianDev(psF32 mean, psF32 sigma, psS32 Npts)
     
    698691    PS_ASSERT_INT_NONNEGATIVE(Npts, NULL);
    699692
    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
    717700    return(gauss);
    718701}
  • trunk/psLib/src/math/psRandom.c

    r4540 r4857  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.10 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-07-12 19:12:01 $
     12*  @version $Revision: 1.11 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-08-23 23:23:05 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    130130}
    131131
     132double 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
    132145double psRandomPoisson(const psRandom *r, double mean)
    133146{
  • trunk/psLib/src/math/psRandom.h

    r4330 r4857  
    1010*  @author GLG, MHPCC
    1111*
    12 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
    13 *  @date $Date: 2005-06-21 03:01:37 $
     12*  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
     13*  @date $Date: 2005-08-23 23:23:05 $
    1414*
    1515*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    4747}
    4848psRandom;
     49
     50psU64 p_psRandomGetSystemSeed();
    4951
    5052/** Allocates a psRandom struct.
     
    8486);
    8587
     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 */
     96double p_psRandomGaussian(
     97    const psRandom *r,                  ///< psRandom struct for RNG
     98    double sigma
     99);
     100
    86101/** Random number generator based on a Poisson distribution with the given mean.
    87102 *  Uses gsl_ran_poisson.
  • trunk/psLib/src/math/psStats.h

    r4540 r4857  
    1414 *  @author GLG, MHPCC
    1515 *
    16  *  @version $Revision: 1.46 $ $Name: not supported by cvs2svn $
    17  *  @date $Date: 2005-07-12 19:12:01 $
     16 *  @version $Revision: 1.47 $ $Name: not supported by cvs2svn $
     17 *  @date $Date: 2005-08-23 23:23:05 $
    1818 *
    1919 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5252    PS_STAT_USE_RANGE =  0x002000,          ///< Range
    5353    PS_STAT_USE_BINSIZE = 0x004000,         ///< Binsize
    54     //    PS_STAT_ROBUST_FOR_SAMPLE = 0x008000    ///< Robust for sample
    5554} psStatsOptions;
    5655
Note: See TracChangeset for help on using the changeset viewer.