kr: Khatri-Rao product of two matrices

Description Usage Arguments Details Value Author(s) Examples

View source: R/kr.R

Description

Return the Khatri-Rao product of two matrices, which is a column-wise Kronecker product.

Usage

1
kr(A, B, w, byrow = TRUE)

Arguments

A, B

matrices. The two matrices A and B should have the same number of columns. We also give the user an option to do row-wise Kronecker product, to avoid transpose. When doing row-wise Kronecker product, the number of rows of A and B should be the same.

w

the weights vector. The length of the vector should match with the dimension of the matrices. If performing column-wise Kronecker product, the length of w should be the same as the column number of A and B. If performing row-wise Kronecker prodoct, the length of w should be the same as the row number of A and B. The default is a vector of 1 if no value provided.

byrow

a logical variable controlling whether to perform row/column-wise Kronecker product. The default is byrow=TRUE.

Details

The column/row-wise Kronecker product.

Value

A matrix of the Khatri-Rao product.

Author(s)

Yiwen Zhang and Hua Zhou

Examples

1
2
3
X <- matrix(rnorm(30), 10, 3)
Y <- matrix(runif(50), 10, 5)
C <- kr(X, Y)

MGLM documentation built on May 2, 2019, 1:38 p.m.