aGrUM  0.14.2
multiDimBijArray.h
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  ***************************************************************************/
28 #ifndef GUM_MULTIDIMBIJARRAY_H
29 #define GUM_MULTIDIMBIJARRAY_H
30 
31 #include <initializer_list>
32 
33 #include <agrum/core/bijection.h>
34 
37 
38 namespace gum {
39 
50  template < typename GUM_SCALAR >
51  class MultiDimBijArray : public MultiDimWithOffset< GUM_SCALAR > {
52  public:
53  using VarBijection =
55 
56  // =========================================================================
58  // =========================================================================
60 
68  MultiDimBijArray(const VarBijection& bijection,
69  const MultiDimArray< GUM_SCALAR >& array);
70 
78  MultiDimBijArray(const VarBijection& bijection,
79  const MultiDimBijArray< GUM_SCALAR >& array);
80 
90 
94  virtual ~MultiDimBijArray();
95 
97  // ========================================================================
99  // ========================================================================
101 
108 
114  virtual void set(const Instantiation& i, const GUM_SCALAR& value) const;
115 
122  virtual void add(const DiscreteVariable& v);
123 
130  virtual void erase(const DiscreteVariable& v);
131 
137  virtual void fill(const GUM_SCALAR& d) const;
138 
145  virtual void populate(const std::vector< GUM_SCALAR >& v) const;
146 
153  virtual void populate(std::initializer_list< GUM_SCALAR > l) const;
154 
156  // ========================================================================
158  // ========================================================================
160 
161  virtual const std::string& name() const;
162 
163  virtual GUM_SCALAR get(const Instantiation& i) const;
164 
165  virtual Size realSize() const;
166 
168 
170 
171  protected:
172  virtual GUM_SCALAR& _get(const Instantiation& i) const;
173 
174  virtual void _commitMultipleChanges();
175 
176  virtual void _replace(const DiscreteVariable* x, const DiscreteVariable* y);
177 
178  private:
181 
183  std::string __name;
184  };
185 
186 
187 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
188  extern template class MultiDimBijArray< double >;
189 #endif
190 
191 } // namespace gum
192 
194 
195 #endif // GUM_MULTIDIMBIJARRAY_H
virtual GUM_SCALAR & _get(const Instantiation &i) const
Return a data, given a Instantiation.
const MultiDimArray< GUM_SCALAR > & __array
The true data.
Decorator of a MultiDimArray, using a bijection over the variables.
Definition: multiDimArray.h:36
virtual const std::string & name() const
Returns the real name of the multiDim implementation.
MultiDimBijArray< GUM_SCALAR > & operator=(const MultiDimBijArray< GUM_SCALAR > &from)
virtual void fill(const GUM_SCALAR &d) const
This will raise an exception: you can&#39;t change the data.
virtual Size realSize() const
Returns the real number of parameters used for this table.
Headers of the MultiDimWithOffset class.
std::string __name
The class name.
Base class for discrete random variable.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
virtual void _commitMultipleChanges()
Synchronize content after MultipleChanges.
Bijection< const DiscreteVariable *, const DiscreteVariable *> VarBijection
virtual MultiDimBijArray< GUM_SCALAR > * newFactory() const
Class constructor.
MultiDimBijArray(const VarBijection &bijection, const MultiDimArray< GUM_SCALAR > &array)
Class constructor.
virtual void populate(const std::vector< GUM_SCALAR > &v) const
This will raise an exception: you can&#39;t change the variables in a MultiDimBijArray.
Multidimensional matrix stored as an array in memory.
Definition: multiDimArray.h:51
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1803
virtual void add(const DiscreteVariable &v)
This will raise an exception: you can&#39;t change the variables in a MultiDimBijArray.
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:80
virtual ~MultiDimBijArray()
Class destructor.
virtual void erase(const DiscreteVariable &v)
This will raise an exception: you can&#39;t change the variables in a MultiDimBijArray.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
Implementation of the MultiDimBijArray class.
Header of the MultiDimArray class.
Set of pairs of elements with fast search for both elements.
virtual void _replace(const DiscreteVariable *x, const DiscreteVariable *y)
Replace variable x by y.