View source: R/mapper_repeat.R
bm_repeat_indexing | R Documentation |
Helper methods for regular and interleaved state vector indexing, meant for use in bru_mapper_repeat mappers.
bm_repeat_indexing(n_map, n_rep, interleaved = FALSE)
bm_repeat_indexing_matrix(n_map, n_rep)
n_map |
The block mapper size |
n_rep |
The number of times the block is repeated |
interleaved |
logical; if |
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.
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 matrix A
such that
z <- A %*% x
constructs a blockwise version z = c(x1, x2, ..., xn)
of
an interleaved state vector x = c(x1[1], x2[1], ..., x1[2], x2[2], ...)
.
Each block is of size n_map
, and there are n_rep
blocks. The reverse
operation, taking a blockwise z = c(x1, x2, ..., xn)
to an interleaved
vector is x <- Matrix::t(A) %*% z
.
(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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.