inner.Rd
The inner product
inner(M)
Returns a k-tensor, an inner product
The inner product of two vectors x and y is usually written ⟨x,y⟩ or x⋅y, but the most general form would be xTMy where M is a matrix. Noting that inner products are multilinear, that is ⟨x,ay+bz⟩=a⟨x,y⟩+b⟨x,z⟩ and ⟨ax+by,z⟩=a⟨x,z⟩+b⟨y,z⟩, we see that the inner product is indeed a multilinear map, that is, a tensor.
Given a square matrix M, function inner(M)
returns the
2-form that maps x,y to
xTMy. Non-square matrices are
effectively padded with zeros.
A short vignette is provided with the package: type
vignette("inner")
at the commandline.
inner(diag(7))
#> A linear map from V^2 to R with V=R^7:
#> val
#> 6 6 = 1
#> 7 7 = 1
#> 5 5 = 1
#> 3 3 = 1
#> 2 2 = 1
#> 4 4 = 1
#> 1 1 = 1
inner(matrix(1:9,3,3))
#> A linear map from V^2 to R with V=R^3:
#> val
#> 3 3 = 9
#> 2 3 = 8
#> 1 3 = 7
#> 3 2 = 6
#> 2 2 = 5
#> 1 2 = 4
#> 3 1 = 3
#> 2 1 = 2
#> 1 1 = 1
## Compare the following two:
Alt(inner(matrix(1:9,3,3))) # An alternating k tensor
#> A linear map from V^2 to R with V=R^3:
#> val
#> 3 2 = -1
#> 3 1 = -2
#> 2 3 = 1
#> 1 3 = 2
#> 2 1 = -1
#> 1 2 = 1
as.kform(inner(matrix(1:9,3,3))) # Same thing coerced to a kform
#> An alternating linear map from V^2 to R with V=R^3:
#> val
#> 2 3 = 2
#> 1 3 = 4
#> 1 2 = 2
f <- as.function(inner(diag(7)))
X <- matrix(rnorm(14),ncol=2) # random element of (R^7)^2
f(X) - sum(X[,1]*X[,2]) # zero to numerical precision
#> [1] 0
## verify positive-definiteness:
g <- as.function(inner(crossprod(matrix(rnorm(56),8,7))))
stopifnot(g(kronecker(rnorm(7),t(c(1,1))))>0)