60 template <
typename GUM_SCALAR >
62 const std::string&
name,
73 template <
typename GUM_SCALAR >
81 template <
typename GUM_SCALAR >
88 template <
typename GUM_SCALAR >
92 this->
cpf().content()->newFactory());
96 template <
typename GUM_SCALAR >
111 template <
typename GUM_SCALAR >
116 _cpf_ =
new Tensor< GUM_SCALAR >();
118 for (
auto var: source.
cpf().variablesSequence()) {
124 for (inst.setFirst(), jnst.
setFirst(); !(inst.end() || jnst.
end()); inst.inc(), jnst.
inc()) {
125 _cpf_->set(inst, source.
cpf().get(jnst));
128 GUM_ASSERT(inst.end() && jnst.
end());
133 template <
typename GUM_SCALAR >
139 template <
typename GUM_SCALAR >
145 template <
typename GUM_SCALAR >
150 template <
typename GUM_SCALAR >
155 template <
typename GUM_SCALAR >
160 template <
typename GUM_SCALAR >
173 template <
typename GUM_SCALAR >
177 template <
typename GUM_SCALAR >
187 cast->addParent(*
this);
193 if (
type().label_map()[inst.
val(my_var)] == inst.
val(cast_var)) {
194 cast->cpf().set(inst, 1);
196 cast->cpf().set(inst, 0);
203 template <
typename GUM_SCALAR >
210 std::stringstream msg;
211 msg <<
type().name() <<
" is not a subtype of " <<
cast->type().name();
217 template <
typename GUM_SCALAR >
220 _cpf_ =
new Tensor< GUM_SCALAR >();
236 template <
typename GUM_SCALAR >
238 if (&(old_type) ==
_type_) {
250 _cpf_ =
new Tensor< GUM_SCALAR >();
252 for (
auto var: old->variablesSequence()) {
253 if (var != &(old_type.
variable())) {
262 for (inst.setFirst(), jnst.
setFirst(); !(inst.end() || jnst.
end()); inst.inc(), jnst.
inc()) {
263 _cpf_->set(inst, old->get(jnst));
268 GUM_ASSERT(inst.end() && jnst.
end());
274 template <
typename GUM_SCALAR >
279 template <
typename GUM_SCALAR >
286 _cpf_ =
new Tensor< GUM_SCALAR >();
288 for (
auto var: old->variablesSequence()) {
289 if (var != &(
_type_->variable())) {
292 _cpf_->add(t->variable());
298 for (inst.setFirst(), jnst.
setFirst(); !(inst.end() || jnst.
end()); inst.inc(), jnst.
inc()) {
299 _cpf_->set(inst, old->get(jnst));
307 GUM_ASSERT(inst.end() && jnst.
end());
Headers of gum::PRMAttribute.
bool existsFirst(const T1 &first) const
Returns true if first is the first element in a pair in the gum::Bijection.
void insert(const T1 &first, const T2 &second)
Inserts a new association in the gum::Bijection.
const T2 & second(const T1 &first) const
Returns the second value of a pair given its first value.
Set of pairs of elements with fast search for both elements.
Base class for discrete random variable.
virtual Size domainSize() const =0
Exception : a similar element already exists.
Exception : fatal (unknown ?) error.
Class for assigning/browsing values to tuples of discrete variables.
bool end() const
Returns true if the Instantiation reached the end.
Idx pos(const DiscreteVariable &v) const final
Returns the position of the variable v.
void inc()
Operator increment.
Idx val(Idx i) const
Returns the current value of the variable at position i.
void setFirst()
Assign the first values to the tuple of the Instantiation.
<agrum/base/multidim/multiDimImplementation.h>
Exception : the element we looked for cannot be found.
Exception : operation not allowed.
aGrUM's Tensor is a multi-dimensional array with tensor operators.
Exception : wrong type for this operation.
PRMAttribute is a member of a Class in a PRM.
virtual const Tensor< GUM_SCALAR > & cpf() const =0
See gum::PRMClassElement::cpf().
PRMAttribute(const std::string &name)
Destructor.
virtual PRMType & type()=0
See gum::PRMClassElement::type().
Abstract class representing an element of PRM class.
virtual std::string cast(const PRMType &t) const
Returns the name of the cast descendant with PRMType t of this PRMClassElement.
ClassElementType
Returns true if obj_ptr is of type PRMReferenceSlot.
virtual PRMType & type()=0
Return a reference over the gum::PRMType of this class element.
std::string safeName_
The safe name of this PRMClassElement.
A PRMClass is an object of a PRM representing a fragment of a Bayesian network which can be instantia...
const std::string & name() const
Returns the name of this object.
static std::string LEFT_CAST()
Enumeration of the different types of objects handled by a PRM.
static std::string RIGHT_CAST()
Enumeration of the different types of objects handled by a PRM.
<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 PRMType * 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.
const std::vector< Idx > & label_map() const
Returns the vector in which the i-th element is the Idx of the super type's label for the i-th label ...
DiscreteVariable & variable()
Return a reference on the DiscreteVariable contained in this.
const std::string & name() const
Returns the name of this object.
#define GUM_ERROR(type, msg)
namespace for all probabilistic relational models entities
Tensor< GUM_SCALAR > * copyTensor(const Bijection< const DiscreteVariable *, const DiscreteVariable * > &bij, const Tensor< GUM_SCALAR > &source)
Returns a copy of a Tensor after applying a bijection over the variables in source.
gum is the global namespace for all aGrUM entities