aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
multiDimBijArray.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2026 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2026 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
49
50#ifndef GUM_MULTIDIMBIJARRAY_H
51#define GUM_MULTIDIMBIJARRAY_H
52
55
56#include <initializer_list>
57
58namespace gum {
59
70 template < typename GUM_ELEMENT >
71 class MultiDimBijArray final: public MultiDimWithOffset< GUM_ELEMENT > {
72 public:
74
75 // =========================================================================
77 // =========================================================================
79
87 MultiDimBijArray(const VarBijection& bijection, const MultiDimArray< GUM_ELEMENT >& array);
88
97
107
111 ~MultiDimBijArray() override;
112
114 // ========================================================================
116 // ========================================================================
118
124
130 void set(const Instantiation& i, const GUM_ELEMENT& value) const override;
131
138 void add(const DiscreteVariable& v) override;
139
146 void erase(const DiscreteVariable& v) override;
147
153 void fill(const GUM_ELEMENT& d) const override;
154
161 void populate(const std::vector< GUM_ELEMENT >& v) const override;
162
169 void populate(std::initializer_list< GUM_ELEMENT > l) const override;
170
172 // ========================================================================
174 // ========================================================================
176
177 const std::string& name() const override;
178
179 GUM_ELEMENT get(const Instantiation& i) const override;
180
181 Size realSize() const override;
182
183 [[nodiscard]] MultiDimBijArray< GUM_ELEMENT >* newFactory() const override;
184
186
187 protected:
188 GUM_ELEMENT& get_(const Instantiation& i) const override;
189
190 void commitMultipleChanges_() override;
191
192 void replace_(const DiscreteVariable* x, const DiscreteVariable* y) override;
193
194 private:
197
199 std::string _name_;
200 };
201
202
203#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
204 extern template class MultiDimBijArray< double >;
205#endif
206
207} // namespace gum
208
210
211#endif // GUM_MULTIDIMBIJARRAY_H
Set of pairs of elements with fast search for both elements.
Set of pairs of elements with fast search for both elements.
Definition bijection.h:1640
Base class for discrete random variable.
Class for assigning/browsing values to tuples of discrete variables.
Multidimensional matrix stored as an array in memory.
Decorator of a MultiDimArray, using a bijection over the variables.
GUM_ELEMENT & get_(const Instantiation &i) const override
Return a data, given a Instantiation.
void set(const Instantiation &i, const GUM_ELEMENT &value) const override
MultiDimBijArray< GUM_ELEMENT > * newFactory() const override
Class constructor.
const std::string & name() const override
Returns the real name of the multiDim implementation.
GUM_ELEMENT get(const Instantiation &i) const override
Returns the value pointed by i.
std::string _name_
The class name.
void add(const DiscreteVariable &v) override
This will raise an exception: you can't change the variables in a MultiDimBijArray.
void commitMultipleChanges_() override
Synchronize content after MultipleChanges.
Bijection< const DiscreteVariable *, const DiscreteVariable * > VarBijection
Size realSize() const override
Returns the real number of parameters used for this table.
const MultiDimArray< GUM_ELEMENT > & _array_
The true data.
MultiDimBijArray< GUM_ELEMENT > & operator=(const MultiDimBijArray< GUM_ELEMENT > &from)
~MultiDimBijArray() override
Class destructor.
MultiDimBijArray(const VarBijection &bijection, const MultiDimArray< GUM_ELEMENT > &array)
Class constructor.
void erase(const DiscreteVariable &v) override
This will raise an exception: you can't change the variables in a MultiDimBijArray.
void populate(const std::vector< GUM_ELEMENT > &v) const override
This will raise an exception: you can't change the variables in a MultiDimBijArray.
void replace_(const DiscreteVariable *x, const DiscreteVariable *y) override
This is called by MultiDimContainer::replace() to proceed with the replacing between x and y.
void fill(const GUM_ELEMENT &d) const override
This will raise an exception: you can't change the data.
MultiDimWithOffset()
Class constructor.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Header of the MultiDimArray class.
Implementation of the MultiDimBijArray class.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46