aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
PRMScalarAttribute.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
48
49#ifndef GUM_SCALAR_ATTRIBUTE_H
50#define GUM_SCALAR_ATTRIBUTE_H
51
52#include <agrum/agrum.h>
53
55
56namespace gum {
57 namespace prm {
58
83 template < GUM_Numeric GUM_SCALAR >
84 class PRMScalarAttribute: public PRMAttribute< GUM_SCALAR > {
85 public:
86 // ========================================================================
88 // ========================================================================
90
103 PRMScalarAttribute(std::string_view name,
104 const PRMType& type,
107
109 ~PRMScalarAttribute() override;
110
112 // ========================================================================
114 // ========================================================================
116
120
122 const PRMAttribute< GUM_SCALAR >& source) override;
123
126
128 PRMType& type() override;
129
131 const PRMType& type() const override;
132
134 const Tensor< GUM_SCALAR >& cpf() const override;
135
137 void addParent(const PRMClassElement< GUM_SCALAR >& elt) override;
138
140 void addChild(const PRMClassElement< GUM_SCALAR >& elt) override;
141
144 void becomeCastDescendant(PRMType& subtype) override;
145
147 void swap(const PRMType& old_type, const PRMType& new_type) override;
148
150
151 protected:
154
157
158 PRMType* type_() override;
159 void type_(PRMType* t) override;
160
161 private:
162 // ========================================================================
164 // ========================================================================
166
169
171 Tensor< GUM_SCALAR >* _cpf_;
172
174 };
175
176
177#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
178 extern template class PRMScalarAttribute< double >;
179#endif
180
181
182 } /* namespace prm */
183} // namespace gum
184
186
187#endif /* GUM_SCALAR_ATTRIBUTE_H */
Headers of gum::PRMAttribute.
Inline implementation of gum::PRMScalarAttribute.
Set of pairs of elements with fast search for both elements.
Definition bijection.h:1640
Multidimensional matrix stored as an array in memory.
PRMAttribute(std::string_view name)
Destructor.
Abstract class representing an element of PRM class.
ClassElementType
Returns true if obj_ptr is of type PRMReferenceSlot.
A PRMClass is an object of a PRM representing a fragment of a Bayesian network which can be instantia...
Definition PRMClass.h:77
const std::string & name() const
Returns the name of this object.
<agrum/PRM/elements/scalarAttribute.h>
void swap(const PRMType &old_type, const PRMType &new_type) override
Swap old_type with new_type in the PRMClassElement cpt.
~PRMScalarAttribute() override
Destructor.
void addParent(const PRMClassElement< GUM_SCALAR > &elt) override
See gum::PRMClassElement::addParent_().
void copyCpf(const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bif, const PRMAttribute< GUM_SCALAR > &source) override
See gum::PRMClassElement::elt_type().
PRMType * _type_
The random variable type of this attribute.
Tensor< GUM_SCALAR > * _cpf_
A pointer on the Tensor of this attribute.
void addChild(const PRMClassElement< GUM_SCALAR > &elt) override
See gum::PRMClassElement::addChild_().
PRMType & type() override
See gum::PRMClassElement::type().
void becomeCastDescendant(PRMType &subtype) override
See gum::PRMClassElement::elt_type().
const Tensor< GUM_SCALAR > & cpf() const override
See gum::PRMClassElement::cpf().
void setAsCastDescendant(PRMAttribute< GUM_SCALAR > *attr) override
See gum::PRMClassElement::elt_type().
PRMClassElement< GUM_SCALAR >::ClassElementType elt_type() const override
See gum::PRMClassElement::elt_type().
PRMAttribute< GUM_SCALAR > * getCastDescendant() const override
See gum::PRMClassElement::elt_type().
PRMAttribute< GUM_SCALAR > * newFactory(const PRMClass< GUM_SCALAR > &c) const override
See gum::PRMClassElement::elt_type().
PRMScalarAttribute & operator=(const PRMScalarAttribute &from)
Copy operator. Don't use it.
PRMScalarAttribute(std::string_view name, const PRMType &type, MultiDimImplementation< GUM_SCALAR > *impl=new MultiDimArray< GUM_SCALAR >())
Constructor used by gum::Class.
PRMAttribute< GUM_SCALAR > * copy(Bijection< const DiscreteVariable *, const DiscreteVariable * > bij) const override
See gum::PRMClassElement::elt_type().
This is a decoration of the DiscreteVariable class.
Definition PRMType.h:78
namespace for all probabilistic relational models entities
Definition agrum.h:68
gum is the global namespace for all aGrUM entities
Definition agrum.h:46