Changeset 377


Ignore:
Timestamp:
Aug 8, 2005, 1:33:13 AM (17 years ago)
Author:
Jari Häkkinen
Message:

Replaced utility::random_singleton.* with random::random.*

Location:
trunk
Files:
2 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/gslapi/utility.cc

    r358 r377  
    44
    55#include <c++_tools/gslapi/vector.h>
    6 #include <c++_tools/utility/random_singleton.h>
     6#include <c++_tools/random/random.h>
    77
    88#include <utility>
     
    3333  {
    3434    vector vec(invec);
    35     utility::random_singleton*
    36       rnd=utility::random_singleton::instance();
     35    random::DiscreteUniform rnd;
    3736    for (size_t i=0; i<vec.size(); i++){
    38       size_t index = rnd->uniform_int(vec.size()-i);
     37      size_t index = rnd(vec.size()-i);
    3938      invec[i]=vec(index);
    4039      vec(index)=vec(vec.size()-i-1);
  • trunk/lib/random/random.h

    r375 r377  
    276276    /// @brief Constructor.
    277277    ///
     278    /// @todo The default behaviour of the underlying RNG should be
     279    /// setup when this constructor is used.
     280    ///
     281    inline DiscreteUniform(void)
     282      : min_(0), range_(0) {}
     283
     284    ///
     285    /// @brief Constructor.
     286    ///
    278287    /// @param \a range is number of different integers that can be
    279288    /// generated \f$ (b-a+1) \f$ \a min is the minimal integer that
  • trunk/lib/svm/CrossValidation.cc

    r301 r377  
    44#include <c++_tools/gslapi/vector.h>
    55#include <c++_tools/svm/CrossValidation.h>
    6 #include <c++_tools/utility/random_singleton.h>
     6#include <c++_tools/random/random.h>
    77
    88#include <vector>
     
    2424    }
    2525
    26     utility::my_uniform_rng a;
     26    random::DiscreteUniform a;
    2727    random_shuffle(index_negative_.begin(), index_negative_.end(), a);
    2828    random_shuffle(index_positive_.begin(), index_positive_.end(), a);
     
    3131  std::vector<size_t> CrossValidation::next()
    3232  {
     33    random::DiscreteUniform a;
    3334    if (count_==k_){
    3435      count_=0;
    35       utility::my_uniform_rng a;
    3636      random_shuffle(index_negative_.begin(), index_negative_.end(), a);
    3737      random_shuffle(index_positive_.begin(), index_positive_.end(), a);
  • trunk/lib/svm/SVM.cc

    r330 r377  
    88#include <c++_tools/gslapi/vector.h>
    99#include <c++_tools/statistics/Averager.h>
    10 #include <c++_tools/utility/random_singleton.h>
     10#include <c++_tools/random/random.h>
    1111
    1212#include <iostream>
     
    119119  void Index::shuffle(void)
    120120  {
    121     utility::my_uniform_rng a;
     121    random::DiscreteUniform a;
    122122    random_shuffle(vec_.begin()+nof_sv_, vec_.end(), a);
    123123  }
  • trunk/lib/utility/Makefile.am

    r366 r377  
    22##
    33## $Id: Makefile.am 281 2005-04-20 16:45:02Z peter $
    4 
    54
    65
     
    98noinst_LTLIBRARIES = libutility.la
    109libutility_la_SOURCES = \
    11   Alignment.cc FileIO.cc kNNI.cc Merge.cc NNI.cc PCA.cc\
    12   random_singleton.cc stl_utility.cc SVD.cc utility.cc WeNNI.cc
     10  Alignment.cc FileIO.cc kNNI.cc Merge.cc NNI.cc PCA.cc \
     11  stl_utility.cc SVD.cc utility.cc WeNNI.cc
    1312
    1413include_utilitydir = $(includedir)/c++_tools/utility
     
    1615include_utility_HEADERS = \
    1716  Alignment.h Exception.h FileIO.h kNNI.h Merge.h NNI.h PCA.h \
    18   random_singleton.h stl_utility.h SVD.h utility.h WeNNI.h
    19 
     17  stl_utility.h SVD.h utility.h WeNNI.h
  • trunk/test/rnd_test.cc

    r373 r377  
    11// $Id$
    22
     3#include <c++_tools/random/random.h>
     4
    35#include <iostream>
    4 #include <c++_tools/utility/random_singleton.h>
    56
    67
    7 using namespace theplu;
     8int main(const int argc,const char* argv[])
     9{
     10  theplu::random::ContinuousUniform uniform;
    811
    9 int main()
    10 {
    11   utility::random_singleton* my_rnd;
    12   my_rnd = utility::random_singleton::instance( -1 );
    13  
     12  theplu::random::RNG* rng=theplu::random::RNG::instance();
    1413
    1514  return 0;
  • trunk/test/svd_test.cc

    r358 r377  
    33#include <c++_tools/utility/SVD.h>
    44#include <c++_tools/gslapi/matrix.h>
    5 #include <c++_tools/utility/random_singleton.h>
     5#include <c++_tools/random/random.h>
    66#include <c++_tools/gslapi/vector.h>
    77
     
    1919
    2020
    21 bool test(size_t m, size_t n, utility::SVD::SVDalgorithm algo) {
    22 
     21bool test(size_t m, size_t n, utility::SVD::SVDalgorithm algo)
     22{
    2323  // accepted error, Jari: should be picked up from GSL
    2424  double MAXTOL=1e-13;
    25   utility::random_singleton* rng=utility::random_singleton::instance(-1);
    2625
    2726  // initialise a random test-matrix
     27  theplu::random::ContinuousUniform rnd;
    2828  gslapi::matrix A(m,n);
    2929  for (size_t i=0; i<m; ++i)
    3030    for(size_t j=0; j<n; ++j)
    31       A(i,j)=1000*rng->uniform_double();
     31      A(i,j)=1000*rnd();
    3232
    3333  utility::SVD svd(A);
Note: See TracChangeset for help on using the changeset viewer.