aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
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
52// allow partialInstantiationPatterns to be used
53#define GUM_PARTIAL_INSTANTIATION_PATTERN_ALLOWED 1
54
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
72#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
73
74#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_IMPL2ARRAY_NAME partialInstantiationMultiDimArray
76#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_IMPL2ARRAY_NAME
77
78#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_NAME partialInstantiationMultiDimArray4Pointers
80#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_NAME
81
82#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_IMPL2ARRAY_NAME \
83 partialInstantiationMultiDimArray4Pointers
85#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_IMPL2ARRAY_NAME
86
88
89#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME partialInstantiationMultiDimImplementation
91#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
92
93#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_NAME \
94 partialInstantiationMultiDimImplementation4Pointers
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
104#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
105
107GUM_MULTI_DIM_DECORATOR_PARTIAL_INST(partialInstantiation)
108
109//
110// DO NOT FORGET TO REGISTER YOUR BINARY FUNCTIONS
111//
112
113namespace gum {
114
115 // the function used to register all the above functions
116 template < typename GUM_ELEMENT >
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
127 MultiDimArrayString,
129
130 // register default basename functions
132 BaseNameString,
133 &partialInstantiationMultiDimImplementation);
134 });
135 }
136
137 // the function used to register all the above functions
138 template < typename GUM_ELEMENT >
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
148 MultiDimArrayString,
150
151 // register default basename functions
153 "i",
154 BaseNameString,
155 &partialInstantiationMultiDimImplementation4Pointers);
156 });
157 }
158
159 template < typename GUM_ELEMENT >
163
164 template < typename GUM_ELEMENT >
168
169} /* namespace gum */
170
171// remove permission to use operatorsPatterns
172#undef GUM_PARTIAL_INSTANTIATION_PATTERN_ALLOWED
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
void partialInstantiation4MultiDimInit()
The function used to register all the instantiation operators on multidimImplementations over non-poi...
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.
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.
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.
void pointerPartialInstantiation4MultiDimInit()
The function used to register all the instantiations on multidimImplementations over pointers types.
Headers for partial instantiation functions.
#define GUM_MULTI_DIM_DECORATOR_PARTIAL_INST(NAME)
the pattern used by all the partial instantiations of multidimensional tables
the pattern used by all the partial instantiations of multidimensional tables
the pattern used by all the partial instantiations of multidimensional tables
Headers for PartialInstantiationRegister4MultiDim.
void init()
Initialize the partial instantiation functions.