Computes element-wise addition of two sparse_numeric vectors.

sparse_add(x, y, ...)

# S4 method for class 'sparse_numeric,sparse_numeric'
sparse_add(x, y, ...)

Arguments

x

A sparse_numeric object.

y

A sparse_numeric object of the same length as x.

...

Additional arguments.

Value

A sparse_numeric object representing the element-wise sum of x and y.

Examples

x <- new("sparse_numeric", value = c(1, 2), pos = c(2L, 5L), length = 6L)
y <- new("sparse_numeric", value = c(3, 4), pos = c(1L, 5L), length = 6L)
sparse_add(x, y)
#> sparse_numeric object of length 6 
#> Non-zero elements:
#>   pos value
#> 1   1     3
#> 2   2     1
#> 3   5     6