20 #ifndef CIVITA_TENSOROP_H 21 #define CIVITA_TENSOROP_H 22 #include "tensorVal.h" 23 #include "ravelState.h" 35 std::function<double(double)>
f;
36 std::shared_ptr<ITensor>
arg;
43 std::size_t
size()
const override {
return arg?
arg->size(): 1;}
52 std::function<double(double,double)>
f;
68 throw std::runtime_error(
"inputs undefined");
78 {
return max(
arg1->timestamp(),
arg2->timestamp());}
84 std::vector<TensorPtr>
args;
85 std::function<void(double&,double)>
f;
90 double operator[](std::size_t i)
const override;
98 std::function<void(double&,double,std::size_t)>
f;
100 std::shared_ptr<ITensor>
arg;
107 double operator[](std::size_t)
const override;
125 double operator[](std::size_t i)
const override;
140 double operator[](std::size_t i)
const override;
200 std::size_t
dimension=std::numeric_limits<std::size_t>::max();
211 std::function<void(double&,double,std::size_t)>
f;
232 double operator[](std::size_t i)
const override;
249 double operator[](std::size_t i)
const override;
266 double operator[](std::size_t i)
const override;
279 throw std::runtime_error(
"Sort by Value only applicable for rank 1 tensors");
290 std::size_t
size()
const override {
320 arg->hypercube().xvectors.end());
321 std::set<std::size_t> idx;
322 for (
auto& i:
arg->index())
342 std::set<std::size_t> idx;
343 for (
auto& i:
arg->index())
345 idx.insert(i+j*
arg->size());
double operator[](std::size_t i) const override
return or compute data at a location
double operator[](std::size_t i) const override
return or compute data at a location
calculate the sum along an axis or whole tensor
virtual void computeTensor() const =0
computeTensor updates the above two mutable fields, but is logically const
std::vector< TensorPtr > args
double operator[](std::size_t i) const override
return or compute data at a location
If a rank 1 argument, sort by the value of the argument.
std::size_t numSpreadElements
virtual const Hypercube & hypercube() const
information describing the axes, types and labels of this tensor
double argVal
op arg value, eg binsize or delta in difference op
void setArgument(const TensorPtr &a, const ITensor::Args &args={"", 0}) override
argument indices corresponding to this indices, when sparse
calculates the average along an axis or whole tensor
Timestamp timestamp() const override
timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when...
double operator[](std::size_t i) const override
return or compute data at a location
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 ...
const Index & index() const override
the index vector - assumed to be ordered and unique
double operator[](std::size_t) const override
return or compute data at a location
compute the reduction along the indicated dimension, ignoring any missing entry (NaNs) ...
reduce all elements to a single number
void setArgument(const TensorPtr &a, const ITensor::Args &args={"", 0}) override
virtual const Index & index() const
the index vector - assumed to be ordered and unique
ElementWiseOp(F f, const std::shared_ptr< ITensor > &arg={})
Timestamp timestamp() const override
timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when...
perform an operation elementwise over a tensor valued argument
std::vector< std::size_t > arg_index
std::map< std::size_t, std::vector< SOI > > sumOverIndices
std::shared_ptr< ITensor > arg
Timestamp timestamp() const override
timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when...
double operator[](std::size_t i) const override
return or compute data at a location
std::function< void(double &, double)> f
void setSpreadDimensions(const Hypercube &hc)
double operator[](std::size_t i) const override
return or compute data at a location
void setSpreadDimensions(const Hypercube &hc)
const Index & index() const override
the index vector - assumed to be ordered and unique
std::size_t size() const override
return number of elements in tensor - maybe less than hypercube.numElements if sparse ...
double operator[](std::size_t i) const override
return or compute data at a location
ReduceAllOp(F f, double init, const std::shared_ptr< ITensor > &arg={})
Timestamp timestamp() const override
timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when...
std::vector< std::size_t > permutation
std::size_t pivotIndex(std::size_t i) const
virtual std::size_t size() const
return number of elements in tensor - maybe less than hypercube.numElements if sparse ...
const Hypercube & hypercube(const Hypercube &hc) override
std::vector< std::size_t > permutedIndex
void setArgument(const TensorPtr &a, const ITensor::Args &args={"", 0}) override
TensorPtr arg
argument indices corresponding to this indices, when sparse
corresponds to the OLAP pivot operation
void setArguments(const std::vector< TensorPtr > &a, const ITensor::Args &) override
void setArgument(const TensorPtr &a, const ITensor::Args &) override
void setArgument(const TensorPtr &a, const ITensor::Args &) override
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...
std::size_t hcIndex(const std::initializer_list< T > &indices) const
Timestamp timestamp() const override
timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when...
void setArguments(const TensorPtr &a1, const TensorPtr &a2, const ITensor::Args &) override
void setArgument(const TensorPtr &a, const ITensor::Args &) override
calculate the minimum along an axis or whole tensor
arguments relevant for tensor expressions, not always meaningful. Exception thrown if not...
ReductionOp(F f, double init, const TensorPtr &arg={}, const std::string &dimName="")
const Hypercube & hypercube() const override
information describing the axes, types and labels of this tensor
Scan(F f, const TensorPtr &arg={}, const std::string &dimName="", double av=0)
BinOp(F f, const TensorPtr &arg1={}, const TensorPtr &arg2={})
perform a binary operation elementwise over two tensor arguments. Arguments need to be conformal: at ...
Timestamp timestamp() const override
timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when...
std::size_t size() const override
return number of elements in tensor - maybe less than hypercube.numElements if sparse ...
calculate the maximum along an axis or whole tensor
Timestamp timestamp() const override
timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when...
std::function< void(double &, double, std::size_t)> f
void setOrientation(const std::vector< std::string > &axes)
set's the pivots orientation
std::shared_ptr< ITensor > TensorPtr
void setArgument(const TensorPtr &a, const ITensor::Args &args={"", 0}) override
std::size_t dimension
dimension to apply operation over. >rank = all dims
const Hypercube & hypercube(Hypercube &&hc) override
std::shared_ptr< ITensor > arg
corresponds to OLAP slice operation
ReduceArguments(F f, double init)
const std::vector< std::size_t > & permutation() const
void computeTensor() const override
computeTensor updates the above two mutable fields, but is logically const
std::size_t size() const override
return number of elements in tensor - maybe less than hypercube.numElements if sparse ...
std::function< void(double &, double, std::size_t)> f
Timestamp timestamp() const override
timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when...
std::vector< std::size_t > permutedIndex
permutation of axes
void computeTensor() const override
computeTensor updates the above two mutable fields, but is logically const
const Hypercube & hypercube() const override
information describing the axes, types and labels of this tensor
elementwise reduction over a vector of arguments
double operator[](std::size_t i) const override
return or compute data at a location
void setPermutation(const std::vector< std::size_t > &p)
calculates the standard deviation along an axis or whole tensor
void setArgument(const TensorPtr &arg, const ITensor::Args &args) override
SortByValue(ravel::HandleSort::Order order)
double operator[](std::size_t i) const override
return or compute data at a location
double operator[](std::size_t i) const override
return or compute data at a location
double operator[](std::size_t i) const override
return or compute data at a location
void setArgument(const TensorPtr &a, const ITensor::Args &) override
std::vector< std::size_t > m_permutation
std::function< double(double)> f
calculate the product along an axis or whole tensor
const Hypercube & hypercube() const override
information describing the axes, types and labels of this tensor
Timestamp timestamp() const override
timestamp indicating how old the dependendent data might be. Used in CachedTensorOp to determine when...
std::function< double(double, double)> f
void setArgument(const TensorPtr &a, const ITensor::Args &) override
ravel::HandleSort::Order order
double operator[](std::size_t i) const override
return or compute data at a location