20 #ifndef CIVITA_TENSORINTERFACE_H 21 #define CIVITA_TENSORINTERFACE_H 22 #include "hypercube.h" 25 #ifndef CLASSDESC_ACCESS 26 #define CLASSDESC_ACCESS(x) 59 for (
auto& xv: hc.xvectors)
61 auto dim=dimensions.find(xv.name);
62 if (dim!=dimensions.end())
64 xv.dimension=dim->second;
74 virtual double operator[](std::size_t)
const=0;
76 virtual std::size_t
size()
const {
77 std::size_t s=
index().size();
86 return (*
this)[hcIdx];
88 auto i=idx.linealOffset(hcIdx);
96 std::size_t
hcIndex(
const std::initializer_list<T>& indices)
const 97 {
return hypercube().linealIndex(indices);}
100 double operator()(
const std::initializer_list<T>& indices)
const 103 using Timestamp=std::chrono::time_point<std::chrono::high_resolution_clock>;
122 const std::vector<TensorPtr>& a2,
130 {
throw std::runtime_error(
"setArgument(s) variant not implemented");}
void imposeDimensions(const Dimensions &dimensions)
impose dimensions according to dimension map dimensions
virtual void setArguments(const std::vector< TensorPtr > &a1, const std::vector< TensorPtr > &a2, const ITensor::Args &args={"", 0})
double operator()(const std::initializer_list< T > &indices) const
virtual const Hypercube & hypercube() const
information describing the axes, types and labels of this tensor
std::vector< unsigned > shape() const
ITensor(const std::vector< unsigned > &dims)
virtual const Hypercube & hypercube(const Hypercube &hc)
virtual Timestamp timestamp() const =0
timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when...
virtual const Index & index() const
the index vector - assumed to be ordered and unique
virtual std::size_t size() const
return number of elements in tensor - maybe less than hypercube.numElements if sparse ...
ITensor & operator=(const ITensor &)=default
virtual const Hypercube & hypercube(Hypercube &&hc)
std::chrono::time_point< std::chrono::high_resolution_clock > Timestamp
std::size_t hcIndex(const std::initializer_list< T > &indices) const
virtual void setArguments(const TensorPtr &, const TensorPtr &, const ITensor::Args &args={})
arguments relevant for tensor expressions, not always meaningful. Exception thrown if not...
virtual void setArgument(const TensorPtr &, const ITensor::Args &args={"", 0})
std::shared_ptr< ITensor > TensorPtr
virtual double operator[](std::size_t) const =0
return or compute data at a location
ITensor(const Hypercube &hc)
virtual void setArguments(const std::vector< TensorPtr > &a, const ITensor::Args &args={"", 0})
double atHCIndex(std::size_t hcIdx) const
returns the data value at hypercube index hcIdx, or NaN if
CLASSDESC_ACCESS(ITensor)