Tenncor
ileaf.hpp
Go to the documentation of this file.
1 
9 #include "teq/ileaf.hpp"
10 
11 #include "eteq/eigen.hpp"
12 
13 #ifndef ETEQ_ILEAF_HPP
14 #define ETEQ_ILEAF_HPP
15 
16 namespace eteq
17 {
18 
20 template <typename T>
21 struct iLeaf : public teq::iLeaf
22 {
23  virtual ~iLeaf (void) = default;
24 
26  const teq::Shape& shape (void) const override
27  {
28  return shape_;
29  }
30 
32  void* data (void) override
33  {
34  return data_.data();
35  }
36 
38  const void* data (void) const override
39  {
40  return data_.data();
41  }
42 
44  size_t type_code (void) const override
45  {
46  return egen::get_type<T>();
47  }
48 
50  std::string type_label (void) const override
51  {
52  return egen::name_type(egen::get_type<T>());
53  }
54 
56  size_t nbytes (void) const override
57  {
58  return sizeof(T) * shape_.n_elems();
59  }
60 
61 protected:
64  shape_(shape) {}
65 
68 
71 };
72 
73 }
74 
75 #endif // ETEQ_ILEAF_HPP
const teq::Shape & shape(void) const override
Implementation of iTensor.
Definition: ileaf.hpp:26
iLeaf(T *data, teq::Shape shape)
Definition: ileaf.hpp:62
Definition: constant.hpp:17
TensMapT< T > make_tensmap(T *data, const teq::Shape &shape)
Return Eigen Tensor given raw data and teq Shape.
Definition: eigen.hpp:201
TensorT< T > data_
Data Source.
Definition: ileaf.hpp:67
Definition: shape.hpp:62
std::string type_label(void) const override
Implementation of iData.
Definition: ileaf.hpp:50
virtual ~iLeaf(void)=default
teq::Shape shape_
Shape utility to avoid excessive conversion between data_.dimensions()
Definition: ileaf.hpp:70
size_t type_code(void) const override
Implementation of iData.
Definition: ileaf.hpp:44
size_t nbytes(void) const override
Implementation of iData.
Definition: ileaf.hpp:56
const void * data(void) const override
Implementation of iData.
Definition: ileaf.hpp:38
Eigen::Tensor< T, 8 > TensorT
Eigen Tensor.
Definition: eigen.hpp:35
iLeaf extension of TEQ iLeaf containing Eigen data objects
Definition: ileaf.hpp:21
NElemT n_elems(void) const
Return the total number of elements represented by the shape.
Definition: shape.hpp:118
void * data(void) override
Implementation of iData.
Definition: ileaf.hpp:32
Leaf of the graph commonly representing the variable in an equation.
Definition: ileaf.hpp:19