Learn R Programming

stokes (version 1.0-8)

inner: Inner product operator

Description

The inner product

Usage

inner(M)

Arguments

M

square matrix

Value

Returns a \(k\)-tensor, an inner product

Details

The inner product of two vectors xx and yy is usually written x,y<x,y> or xyx.y, but the most general form would be x^TMyx'My where MM is a matrix. Noting that inner products are multilinear, that is x,ay+bz=ax,y+bx,z<x,ay+bz>=a<x,y>+b<y,z> and ax+by,z=ax,z+by,z<x,ay+bz>=a<x,y>+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,yx,y to x^TMyx'My.

See also the inner vignette which contains more details and examples.

See Also

kform

Examples

Run this code
# NOT RUN {
inner(diag(7))
inner(matrix(1:9,3,3))

## Compare the following two:
Alt(inner(matrix(1:9,3,3)))      # An alternating k tensor
as.kform(inner(matrix(1:9,3,3))) # Same thing coerced to a kform

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

## verify positive-definiteness:
g <- as.function(inner(crossprod(matrix(rnorm(56),8,7))))
stopifnot(g(kronecker(rnorm(7),t(c(1,1))))>0)

# }

Run the code above in your browser using DataLab