aGrUM  0.16.0
concreteLeaf.h
Go to the documentation of this file.
1 
30 // =========================================================================
31 #ifndef GUM_CONCRETE_LEAF_H
32 #define GUM_CONCRETE_LEAF_H
33 // =========================================================================
34 #include <agrum/agrum.h>
35 #include <agrum/core/hashTable.h>
37 #include <agrum/core/sequence.h>
38 // =========================================================================
40 // =========================================================================
44 // =========================================================================
45 
46 namespace gum {
47 
57  template < TESTNAME AttributeSelection, bool isScalar >
58  class ConcreteLeaf : public AbstractLeaf {
60 
61  public:
62  // ==========================================================================
64  // ==========================================================================
66 
67  // ###################################################################
69  // ###################################################################
72  const Sequence< ValueType >* valueDomain) :
73  AbstractLeaf(leafId),
74  __n1(n1), __valueDomain(valueDomain) {
75  GUM_CONSTRUCTOR(ConcreteLeaf);
76  }
77 
78  // ###################################################################
80  // ###################################################################
81  ~ConcreteLeaf() { GUM_DESTRUCTOR(ConcreteLeaf); }
82 
83  // ============================================================================
85  // ============================================================================
86  void* operator new(size_t s) {
88  }
89  void operator delete(void* p) {
91  }
92 
94 
95  // ###################################################################
97  // ###################################################################
98  virtual double effectif(Idx moda) const {
99  return __effectif(moda, Int2Type< isScalar >());
100  }
101 
102  private:
103  double __effectif(Idx moda, Int2Type< true >) const {
104  return (double)__n1->effectif(Idx(__valueDomain->atPos(moda)));
105  }
106  double __effectif(Idx moda, Int2Type< false >) const {
107  return (double)__n1->effectif(moda);
108  }
109 
110  public:
111  virtual double total() const { return double(__n1->nbObservation()); }
112 
113  Idx nbModa() const { return __nbModa(Int2Type< isScalar >()); }
114 
115  private:
116  Idx __nbModa(Int2Type< true >) const { return __valueDomain->size(); }
117  Idx __nbModa(Int2Type< false >) const { return __n1->valueDomain(); }
118 
119  public:
120  std::string toString() {
121  std::stringstream ss;
122  ss << "{ Id : " << this->id() << "}";
123  return ss.str();
124  }
125 
126  private:
129  };
130 
131 
132 } /* namespace gum */
133 
134 
135 #endif // GUM_CONCRETE_LEAF_H
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
double __effectif(Idx moda, Int2Type< false >) const
Definition: concreteLeaf.h:106
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
std::string toString()
Definition: concreteLeaf.h:120
The generic class for storing (ordered) sequences of objects.
Definition: sequence.h:1022
<agrum/FMDP/learning/datastructure/leaves/abstractLeaf.h>
Definition: abstractLeaf.h:53
Idx nbModa() const
Definition: concreteLeaf.h:113
const Sequence< ValueType > * __valueDomain
Definition: concreteLeaf.h:128
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
ValueSelect< isScalar, double, Idx >::type ValueType
Definition: concreteLeaf.h:59
<agrum/FMDP/learning/datastructure/leaves/concreteLeaf.h>
Definition: concreteLeaf.h:58
~ConcreteLeaf()
Default destructor.
Definition: concreteLeaf.h:81
double __effectif(Idx moda, Int2Type< true >) const
Definition: concreteLeaf.h:103
ConcreteLeaf(NodeId leafId, NodeDatabase< AttributeSelection, isScalar > *n1, const Sequence< ValueType > *valueDomain)
Default constructor.
Definition: concreteLeaf.h:70
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual double total() const
Definition: concreteLeaf.h:111
Idx __nbModa(Int2Type< false >) const
Definition: concreteLeaf.h:117
Idx __nbModa(Int2Type< true >) const
Definition: concreteLeaf.h:116
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
virtual double effectif(Idx moda) const
Gaves the leaf effectif for given modality.
Definition: concreteLeaf.h:98
NodeDatabase< AttributeSelection, isScalar > * __n1
Definition: concreteLeaf.h:127
Size Idx
Type for indexes.
Definition: types.h:53
void * allocate(const size_t &objectSize)
Allocates a block.
static SmallObjectAllocator & instance()
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size NodeId
Type for node ids.
Definition: graphElements.h:98
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
<agrum/FMDP/learning/datastructure/nodeDatabase.h>
Definition: nodeDatabase.h:58