Minsky: 3.17.0
minsky::RavelTensor Class Reference
Inheritance diagram for minsky::RavelTensor:
Inheritance graph
Collaboration diagram for minsky::RavelTensor:
Collaboration graph

Public Member Functions

 RavelTensor (const Ravel &ravel)
 
void setArgument (const TensorPtr &a, const Args &) override
 
double operator[] (size_t i) const override
 
size_t size () const override
 return number of elements in tensor - maybe less than hypercube.numElements if sparse More...
 
const Index & index () const override
 the index vector - assumed to be ordered and unique More...
 
Timestamp timestamp () const override
 timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when to invalidate the cache More...
 
const Hypercube & hypercube () const override
 information describing the axes, types and labels of this tensor More...
 
- 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 ()
 
virtual const Hypercube & hypercube (const Hypercube &hc)
 
virtual const Hypercube & hypercube (Hypercube &&hc)
 
std::size_t rank () const
 
std::vector< unsigned > shape () const
 
void imposeDimensions (const Dimensions &dimensions)
 impose dimensions according to dimension map dimensions More...
 
virtual double operator[] (std::size_t) const =0
 return or compute data at a location 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 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})
 

Private Member Functions

 CLASSDESC_ACCESS (Ravel)
 

Private Attributes

const Ravelravel
 
vector< TensorPtrchain
 
TensorPtr arg
 
Timestamp m_timestamp
 

Additional Inherited Members

- Public Types inherited from civita::ITensor
using Timestamp = std::chrono::time_point< std::chrono::high_resolution_clock >
 
- Protected Member Functions inherited from civita::ITensor
void notImpl () const
 
- Protected Attributes inherited from civita::ITensor
Hypercube m_hypercube
 
Index m_index
 

Detailed Description

Definition at line 1495 of file minskyTensorOps.cc.

Constructor & Destructor Documentation

◆ RavelTensor()

minsky::RavelTensor::RavelTensor ( const Ravel ravel)
inline

Definition at line 1504 of file minskyTensorOps.cc.

1504 : ravel(ravel) {}

Member Function Documentation

◆ CLASSDESC_ACCESS()

minsky::RavelTensor::CLASSDESC_ACCESS ( Ravel  )
private

◆ hypercube()

const Hypercube& minsky::RavelTensor::hypercube ( ) const
inlineoverridevirtual

information describing the axes, types and labels of this tensor

Reimplemented from civita::ITensor.

Definition at line 1532 of file minskyTensorOps.cc.

1532 {return chain.empty()? m_hypercube: chain.back()->hypercube();}
vector< TensorPtr > chain
Hypercube m_hypercube

◆ index()

const Index& minsky::RavelTensor::index ( ) const
inlineoverridevirtual

the index vector - assumed to be ordered and unique

Reimplemented from civita::ITensor.

Definition at line 1528 of file minskyTensorOps.cc.

1529  {return chain.empty()? m_index: chain.back()->index();}
vector< TensorPtr > chain

◆ operator[]()

double minsky::RavelTensor::operator[] ( size_t  i) const
inlineoverride

Definition at line 1513 of file minskyTensorOps.cc.

References civita::createRavelChain(), and minsky::Ravel::getState().

1513  {
1514  double v=0;
1515  if (!chain.empty())
1516  {
1517  v=(*chain.back())[i];
1518  if (m_timestamp<chain.back()->timestamp())
1519  { // update hypercube if argument has changed
1520  const_cast<Ravel&>(ravel).populateHypercube(arg->hypercube());
1522  m_timestamp=Timestamp::clock::now();
1523  }
1524  }
1525  return v;
1526  }
ravel::RavelState getState() const
get the current state of the Ravel
Definition: ravelWrap.h:206
vector< TensorPtr > createRavelChain(const ravel::RavelState &state, const TensorPtr &arg)
creates a chain of tensor operations that represents a Ravel in state state, operating on arg ...
Definition: tensorOp.cc:497
vector< TensorPtr > chain
Here is the call graph for this function:

◆ setArgument()

void minsky::RavelTensor::setArgument ( const TensorPtr a,
const Args  
)
inlineoverridevirtual

Reimplemented from civita::ITensor.

Definition at line 1506 of file minskyTensorOps.cc.

References civita::createRavelChain(), and minsky::Ravel::getState().

1506  {
1507  // not sure how to avoid this const cast here
1508  arg=a;
1509  const_cast<Ravel&>(ravel).populateHypercube(a->hypercube());
1511  }
ravel::RavelState getState() const
get the current state of the Ravel
Definition: ravelWrap.h:206
vector< TensorPtr > createRavelChain(const ravel::RavelState &state, const TensorPtr &arg)
creates a chain of tensor operations that represents a Ravel in state state, operating on arg ...
Definition: tensorOp.cc:497
vector< TensorPtr > chain
Here is the call graph for this function:

◆ size()

size_t minsky::RavelTensor::size ( ) const
inlineoverridevirtual

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

Reimplemented from civita::ITensor.

Definition at line 1527 of file minskyTensorOps.cc.

1527 {return chain.empty()? 1: chain.back()->size();}
vector< TensorPtr > chain

◆ timestamp()

Timestamp minsky::RavelTensor::timestamp ( ) const
inlineoverridevirtual

timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when to invalidate the cache

Implements civita::ITensor.

Definition at line 1530 of file minskyTensorOps.cc.

1531  {return chain.empty()? Timestamp(): chain.back()->timestamp();}
vector< TensorPtr > chain
std::chrono::time_point< std::chrono::high_resolution_clock > Timestamp
Timestamp timestamp() const override
timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when...

Member Data Documentation

◆ arg

TensorPtr minsky::RavelTensor::arg
private

Definition at line 1499 of file minskyTensorOps.cc.

◆ chain

vector<TensorPtr> minsky::RavelTensor::chain
mutableprivate

Definition at line 1498 of file minskyTensorOps.cc.

◆ m_timestamp

Timestamp minsky::RavelTensor::m_timestamp
mutableprivate

Definition at line 1500 of file minskyTensorOps.cc.

◆ ravel

const Ravel& minsky::RavelTensor::ravel
private

Definition at line 1497 of file minskyTensorOps.cc.


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