aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
multiDimSparse.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
48
#ifndef GUM_MULTI_DIM_SPARSE_H
49
#define GUM_MULTI_DIM_SPARSE_H
50
51
#include <vector>
52
53
#include <
agrum/agrum.h
>
54
55
#include <
agrum/base/multidim/implementations/multiDimWithOffset.h
>
56
57
namespace
gum
{
58
59
// ===========================================================================
60
// === GUM_MULTI_DIM_ARRAY ===
61
// ===========================================================================
71
template
<
typename
GUM_ELEMENT >
72
class
MultiDimSparse
final:
public
MultiDimWithOffset
< GUM_ELEMENT > {
73
public
:
74
// =========================================================================
76
// =========================================================================
78
83
explicit
MultiDimSparse
(
const
GUM_ELEMENT& default_value);
84
93
MultiDimSparse
(
const
MultiDimSparse< GUM_ELEMENT >
& from);
94
103
107
~MultiDimSparse
()
override
;
108
109
111
// =========================================================================
113
// =========================================================================
115
116
[[nodiscard]]
MultiDimContainer< GUM_ELEMENT >
*
newFactory
()
const override
;
117
118
void
add
(
const
DiscreteVariable
& v)
override
;
119
120
void
erase
(
const
DiscreteVariable
& v)
override
;
121
122
void
fill
(
const
GUM_ELEMENT& d)
const override
;
123
124
GUM_ELEMENT
get
(
const
Instantiation
& i)
const override
;
125
126
void
set
(
const
Instantiation
& i,
const
GUM_ELEMENT& value)
const override
;
127
128
const
std::string&
name
()
const override
;
129
130
Size
realSize
()
const override
;
131
133
134
protected
:
137
mutable
HashTable< Size, GUM_ELEMENT >
params_
;
138
140
mutable
GUM_ELEMENT
default_
;
141
143
void
commitMultipleChanges_
()
override
;
144
149
GUM_ELEMENT&
get_
(
const
Instantiation
& i)
const override
;
150
151
// =========================================================================
153
// =========================================================================
155
156
void
replace_
(
const
DiscreteVariable
* x,
const
DiscreteVariable
* y)
override
;
157
159
};
160
161
162
#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
163
extern
template
class
GUM_SHARED_PUBLIC
MultiDimSparse< double >
;
164
#endif
165
166
167
}
/* namespace gum */
168
169
#include <
agrum/base/multidim/implementations/multiDimSparse_tpl.h
>
170
171
#endif
/* GUM_MULTI_DIM_SPARSE_H */
agrum.h
gum::DiscreteVariable
Base class for discrete random variable.
Definition
discreteVariable.h:80
gum::HashTable< Size, GUM_ELEMENT >
gum::Instantiation
Class for assigning/browsing values to tuples of discrete variables.
Definition
instantiation.h:102
gum::MultiDimContainer
Abstract base class for all multi dimensionnal containers.
Definition
multiDimContainer.h:113
gum::MultiDimSparse::fill
void fill(const GUM_ELEMENT &d) const override
Fill the table with d.
Definition
multiDimSparse_tpl.h:137
gum::MultiDimSparse::newFactory
MultiDimContainer< GUM_ELEMENT > * newFactory() const override
Class constructor.
Definition
multiDimSparse_tpl.h:148
gum::MultiDimSparse::name
const std::string & name() const override
Returns the real name of the multiDim implementation.
Definition
multiDimSparse_tpl.h:154
gum::MultiDimSparse::add
void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
Definition
multiDimSparse_tpl.h:116
gum::MultiDimSparse::get
GUM_ELEMENT get(const Instantiation &i) const override
Returns the value pointed by i.
Definition
multiDimSparse_tpl.h:84
gum::MultiDimSparse::set
void set(const Instantiation &i, const GUM_ELEMENT &value) const override
Changes the value pointed by i.
Definition
multiDimSparse_tpl.h:97
gum::MultiDimSparse::params_
HashTable< Size, GUM_ELEMENT > params_
The true data : the values is mutable since we can change the value in a const multiDimArray.
Definition
multiDimSparse.h:137
gum::MultiDimSparse::get_
GUM_ELEMENT & get_(const Instantiation &i) const override
Definition
multiDimSparse_tpl.h:166
gum::MultiDimSparse::erase
void erase(const DiscreteVariable &v) override
Removes a var from the variables of the multidimensional matrix.
Definition
multiDimSparse_tpl.h:124
gum::MultiDimSparse::replace_
void replace_(const DiscreteVariable *x, const DiscreteVariable *y) override
Replace variable x by y.
Definition
multiDimSparse_tpl.h:160
gum::MultiDimSparse::default_
GUM_ELEMENT default_
The default value.
Definition
multiDimSparse.h:140
gum::MultiDimSparse::realSize
Size realSize() const override
Returns the real number of parameters used for this table.
Definition
multiDimSparse_tpl.h:143
gum::MultiDimSparse::MultiDimSparse
MultiDimSparse(const GUM_ELEMENT &default_value)
Default constructor: creates an empty null dimensional matrix.
Definition
multiDimSparse_tpl.h:57
gum::MultiDimSparse::commitMultipleChanges_
void commitMultipleChanges_() override
Synchronise content after MultipleChanges.
Definition
multiDimSparse_tpl.h:131
gum::MultiDimWithOffset::MultiDimWithOffset
MultiDimWithOffset()
Class constructor.
Definition
multiDimWithOffset_tpl.h:62
gum::Size
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition
types.h:74
multiDimSparse_tpl.h
Implementation of MultiDimSparse.
multiDimWithOffset.h
Headers of the MultiDimWithOffset class.
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
gum::MultiDimSparse< double >
template class GUM_SHARED_PUBLIC MultiDimSparse< double >
Definition
multiDimSparse.cpp:55
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0