Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages | Search for

# t-eoRandom.cpp

    00001 /* -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
    00002
    00003     t-eoRandom.cpp
    00004       Test program for random generator
    00005
    00006     (c) GeNeura Team, 1999
    00007
    00008     This program is free software; you can redistribute it and/or modify
    00009     it under the terms of the GNU General Public License as published by
    00010     the Free Software Foundation; either version 2 of the License, or
    00011     (at your option) any later version.
    00012
    00013     This program is distributed in the hope that it will be useful,
    00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00016     GNU General Public License for more details.
    00017
    00018     You should have received a copy of the GNU General Public License
    00019     along with this program; if not, write to the Free Software
    00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00021
    00022     Contact: todos@geneura.ugr.es, http://geneura.ugr.es
    00023
    00024 */
    00025
    00030 //-----------------------------------------------------------------------------
    00031
    00032 #include <iostream>   // cout
    00033 #include <fstream>  // ostrstream, istrstream
    00034 #include <utils/eoRndGenerators.h>         // eoBin
    00035 //#include <eoNormal.h>
    00036 //#include <eoNegExp.h>
    00037
    00038 //-----------------------------------------------------------------------------
    00039
    00040 int main() {
    00041   eoUniformGenerator<float> u1(-2.5,3.5);
    00042   eoUniformGenerator<double> u2(0.003, 0.05 );
    00043   eoUniformGenerator<unsigned long> u3( 10000U, 10000000U);
    00044
    00045   try
    00046   { // throws an error
    00047     eoUniformGenerator<unsigned long> utest( 10000000U, 10000U);
    00048     throw; // if this succeeds something is wrong, make sure that that is noticed
    00049   }
    00050   catch (std::logic_error& e)
    00051   {
    00052     std::cout << e.what() << std::endl;
    00053   }
    00054
    00055   std::ofstream os("t-eoRandom.out");
    00056
    00057   for ( unsigned i = 0; i < 100; i ++)
    00058   {
    00059     os << u1() << "\t" << u2() << "\t" << u3() << std::endl;
    00060   }
    00061
    00062   return 0; // to avoid VC++ complaints
    00063
    00064 }
    00065
    00066 //-----------------------------------------------------------------------------