Computes the Generalized Kronecker Delta.

delta(n, p = 1)

Arguments

n

number of elements for each dimension.

p

order of the generalized Kronecker delta, p=1 for the standard Kronecker delta.

Value

array representing the generalized Kronecker delta tensor.

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(), diagonal(), einstein(), epsilon(), index()

Examples

### Kronecker delta 3x3
delta(3)
#>      [,1] [,2] [,3]
#> [1,]    1    0    0
#> [2,]    0    1    0
#> [3,]    0    0    1

### generalized Kronecker delta 3x3 of order 2
delta(3, p = 2)  
#> , , 1, 1
#> 
#>      [,1] [,2] [,3]
#> [1,]    0    0    0
#> [2,]    0    0    0
#> [3,]    0    0    0
#> 
#> , , 2, 1
#> 
#>      [,1] [,2] [,3]
#> [1,]    0   -1    0
#> [2,]    1    0    0
#> [3,]    0    0    0
#> 
#> , , 3, 1
#> 
#>      [,1] [,2] [,3]
#> [1,]    0    0   -1
#> [2,]    0    0    0
#> [3,]    1    0    0
#> 
#> , , 1, 2
#> 
#>      [,1] [,2] [,3]
#> [1,]    0    1    0
#> [2,]   -1    0    0
#> [3,]    0    0    0
#> 
#> , , 2, 2
#> 
#>      [,1] [,2] [,3]
#> [1,]    0    0    0
#> [2,]    0    0    0
#> [3,]    0    0    0
#> 
#> , , 3, 2
#> 
#>      [,1] [,2] [,3]
#> [1,]    0    0    0
#> [2,]    0    0   -1
#> [3,]    0    1    0
#> 
#> , , 1, 3
#> 
#>      [,1] [,2] [,3]
#> [1,]    0    0    1
#> [2,]    0    0    0
#> [3,]   -1    0    0
#> 
#> , , 2, 3
#> 
#>      [,1] [,2] [,3]
#> [1,]    0    0    0
#> [2,]    0    0    1
#> [3,]    0   -1    0
#> 
#> , , 3, 3
#> 
#>      [,1] [,2] [,3]
#> [1,]    0    0    0
#> [2,]    0    0    0
#> [3,]    0    0    0
#>