Changeset 26589


Ignore:
Timestamp:
11/10/21 11:15:18 (3 years ago)
Author:
bulthuis
Message:

BUG: Try to fix bugs on tests

Location:
issm/trunk-jpl/src/c/shared/Random
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/shared/Random/randomgenerator.cpp

    r26588 r26589  
    55#include <iostream>
    66#include "./randomgenerator.h"
    7 
    8 rnd_uniform_distribution::rnd_uniform_distribution()
    9 {/*{{{*/
    10 
    11         a   = 1103515245;       // BSD Formula
    12         c  = 12345;                                     // BSD Formula
    13         m = 2147483648;                 // BSD Formula
    14         _seed = 0;
    15         lbound = 0.0;
    16         ubound = 1.0;
    17         return;
    18 }
    19 /*}}}*/
    20 rnd_uniform_distribution::rnd_uniform_distribution(double lower,double upper){/*{{{*/
    21 
    22         a   = 1103515245;               // BSD Formula
    23         c  = 12345;                                     // BSD Formula
    24         m = 2147483648;                 // BSD Formula
    25         _seed = 0;
    26         lbound = 1.0;//lower;
    27         ubound = upper;
    28         return;
    29 }
    30 /*}}}*/
    31 rnd_uniform_distribution::~rnd_uniform_distribution(){}
    32 
    33 rnd_normal_distribution::rnd_normal_distribution(){/*{{{*/
    34 
    35         _seed = 0;
    36         mean   = 0;
    37         sdev  = 1.0;
    38         return;
    39 }
    40 /*}}}*/
    41 rnd_normal_distribution::rnd_normal_distribution(double m,double s){/*{{{*/
    42 
    43         _seed = 0;
    44         mean   = m;
    45         sdev  = s;
    46         return;
    47 }
    48 /*}}}*/
    49 rnd_normal_distribution::~rnd_normal_distribution(){}
  • issm/trunk-jpl/src/c/shared/Random/randomgenerator.h

    r26588 r26589  
    1717    unsigned int m;
    1818    unsigned _seed;
    19     double lbound;
    20     double ubound;
     19    double a1;
     20    double a2;
    2121
    2222    int drnd() { return( _seed = ( a * _seed + c ) % m ); }
     
    2525
    2626    /*constructors, destructors: */
    27     rnd_uniform_distribution();
    28     rnd_uniform_distribution(double a_1,double a_2);
    29     ~rnd_uniform_distribution();
    30 
     27    rnd_uniform_distribution() : _seed( 0 ), a( 1103515245 ), c( 12345 ), m( 2147483648 ), a1(0.0), a2(1.0) {}
     28    rnd_uniform_distribution(double a_1,double a_2) : _seed( 0 ), a( 1103515245 ), c( 12345 ), m( 2147483648 ), a1(a_1), a2(a_2) {}
    3129    void seed( unsigned int s ) { _seed = s; }
    3230    unsigned int get_seed() { return _seed; }
    33     double generator() { return (ubound-lbound)*(double) drnd()/ m + lbound; }
     31    double generator() { return (a2-a1)*(double) drnd()/ m + a1; }
    3432
    3533};
     
    4442
    4543  public:
    46 
    47     /*constructors, destructors: */
    48     rnd_normal_distribution();
    49     rnd_normal_distribution(double m,double s);
    50     //
    51     ~rnd_normal_distribution();
    52 
     44    rnd_normal_distribution() : _seed( 0 ), mean( 0), sdev(1.0) {}
     45    rnd_normal_distribution(double m,double s) : _seed( 0 ), mean( m ), sdev(s) {}
    5346    void seed( unsigned int s ) { _seed = s; }
    5447    double generator()
Note: See TracChangeset for help on using the changeset viewer.