aGrUM  0.16.0
multiDimBijArray_tpl.h
Go to the documentation of this file.
1 
32 
33 namespace gum {
34 
35  template < typename GUM_SCALAR >
37  const MultiDimBijArray< GUM_SCALAR >& from) :
38  MultiDimWithOffset< GUM_SCALAR >(),
39  __array(from.__array), __name(from.__name) {
40  GUM_CONS_CPY(MultiDimBijArray);
41 
42  for (auto var : from.variablesSequence()) {
44  }
45  }
46 
47  template < typename GUM_SCALAR >
49  const VarBijection& bijection, const MultiDimArray< GUM_SCALAR >& array) :
50  MultiDimWithOffset< GUM_SCALAR >(),
51  __array(array), __name("MultiDimBijArray") {
52  GUM_CONSTRUCTOR(MultiDimBijArray);
53 
54  for (auto var : array.variablesSequence()) {
56  }
57  }
58 
59  template < typename GUM_SCALAR >
61  const VarBijection& bijection, const MultiDimBijArray< GUM_SCALAR >& array) :
62  MultiDimWithOffset< GUM_SCALAR >(),
63  __array(array.__array), __name("MultiDimBijArray") {
64  GUM_CONSTRUCTOR(MultiDimBijArray);
65 
66  for (auto var : array.variablesSequence()) {
68  }
69  }
70 
71  template < typename GUM_SCALAR >
73  GUM_DESTRUCTOR(MultiDimBijArray);
74  }
75 
76  template < typename GUM_SCALAR >
79  GUM_ERROR(OperationNotAllowed, "MultiDimBijArray are readonly.");
80  }
81 
82  template < typename GUM_SCALAR >
85  return new MultiDimBijArray< GUM_SCALAR >(*this);
86  }
87 
88  template < typename GUM_SCALAR >
89  INLINE const std::string& MultiDimBijArray< GUM_SCALAR >::name() const {
90  return __name;
91  }
92 
93  template < typename GUM_SCALAR >
95  GUM_ERROR(OperationNotAllowed, "MultiDimBijArray<GUM_SCALAR> are read only.");
96  }
97 
98  template < typename GUM_SCALAR >
100  GUM_ERROR(OperationNotAllowed, "MultiDimBijArray<GUM_SCALAR> are read only.");
101  }
102 
103  template < typename GUM_SCALAR >
105  return (Size)0;
106  }
107 
108  template < typename GUM_SCALAR >
109  INLINE void MultiDimBijArray< GUM_SCALAR >::fill(const GUM_SCALAR& d) const {
110  GUM_ERROR(OperationNotAllowed, "MultiDimBijArray<GUM_SCALAR> are read only.");
111  }
112 
113  template < typename GUM_SCALAR >
115  // Do nothing
116  }
117 
118  template < typename GUM_SCALAR >
119  INLINE GUM_SCALAR
121  if (i.isMaster(this)) {
122  return __array._values[this->_offsets[&i]];
123  } else {
124  return __array._values[this->_getOffs(i)];
125  }
126  }
127 
128  template < typename GUM_SCALAR >
130  const GUM_SCALAR& value) const {
131  GUM_ERROR(OperationNotAllowed, "MultiDimBijArray<GUM_SCALAR> are read only.");
132  }
133 
134  template < typename GUM_SCALAR >
136  const std::vector< GUM_SCALAR >& v) const {
137  GUM_ERROR(OperationNotAllowed, "MultiDimBijArray<GUM_SCALAR> are read only.");
138  }
139 
140  template < typename GUM_SCALAR >
142  std::initializer_list< GUM_SCALAR > l) const {
143  GUM_ERROR(OperationNotAllowed, "MultiDimBijArray<GUM_SCALAR> are read only.");
144  }
145 
146  template < typename GUM_SCALAR >
147  INLINE GUM_SCALAR&
149  GUM_ERROR(OperationNotAllowed, "MultiDimBijArray<GUM_SCALAR> are read only.");
150  }
151 
152  template < typename GUM_SCALAR >
154  const DiscreteVariable* y) {
156  }
157 
158 } // namespace gum
virtual GUM_SCALAR & _get(const Instantiation &i) const
Return a data, given a Instantiation.
const MultiDimArray< GUM_SCALAR > & __array
The true data.
const T2 & second(const T1 &first) const
Returns the second value of a pair given its first value.
Decorator of a MultiDimArray, using a bijection over the variables.
Definition: multiDimArray.h:39
virtual const std::string & name() const
Returns the real name of the multiDim implementation.
HashTable< const Instantiation *, Size > _offsets
The position in the array of each slave Instantiation.
MultiDimBijArray< GUM_SCALAR > & operator=(const MultiDimBijArray< GUM_SCALAR > &from)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
std::string __name
The class name.
virtual GUM_SCALAR get(const Instantiation &i) const
Returns the value pointed by i.
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
virtual void _commitMultipleChanges()
Synchronize content after MultipleChanges.
virtual void add(const DiscreteVariable &v)
Adds a new var to the variables of the multidimensional matrix.
virtual void set(const Instantiation &i, const GUM_SCALAR &value) const
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.
Abstract class for Multidimensional matrix stored as an array in memory and with an offset associated...
virtual void _replace(const DiscreteVariable *x, const DiscreteVariable *y) override
Replace variable x by y.
Multidimensional matrix stored as an array in memory.
Definition: multiDimArray.h:54
Set of pairs of elements with fast search for both elements.
Definition: bijection.h:1805
Size _getOffs(const Instantiation &i) const
Compute the offset of a Instantiation.
virtual void add(const DiscreteVariable &v)
This will raise an exception: you can&#39;t change the variables in a MultiDimBijArray.
virtual const Sequence< const DiscreteVariable *> & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:83
virtual ~MultiDimBijArray()
Class destructor.
bool isMaster(const MultiDimAdressable *m) const
Indicates whether m is the master of this instantiation.
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:48
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
virtual void _replace(const DiscreteVariable *x, const DiscreteVariable *y)
Replace variable x by y.