TTensor


This template represents tensor or multidimensional array.

You can find more information in comments below.

template<class TYPE, size_t SIZE, size_t ...Dimensions>
class TTensor<TYPE, SIZE, Dimensions...>
{
public:
    const static size_t Size; // Element count
    const static size_t TotalSize; // Total element count

    TTensor() = default;

    TTensor(const std::initializer_list<TTensor<TYPE, Dimensions...>> &values); // Create and populate with specified values

    const TTensor<TYPE, Dimensions...> &operator[](const size_t index) const; // Get element value
    TTensor<TYPE, Dimensions...> &operator[](const size_t index); // Get/set element value
};

Additionally following operators exists.

template<class TYPE, size_t SIZE, size_t ...Dimensions>
bool operator==(const TTensor<TYPE, SIZE, Dimensions...> &a, const TTensor<TYPE, SIZE, Dimensions...> &b); // Check whether tensors are equal. Can be used for non-float data types only
template<class TYPE, size_t SIZE, size_t ...Dimensions>
bool operator!=(const TTensor<TYPE, SIZE, Dimensions...> &a, const TTensor<TYPE, SIZE, Dimensions...> &b); // Check whether tensors aren't equal. Can be used for non-float data types only
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> operator+(const TTensor<TYPE, SIZE, Dimensions...> &a, const TYPE value); // Add tensor and scalar
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> operator-(const TTensor<TYPE, SIZE, Dimensions...> &a, const TYPE value); // Subtract tensor and scalar
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> operator*(const TTensor<TYPE, SIZE, Dimensions...> &a, const TYPE value); // Multiply tensor and scalar
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> operator/(const TTensor<TYPE, SIZE, Dimensions...> &a, const TYPE value); // Divide tensor and scalar
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> operator+(const TYPE value, const TTensor<TYPE, SIZE, Dimensions...> &a); // Add scalar and tensor
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> operator-(const TYPE value, const TTensor<TYPE, SIZE, Dimensions...> &a); // Subtract scalar and tensor
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> operator*(const TYPE value, const TTensor<TYPE, SIZE, Dimensions...> &a); // Multiply scalar and tensor
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> operator/(const TYPE value, const TTensor<TYPE, SIZE, Dimensions...> &a); // Divide scalar and tensor
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> &operator+=(TTensor<TYPE, SIZE, Dimensions...> &a, const TYPE value); // Add scalar to tensor
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> &operator-=(TTensor<TYPE, SIZE, Dimensions...> &a, const TYPE value); // Subtract scalar from tensor
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> &operator*=(TTensor<TYPE, SIZE, Dimensions...> &a, const TYPE value); // Multiply tensor by scalar
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> &operator/=(TTensor<TYPE, SIZE, Dimensions...> &a, const TYPE value); // Divide tensor by scalar
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> operator+(const TTensor<TYPE, SIZE, Dimensions...> &a, const TTensor<TYPE, SIZE, Dimensions...> &b); // Add tensors(their elements)
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> operator-(const TTensor<TYPE, SIZE, Dimensions...> &a, const TTensor<TYPE, SIZE, Dimensions...> &b); // Subtract tensors(their elements)
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> operator*(const TTensor<TYPE, SIZE, Dimensions...> &a, const TTensor<TYPE, SIZE, Dimensions...> &b); // Multiply tensors(their elements)
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> operator/(const TTensor<TYPE, SIZE, Dimensions...> &a, const TTensor<TYPE, SIZE, Dimensions...> &b); // Divide tensors(their elements)
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> &operator+=(TTensor<TYPE, SIZE, Dimensions...> &a, const TTensor<TYPE, SIZE, Dimensions...> &b); // Add tensor to tensor(its elements)
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> &operator-=(TTensor<TYPE, SIZE, Dimensions...> &a, const TTensor<TYPE, SIZE, Dimensions...> &b); // Subtract tensor from tensor(its elements)
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> &operator*=(TTensor<TYPE, SIZE, Dimensions...> &a, const TTensor<TYPE, SIZE, Dimensions...> &b); // Multiply tensor by tensor(its elements)
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> &operator/=(TTensor<TYPE, SIZE, Dimensions...> &a, const TTensor<TYPE, SIZE, Dimensions...> &b); // Divide tensor by tensor(its elements)
template<class TYPE, size_t SIZE, size_t ...Dimensions>
TTensor<TYPE, SIZE, Dimensions...> operator-(const TTensor<TYPE, SIZE, Dimensions...> &a); // Inverse tensor

Also there are some functions which can be used with TTensor template. Here they are.

Namespace: ntl
Include: NTL/Core/Tensor.h