einstein {calculus}R Documentation

Numerical and Symbolic Einstein Summation

Description

Implements the Einstein notation for summation over repeated indices.

Usage

einstein(..., drop = TRUE)

Arguments

...

arbitrary number of indexed arrays. See index.

drop

logical. Drop summation indices? If FALSE, keep dummy dimensions.

Value

array.

References

Guidotti, E. (2020). "calculus: High dimensional numerical and symbolic calculus in R". https://arxiv.org/abs/2101.00086

See Also

Other tensor algebra: contraction(), delta(), diagonal(), epsilon(), index()

Examples

### A{i,j} B{j,k}
a <- array(letters[1:6], dim = c(i=2, j=3))
b <- array(letters[1:3], dim = c(j=3, k=1))
einstein(a,b)

### A{i,j} B{j,k,k} C{k,l} D{j,k}
a <- array(1:10, dim = c(i=2, j=5))
b <- array(1:45, dim = c(j=5, k=3, k=3))
c <- array(1:12, dim = c(k=3, l=4))
d <- array(1:15, dim = c(j=5, k=3))
einstein(a,b,c,d)


[Package calculus version 0.3.1 Index]