IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 29, 2009, 6:15:31 PM (17 years ago)
Author:
beaumont
Message:

merged with head

Location:
branches/cnb_branches/cnb_branch_20090301
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090301

  • branches/cnb_branches/cnb_branch_20090301/ppSim/src/ppSimRandomGaussian.c

    r18011 r23594  
    2929
    3030/* integrate a gaussian from -5 sigma to +5 sigma */
    31 void p_ppSimRandomGaussianInit () {
    32  
     31void p_ppSimRandomGaussianInit (void) {
     32
    3333  int i;
    3434  long A, B;
    3535  double val, x, dx, dx1, dx2, dx3, df;
    3636  double mean, sigma;
    37  
     37
    3838  /* no need to generate this if it already exists */
    3939  if (gaussint) return;
     
    4242  for (B = 0; A == time(NULL); B++);
    4343  srand48(B);
    44  
     44
    4545  Ngaussint = 0x1000;
    4646  ppSimRandomGaussianAlloc (Ngaussint + 1);
     
    5353  mean = 0.0;
    5454  sigma = 1.0;
    55  
     55
    5656  for (i = 0, x = -7.0; (i < Ngaussint) && (x < 7.0); x += dx)  {
    57     df = (3.0*p_ppSimGaussian(x    , mean, sigma) + 
     57    df = (3.0*p_ppSimGaussian(x    , mean, sigma) +
    5858          9.0*p_ppSimGaussian(x+dx1, mean, sigma) +
    59           9.0*p_ppSimGaussian(x+dx2, mean, sigma) + 
     59          9.0*p_ppSimGaussian(x+dx2, mean, sigma) +
    6060          3.0*p_ppSimGaussian(x+dx3, mean, sigma)) * (dx1/8.0);
    6161    val += df;
     
    6767}
    6868
    69 // XXX we are using drand48() rather than the random var supplied by rnd 
     69// XXX we are using drand48() rather than the random var supplied by rnd
    7070double ppSimRandomGaussian (const psRandom *rnd, double mean, double sigma) {
    71  
     71
    7272  int i;
    7373  double y;
    74  
     74
    7575  if (gaussint == NULL) {
    7676      p_ppSimRandomGaussianInit ();
     
    8080  i = Ngaussint*y;
    8181  y = gaussint[i]*sigma + mean;
    82  
     82
    8383  return (y);
    84  
     84
    8585}
    86  
    87 // XXX we are using drand48() rather than the random var supplied by rnd 
     86
     87// XXX we are using drand48() rather than the random var supplied by rnd
    8888double ppSimRandomGaussianNorm (const psRandom *rnd) {
    89  
     89
    9090  int i;
    9191  double y;
    92  
     92
    9393  if (gaussint == NULL) {
    9494      p_ppSimRandomGaussianInit ();
     
    9898  i = Ngaussint*y;
    9999  y = gaussint[i];
    100  
     100
    101101  return (y);
    102102}
Note: See TracChangeset for help on using the changeset viewer.