Other operators

Transpose-dot

The dot product between the transpose of a tensor with itself. Results in a symmetric tensor.

\[\mathbf{A} = \mathbf{B}^\text{T} \cdot \mathbf{B} \Leftrightarrow A_{ij} = B_{ki}^\text{T} B_{kj} = B_{ik} B_{kj}\]
\[\mathbf{A} = \mathbf{B} \cdot \mathbf{B}^\text{T} \Leftrightarrow A_{ij} = B_{ik} B_{jk}^\text{T} = B_{ik} B_{kj}\]
Tensors.tdotFunction.
tdot(::SecondOrderTensor)

Computes the transpose-dot of a second order tensor with itself. Returns a SymmetricTensor.

Example:

julia> A = rand(Tensor{2,3})
3×3 Tensors.Tensor{2,3,Float64,9}:
 0.590845  0.460085  0.200586
 0.766797  0.794026  0.298614
 0.566237  0.854147  0.246837

julia> tdot(A)
3×3 Tensors.SymmetricTensor{2,3,Float64,6}:
 1.2577   1.36435   0.48726
 1.36435  1.57172   0.540229
 0.48726  0.540229  0.190334
source
Tensors.dottFunction.
dott(::SecondOrderTensor)

Computes the dot-transpose of a second order tensor with itself. Returns a SymmetricTensor.

Example:

julia> A = rand(Tensor{2,3})
3×3 Tensors.Tensor{2,3,Float64,9}:
 0.590845  0.460085  0.200586
 0.766797  0.794026  0.298614
 0.566237  0.854147  0.246837

julia> dott(A)
3×3 Tensors.SymmetricTensor{2,3,Float64,6}:
 0.601011  0.878275  0.777051
 0.878275  1.30763   1.18611
 0.777051  1.18611   1.11112
source

Norm

The (2)-norm of a tensor is defined for a vector, second order tensor and fourth order tensor as

\[\|\mathbf{a}\| = \sqrt{\mathbf{a} \cdot \mathbf{a}} \Leftrightarrow \|a_i\| = \sqrt{a_i a_i}\]
\[\|\mathbf{A}\| = \sqrt{\mathbf{A} : \mathbf{A}} \Leftrightarrow \|A_{ij}\| = \sqrt{A_{ij} A_{ij}}\]
\[\|\mathsf{A}\| = \sqrt{\mathsf{A} :: \mathsf{A}} \Leftrightarrow \|A_{ijkl}\| = \sqrt{A_{ijkl} A_{ijkl}}\]
Base.LinAlg.normFunction.
norm(::Vec)
norm(::SecondOrderTensor)
norm(::FourthOrderTensor)

Computes the norm of a tensor.

Example:

julia> A = rand(Tensor{2,3})
3×3 Tensors.Tensor{2,3,Float64,9}:
 0.590845  0.460085  0.200586
 0.766797  0.794026  0.298614
 0.566237  0.854147  0.246837

julia> norm(A)
1.7377443667834922
source

Trace

The trace for a second order tensor is defined as the sum of the diagonal elements. This can be written as

\[\text{tr}(\mathbf{A}) = \mathbf{I} : \mathbf{A} \Leftrightarrow \text{tr}(A_{ij}) = A_{ii}\]
Base.LinAlg.traceFunction.
trace(::SecondOrderTensor)

Computes the trace of a second order tensor. The synonym vol can also be used.

Example:

julia> A = rand(SymmetricTensor{2,3})
3×3 Tensors.SymmetricTensor{2,3,Float64,6}:
 0.590845  0.766797  0.566237
 0.766797  0.460085  0.794026
 0.566237  0.794026  0.854147

julia> trace(A)
1.9050765715072775
source

Determinant

Determinant for a second order tensor.

Base.LinAlg.detFunction.
det(::SecondOrderTensor)

Computes the determinant of a second order tensor.

Example:

julia> A = rand(SymmetricTensor{2,3})
3×3 Tensors.SymmetricTensor{2,3,Float64,6}:
 0.590845  0.766797  0.566237
 0.766797  0.460085  0.794026
 0.566237  0.794026  0.854147

julia> det(A)
-0.1005427219925894
source

Inverse

Inverse of a second order tensor such that

\[\mathbf{A}^{-1} \cdot \mathbf{A} = \mathbf{I}\]

where $\mathbf{I}$ is the second order identitiy tensor.

Base.invFunction.
inv(::SecondOrderTensor)

Computes the inverse of a second order tensor.

Example:

julia> A = rand(Tensor{2,3})
3×3 Tensors.Tensor{2,3,Float64,9}:
 0.590845  0.460085  0.200586
 0.766797  0.794026  0.298614
 0.566237  0.854147  0.246837

julia> inv(A)
3×3 Tensors.Tensor{2,3,Float64,9}:
  19.7146   -19.2802    7.30384
   6.73809  -10.7687    7.55198
 -68.541     81.4917  -38.8361
source

Transpose

Transpose of tensors is defined by changing the order of the tensor's "legs". The transpose of a vector/symmetric tensor is the vector/tensor itself. The transpose of a second order tensor can be written as:

\[A_{ij}^\text{T} = A_{ji}\]

and for a fourth order tensor the minor transpose can be written as

\[A_{ijkl}^\text{t} = A_{jilk}\]

and the major transpose as

\[A_{ijkl}^\text{T} = A_{klij}\]
Base.transposeFunction.
transpose(::Vec)
transpose(::SecondOrderTensor)
transpose(::FourthOrderTensor)

Computes the transpose of a tensor. For a fourth order tensor, the transpose is the minor transpose.

Example:

julia> A = rand(Tensor{2,2})
2×2 Tensors.Tensor{2,2,Float64,4}:
 0.590845  0.566237
 0.766797  0.460085

julia> A'
2×2 Tensors.Tensor{2,2,Float64,4}:
 0.590845  0.766797
 0.566237  0.460085
source
minortranspose(::FourthOrderTensor)

Computes the minor transpose of a fourth order tensor.

source
majortranspose(::FourthOrderTensor)

Computes the major transpose of a fourth order tensor.

source

Symmetric

The symmetric part of a second and fourth order tensor is defined by:

\[\mathbf{A}^\text{sym} = \frac{1}{2}(\mathbf{A} + \mathbf{A}^\text{T}) \Leftrightarrow A_{ij}^\text{sym} = \frac{1}{2}(A_{ij} + A_{ji})\]
\[\mathsf{A}^\text{sym} = \frac{1}{2}(\mathsf{A} + \mathsf{A}^\text{t}) \Leftrightarrow A_{ijkl}^\text{sym} = \frac{1}{2}(A_{ijkl} + A_{jilk})\]
Tensors.symmetricFunction.
symmetric(::SecondOrderTensor)
symmetric(::FourthOrderTensor)

Computes the symmetric part of a second or fourth order tensor. For a fourth order tensor, the symmetric part is the same as the minor symmetric part. Returns a SymmetricTensor.

Example:

julia> A = rand(Tensor{2,2})
2×2 Tensors.Tensor{2,2,Float64,4}:
 0.590845  0.566237
 0.766797  0.460085

julia> symmetric(A)
2×2 Tensors.SymmetricTensor{2,2,Float64,3}:
 0.590845  0.666517
 0.666517  0.460085
source
minorsymmetric(::FourthOrderTensor)

Computes the minor symmetric part of a fourth order tensor, returns a SymmetricTensor{4}.

source
majorsymmetric(::FourthOrderTensor)

Computes the major symmetric part of a fourth order tensor, returns a Tensor{4}.

source

Skew symmetric

The skew symmetric part of a second order tensor is defined by

\[\mathbf{A}^\text{skw} = \frac{1}{2}(\mathbf{A} - \mathbf{A}^\text{T}) \Leftrightarrow A^\text{skw}_{ij} = \frac{1}{2}(A_{ij} - A_{ji})\]

The skew symmetric part of a symmetric tensor is zero.

Tensors.skewFunction.
skew(::SecondOrderTensor)

Computes the skew-symmetric (anti-symmetric) part of a second order tensor, returns a Tensor{2}.

source

Deviator

The deviatoric part of a second order tensor is defined by

\[\mathbf{A}^\text{dev} = \mathbf{A} - \frac{1}{3} \mathrm{trace}[\mathbf{A}] \mathbf{I} \Leftrightarrow A_{ij}^\text{dev} = A_{ij} - \frac{1}{3}A_{kk}\delta_{ij}\]
Tensors.devFunction.
dev(::SecondOrderTensor)

Computes the deviatoric part of a second order tensor.

Example:

julia> A = rand(Tensor{2,3});

julia> dev(A)
3×3 Tensors.Tensor{2,3,Float64,9}:
 0.0469421  0.460085   0.200586
 0.766797   0.250123   0.298614
 0.566237   0.854147  -0.297065

julia> trace(dev(A))
0.0
source

Cross product

The cross product between two vectors is defined as

\[\mathbf{a} = \mathbf{b} \times \mathbf{c} \Leftrightarrow a_i = \epsilon_{ijk} b_j c_k\]
Base.LinAlg.crossFunction.
cross(::Vec, ::Vec)

Computes the cross product between two Vec vectors, returns a Vec{3}. For dimensions 1 and 2 the Vec's are expanded to 3D first. The infix operator × (written \times) can also be used.

Example:

julia> a = rand(Vec{3})
3-element Tensors.Tensor{1,3,Float64,3}:
 0.590845
 0.766797
 0.566237

julia> b = rand(Vec{3})
3-element Tensors.Tensor{1,3,Float64,3}:
 0.460085
 0.794026
 0.854147

julia> a × b
3-element Tensors.Tensor{1,3,Float64,3}:
  0.20535
 -0.24415
  0.116354
source

Eigenvalues and eigenvectors

The eigenvalues and eigenvectors of a (symmetric) second order tensor, $\mathbf{A}$ can be solved from the eigenvalue problem

\[\mathbf{A} \cdot \mathbf{v}_i = \lambda_i \mathbf{v}_i \qquad i = 1, \dots, \text{dim}\]

where $\lambda_i$ are the eigenvalues and $\mathbf{v}_i$ are the corresponding eigenvectors.

Base.LinAlg.eigFunction.
eig(::SymmetricSecondOrderTensor)

Computes the eigenvalues and eigenvectors of a symmetric second order tensor.

Example:

julia> A = rand(SymmetricTensor{2,3})
3×3 Tensors.SymmetricTensor{2,3,Float64,6}:
 0.590845  0.766797  0.566237
 0.766797  0.460085  0.794026
 0.566237  0.794026  0.854147

julia> Λ, Φ = eig(A);

julia> Λ
3-element Tensors.Tensor{1,3,Float64,3}:
 -0.312033
  0.15636
  2.06075

julia> Φ
3×3 Tensors.Tensor{2,3,Float64,9}:
  0.492843  -0.684993  0.536554
 -0.811724  -0.139855  0.567049
  0.313385   0.715     0.624952

julia> Φ ⋅ diagm(Tensor{2,3}, Λ) ⋅ inv(Φ) # Same as A
3×3 Tensors.Tensor{2,3,Float64,9}:
 0.590845  0.766797  0.566237
 0.766797  0.460085  0.794026
 0.566237  0.794026  0.854147
source

Rotations

Tensors.rotateFunction.

Rotate a three dimensional vector x around another vector u a total of θ radians.

rotate(x::Vec{3}, u::Vec{3}, θ::Number)

Example:

julia> x = Vec{3}((0.0, 0.0, 1.0))
3-element Tensors.Tensor{1,3,Float64,3}:
 0.0
 0.0
 1.0

julia> u = Vec{3}((0.0, 1.0, 0.0))
3-element Tensors.Tensor{1,3,Float64,3}:
 0.0
 1.0
 0.0

julia> rotate(x, u, π/2)
3-element Tensors.Tensor{1,3,Float64,3}:
 1.0
 0.0
 6.12323e-17
source

Special operations

For computing a special dot product between two vectors $\mathbf{a}$ and $\mathbf{b}$ with a fourth order symmetric tensor $\mathbf{C}$ such that $a_k C_{ikjl} b_l$ there is dotdot(a, C, b). This function is useful because it is the expression for the tangent matrix in continuum mechanics when the displacements are approximated by scalar shape functions.

Tensors.dotdotFunction.
dotdot(::Vec, ::SymmetricFourthOrderTensor, ::Vec)

Computes a special dot product between two vectors and a symmetric fourth order tensor such that $a_k C_{ikjl} b_l$.

source