Modified eoInit so that it would use the eoRndGenerator base class.
To be able to use the primitive std::generate function, added a set of wrappers in eoSTLFunctor.h that have the copy semantics most STL functions expect (namely pass-by-value rather then pass-by-reference). Updated test/Makefile.am to also test t-eoRandom
This commit is contained in:
parent
e28211188a
commit
a79075f673
11 changed files with 240 additions and 83 deletions
|
|
@ -3,8 +3,8 @@
|
|||
t-eoRandom.cpp
|
||||
Test program for random generator
|
||||
|
||||
(c) GeNeura Team, 1999
|
||||
|
||||
(c) GeNeura Team, 1999
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
|
|
@ -18,19 +18,19 @@
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Contact: todos@geneura.ugr.es, http://geneura.ugr.es
|
||||
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
CVS Info: $Date: 2001-02-18 04:34:57 $ $Author: evomarc $ $Revision: 1.9 $
|
||||
CVS Info: $Date: 2001-02-19 12:23:13 $ $Author: maartenkeijzer $ $Revision: 1.10 $
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <iostream> // cout
|
||||
#include <strstream> // ostrstream, istrstream
|
||||
#include <fstream> // ostrstream, istrstream
|
||||
#include <utils/eoRndGenerators.h> // eoBin
|
||||
//#include <eoNormal.h>
|
||||
//#include <eoNegExp.h>
|
||||
|
|
@ -38,27 +38,28 @@ CVS Info: $Date: 2001-02-18 04:34:57 $ $Author: evomarc $ $Revision: 1.9 $
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
main() {
|
||||
try{
|
||||
eoUniformGenerator<float> u1(-2.5,3.5);
|
||||
eoUniformGenerator<double> u2(0.0003, 0.0005 );
|
||||
eoUniformGenerator<unsigned long> u3( 100000U, 10000000U);
|
||||
eoUniformGenerator<double> u2(0.003, 0.05 );
|
||||
eoUniformGenerator<unsigned long> u3( 10000U, 10000000U);
|
||||
|
||||
eoNegExpGenerator<float> e1(3.5);
|
||||
eoNegExpGenerator<double> e2(0.003 );
|
||||
eoNegExpGenerator<long> e3( 10000U);
|
||||
/* cout << "n1\t\tn2\t\tn3\t\te1\t\te2\t\te3" << endl; */
|
||||
for ( unsigned i = 0; i < 100; i ++) {
|
||||
cout << "Uniform: " << u1() << "\t" << u2() << "\t" << u3() << endl;
|
||||
cout << "NegExp: " << e1() << "\t" << e2() << "\t" << e3() << endl;
|
||||
try
|
||||
{ // throws an error
|
||||
eoUniformGenerator<unsigned long> utest( 10000000U, 10000U);
|
||||
}
|
||||
}
|
||||
|
||||
catch (exception& e)
|
||||
{
|
||||
cout << "exception: " << e.what() << endl;;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
catch (logic_error& e)
|
||||
{
|
||||
cout << e.what() << endl;
|
||||
}
|
||||
|
||||
ofstream os("t-eoRandom.out");
|
||||
|
||||
for ( unsigned i = 0; i < 100; i ++)
|
||||
{
|
||||
os << u1() << "\t" << u2() << "\t" << u3() << endl;
|
||||
}
|
||||
|
||||
return 0; // to avoid VC++ complaints
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
Reference in a new issue