Tensors as arrays¶
Internal memory layout¶
A tensor of tmech consists of a contiguous one-dimensional array combined with an indexing scheme that maps unsigned integers to the location of an element in the array. The number of indices is defined by the rank and the range of the indices by the dimension of a tensor. The scheme used to map indices into a location in the array is given by this formula
where denotes the rank,
the dimension,
is the
is the index
for array indexing.
This produces the following storing scheme for second order tensor
and for fourth order tensor
Performance¶
For tensors up to the rank equal to 8 and dimension 3 the memory is stack-allocated which makes them more efficient. For higher rank tensors the memory is heap-allocated.