aGrUM  0.14.2
simpleUTGenerator.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
27 
28 namespace gum {
29 
30  // Default constructor.
32 
33  // Destructor.
35 
36  // Generates a UT using floats.
37  // @param varID The variable id of the UT owner.
38  // @param ut A reference on the UT to fill.
40  const Potential< float >& ut) {
41  std::vector< float > v;
42 
43  for (Size i = 0; i < ut.domainSize(); ++i)
44  v.push_back((float)rand() * 1000);
45 
46  ut.populate(v);
47  }
48 
49  // Generates a UT using doubles.
50  // @param varID The variable id of the UT owner.
51  // @param ut A reference on the UT to fill.
53  const Potential< double >& ut) {
54  std::vector< double > v;
55 
56  for (Size i = 0; i < ut.domainSize(); ++i)
57  v.push_back((double)rand() * 1000);
58 
59  ut.populate(v);
60  }
61 
62 } /* namespace gum */
aGrUM&#39;s Potential is a multi-dimensional array with tensor operators.
Definition: potential.h:57
Class for generating Utility Tables.
virtual Size domainSize() const final
Returns the product of the variables domain size.
SimpleUTGenerator()
Default constructor.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
virtual void populate(const std::vector< GUM_SCALAR > &v) const final
Automatically fills this MultiDimContainer with the values in v.
virtual void generateUT(const Idx &varId, const Potential< float > &ut)
Generates a UT using floats.
Abstract class for generating Utility Tables.
virtual ~SimpleUTGenerator()
Destructor.
Size Idx
Type for indexes.
Definition: types.h:50
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45