blockMult: Multiplication of Block Diagonal Matrix and Vector

Description Usage Arguments Value Author(s) See Also Examples

Description

Computes the matrix product between a block diagonal square matrix and a column vector (or matrix).

Usage

1
2
blockMult(mat, X, n.blocks = 1, block.sizes = rep(dim(mat)[1]/n.blocks,
  n.blocks))

Arguments

mat

A block diagonal, square matrix.

X

Vector or matrix to multiply by mat; length(X) needs to be a multiple of dim(mat)[1].

n.blocks

Number of diagonal blocks in mat (or R). Defaults to 1 (i.e. a full matrix) if neither n.blocks nor block.sizes given, o.w. it defaults to length(block.sizes)).

block.sizes

A vector of length n.blocks with the size of each of the diagonal blocks. If not given it will assume equal-sized blocks.

Value

Returns mat * X.

Author(s)

Johan Lindstrom

See Also

Other basic linear algebra: crossDist, makeCholBlock, norm2, sumLogDiag

Other block matrix functions: calc.FXtF2, calc.FX, calc.mu.B, calc.tFXF, calc.tFX, makeCholBlock, makeSigmaB, makeSigmaNu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#create a matrix
mat <- cbind(c(1,0,0), c(0,2,1), c(0,1,2))
#define the number of blocks and block sizes
block.sizes <- c(1,2)
n.blocks <- length(block.sizes)

#define a X vector
X <- matrix(c(1,2,3,1,1,1), 3, 2)

#compute mat %*% X
blockMult(mat, X, n.blocks, block.sizes)
#or the old fashioned way
mat %*% X

SpatioTemporal documentation built on May 2, 2019, 8:49 a.m.