aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
o4DGContext_inl.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
52
53
#include <
agrum/base/multidim/utils/FunctionGraphUtilities/operators/o4DGContext.h
>
54
55
namespace
gum
{
56
57
INLINE
const
NodeId
&
O4DGContext::DG1Node
()
const
{
return
_DG1ExploredNode_
; }
58
59
INLINE
const
NodeId
&
O4DGContext::DG2Node
()
const
{
return
_DG2ExploredNode_
; }
60
61
// Set DG1 diagram current explored Node
62
INLINE
void
O4DGContext::setDG1Node
(
const
NodeId
& exploredNode) {
63
_DG1ExploredNode_
= exploredNode;
64
}
65
66
// Set DG2 diagram current explored Node
67
INLINE
void
O4DGContext::setDG2Node
(
const
NodeId
& exploredNode) {
68
_DG2ExploredNode_
= exploredNode;
69
}
70
71
// Changes given variable modality
72
INLINE
void
O4DGContext::chgVarModality
(
Idx
varIndex,
Idx
newModality) {
73
_varInstantiation_
[varIndex] = newModality;
74
}
75
76
// Changes given variable modality
77
INLINE
Idx
O4DGContext::varModality
(
Idx
varIndex) {
return
_varInstantiation_
[varIndex]; }
78
79
// Returns o4DGContext key
80
INLINE
const
double
&
O4DGContext::key
(
short
int
* instNeeded) {
81
_key_
=
_DG1ExploredNode_
*
_logPrime_
[
_offset1_
] +
_DG2ExploredNode_
*
_logPrime_
[
_offset2_
];
82
83
for
(
Idx
varPos = 0, offset =
_offsetv_
; varPos <
_nbVar_
; varPos++, offset--)
84
if
(instNeeded[varPos])
_key_
+=
_varInstantiation_
[varPos] *
_logPrime_
[offset];
85
86
return
_key_
;
87
}
88
89
INLINE
void
* O4DGContext::operator
new
(
size_t
s) {
90
return
SmallObjectAllocator::instance
().
allocate
(s);
91
}
92
93
INLINE
void
O4DGContext::operator
delete
(
void
* p) {
94
SmallObjectAllocator::instance
().
deallocate
(p,
sizeof
(
O4DGContext
));
95
}
96
98
99
100
}
/* end of namespace gum */
gum::O4DGContext::DG2Node
const NodeId & DG2Node() const
Get DG2 diagram current explored Node.
Definition
o4DGContext_inl.h:59
gum::O4DGContext::setDG2Node
void setDG2Node(const NodeId &)
Set DG2 diagram current explored Node.
Definition
o4DGContext_inl.h:67
gum::O4DGContext::_offset2_
static const Idx _offset2_
Definition
o4DGContext.h:159
gum::O4DGContext::_DG2ExploredNode_
NodeId _DG2ExploredNode_
DG2 Diagram current explored node.
Definition
o4DGContext.h:144
gum::O4DGContext::chgVarModality
void chgVarModality(Idx, Idx)
Changes given variable modality.
Definition
o4DGContext_inl.h:72
gum::O4DGContext::setDG1Node
void setDG1Node(const NodeId &)
Set DG1 diagram current explored Node.
Definition
o4DGContext_inl.h:62
gum::O4DGContext::_offset1_
static const Idx _offset1_
Definition
o4DGContext.h:158
gum::O4DGContext::_key_
double _key_
The key use to store the context as a key in the hashtable.
Definition
o4DGContext.h:152
gum::O4DGContext::key
const double & key(short int *instNeeded)
Returns o4DGContext key.
Definition
o4DGContext_inl.h:80
gum::O4DGContext::varModality
Idx varModality(Idx)
Changes given variable modality.
Definition
o4DGContext_inl.h:77
gum::O4DGContext::_logPrime_
static const double _logPrime_[]
Table containing the log2 of prime numbers.
Definition
o4DGContext.h:155
gum::O4DGContext::_offsetv_
static const Idx _offsetv_
Definition
o4DGContext.h:157
gum::O4DGContext::_varInstantiation_
Idx * _varInstantiation_
Vector containing for each retrograde variable its current modality 0 meaning no instantiation done =...
Definition
o4DGContext.h:148
gum::O4DGContext::DG1Node
const NodeId & DG1Node() const
Get DG1 diagram current explored Node.
Definition
o4DGContext_inl.h:57
gum::O4DGContext::_DG1ExploredNode_
NodeId _DG1ExploredNode_
DG1 Diagram current explored node.
Definition
o4DGContext.h:141
gum::O4DGContext::O4DGContext
O4DGContext(Idx *, Idx)
Default constructor.
Definition
o4DGContext.cpp:98
gum::O4DGContext::_nbVar_
Idx _nbVar_
Definition
o4DGContext.h:149
gum::SmallObjectAllocator::instance
static SmallObjectAllocator & instance()
Definition
smallObjectAllocator_inl.h:96
gum::SmallObjectAllocator::allocate
void * allocate(const size_t &objectSize)
Allocates a block.
Definition
smallObjectAllocator.cpp:72
gum::SmallObjectAllocator::deallocate
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
Definition
smallObjectAllocator_inl.h:116
gum::Idx
Size Idx
Type for indexes.
Definition
types.h:79
gum::NodeId
Size NodeId
Type for node ids.
Definition
graphElements.h:117
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
o4DGContext.h
Class used to manipulate o4DGContext in Function Graph Operations.
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0