aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
scheduleProjection_tpl.h
Go to the documentation of this file.
1
/**
2
*
3
* Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4
* info_at_agrum_dot_org
5
*
6
* This library is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this library. If not, see <http://www.gnu.org/licenses/>.
18
*
19
*/
20
21
22
/** @file
23
* @brief A generic class to project efficiently a ScheduleMultiDim over a
24
*subset
25
* of its variables
26
*
27
* @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
28
*/
29
30
#
ifndef
DOXYGEN_SHOULD_SKIP_THIS
31
32
#
include
<
agrum
/
agrum
.
h
>
33
34
namespace
gum
{
35
36
/// default constructor
37
template
<
typename
GUM_SCALAR >
38
ScheduleProjection< GUM_SCALAR >::ScheduleProjection() {
39
/// for debugging purposes
40
GUM_CONSTRUCTOR(ScheduleProjection);
41
}
42
43
/// copy constructor
44
template
<
typename
GUM_SCALAR
>
45
ScheduleProjection
<
GUM_SCALAR
>::
ScheduleProjection
(
46
const
ScheduleProjection
<
GUM_SCALAR
>&
from
) {
47
/// for debugging purposes
48
GUM_CONS_CPY
(
ScheduleProjection
);
49
}
50
51
/// destructor
52
template
<
typename
GUM_SCALAR
>
53
ScheduleProjection
<
GUM_SCALAR
>::~
ScheduleProjection
() {
54
/// for debugging purposes
55
GUM_DESTRUCTOR
(
ScheduleProjection
);
56
}
57
58
/// creates and returns the projection of the table over a subset of its vars
59
template
<
typename
GUM_SCALAR
>
60
INLINE
ScheduleMultiDim
<
GUM_SCALAR
>
61
ScheduleProjection
<
GUM_SCALAR
>::
project
(
const
MultiDimImplementation
<
GUM_SCALAR
>&
table
,
62
const
Set
<
const
DiscreteVariable
* >&
del_vars
,
63
Schedule
<
GUM_SCALAR
>&
schedule
) {
64
ScheduleMultiDim
<
GUM_SCALAR
>
sched_table
(
table
);
65
return
project
(
sched_table
,
del_vars
,
schedule
);
66
}
67
68
/// creates and returns the projection of the table over a subset of its vars
69
template
<
typename
GUM_SCALAR
>
70
template
<
template
<
typename
>
class
TABLE
>
71
INLINE
ScheduleMultiDim
<
GUM_SCALAR
>
72
ScheduleProjection
<
GUM_SCALAR
>::
project
(
const
TABLE
<
GUM_SCALAR
>&
table
,
73
const
Set
<
const
DiscreteVariable
* >&
del_vars
,
74
Schedule
<
GUM_SCALAR
>&
schedule
) {
75
ScheduleMultiDim
<
GUM_SCALAR
>
sched_table
(*(
table
.
content
()));
76
return
project
(
sched_table
,
del_vars
,
schedule
);
77
}
78
79
/** @brief returns a rough estimate of the number of operations that will be
80
* performed to compute the projection */
81
template
<
typename
GUM_SCALAR
>
82
INLINE
float
ScheduleProjection
<
GUM_SCALAR
>::
nbOperations
(
83
const
MultiDimImplementation
<
GUM_SCALAR
>&
table
,
84
const
Set
<
const
DiscreteVariable
* >&
del_vars
,
85
const
Schedule
<
GUM_SCALAR
>&
schedule
) {
86
ScheduleMultiDim
<
GUM_SCALAR
>
sched_table
(
table
);
87
return
nbOperations
(
sched_table
,
del_vars
,
schedule
);
88
}
89
90
/** @brief returns a rough estimate of the number of operations that will be
91
* performed to compute the projection */
92
template
<
typename
GUM_SCALAR
>
93
template
<
template
<
typename
>
class
TABLE
>
94
INLINE
float
95
ScheduleProjection
<
GUM_SCALAR
>::
nbOperations
(
const
TABLE
<
GUM_SCALAR
>&
table
,
96
const
Set
<
const
DiscreteVariable
* >&
del_vars
,
97
const
Schedule
<
GUM_SCALAR
>&
schedule
) {
98
ScheduleMultiDim
<
GUM_SCALAR
>
sched_table
(*(
table
.
content
()));
99
return
nbOperations
(
sched_table
,
del_vars
,
schedule
);
100
}
101
102
/// returns the memory consumption used during the projection
103
template
<
typename
GUM_SCALAR
>
104
INLINE
std
::
pair
<
long
,
long
>
ScheduleProjection
<
GUM_SCALAR
>::
memoryUsage
(
105
const
MultiDimImplementation
<
GUM_SCALAR
>&
table
,
106
const
Set
<
const
DiscreteVariable
* >&
del_vars
,
107
const
Schedule
<
GUM_SCALAR
>&
schedule
) {
108
ScheduleMultiDim
<
GUM_SCALAR
>
sched_table
(
table
);
109
return
memoryUsage
(
sched_table
,
del_vars
,
schedule
);
110
}
111
112
/// returns the memory consumption used during the projection
113
template
<
typename
GUM_SCALAR
>
114
template
<
template
<
typename
>
class
TABLE
>
115
INLINE
std
::
pair
<
long
,
long
>
116
ScheduleProjection
<
GUM_SCALAR
>::
memoryUsage
(
const
TABLE
<
GUM_SCALAR
>&
table
,
117
const
Set
<
const
DiscreteVariable
* >&
del_vars
,
118
const
Schedule
<
GUM_SCALAR
>&
schedule
) {
119
ScheduleMultiDim
<
GUM_SCALAR
>
sched_table
(*(
table
.
content
()));
120
return
memoryUsage
(
sched_table
,
del_vars
,
schedule
);
121
}
122
123
}
/* namespace gum */
124
125
#
endif
/* DOXYGEN_SHOULD_SKIP_THIS */
gum::Set::emplace
INLINE void emplace(Args &&... args)
Definition:
set_tpl.h:643