# Tensors

FISH supports 3x3 symmetric tensors, to represent stress and strain states.

Tensors can also be created from matrices and lists, see the tensor library function.

Component Access

Tensor components can be accessed using parentheses, either using a single argument index int the range 1 to 6 (component order xx, yy, zz, xy, xz, yz) or using two arguments each in the range 1 to 3.

Tensor components can also be accessed using the c -> operator and the xx, yy, zz, xy, xz, yz, yx, zx, zy accessors.

The example below illustrates the various method of accessing individual components of tensors.

    local a = tensor(2,3,4,1,6,5)
local b = tensor(8,8,3,7,3,5)

local c = a(5)   ; c = 6.0
local d = a(1,3) ; d = 6.0
local e = a->xz  ; e = 6.0

a(5) = 6.0    ; These are all equivalent
a(1,3) = 6.0
a->xz = 6.0


Mathematical Operations

Tensors can be added and multiplied.

A tensor can be multiplied by a vector to get another vector.

Note that the result of a tensor multiplication is a matrix.

Please see Arithmetic for a complete table of operator support.

See the Tensor Utilities for available methods.

Iteration

Tensors are an iterable type. This means you can use it as the target of a loop foreach statement (see Loop ForEach) and can be split (see Splitting). Each component of the tensor is iterated in the order xx, yy, zz, xy, xz, yz.

As with most aggregate types, when the value is listed it will simply indicate Tensor. To see the contents of the tensor use the fish list contents command.