gmult {spam}R Documentation

Generalized Multiplication

Description

Multiplying specific submatrices of a spam matrix with different factors.

Usage

gmult(x, splits, fact)

Arguments

x

a spam matrix.

splits

vector of how to split the matrix into submatrices. It starts with 1 and ends with max(dim(X))+1.

fact

matrix of factors to multiply submatrices defined by splits. Dimensions of fact must correspond to the length(splits)-1.

Value

Spam matrix, where each specified submatrix is multiplied with a factor.

Author(s)

Florian Gerber, Roman Flury

Examples

x <- spam(1, 15, 15)
print(x, minimal = FALSE)

splits <- c(1,2,8,ncol(x)+1) # divide matrix into 9 submatrices
fact <- array(1:9, c(3,3))   # multiply each submatrix with a different factor
oF <- gmult(x, splits, fact)
print(oF, minimal = FALSE)

[Package spam version 2.10-0 Index]