PinkGenerator.cpp

Go to the documentation of this file.
00001 #include "PinkGenerator.h"
00002 
00003 
00004 double PinkGenerator::av[3][5] = {{4.3606e-3, 5.9961e-3, 8.3586e-3, 0.0, 0.0},
00005                                   {0.0100, 0.00763, 0.00832, 0.01036, 0.0},
00006                                   {0.00224, 0.00821, 0.00798, 0.00694, 0.00992}};
00007 
00008 double PinkGenerator::pv[3][5] = {{3.1878e-1, 7.7686e-1, 9.7785e-1, 0.0, 0.0},
00009                                   {0.3030, 0.74170, 0.91680, 0.97820, 0.0},
00010                                   {0.15571, 0.30194, 0.74115, 0.93003, 0.98035}};
00011 
00012 //ThreadSpecificRandomDistribution< UniformDistribution > PinkGenerator::white_noise;
00013 
00014 UniformDistribution PinkGenerator::white_noise;
00015 MersenneTwister19937 PinkGenerator::mt;
00016 
00017 PinkGenerator::PinkGenerator(int numGen)
00018 {
00019     setNumGen(numGen);
00020 }
00021 
00022 
00023 void PinkGenerator::setNumGen(int numGen)
00024 {
00025     if (numGen>=3 && numGen <= 5)
00026         nGen=numGen;
00027     else
00028         nGen=3;
00029 
00030     reset();
00031 }
00032 
00033 PinkGenerator::~PinkGenerator()
00034 {
00035 }
00036 
00037 
00038 int PinkGenerator::adjust(double dt)
00039 {
00040 //    white_noise.set(UniformDistribution(0.0, 1.0));
00041     return 0;
00042 }
00043 
00044 
00045 int PinkGenerator::reset()
00046 {
00047     for (int i=0; i<nGen; i++)
00048 //        randreg[i]=av[nGen-3][i]*(2*white_noise()-0.5);               
00049         randreg[i]=av[nGen-3][i]*(2*white_noise(mt)-0.5);               
00050 
00051     return 0;
00052 }
00053 
00054 
00055 void PinkGenerator::advance()
00056 {
00057 //    double rv=2*white_noise();
00058     double rv=2*white_noise(mt);
00059     value=0.0;
00060 
00061     for (int i=0; i<nGen; i++)
00062     {
00063         if (rv > pv[nGen-3][i])
00064 //            randreg[i] = av[nGen-3][i]*(2*white_noise()-0.5);
00065             randreg[i] = av[nGen-3][i]*(2*white_noise(mt)-0.5);
00066 
00067         value += randreg[i];
00068     }
00069 }

Generated on Wed Jul 9 16:34:39 2008 for PCSIM by  doxygen 1.5.5