Vaucanson  1.4.1
random.hh
Go to the documentation of this file.
1 // random.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_MISC_RANDOM_HH
18 # define VCSN_MISC_RANDOM_HH
19 
25 # include <vaucanson/algebra/implementation/letter/range.hh>
27 
28 namespace vcsn {
29  namespace misc {
30 
32  namespace random {
33 
36 
37  template<typename T>
38  T generate ();
39 
44  template<typename T>
45  T generate (T min, T max);
46 
47 
49  template<>
50  char generate<char> ();
51 
53  template<>
54  char generate<char> (char min, char max);
55 
57  char generate_letter ();
58 
60  char generate_digit ();
61 
63  template<>
64  bool generate<bool> ();
65 
67  template<>
68  int generate<int> ();
69 
71  template<>
72  int generate<int> (int min, int max);
73 
75  template<>
76  unsigned generate<unsigned> ();
77 
79  template<>
80  unsigned generate<unsigned> (unsigned min, unsigned max);
81 
83  template<>
84  float generate<float> ();
85 
87  template<>
88  float generate<float> (float min, float max);
89 
91  template<>
92  double generate<double> ();
93 
95  template<>
96  double generate<double> (double min, double max);
97 
99  template <class IteratorValueType, class InputIterator, class OutputIterator>
100  void sample_n (const IteratorValueType&, InputIterator first, InputIterator end,
101  OutputIterator out, unsigned n);
102 
104  template<>
105  vcsn::algebra::RationalNumber generate<vcsn::algebra::RationalNumber> ();
106 
115  template<>
117  generate<vcsn::algebra::RationalNumber>
120 
122 # define DECLARE_PAIR_SPECIALIZATION(TYPE1, TYPE2) \
123  template <> \
124  std::pair<TYPE1, TYPE2> generate<std::pair<TYPE1, TYPE2> >()
125 
126  DECLARE_PAIR_SPECIALIZATION(char, char);
127  DECLARE_PAIR_SPECIALIZATION(char, int);
128  DECLARE_PAIR_SPECIALIZATION(int, int);
129  DECLARE_PAIR_SPECIALIZATION(int, char);
130 
131 # undef DECLARE_PAIR_SPECIALIZATION
132 
134 
135  typedef
136  vcsn::algebra::static_char_interval<'a', 'z'>
138 
139  typedef
140  vcsn::algebra::static_ranged<char, small_alpha_interval_t>
142 
144  template <>
151  }
152  } // end of namespace misc.
153 } // end of namespace vcsn.
154 
155 
156 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
157 # include <vaucanson/misc/random.hxx>
158 # endif // VCSN_USE_INTERFACE_ONLY
159 
160 
161 #endif // ! VCSN_MISC_RANDOM_HH