Learn R Programming

spam (version 0.20-3)

kronecker: Kronecker products on sparse matrices

Description

Computes the generalised kronecker product of two arrays, X and Y.

Usage

kronecker.spam(X, Y, FUN = "*", make.dimnames = FALSE, ...)

Arguments

X
sparse matrix of class spam, a vector or a matrix.
Y
sparse matrix of class spam, a vector or a matrix.
FUN
a function; it may be a quoted string. See details
make.dimnames
Provide dimnames that are the product of the dimnames of 'X' and 'Y'.
...
optional arguments to be passed to FUN.

Value

  • An array A with dimensions dim(X) * dim(Y).

Details

The sparsity structure is determined by the ordinary %x%. Hence, the result of kronecker(X, Y, FUN = "+") is different depending on the input.

Examples

Run this code
# Starting with non-spam objects, we get a spam matrix
kronecker.spam( diag(2), array(1:4,c(2,2)))

kronecker( diag.spam(2), array(1:4,c(2,2)))

# Notice the preservation of sparsity structure: 
kronecker( diag.spam(2), array(1:4,c(2,2)),FUN="+")

Run the code above in your browser using DataLab