aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
partialInstantiation4MultiDim_tpl.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
#pragma once
42
43
50
51
#include <
agrum/base/multidim/utils/partialInstantiation4MultiDim.h
>
// to ease IDE parser
52
// allow partialInstantiationPatterns to be used
53
#define GUM_PARTIAL_INSTANTIATION_PATTERN_ALLOWED 1
54
55
#include <
agrum/base/multidim/utils/partialInstantiationRegister4MultiDim.h
>
56
57
#define GUM_MULTI_DIM_DECORATOR_PARTIAL_INST(NAME) \
58
namespace gum { \
59
template < typename GUM_ELEMENT > \
60
MultiDimImplementation< GUM_ELEMENT >* \
61
NAME(const MultiDimDecorator< GUM_ELEMENT >& table, \
62
const HashTable< const DiscreteVariable*, Idx >& inst_vars) { \
63
const MultiDimImplementation< GUM_ELEMENT >* impl = table.content(); \
64
return NAME(*impl, inst_vars); \
65
} \
66
}
67
69
70
#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME partialInstantiationMultiDimArray
71
#include <
agrum/base/multidim/utils/patterns/partialInstantiationPattern4MultiDimArray.h
>
72
#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
73
74
#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_IMPL2ARRAY_NAME partialInstantiationMultiDimArray
75
#include <
agrum/base/multidim/utils/patterns/partialInstantiationPattern4MultiDimArray.h
>
76
#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_IMPL2ARRAY_NAME
77
78
#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_NAME partialInstantiationMultiDimArray4Pointers
79
#include <
agrum/base/multidim/utils/patterns/partialInstantiationPattern4MultiDimArray.h
>
80
#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_NAME
81
82
#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_IMPL2ARRAY_NAME \
83
partialInstantiationMultiDimArray4Pointers
84
#include <
agrum/base/multidim/utils/patterns/partialInstantiationPattern4MultiDimArray.h
>
85
#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_IMPL2ARRAY_NAME
86
88
89
#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME partialInstantiationMultiDimImplementation
90
#include <
agrum/base/multidim/utils/patterns/partialInstantiationPattern4BaseName.h
>
91
#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
92
93
#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_NAME \
94
partialInstantiationMultiDimImplementation4Pointers
95
#include <
agrum/base/multidim/utils/patterns/partialInstantiationPattern4BaseName.h
>
96
#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
97
98
// the operators that should be used to select appropriately the functions
99
// to partially instantiate multiDims
100
102
#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME partialInstantiation
103
#include <
agrum/base/multidim/utils/patterns/partialInstantiationPattern4MultiDimImplementation.h
>
104
#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
105
107
GUM_MULTI_DIM_DECORATOR_PARTIAL_INST
(partialInstantiation)
108
109
//
110
// DO NOT FORGET TO REGISTER YOUR BINARY FUNCTIONS
111
//
112
113
namespace
gum
{
114
115
// the function used to register all the above functions
116
template
<
typename
GUM_ELEMENT >
117
void
partialInstantiation4MultiDimInit
() {
118
// ensure that only one thread will register the projections
119
static
std::once_flag first;
120
std::call_once(first, []() {
121
std::string MultiDimArrayString(
"MultiDimArray"
);
122
std::string MultiDimDecisionDiagramString(
"MultiDimDecisionDiagram"
);
123
std::string BaseNameString(
"MultiDimImplementation"
);
124
125
// register base functions for multiDimArrays
126
registerPartialInstantiation< GUM_ELEMENT >
(
"i"
,
127
MultiDimArrayString,
128
&
partialInstantiationMultiDimArray
);
129
130
// register default basename functions
131
registerPartialInstantiation< GUM_ELEMENT >
(
"i"
,
132
BaseNameString,
133
&partialInstantiationMultiDimImplementation);
134
});
135
}
136
137
// the function used to register all the above functions
138
template
<
typename
GUM_ELEMENT >
139
void
pointerPartialInstantiation4MultiDimInit
() {
140
// ensure that only one thread will register the projections
141
static
std::once_flag first;
142
std::call_once(first, []() {
143
std::string MultiDimArrayString(
"MultiDimArray"
);
144
std::string BaseNameString(
"MultiDimImplementation"
);
145
146
// register base functions for multiDimArrays
147
registerPartialInstantiation< GUM_ELEMENT* >
(
"i"
,
148
MultiDimArrayString,
149
&
partialInstantiationMultiDimArray4Pointers
);
150
151
// register default basename functions
152
registerPartialInstantiation< GUM_ELEMENT* >
(
153
"i"
,
154
BaseNameString,
155
&partialInstantiationMultiDimImplementation4Pointers);
156
});
157
}
158
159
template
<
typename
GUM_ELEMENT >
160
void
PartialInstantiation4MultiDimInitialize< GUM_ELEMENT >::init
() {
161
partialInstantiation4MultiDimInit< GUM_ELEMENT >
();
162
}
163
164
template
<
typename
GUM_ELEMENT >
165
void
PartialInstantiation4MultiDimInitialize< GUM_ELEMENT* >::init
() {
166
pointerPartialInstantiation4MultiDimInit< GUM_ELEMENT >
();
167
}
168
169
}
/* namespace gum */
170
171
// remove permission to use operatorsPatterns
172
#undef GUM_PARTIAL_INSTANTIATION_PATTERN_ALLOWED
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
gum::partialInstantiation4MultiDimInit
void partialInstantiation4MultiDimInit()
The function used to register all the instantiation operators on multidimImplementations over non-poi...
Definition
partialInstantiation4MultiDim_tpl.h:117
gum::partialInstantiationMultiDimArray
MultiDimArray< GUM_ELEMENT > * partialInstantiationMultiDimArray(const MultiDimArray< GUM_ELEMENT > *table, const HashTable< const DiscreteVariable *, Idx > &inst_vars)
A specialized function for instantiating variables in a multiDimArray.
gum::partialInstantiationMultiDimArray4Pointers
MultiDimArray< GUM_ELEMENT * > * partialInstantiationMultiDimArray4Pointers(const MultiDimArray< GUM_ELEMENT * > *table, const HashTable< const DiscreteVariable *, Idx > &inst_vars)
A specialized function for instantiating variables in a MultiDimArray.
gum::registerPartialInstantiation
void registerPartialInstantiation(std::string_view instantiation_func_name, std::string_view type_multidim, typename PartialInstantiationRegister4MultiDim< GUM_ELEMENT >::PartialInstantiationPtr function)
A function to more easily register new instantiation functions in MultiDims.
gum::pointerPartialInstantiation4MultiDimInit
void pointerPartialInstantiation4MultiDimInit()
The function used to register all the instantiations on multidimImplementations over pointers types.
Definition
partialInstantiation4MultiDim_tpl.h:139
partialInstantiation4MultiDim.h
Headers for partial instantiation functions.
GUM_MULTI_DIM_DECORATOR_PARTIAL_INST
#define GUM_MULTI_DIM_DECORATOR_PARTIAL_INST(NAME)
Definition
partialInstantiation4MultiDim_tpl.h:57
partialInstantiationPattern4BaseName.h
the pattern used by all the partial instantiations of multidimensional tables
partialInstantiationPattern4MultiDimArray.h
the pattern used by all the partial instantiations of multidimensional tables
partialInstantiationPattern4MultiDimImplementation.h
the pattern used by all the partial instantiations of multidimensional tables
partialInstantiationRegister4MultiDim.h
Headers for PartialInstantiationRegister4MultiDim.
gum::PartialInstantiation4MultiDimInitialize::init
void init()
Initialize the partial instantiation functions.
Definition
partialInstantiation4MultiDim_tpl.h:160
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0