Skip to main content
Have a personal or library account? Click to login
Tensors.jl — Tensor Computations in Julia Cover

Tensors.jl — Tensor Computations in Julia

Open Access
|Mar 2019

Figures & Tables

Table 1

Summary of implemented tensor operations. u, v denotes vectors, A, B denotes second-order symmetric or non-symmetric tensors, and C, D denotes fourth-order symmetric or non-symmetric tensors. We note that instead of using : for infix double contraction we use ⊡ (written as \boxdot). This is because : does not have the same operator precedence as multiplication in Julia.

OperationJulia codeinfix
Single contraction
u · v (uivi)dot(u, v)u · v
A · v (Aijvj)dot(A, v)A · v
A · B (AijBjk)dot(A, B)A · B
Double contraction
A : B (AijBij)dcontract(A, B)A ⊡ B
C : B (CijklBkl)dcontract(C, B)C ⊡ B
C : D (CijklDklmn)dcontract(A, D)C ⊡ D
Outer product
uv (uivj)otimes(u, v)u ⊗ v
AB (AijBkl)otimes(A, B)A ⊗ B
Other operations
det(A)det(A)
inv(A)inv(A)
norm(A)norm(A)
ATtranspose(A)
12(A+AT)symmetric(A)
12(A    AT)skew(A)
Table 2

Comparison of performance for some tensor operations using Tensors.jl and Voigt format using Julia Arrays.

OperationTensorArraySpeed-up
Single contraction
u · u1.241 ns9.795 ns×7.9
A · u2.161 ns58.769 ns×27.2
A · A3.117 ns44.395 ns×14.2
Asym · Asym5.125 ns44.498 ns×8.7
Double contraction
A : A1.927 ns12.189 ns×6.3
Asym : Asym1.927 ns12.187 ns×6.3
C : A6.087 ns78.554 ns×12.9
C : C60.820 ns280.502 ns×4.6
Csym : Csym22.104 ns281.003 ns×12.7
Asym : Csym : Asym9.466 ns89.747 ns×9.5
Outer product
uu2.167 ns32.447 ns×15.0
AA9.801 ns6.568 ns×8.8
Other operations
det(A)1.924 ns177.134 ns×92.1
inv(Asym)4.587 ns635.858 ns×138.6
norm(A)1.990 ns16.752 ns×8.4
DOI: https://doi.org/10.5334/jors.182 | Journal eISSN: 2049-9647
Language: English
Submitted on: Jun 11, 2017
Accepted on: Jun 6, 2018
Published on: Mar 21, 2019
Published by: Ubiquity Press
In partnership with: Paradigm Publishing Services
Publication frequency: 1 issue per year

© 2019 Kristoffer Carlsson, Fredrik Ekre, published by Ubiquity Press
This work is licensed under the Creative Commons Attribution 4.0 License.