Txeo v0.1
A Developer-Friendly TensorFlow C++ Wrapper
Loading...
Searching...
No Matches
TensorOp.h
Go to the documentation of this file.
1#ifndef TENSOROP_H
2#define TENSOROP_H
3#pragma once
4
5#include "txeo/Matrix.h"
6#include "txeo/Tensor.h"
7#include "txeo/Vector.h"
8
9namespace txeo {
10
20template <typename T>
21class TensorOp {
22 public:
23 TensorOp(const TensorOp &) = delete;
24 TensorOp(TensorOp &&) = delete;
25 TensorOp &operator=(const TensorOp &) = delete;
27 ~TensorOp() = default;
28
45 static txeo::Tensor<T> sum(const txeo::Tensor<T> &left, const txeo::Tensor<T> &right);
46
63
78 static txeo::Tensor<T> sum(const txeo::Tensor<T> &left, const T &right);
79
92 static txeo::Tensor<T> &sum_by(txeo::Tensor<T> &left, const T &right);
93
110 static txeo::Tensor<T> subtract(const txeo::Tensor<T> &left, const txeo::Tensor<T> &right);
111
128
142 static txeo::Tensor<T> subtract(const txeo::Tensor<T> &left, const T &right);
143
157 static txeo::Tensor<T> &subtract_by(txeo::Tensor<T> &left, const T &right);
158
173 static txeo::Tensor<T> subtract(const T &left, const txeo::Tensor<T> &right);
174
188 static const T &subtract_by(const T &left, txeo::Tensor<T> &right);
189
203 static txeo::Tensor<T> multiply(const txeo::Tensor<T> &left, const T &right);
204
217 static txeo::Tensor<T> &multiply_by(txeo::Tensor<T> &left, const T &right);
218
233 static txeo::Tensor<T> divide(const txeo::Tensor<T> &left, const T &right);
234
247 static txeo::Tensor<T> &divide_by(txeo::Tensor<T> &left, const T &right);
248
263 static txeo::Tensor<T> divide(const T &left, const txeo::Tensor<T> &right);
264
278 static txeo::Tensor<T> &divide_by(const T &scalar, txeo::Tensor<T> &tensor);
279
297
315
332
348
366 static txeo::Matrix<T> product(const txeo::Matrix<T> &left, const txeo::Matrix<T> &right);
367
385 static T dot(const txeo::Vector<T> &left, const txeo::Vector<T> &right);
386
387 private:
388 TensorOp() = default;
389};
390
395class TensorOpError : public std::runtime_error {
396 public:
397 using std::runtime_error::runtime_error;
398};
399
400} // namespace txeo
401#endif
A class representing a matrix, derived from Tensor.
Definition Matrix.h:42
Implements the mathematical concept of tensor, which is a magnitude of multiple order....
Definition Tensor.h:48
Exceptions concerning txeo::TensorOp.
Definition TensorOp.h:395
A utility class for performing operations on tensors and vectors.
Definition TensorOp.h:21
static const T & subtract_by(const T &left, txeo::Tensor< T > &right)
In-place element-wise subtraction of tensor from scalar.
static txeo::Tensor< T > & divide_by(txeo::Tensor< T > &left, const T &right)
In-place element-wise division of tensor by scalar.
static txeo::Tensor< T > & sum_by(txeo::Tensor< T > &left, const txeo::Tensor< T > &right)
Sums the left operand with the right operand (in-place)
static T dot(const txeo::Vector< T > &left, const txeo::Vector< T > &right)
Computes the dot product of two vectors.
static txeo::Tensor< T > sum(const txeo::Tensor< T > &left, const T &right)
Element-wise sum of tensor and scalar (out-of-place)
static txeo::Tensor< T > & hadamard_prod_by(txeo::Tensor< T > &left, const txeo::Tensor< T > &right)
Performs element-wise multiplication of the left operand by the right operand (in-place)
static txeo::Tensor< T > subtract(const txeo::Tensor< T > &left, const txeo::Tensor< T > &right)
Returns the subtraction of two tensors.
static txeo::Tensor< T > divide(const T &left, const txeo::Tensor< T > &right)
Element-wise division of scalar by tensor (out-of-place)
static txeo::Tensor< T > multiply(const txeo::Tensor< T > &left, const T &right)
Returns the multiplication of a tensor and a scalar.
~TensorOp()=default
static txeo::Tensor< T > hadamard_div(const txeo::Tensor< T > &left, const txeo::Tensor< T > &right)
Element-wise Hadamard division (out-of-place)
static txeo::Tensor< T > & subtract_by(txeo::Tensor< T > &left, const txeo::Tensor< T > &right)
Subtracts the left operand by the right operand (in-place)
TensorOp(TensorOp &&)=delete
static txeo::Tensor< T > & divide_by(const T &scalar, txeo::Tensor< T > &tensor)
In-place element-wise division of scalar by tensor elements.
static txeo::Tensor< T > hadamard_prod(const txeo::Tensor< T > &left, const txeo::Tensor< T > &right)
Returns the element-wise product (Hadamard Product) of two tensors.
static txeo::Tensor< T > subtract(const txeo::Tensor< T > &left, const T &right)
Element-wise subtraction of scalar from tensor (out-of-place)
static txeo::Matrix< T > product(const txeo::Matrix< T > &left, const txeo::Matrix< T > &right)
Computes the matrix product of two matrices.
TensorOp & operator=(const TensorOp &)=delete
static txeo::Tensor< T > & multiply_by(txeo::Tensor< T > &left, const T &right)
Multiplies the tensor by a scalar (in-place)
static txeo::Tensor< T > & sum_by(txeo::Tensor< T > &left, const T &right)
In-place element-wise addition of scalar to tensor.
static txeo::Tensor< T > divide(const txeo::Tensor< T > &left, const T &right)
Element-wise division of tensor by scalar (out-of-place)
TensorOp(const TensorOp &)=delete
static txeo::Tensor< T > & hadamard_div_by(txeo::Tensor< T > &left, const txeo::Tensor< T > &right)
In-place element-wise Hadamard division.
static txeo::Tensor< T > sum(const txeo::Tensor< T > &left, const txeo::Tensor< T > &right)
Returns the sum of two tensors.
static txeo::Tensor< T > subtract(const T &left, const txeo::Tensor< T > &right)
Element-wise subtraction of tensor from scalar (out-of-place)
static txeo::Tensor< T > & subtract_by(txeo::Tensor< T > &left, const T &right)
In-place element-wise subtraction of scalar from tensor.
TensorOp & operator=(TensorOp &&)=delete
A class representing a vector, derived from Tensor.
Definition Vector.h:42
Definition Matrix.h:11