Alt.Rd
Converts a k-tensor to alternating form
Alt(S,give_kform)
Given a k-tensor T, we have
Alt(T)(v1,…,vk)=1k!∑σ∈Sksgn(σ)⋅T(vσ(1),…,vσ(k))
Thus for example if k=3:
Alt(T)(v1,v2,v3)=16(+T(v1,v2,v3)−T(v1,v3,v2)−T(v2,v1,v3)+T(v2,v3,v1)+T(v3,v1,v2)−T(v3,v2,v1))
and it is reasonably easy to see that Alt(T) is alternating, in the sense that
Alt(T)(v1,…,vi,…,vj,…,vk)=−Alt(T)(v1,…,vj,…,vi,…,vk)
Function Alt()
is intended to take and return an object of
class ktensor
; but if given a kform
object, it just
returns its argument unchanged.
A short vignette is provided with the package: type
vignette("Alt")
at the commandline.
Returns an alternating k-tensor. To work with k-forms,
which are a much more efficient representation of alternating tensors,
use as.kform()
.
(X <- ktensor(spray(rbind(1:3),6)))
#> A linear map from V^3 to R with V=R^3:
#> val
#> 1 2 3 = 6
Alt(X)
#> A linear map from V^3 to R with V=R^3:
#> val
#> 3 2 1 = -1
#> 3 1 2 = 1
#> 2 3 1 = 1
#> 2 1 3 = -1
#> 1 3 2 = -1
#> 1 2 3 = 1
Alt(X,give_kform=TRUE)
#> An alternating linear map from V^3 to R with V=R^3:
#> val
#> 1 2 3 = 1
S <- as.ktensor(expand.grid(1:3,1:3),rnorm(9))
S
#> A linear map from V^2 to R with V=R^3:
#> val
#> 3 3 = -0.244199607
#> 2 3 = -0.247325302
#> 1 3 = -1.821817661
#> 3 2 = 1.148411606
#> 2 2 = 0.621552721
#> 1 2 = -0.005571287
#> 3 1 = -2.437263611
#> 2 1 = 0.255317055
#> 1 1 = -1.400043517
Alt(S)
#> A linear map from V^2 to R with V=R^3:
#> val
#> 3 2 = 0.6978685
#> 3 1 = -0.3077230
#> 2 3 = -0.6978685
#> 1 3 = 0.3077230
#> 2 1 = 0.1304442
#> 1 2 = -0.1304442
issmall(Alt(S) - Alt(Alt(S))) # should be TRUE; Alt() is idempotent
#> [1] TRUE
a <- rtensor()
V <- matrix(rnorm(21),ncol=3)
LHS <- as.function(Alt(a))(V)
RHS <- as.function(Alt(a,give_kform=TRUE))(V)
c(LHS=LHS,RHS=RHS,diff=LHS-RHS)
#> LHS RHS diff
#> -2.071708e-01 -2.071708e-01 1.665335e-16