bm_repeat_indexing {inlabru} | R Documentation |
Re-indexing matrix for repeated mappers
Description
Helper methods for regular and interleaved state vector indexing, meant for use in bm_repeat mappers.
Usage
bm_repeat_indexing(n_map, n_rep, interleaved = FALSE)
bm_repeat_indexing_matrix(n_map, n_rep)
Arguments
n_map |
The block mapper size |
n_rep |
The number of times the block is repeated |
interleaved |
logical; if |
Value
bm_repeat_indexing
: Returns a list with a vector of offsets,
offsets
, and a vector of relative index values, index
; block k
indexing is given by offsets[k] + index
.
bm_repeat_indexing_matrix
: A sparseMatrix
object.
Functions
-
bm_repeat_indexing()
: Construct the offsets and within-block index vectors for a repeated mapper, with or without interleaving. -
bm_repeat_indexing_matrix()
: Creates a sparse matrixA
such thatz <- A %*% x
constructs a blockwise versionz = c(x1, x2, ..., xn)
of an interleaved state vectorx = c(x1[1], x2[1], ..., x1[2], x2[2], ...)
. Each block is of sizen_map
, and there aren_rep
blocks. The reverse operation, taking a blockwisez = c(x1, x2, ..., xn)
to an interleaved vector isx <- Matrix::t(A) %*% z
.
Examples
(idx <- bm_repeat_indexing(3, 2, FALSE))
(idx <- bm_repeat_indexing(3, 2, TRUE))
(A <- bm_repeat_indexing_matrix(3, 2))
(x_interleaved <- 1:6)
(x_blockwise <- as.vector(A %*% x_interleaved))
(x_recovered <- as.vector(Matrix::t(A) %*% x_blockwise))