Constructs a mapper that aggregates elements of the input state, so it can be used e.g. for weighted summation or integration over blocks of values.
Arguments
- rescale
logical; For
bm_aggregate
andbm_logsumexp
, specifies if the blockwise sums should be normalised by the blockwise weight sums or not:FALSE
: (default) Straight weighted sum, no rescaling.TRUE
: Divide by the sum of the weight values within each block. This is useful for integration averages, when the given weights are plain integration weights. If the weights areNULL
or all ones, this is the same as dividing by the number of entries in each block.
- n_block
Predetermined number of output blocks. If
NULL
, overrides the maximum block index in the inputs. The priority order isinput$n_block
, the mapper definitionn_block
, thenmax(input$block)
.- type
character; if non-NULL, overrides the
rescale
argument, and constructs an aggregation mapper of the given type instead. Supported values are "sum", "average", "logsumexp", and "logaverageexp".- ...
Arguments passed on to
bm_aggregate()
See also
bru_mapper, bru_mapper_generics
Other mappers:
bm_collect()
,
bm_const()
,
bm_factor()
,
bm_fm_mesh_1d
,
bm_fmesher()
,
bm_harmonics()
,
bm_index()
,
bm_linear()
,
bm_logsumexp()
,
bm_marginal()
,
bm_matrix()
,
bm_mesh_B()
,
bm_multi()
,
bm_pipe()
,
bm_repeat()
,
bm_scale()
,
bm_shift()
,
bm_sum()
,
bm_taylor()
,
bru_get_mapper()
,
bru_mapper()
Other specific bm_aggregate method implementations:
ibm_eval()
,
ibm_jacobian()
,
ibm_n()
,
ibm_n_output()
,
ibm_values()
Examples
m <- bm_aggregate()
ibm_eval2(m, list(block = c(1, 2, 1, 2), weights = 1:4), 11:14)
#> $offset
#> [1] 50 80
#>
#> $jacobian
#> 2 x 4 sparse Matrix of class "dgCMatrix"
#>
#> [1,] 1 . 3 .
#> [2,] . 2 . 4
#>
ibm_eval2(m, list(block = c(1, 2, 1, 2), weights = 1:4, n_block = 3), 11:14)
#> $offset
#> [1] 50 80 0
#>
#> $jacobian
#> 3 x 4 sparse Matrix of class "dgCMatrix"
#>
#> [1,] 1 . 3 .
#> [2,] . 2 . 4
#> [3,] . . . .
#>