z+.SparseSignal: + SparseSignal

Description Usage Arguments Author(s) Examples

Description

Add two SparseSignals.

Usage

1
2
## S3 method for class 'SparseSignal'
x + y

Arguments

x
y

Author(s)

Toby Dylan Hocking

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## adding two non-overlapping 1-segment signals gives a signal with
## 2 segments.
x <- SparseSignal(1, 2, 5.5)
x + SparseSignal(4, 10, 3.8) # 2 rows.
## adding two overlapping 1-segment signals with opposite values
## gives a completely sparse signal with 0 segments.
none <- x + SparseSignal(1, 2, -5.5) # 0 rows.
str(none)
## a more complicated example.
x <- SparseSignal(c(10L, 12L, 14L),
                  c(11L, 13L, 16L),
                  c(  1,   2,   3))
y <- SparseSignal(c(10L, 12L, 15L),
                  c(11L, 13L, 17L),
                  c( 1, -2,    4))
x + y
## you can also just add vectors, but they need to be length 1 or
## the number of segments.
x + 1000
x + c(1, 200, 3000)

tdhock/SparseSignals documentation built on May 31, 2019, 7:33 a.m.