Minsky
civita::CachedTensorOp Class Referenceabstract

#include <tensorOp.h>

Inheritance diagram for civita::CachedTensorOp:
Inheritance graph
Collaboration diagram for civita::CachedTensorOp:
Collaboration graph

Public Member Functions

const Index & index () const override
 the index vector - assumed to be ordered and unique More...
 
std::size_t size () const override
 return number of elements in tensor - maybe less than hypercube.numElements if sparse More...
 
double operator[] (std::size_t i) const override
 return or compute data at a location More...
 
const Hypercube & hypercube () const override
 information describing the axes, types and labels of this tensor More...
 
const Hypercube & hypercube (const Hypercube &hc) override
 
const Hypercube & hypercube (Hypercube &&hc) override
 
- Public Member Functions inherited from civita::ITensor
 CLASSDESC_ACCESS (ITensor)
 
 ITensor ()
 
 ITensor (const Hypercube &hc)
 
 ITensor (Hypercube &&hc)
 
 ITensor (const std::vector< unsigned > &dims)
 
 ITensor (const ITensor &)=default
 
 ITensor (ITensor &&)=default
 
ITensoroperator= (const ITensor &)=default
 
ITensoroperator= (ITensor &&)=default
 
virtual ~ITensor ()
 
std::size_t rank () const
 
std::vector< unsigned > shape () const
 
void imposeDimensions (const Dimensions &dimensions)
 impose dimensions according to dimension map dimensions More...
 
double atHCIndex (std::size_t hcIdx) const
 returns the data value at hypercube index hcIdx, or NaN if More...
 
template<class T >
std::size_t hcIndex (const std::initializer_list< T > &indices) const
 
template<class T >
double operator() (const std::initializer_list< T > &indices) const
 
virtual Timestamp timestamp () const =0
 timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when to invalidate the cache More...
 
virtual void setArgument (const TensorPtr &, const ITensor::Args &args={"", 0})
 
virtual void setArguments (const TensorPtr &, const TensorPtr &, const ITensor::Args &args={})
 
virtual void setArguments (const std::vector< TensorPtr > &a, const ITensor::Args &args={"", 0})
 
virtual void setArguments (const std::vector< TensorPtr > &a1, const std::vector< TensorPtr > &a2, const ITensor::Args &args={"", 0})
 

Protected Member Functions

virtual void computeTensor () const =0
 computeTensor updates the above two mutable fields, but is logically const More...
 
- Protected Member Functions inherited from civita::ITensor
void notImpl () const
 

Protected Attributes

TensorVal cachedResult
 
Timestamp m_timestamp
 
- Protected Attributes inherited from civita::ITensor
Hypercube m_hypercube
 
Index m_index
 

Additional Inherited Members

- Public Types inherited from civita::ITensor
using Timestamp = std::chrono::time_point< std::chrono::high_resolution_clock >
 

Detailed Description

Definition at line 129 of file tensorOp.h.

Member Function Documentation

◆ computeTensor()

◆ hypercube() [1/3]

const Hypercube& civita::CachedTensorOp::hypercube ( ) const
inlineoverridevirtual

information describing the axes, types and labels of this tensor

Reimplemented from civita::ITensor.

Reimplemented in civita::SortByValue.

Definition at line 141 of file tensorOp.h.

References cachedResult.

141 {return cachedResult.hypercube();}
TensorVal cachedResult
Definition: tensorOp.h:132

◆ hypercube() [2/3]

const Hypercube& civita::CachedTensorOp::hypercube ( const Hypercube &  hc)
inlineoverridevirtual

Reimplemented from civita::ITensor.

Definition at line 142 of file tensorOp.h.

References cachedResult.

142 {return cachedResult.hypercube(hc);}
TensorVal cachedResult
Definition: tensorOp.h:132

◆ hypercube() [3/3]

const Hypercube& civita::CachedTensorOp::hypercube ( Hypercube &&  hc)
inlineoverridevirtual

Reimplemented from civita::ITensor.

Definition at line 143 of file tensorOp.h.

References cachedResult.

143 {return cachedResult.hypercube(std::move(hc));}
TensorVal cachedResult
Definition: tensorOp.h:132

◆ index()

const Index& civita::CachedTensorOp::index ( ) const
inlineoverridevirtual

the index vector - assumed to be ordered and unique

Reimplemented from civita::ITensor.

Definition at line 138 of file tensorOp.h.

References cachedResult.

138 {return cachedResult.index();}
TensorVal cachedResult
Definition: tensorOp.h:132

◆ operator[]()

double civita::CachedTensorOp::operator[] ( std::size_t  ) const
overridevirtual

return or compute data at a location

Implements civita::ITensor.

Definition at line 174 of file tensorOp.cc.

175  {
176  assert(i<size());
177  if (m_timestamp<timestamp()) {
178  computeTensor();
179  m_timestamp=Timestamp::clock::now();
180  }
181  return cachedResult[i];
182  }
virtual void computeTensor() const =0
computeTensor updates the above two mutable fields, but is logically const
virtual Timestamp timestamp() const =0
timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when...
Timestamp m_timestamp
Definition: tensorOp.h:133
std::size_t size() const override
return number of elements in tensor - maybe less than hypercube.numElements if sparse ...
Definition: tensorOp.h:139
TensorVal cachedResult
Definition: tensorOp.h:132

◆ size()

std::size_t civita::CachedTensorOp::size ( ) const
inlineoverridevirtual

return number of elements in tensor - maybe less than hypercube.numElements if sparse

Reimplemented from civita::ITensor.

Reimplemented in civita::SortByValue.

Definition at line 139 of file tensorOp.h.

References cachedResult.

139 {return cachedResult.size();}
TensorVal cachedResult
Definition: tensorOp.h:132

Member Data Documentation

◆ cachedResult

TensorVal civita::CachedTensorOp::cachedResult
mutableprotected

◆ m_timestamp

Timestamp civita::CachedTensorOp::m_timestamp
mutableprotected

Definition at line 133 of file tensorOp.h.

Referenced by civita::SortByValue::hypercube(), and civita::SortByValue::size().


The documentation for this class was generated from the following files: