klin.solve {klin} | R Documentation |
Solves the system A %*% x == b
for x
given A
and b
, where A
is a Kronecker product of matrices.
klin.solve(A, b)
A |
A list that contains the matrices, preferably of
class Matrix . |
b |
A conformable numeric vector. |
The matrices in the list A
should be square matrices of
the class Matrix
. This allows the user to take advantage of
their special structure (eg sparsity), also, their factors will be
memoized by Matrix
.
A numeric vector x
which solves the system.
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 calling solve
.
Tamas K Papp <tpapp@princeton.edu>
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.
klin.eval
, klin.preparels
,
klin.ls
, klin.klist
.
## dimensions m <- c(4,7,2) ## make random matrices A <- lapply(seq_along(m), function(i) Matrix(rnorm(m[i]^2),m[i],m[i])) b <- rnorm(prod(m)) # make random b x1 <- solve(klin.klist(A),b) # brute force way x2 <- klin.solve(A, b) # using klin.eval range(x1-x2) # should be small