aGrUM  0.16.0
multiDimSparse.h
Go to the documentation of this file.
1 
29 #ifndef GUM_MULTI_DIM_SPARSE_H
30 #define GUM_MULTI_DIM_SPARSE_H
31 
32 #include <agrum/agrum.h>
34 #include <vector>
35 
36 namespace gum {
37 
38  // ===========================================================================
39  // === GUM_MULTI_DIM_ARRAY ===
40  // ===========================================================================
50  template < typename GUM_SCALAR >
51  class MultiDimSparse : public MultiDimWithOffset< GUM_SCALAR > {
52  public:
53  // =========================================================================
55  // =========================================================================
57 
62  explicit MultiDimSparse(const GUM_SCALAR& default_value);
63 
73 
86  virtual ~MultiDimSparse();
87 
88 
90  // =========================================================================
92  // =========================================================================
94 
96 
97  void add(const DiscreteVariable& v);
98 
99  void erase(const DiscreteVariable& v);
100 
101  virtual void fill(const GUM_SCALAR& d) const;
102 
103  virtual GUM_SCALAR get(const Instantiation& i) const;
104 
105  virtual void set(const Instantiation& i, const GUM_SCALAR& value) const;
106 
107  virtual const std::string& name() const;
108 
109  virtual Size realSize() const;
110 
112 
113  protected:
117 
119  mutable GUM_SCALAR _default;
120 
122  virtual void _commitMultipleChanges();
123 
128  virtual GUM_SCALAR& _get(const Instantiation& i) const;
129 
130  // =========================================================================
132  // =========================================================================
134 
135  virtual void _replace(const DiscreteVariable* x, const DiscreteVariable* y);
136 
138  };
139 
140 
141 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
142  extern template class MultiDimSparse< double >;
143 #endif
144 
145 
146 } /* namespace gum */
147 
149 
150 #endif /* GUM_MULTI_DIM_SPARSE_H */
GUM_SCALAR _default
The default value.
void erase(const DiscreteVariable &v)
Removes a var from the variables of the multidimensional matrix.
virtual ~MultiDimSparse()
Copy operator.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Base class for discrete random variable.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
Abstract base class for all multi dimensionnal containers.
virtual MultiDimContainer< GUM_SCALAR > * newFactory() const
Class constructor.
Abstract class for Multidimensional matrix stored as an array in memory and with an offset associated...
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual void _commitMultipleChanges()
Synchronise content after MultipleChanges.
void add(const DiscreteVariable &v)
Adds a new var to the variables of the multidimensional matrix.
virtual const std::string & name() const
Returns the real name of the multiDim implementation.
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:83
MultiDimSparse(const GUM_SCALAR &default_value)
Default constructor: creates an empty null dimensional matrix.
virtual GUM_SCALAR & _get(const Instantiation &i) const
HashTable< Size, GUM_SCALAR > _params
The true data : the values is mutable since we can change the value in a const multiDimArray.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
virtual void _replace(const DiscreteVariable *x, const DiscreteVariable *y)
Replace variable x by y.
virtual void fill(const GUM_SCALAR &d) const
Fill the table with d.
virtual Size realSize() const
Returns the real number of parameters used for this table.
Multidimensional matrix stored as a sparse array in memory.