Defines a mapper that adds the effects of each submapper.
The ibm_n()
method returns the sum of ibm_n(mappers[[k]])
, and
ibm_values()
returns seq_len(ibm_n(mapper))
.
Usage
bm_sum(mappers, single_input = FALSE)
bru_mapper_sum(...)
# S3 method for class 'bm_sum'
x[i, drop = TRUE]
# S3 method for class 'bru_mapper_sum'
x[i, drop = TRUE]
Arguments
- mappers
A list of
bru_mapper
objects.- single_input
logical. If
TRUE
, the input is passed to all sub-mappers. Otherwise, the input should be a list, data.frame, or matrix. If themappers
list has named entries, theinput
can reference their corresponding sub-mapper using its name.- ...
Arguments passed on to
bm_sum()
- x
object from which to extract element(s)
- i
indices specifying element(s) to extract
- drop
logical; For
[.bm_sum
, whether to extract an individual mapper wheni
identifies a single element. IfFALSE
, a list of sub-mappers is returned (suitable e.g. for creating a newbm_sum
object). Default:TRUE
Value
A bm_sum
object.
[
-indexing abm_sum
extracts a subsetbm_sum
object (for dropFALSE
) or an individual sub-mapper (for dropTRUE
, andi
identifies a single element)
See also
bru_mapper, bru_mapper_generics
Other mappers:
bm_aggregate()
,
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_taylor()
,
bru_get_mapper()
,
bru_mapper()
Other specific bm_sum method implementations:
ibm_eval()
,
ibm_invalid_output()
,
ibm_is_linear()
,
ibm_jacobian()
,
ibm_linear()
,
ibm_n()
,
ibm_n_output()
,
ibm_names()
,
ibm_values()
Examples
(m <- bm_sum(list(a = bm_index(3), b = bm_index(2))))
#> sum(a = index, b = index)
ibm_n(m)
#> [1] 5
ibm_values(m)
#> [1] 1 2 3 4 5
ibm_jacobian(m, list(a = 1:3, b = c(1, 1, 2)))
#> 3 x 5 sparse Matrix of class "dgCMatrix"
#>
#> [1,] 1 . . 1 .
#> [2,] . 1 . 1 .
#> [3,] . . 1 . 1
ibm_eval(
m,
list(a = 1:3, b = c(1, 1, 2)),
seq_len(ibm_n(m))
)
#> [1] 5 6 8