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 (2022). "calculus: High-Dimensional Numerical and Symbolic Calculus in R." Journal of Statistical Software, 104(5), 1-37. doi:10.18637/jss.v104.i05

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 1.0.1 Index]