17 #ifndef VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_RANDOM_VISITOR_HXX
18 # define VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_RANDOM_VISITOR_HXX
23 # include <vaucanson/algebra/implementation/series/rat/random_visitor.hh>
24 # include <vaucanson/algebra/implementation/series/rat/nodes.hh>
30 template <
typename M_,
typename W_>
31 RandomVisitor<M_, W_>::RandomVisitor(
unsigned nb_star_max) :
33 nb_star_max_(nb_star_max)
36 template <
typename M_,
typename W_>
37 RandomVisitor<M_, W_>::RandomVisitor() :
39 nb_star_max_(nb_star_max_default)
42 template<
typename M_,
typename W_>
44 RandomVisitor<M_,W_>::product(
const Node<M_, W_>* left_,
45 const Node<M_, W_>* right_)
48 right_->accept(*
this);
55 template <
class M_,
class W_>
57 RandomVisitor<M_,W_>::left_weight(
const W_&,
const Node<M_, W_>* node)
62 template <
class M_,
class W_>
64 RandomVisitor<M_,W_>::right_weight(
const W_&,
const Node<M_, W_>* node)
69 template<
typename M_,
typename W_>
71 RandomVisitor<M_,W_>::sum(
const Node<M_, W_>* left_,
72 const Node<M_, W_>* right_)
74 unsigned r = rand() * 2 / RAND_MAX;
78 right_->accept(*
this);
81 template<
typename M_,
typename W_>
86 unsigned n = rand() * nb_star_max_ / RAND_MAX;
89 for (
unsigned i = 0; i < n; ++i)
98 template<
typename M_,
typename W_>
100 RandomVisitor<M_,W_>::constant(
const M_& m)
106 template <
class M_,
class W_>
108 RandomVisitor<M_,W_>::one()
114 template <
class M_,
class W_>
116 RandomVisitor<M_,W_>::zero()
120 template<
typename M_,
typename W_>
123 assertion(not_empty);
131 #endif // ! VCSN_ALGEBRA_IMPLEMENTATION_SERIES_RAT_RANDOM_VISITOR_HXX