Implements the Einstein notation for summation over repeated indices.

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)
#> [,1] #> [1,] "(a) * (a) + (c) * (b) + (e) * (c)" #> [2,] "(b) * (a) + (d) * (b) + (f) * (c)"
### 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)
#> [,1] [,2] [,3] [,4] #> [1,] 56370 118800 181230 243660 #> [2,] 66700 140500 214300 288100