klin.eval: Evaluate Kronecker product times a vector

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Computes the product A %*% x, where A is a Kronecker product of matrices.

Usage

1
klin.eval(A, x, transpose = FALSE)

Arguments

A

A list that contains the matrices, preferably of class Matrix.

x

A conformable numeric vector.

transpose

If TRUE, the transpose of the matrices in A is used (implemented by calling crossprod).

Details

The matrices in the list A should be of the class Matrix. This allows the user to take advantage of their special structure (eg sparsity).

Value

A vector which equals (A[[1]] %x% ... %x% A[[length(A)]]) %*% x.

Note

The algorithm (given in the reference) is orders of magnitude more efficient (both in terms of CPU and memory usage) than computing the Kronecker product and doing the matrix multiplication.

Author(s)

Tamas K Papp <tpapp@princeton.edu>

References

Paul E. Buis and Wayne R. Dyksen. Efficient Vector and Parallel Manipulation of Tensor Products. ACM Transactions on Mathematical Software, Vol. 22, No. 1, March 1996, Pages 18–23.

See Also

klin.solve, klin.preparels, klin.ls, klin.klist.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## dimensions
n <- c(6,5,3)
m <- c(4,7,2)
## make random matrices
A <- lapply(seq_along(n),
            function(i) Matrix(rnorm(m[i]*n[i]),m[i],n[i]))
x <- rnorm(prod(n))		# make random x
b1 <- klin.klist(A) %*% x     # brute force way
b2 <- klin.eval(A, x)           # using klin.eval
range(b1-b2)			# should be small

klin documentation built on May 2, 2019, 1:05 p.m.