aGrUM 2.3.2
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-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
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 < typename GUM_SCALAR >
84 class PRMScalarAttribute: public PRMAttribute< GUM_SCALAR > {
85 public:
86 // ========================================================================
88 // ========================================================================
90
103 PRMScalarAttribute(const std::string& name,
104 const PRMType& type,
107
109 virtual ~PRMScalarAttribute();
110
112 // ========================================================================
114 // ========================================================================
116
120
122 const PRMAttribute< GUM_SCALAR >& source);
123
126
128 virtual PRMType& type();
129
131 virtual const PRMType& type() const;
132
134 virtual const Tensor< GUM_SCALAR >& cpf() const;
135
137 virtual void addParent(const PRMClassElement< GUM_SCALAR >& elt);
138
140 virtual void addChild(const PRMClassElement< GUM_SCALAR >& elt);
141
144 virtual void becomeCastDescendant(PRMType& subtype);
145
147 virtual void swap(const PRMType& old_type, const PRMType& new_type);
148
150
151 protected:
154
157
158 virtual PRMType* type_();
159 virtual void type_(PRMType* t);
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:1594
Multidimensional matrix stored as an array in memory.
<agrum/base/multidim/multiDimImplementation.h>
PRMAttribute(const std::string &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:75
const std::string & name() const
Returns the name of this object.
<agrum/PRM/elements/scalarAttribute.h>
virtual void swap(const PRMType &old_type, const PRMType &new_type)
Swap old_type with new_type in the PRMClassElement cpt.
virtual PRMAttribute< GUM_SCALAR > * newFactory(const PRMClass< GUM_SCALAR > &c) const
See gum::PRMClassElement::elt_type().
virtual const Tensor< GUM_SCALAR > & cpf() const
See gum::PRMClassElement::cpf().
PRMType * _type_
The random variable type of this attribute.
Tensor< GUM_SCALAR > * _cpf_
A pointer on the Tensor of this attribute.
virtual PRMClassElement< GUM_SCALAR >::ClassElementType elt_type() const
See gum::PRMClassElement::elt_type().
virtual PRMAttribute< GUM_SCALAR > * copy(Bijection< const DiscreteVariable *, const DiscreteVariable * > bij) const
See gum::PRMClassElement::elt_type().
virtual void becomeCastDescendant(PRMType &subtype)
See gum::PRMClassElement::elt_type().
virtual PRMAttribute< GUM_SCALAR > * getCastDescendant() const
See gum::PRMClassElement::elt_type().
virtual void setAsCastDescendant(PRMAttribute< GUM_SCALAR > *attr)
See gum::PRMClassElement::elt_type().
virtual void addChild(const PRMClassElement< GUM_SCALAR > &elt)
See gum::PRMClassElement::addChild_().
virtual void copyCpf(const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bif, const PRMAttribute< GUM_SCALAR > &source)
See gum::PRMClassElement::elt_type().
PRMScalarAttribute(const std::string &name, const PRMType &type, MultiDimImplementation< GUM_SCALAR > *impl=new MultiDimArray< GUM_SCALAR >())
Constructor used by gum::Class.
PRMScalarAttribute & operator=(const PRMScalarAttribute &from)
Copy operator. Don't use it.
virtual PRMType & type()
See gum::PRMClassElement::type().
virtual ~PRMScalarAttribute()
Destructor.
virtual void addParent(const PRMClassElement< GUM_SCALAR > &elt)
See gum::PRMClassElement::addParent_().
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