Learn R Programming

klin (version 2007-02-05)

klin.eval: Evaluate Kronecker product times a vector

Description

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

Usage

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).

Value

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

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).

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

Run this code
## 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

Run the code above in your browser using DataLab