Unlimited learning, half price | 50% off

Last chance! 50% off unlimited learning

Sale ends in


fastmatrix (version 0.5-7721)

kronecker.prod: Kronecker product on matrices

Description

Computes the kronecker product of two matrices, x and y.

Usage

kronecker.prod(x, y = x)

Value

An array with dimensions dim(x) * dim(y).

Arguments

x

a numeric matrix or vector.

y

a numeric matrix or vector.

Details

Let \boldX be an m×n and \boldY a p×q matrix. The mp×nq matrix defined by [x11\boldYx1n\boldYxm1\boldYxmn\boldY], is called the Kronecker product of \boldX and \boldY.

References

Magnus, J.R., Neudecker, H. (2007). Matrix Differential Calculus with Applications in Statistics and Econometrics, 3rd Edition. Wiley, New York.

See Also

kronecker function from base package is based on outer. Our C version is slightly faster.

Examples

Run this code
# block diagonal matrix:
a <- diag(1:3)
b <- matrix(1:4, ncol = 2)
kronecker.prod(a, b)

# examples with vectors
ones <- rep(1, 4)
y <- 1:3
kronecker.prod(ones, y) # 12-dimensional vector
kronecker.prod(ones, t(y)) # 3 x 3 matrix

Run the code above in your browser using DataLab