Struct Tensor

Generic multi-dimensional array template

struct Tensor(T, ulong dim, sizes...) ;

Constructors

NameDescription
this (initVal) Single element constructor
this (t) Tensor constructor
this (components) Tuple constructor

Properties

NameTypeDescription
vecElements[set] stringSymbolic element access for vector

Methods

NameDescription
opAssign (t) Tensor = Tensor
opIndex (index) T = Tensor[index]
opIndex (indices) T = Tensor[i, j, ...]
opIndexAssign (n, index) Tensor[index] = T
opIndexAssign (t, indices) Tensor[i, j, ...] = T

Templates

NameDescription
opDispatch Swizzling

Description

This template mainly serves as a base for creating various more specialized algebraic objects via encapsulation. Think of Tensor as a backend for e.g. Vector and Matrix.

T - element type, usually numeric (float or double)

dim - number of dimensions (tensor order): 0 - scalar, 1 - vector, 2 - matrix, 3 - 3D array, (higer dimensions are also possible).

sizes - tuple defining sizes for each dimension: 3 - 3-vector, 4,4 - 4x4 matrix, etc.

Data storage type (stack or heap) is statically selected: if given size(s) imply data size larger than MaxStaticTensorSize, data is allocated on heap (as dynamic array). Otherwise, data is allocated on stack (as static array).