inner: Inner product operator

innerR Documentation

Inner product operator

Description

\loadmathjax

The inner product

Usage

inner(M)

Arguments

M

square matrix

Details

The inner product of two vectors \mjeqn\mathbfxx and \mjeqn\mathbfyy is usually written \mjeqn\left\langle\mathbfx,\mathbfy\right\rangle<x,y> or \mjeqn\mathbfx\cdot\mathbfyx.y, but the most general form would be \mjeqn\mathbfx^TM\mathbfyx'My where \mjeqnMM is a matrix. Noting that inner products are multilinear, that is \mjeqn\left\langle\mathbfx,a\mathbfy+b\mathbfz\right\rangle=a\left\langle\mathbfx,\mathbfy\right\rangle+b\left\langle\mathbfx,\mathbfz\right\rangle<x,ay+bz>=a<x,y>+b<y,z> and \mjeqn\left\langle a\mathbfx+b\mathbfy,\mathbfz\right\rangle=a\left\langle\mathbfx,\mathbfz\right\rangle+b\left\langle\mathbfy,\mathbfz\right\rangle<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 \mjseqnM, function inner(M) returns the \mjseqn2-form that maps \mjeqn\mathbfx,\mathbfyx,y to \mjeqn\mathbfx^TM\mathbfyx'My. Non-square matrices are effectively padded with zeros.

A short vignette is provided with the package: type vignette("inner") at the commandline.

Value

Returns a \mjseqnk-tensor, an inner product

Author(s)

Robin K. S. Hankin

See Also

kform

Examples


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)


stokes documentation built on Aug. 19, 2023, 1:07 a.m.