Computes the Khatri-Rao product (column-wise Kronecker product) of two matrices, or a list of matrices.
Examples
A <- matrix(1:4, nrow = 2)
B <- matrix(5:8, nrow = 2)
khatri_rao(A, B)
#> [,1] [,2]
#> [1,] 5 21
#> [2,] 6 24
#> [3,] 10 28
#> [4,] 12 32
# With a list of matrices
C <- matrix(9:12, nrow = 2)
khatri_rao(list(A, B, C))
#> [,1] [,2]
#> [1,] 45 231
#> [2,] 50 252
#> [3,] 54 264
#> [4,] 60 288
#> [5,] 90 308
#> [6,] 100 336
#> [7,] 108 352
#> [8,] 120 384