Minsky
civita::ElementWiseOp Struct Reference

perform an operation elementwise over a tensor valued argument More...

#include <tensorOp.h>

Inheritance diagram for civita::ElementWiseOp:
Inheritance graph
Collaboration diagram for civita::ElementWiseOp:
Collaboration graph

Public Member Functions

template<class F >
 ElementWiseOp (F f, const std::shared_ptr< ITensor > &arg={})
 
void setArgument (const TensorPtr &a, const ITensor::Args &) override
 
const Hypercube & hypercube () const override
 information describing the axes, types and labels of this tensor More...
 
const Index & index () const override
 the index vector - assumed to be ordered and unique More...
 
double operator[] (std::size_t i) const override
 return or compute data at a location More...
 
std::size_t size () const override
 return number of elements in tensor - maybe less than hypercube.numElements if sparse 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...
 
- 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...
 
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})
 

Public Attributes

std::function< double(double)> f
 
std::shared_ptr< ITensorarg
 

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

perform an operation elementwise over a tensor valued argument

Definition at line 33 of file tensorOp.h.

Constructor & Destructor Documentation

◆ ElementWiseOp()

template<class F >
civita::ElementWiseOp::ElementWiseOp ( f,
const std::shared_ptr< ITensor > &  arg = {} 
)
inline

Definition at line 38 of file tensorOp.h.

38 {}): f(f), arg(arg) {}
std::shared_ptr< ITensor > arg
Definition: tensorOp.h:36
std::function< double(double)> f
Definition: tensorOp.h:35

Member Function Documentation

◆ hypercube()

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

information describing the axes, types and labels of this tensor

Reimplemented from civita::ITensor.

Definition at line 40 of file tensorOp.h.

References arg, and civita::ITensor::m_hypercube.

40 {return arg? arg->hypercube(): m_hypercube;}
std::shared_ptr< ITensor > arg
Definition: tensorOp.h:36
Hypercube m_hypercube

◆ index()

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

the index vector - assumed to be ordered and unique

Reimplemented from civita::ITensor.

Definition at line 41 of file tensorOp.h.

References arg, and civita::ITensor::m_index.

41 {return arg? arg->index(): m_index;}
std::shared_ptr< ITensor > arg
Definition: tensorOp.h:36

◆ operator[]()

double civita::ElementWiseOp::operator[] ( std::size_t  ) const
inlineoverridevirtual

return or compute data at a location

Implements civita::ITensor.

Definition at line 42 of file tensorOp.h.

References arg, and f.

42 {return arg? f((*arg)[i]): 0;}
std::shared_ptr< ITensor > arg
Definition: tensorOp.h:36
std::function< double(double)> f
Definition: tensorOp.h:35

◆ setArgument()

void civita::ElementWiseOp::setArgument ( const TensorPtr a,
const ITensor::Args  
)
inlineoverridevirtual

Reimplemented from civita::ITensor.

Definition at line 39 of file tensorOp.h.

References arg.

39 {arg=a;}
std::shared_ptr< ITensor > arg
Definition: tensorOp.h:36

◆ size()

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

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

Reimplemented from civita::ITensor.

Definition at line 43 of file tensorOp.h.

References arg.

43 {return arg? arg->size(): 1;}
std::shared_ptr< ITensor > arg
Definition: tensorOp.h:36

◆ timestamp()

Timestamp civita::ElementWiseOp::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 44 of file tensorOp.h.

References arg.

44 {return arg? arg->timestamp(): Timestamp();}
std::chrono::time_point< std::chrono::high_resolution_clock > Timestamp
std::shared_ptr< ITensor > arg
Definition: tensorOp.h:36

Member Data Documentation

◆ arg

std::shared_ptr<ITensor> civita::ElementWiseOp::arg

Definition at line 36 of file tensorOp.h.

Referenced by hypercube(), index(), operator[](), setArgument(), size(), and timestamp().

◆ f

std::function<double(double)> civita::ElementWiseOp::f

Definition at line 35 of file tensorOp.h.

Referenced by operator[]().


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