kronecker.Rd
Computes the generalised kronecker product of two arrays, X
and
Y
.
kronecker.spam(X, Y, FUN = "*", make.dimnames = FALSE, ...)
sparse matrix of class spam
, a vector or a matrix.
sparse matrix of class spam
, a vector or a matrix.
a function; it may be a quoted string. See details
Provide dimnames that are the product of the dimnames of
X
and Y
.
optional arguments to be passed to FUN
.
An array A
with dimensions
dim(X) * dim(Y)
.
The sparsity structure is determined by the ordinary
%x%
. Hence, the result of kronecker(X, Y, FUN = "+")
is
different depending on the input.
# Starting with non-spam objects, we get a spam matrix
kronecker.spam( diag(2), array(1:4, c(2, 2)))
#> [,1] [,2] [,3] [,4]
#> [1,] 1 3 0 0
#> [2,] 2 4 0 0
#> [3,] 0 0 1 3
#> [4,] 0 0 2 4
#> Class 'spam' (32-bit)
kronecker( diag.spam(2), array(1:4, c(2, 2)))
#> [,1] [,2] [,3] [,4]
#> [1,] 1 3 0 0
#> [2,] 2 4 0 0
#> [3,] 0 0 1 3
#> [4,] 0 0 2 4
#> Class 'spam' (32-bit)
# Notice the preservation of sparsity structure:
kronecker( diag.spam(2), array(1:4, c(2, 2)), FUN="+")
#> Warning: Sparseness structure of 'kronecker(X,Y)' preseved when applying 'FUN'.
#> [,1] [,2] [,3] [,4]
#> [1,] 2 4 0 0
#> [2,] 3 5 0 0
#> [3,] 0 0 2 4
#> [4,] 0 0 3 5
#> Class 'spam' (32-bit)