aGrUM 2.3.2
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-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#pragma once
41
42
49
50// allow partialInstantiationPatterns to be used
51#define GUM_PARTIAL_INSTANTIATION_PATTERN_ALLOWED 1
52
54
55#define GUM_MULTI_DIM_DECORATOR_PARTIAL_INST(NAME) \
56 namespace gum { \
57 template < typename GUM_SCALAR > \
58 MultiDimImplementation< GUM_SCALAR >* \
59 NAME(const MultiDimDecorator< GUM_SCALAR >& table, \
60 const HashTable< const DiscreteVariable*, Idx >& inst_vars) { \
61 const MultiDimImplementation< GUM_SCALAR >* impl = table.content(); \
62 return NAME(*impl, inst_vars); \
63 } \
64 }
65
67
68#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME partialInstantiationMultiDimArray
70#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
71
72#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_IMPL2ARRAY_NAME partialInstantiationMultiDimArray
74#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_IMPL2ARRAY_NAME
75
76#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_NAME partialInstantiationMultiDimArray4Pointers
78#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_NAME
79
80#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_IMPL2ARRAY_NAME \
81 partialInstantiationMultiDimArray4Pointers
83#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_IMPL2ARRAY_NAME
84
86
87#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME partialInstantiationMultiDimImplementation
89#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
90
91#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_POINTER_NAME \
92 partialInstantiationMultiDimImplementation4Pointers
94#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
95
96// the operators that should be used to select appropriately the functions
97// to partially instantiate multiDims
98
100#define GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME partialInstantiation
102#undef GUM_MULTI_DIM_PARTIAL_INSTANTIATION_NAME
103
105GUM_MULTI_DIM_DECORATOR_PARTIAL_INST(partialInstantiation)
106
107//
108// DO NOT FORGET TO REGISTER YOUR BINARY FUNCTIONS
109//
110
111namespace gum {
112
113 // the function used to register all the above functions
114 template < typename GUM_SCALAR >
116 // ensure that only one thread will register the projections
117 static std::once_flag first;
118 std::call_once(first, []() {
119 std::string MultiDimArrayString("MultiDimArray");
120 std::string MultiDimDecisionDiagramString("MultiDimDecisionDiagram");
121 std::string BaseNameString("MultiDimImplementation");
122
123 // register base functions for multiDimArrays
125 MultiDimArrayString,
127
128 // register default basename functions
130 BaseNameString,
131 &partialInstantiationMultiDimImplementation);
132 });
133 }
134
135 // the function used to register all the above functions
136 template < typename GUM_SCALAR >
138 // ensure that only one thread will register the projections
139 static std::once_flag first;
140 std::call_once(first, []() {
141 std::string MultiDimArrayString("MultiDimArray");
142 std::string BaseNameString("MultiDimImplementation");
143
144 // register base functions for multiDimArrays
146 MultiDimArrayString,
148
149 // register default basename functions
151 "i",
152 BaseNameString,
153 &partialInstantiationMultiDimImplementation4Pointers);
154 });
155 }
156
157} /* namespace gum */
158
159// remove permission to use operatorsPatterns
160#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_SCALAR > * partialInstantiationMultiDimArray(const MultiDimArray< GUM_SCALAR > *table, const HashTable< const DiscreteVariable *, Idx > &inst_vars)
A specialized function for instantiating variables in a multiDimArray.
void registerPartialInstantiation(const std::string &instantiation_func_name, const std::string &type_multidim, typename PartialInstantiationRegister4MultiDim< GUM_SCALAR >::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.
MultiDimArray< GUM_SCALAR * > * partialInstantiationMultiDimArray4Pointers(const MultiDimArray< GUM_SCALAR * > *table, const HashTable< const DiscreteVariable *, Idx > &inst_vars)
A specialized function for instantiating variables in a MultiDimArray.
#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.