Home

Awesome

<img src="https://github.com/Jutho/TensorOperations.jl/blob/master/docs/src/assets/logo.svg" width="150">

TensorOperations.jl

Fast tensor operations using a convenient Einstein index notation.

DocumentationDigital Object IdentifierDownloads
DOITensorOperations Downloads
Build StatusPkgEvalCoverageQuality assurance
CIPkgEvalCodecovAqua QA

What's new in v5

What's new in v4

WARNING: TensorOperations 4.0 contains several breaking changes and cannot generally be expected to be compatible with previous versions.

Code example

TensorOperations.jl is mostly used through the @tensor macro which allows one to express a given operation in terms of index notation format, a.k.a. Einstein notation (using Einstein's summation convention).

using TensorOperations
α = randn()
A = randn(5, 5, 5, 5, 5, 5)
B = randn(5, 5, 5)
C = randn(5, 5, 5)
D = zeros(5, 5, 5)
@tensor begin
    D[a, b, c] = A[a, e, f, c, f, g] * B[g, b, e] + α * C[c, a, b]
    E[a, b, c] := A[a, e, f, c, f, g] * B[g, b, e] + α * C[c, a, b]
end

In the second to last line, the result of the operation will be stored in the preallocated array D, whereas the last line uses a different assignment operator := in order to define and allocate a new array E of the correct size. The contents of D and E will be equal.

For more detailed information, please see the documentation.

Citing

See CITATION.bib for the relevant reference(s).