Tenncor
itensor.hpp
Go to the documentation of this file.
1 
9 #include <unordered_set>
10 
11 #include "teq/shape.hpp"
12 
13 #ifndef TEQ_INTERFACE_HPP
14 #define TEQ_INTERFACE_HPP
15 
16 namespace teq
17 {
18 
19 struct iLeaf;
20 
21 struct iFunctor;
22 
24 struct iTraveler
25 {
26  virtual ~iTraveler (void) = default;
27 
29  virtual void visit (iLeaf* leaf) = 0;
30 
32  virtual void visit (iFunctor* func) = 0;
33 };
34 
36 struct iTensor
37 {
38  virtual ~iTensor (void) = default;
39 
41  virtual void accept (iTraveler& visiter) = 0;
42 
44  virtual const Shape& shape (void) const = 0;
45 
47  virtual std::string to_string (void) const = 0;
48 };
49 
51 using TensptrT = std::shared_ptr<iTensor>;
52 
54 using TensrefT = std::weak_ptr<iTensor>;
55 
57 using TensT = std::vector<iTensor*>;
58 
60 using TensptrsT = std::vector<TensptrT>;
61 
63 using TensSetT = std::unordered_set<teq::iTensor*>;
64 
66 using TensptrSetT = std::unordered_set<teq::TensptrT>;
67 
68 }
69 
70 #endif // TEQ_INTERFACE_HPP
std::unordered_set< teq::iTensor * > TensSetT
Hash set of raw tensor pointers.
Definition: itensor.hpp:63
virtual ~iTensor(void)=default
Interface of iOperation-defined operation node.
Definition: ifunctor.hpp:28
std::unordered_set< teq::TensptrT > TensptrSetT
Hash set of tensor smart pointers.
Definition: itensor.hpp:66
Definition: shape.hpp:62
virtual ~iTraveler(void)=default
Interface to travel through graph, treating iLeaf and iFunctor differently.
Definition: itensor.hpp:24
std::shared_ptr< iTensor > TensptrT
Tensor smart pointer.
Definition: itensor.hpp:51
std::vector< TensptrT > TensptrsT
Vector of tensor smart pointers.
Definition: itensor.hpp:60
virtual void visit(iLeaf *leaf)=0
Visit leaf node.
std::vector< iTensor * > TensT
Vector of raw tensor pointers.
Definition: itensor.hpp:57
virtual std::string to_string(void) const =0
Return the string representation of the tensor.
Definition: coord.hpp:16
Interface of traversible and differentiable nodes with shape information.
Definition: itensor.hpp:36
virtual void accept(iTraveler &visiter)=0
Obtain concrete information on either leaf or functor implementations.
std::weak_ptr< iTensor > TensrefT
Tensor weak pointers.
Definition: itensor.hpp:54
Leaf of the graph commonly representing the variable in an equation.
Definition: ileaf.hpp:19
virtual const Shape & shape(void) const =0
Return the shape held by this tensor.