aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
multiDimInterface.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 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-2025 *
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
48
49#ifndef GUM_MULTIDIM_INTERFACE_H
50#define GUM_MULTIDIM_INTERFACE_H
51
52#include <iostream>
53#include <vector>
54
55#include <agrum/agrum.h>
56
59
60namespace gum {
61
62#ifndef DOXYGEN_SHOULD_SKIP_THIS
63 // Forward declaration.
64 class Instantiation;
65#endif
66
67 // ==========================================================================
68 // === MULTIDIM INTERFACE ===
69 // ==========================================================================
83 public:
88 virtual ~MultiDimInterface() {};
89
90 // =========================================================================
92 // =========================================================================
94
99 virtual Idx nbrDim() const = 0;
100
105 virtual Size domainSize() const = 0;
106
121 virtual void add(const DiscreteVariable& v) = 0;
122
130 virtual void erase(const DiscreteVariable& v) = 0;
131
137
145 virtual const DiscreteVariable& variable(Idx i) const = 0;
146
155 virtual const DiscreteVariable& variable(const std::string& name) const = 0;
156
163 virtual Idx pos(const DiscreteVariable& v) const = 0;
164
170 virtual bool contains(const DiscreteVariable& v) const = 0;
171
176 virtual bool empty() const = 0;
177
190 void replace(const DiscreteVariable& x, const DiscreteVariable& y);
191
193
194 protected:
204 virtual void replace_(const DiscreteVariable* x, const DiscreteVariable* y) = 0;
205 };
206
226
235
236} /* namespace gum */
237
238#ifndef GUM_NO_INLINE
240#endif // GUM_NO_INLINE
241
242#endif /* GUM_MULTIDIM_INTERFACE_H */
Base class for discrete random variable.
Class for assigning/browsing values to tuples of discrete variables.
Interface for all classes addressing in a multiDim fashion.
void replace(const DiscreteVariable &x, const DiscreteVariable &y)
Replace variables in this multidim.
virtual const Sequence< const DiscreteVariable * > & variablesSequence() const =0
Returns a const ref to the sequence of DiscreteVariable*.
virtual Size domainSize() const =0
Returns the product of the variables domain size.
virtual ~MultiDimInterface()
Class destructor.
virtual Idx pos(const DiscreteVariable &v) const =0
Returns the index of a variable.
virtual void add(const DiscreteVariable &v)=0
Adds a new var to the variables of the multidimensional matrix.
virtual Idx nbrDim() const =0
Returns the number of vars in the multidimensional container.
virtual const DiscreteVariable & variable(Idx i) const =0
Returns a const ref to the ith var.
virtual void replace_(const DiscreteVariable *x, const DiscreteVariable *y)=0
This is called by MultiDimContainer::replace() to proceed with the replacing between x and y.
virtual bool contains(const DiscreteVariable &v) const =0
Returns true if var is in *this.
virtual void erase(const DiscreteVariable &v)=0
Removes a var from the variables of the multidimensional matrix.
virtual const DiscreteVariable & variable(const std::string &name) const =0
Returns the variable with the name.
virtual bool empty() const =0
Returns true if no var is in *this.
The generic class for storing (ordered) sequences of objects.
Definition sequence.h:972
Base class for discrete random variable.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Size Idx
Type for indexes.
Definition types.h:79
MultiDimInterface & operator>>(MultiDimInterface &c, const DiscreteVariable &v)
Removes a var from the variables of the MutliDimAdressing.
Inline implementation of gumMultiDimInterface.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
std::ostream & operator<<(std::ostream &stream, const AVLTree< Val, Cmp > &tree)
display the content of a tree
Definition AVLTree.h:913
Header file of gum::Sequence, a class for storing (ordered) sequences of objects.