These methods provide operators +
and -
to perform sums
or differences between an fData
object and either another
fData
object or other compliant data structures, like matrices or
vectors or arrays, representing the pointwise measurements of the second
term of the sum.
# S3 method for fData
+(fD, A)
# S3 method for fData
-(fD, A)
the univariate functional dataset in form of fData
object.
either an fData
object, defined on the very same grid of
fD
, or a 1D data structure (such as 1D array or raw
numeric vector), or a 2D data structure (such as 2D array or raw numeric
matrix ), that specifies the second term of the sum.
In case of a 1D data structure, the sum is performed element-wise between
each element of fD
and A
, and A
must have length
P
, size of fD
's grid.
In case of a 2D data structure, the sum is performed element-wise between
corresponding elements of fD
and A
's rows. In this case,
A
must have P
columns, as the size of fD
's grid.
The function returns an fData
object, whose function values
have undergone the sum/difference.
If the second term of the operation is an fData
object, it must be
defined over the same grid as the first.
fD = fData( seq( 0, 1, length.out = 10 ),
values = matrix( seq( 1, 10 ),
nrow = 21, ncol = 10, byrow = TRUE ) )
fD + 1 : 10
#> $t0
#> [1] 0
#>
#> $tP
#> [1] 1
#>
#> $h
#> [1] 0.1111111
#>
#> $P
#> [1] 10
#>
#> $N
#> [1] 21
#>
#> $values
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,] 2 4 6 8 10 12 14 16 18 20
#> [2,] 2 4 6 8 10 12 14 16 18 20
#> [3,] 2 4 6 8 10 12 14 16 18 20
#> [4,] 2 4 6 8 10 12 14 16 18 20
#> [5,] 2 4 6 8 10 12 14 16 18 20
#> [6,] 2 4 6 8 10 12 14 16 18 20
#> [7,] 2 4 6 8 10 12 14 16 18 20
#> [8,] 2 4 6 8 10 12 14 16 18 20
#> [9,] 2 4 6 8 10 12 14 16 18 20
#> [10,] 2 4 6 8 10 12 14 16 18 20
#> [11,] 2 4 6 8 10 12 14 16 18 20
#> [12,] 2 4 6 8 10 12 14 16 18 20
#> [13,] 2 4 6 8 10 12 14 16 18 20
#> [14,] 2 4 6 8 10 12 14 16 18 20
#> [15,] 2 4 6 8 10 12 14 16 18 20
#> [16,] 2 4 6 8 10 12 14 16 18 20
#> [17,] 2 4 6 8 10 12 14 16 18 20
#> [18,] 2 4 6 8 10 12 14 16 18 20
#> [19,] 2 4 6 8 10 12 14 16 18 20
#> [20,] 2 4 6 8 10 12 14 16 18 20
#> [21,] 2 4 6 8 10 12 14 16 18 20
#>
#> attr(,"class")
#> [1] "fData"
fD + array( 1, dim = c( 1, 10 ) )
#> $t0
#> [1] 0
#>
#> $tP
#> [1] 1
#>
#> $h
#> [1] 0.1111111
#>
#> $P
#> [1] 10
#>
#> $N
#> [1] 21
#>
#> $values
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,] 2 3 4 5 6 7 8 9 10 11
#> [2,] 2 3 4 5 6 7 8 9 10 11
#> [3,] 2 3 4 5 6 7 8 9 10 11
#> [4,] 2 3 4 5 6 7 8 9 10 11
#> [5,] 2 3 4 5 6 7 8 9 10 11
#> [6,] 2 3 4 5 6 7 8 9 10 11
#> [7,] 2 3 4 5 6 7 8 9 10 11
#> [8,] 2 3 4 5 6 7 8 9 10 11
#> [9,] 2 3 4 5 6 7 8 9 10 11
#> [10,] 2 3 4 5 6 7 8 9 10 11
#> [11,] 2 3 4 5 6 7 8 9 10 11
#> [12,] 2 3 4 5 6 7 8 9 10 11
#> [13,] 2 3 4 5 6 7 8 9 10 11
#> [14,] 2 3 4 5 6 7 8 9 10 11
#> [15,] 2 3 4 5 6 7 8 9 10 11
#> [16,] 2 3 4 5 6 7 8 9 10 11
#> [17,] 2 3 4 5 6 7 8 9 10 11
#> [18,] 2 3 4 5 6 7 8 9 10 11
#> [19,] 2 3 4 5 6 7 8 9 10 11
#> [20,] 2 3 4 5 6 7 8 9 10 11
#> [21,] 2 3 4 5 6 7 8 9 10 11
#>
#> attr(,"class")
#> [1] "fData"
fD + fD
#> $t0
#> [1] 0
#>
#> $tP
#> [1] 1
#>
#> $h
#> [1] 0.1111111
#>
#> $P
#> [1] 10
#>
#> $N
#> [1] 21
#>
#> $values
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,] 2 4 6 8 10 12 14 16 18 20
#> [2,] 2 4 6 8 10 12 14 16 18 20
#> [3,] 2 4 6 8 10 12 14 16 18 20
#> [4,] 2 4 6 8 10 12 14 16 18 20
#> [5,] 2 4 6 8 10 12 14 16 18 20
#> [6,] 2 4 6 8 10 12 14 16 18 20
#> [7,] 2 4 6 8 10 12 14 16 18 20
#> [8,] 2 4 6 8 10 12 14 16 18 20
#> [9,] 2 4 6 8 10 12 14 16 18 20
#> [10,] 2 4 6 8 10 12 14 16 18 20
#> [11,] 2 4 6 8 10 12 14 16 18 20
#> [12,] 2 4 6 8 10 12 14 16 18 20
#> [13,] 2 4 6 8 10 12 14 16 18 20
#> [14,] 2 4 6 8 10 12 14 16 18 20
#> [15,] 2 4 6 8 10 12 14 16 18 20
#> [16,] 2 4 6 8 10 12 14 16 18 20
#> [17,] 2 4 6 8 10 12 14 16 18 20
#> [18,] 2 4 6 8 10 12 14 16 18 20
#> [19,] 2 4 6 8 10 12 14 16 18 20
#> [20,] 2 4 6 8 10 12 14 16 18 20
#> [21,] 2 4 6 8 10 12 14 16 18 20
#>
#> attr(,"class")
#> [1] "fData"
fD = fData( seq( 0, 1, length.out = 10 ),
values = matrix( seq( 1, 10 ),
nrow = 21, ncol = 10, byrow = TRUE ) )
fD - 2 : 11
#> $t0
#> [1] 0
#>
#> $tP
#> [1] 1
#>
#> $h
#> [1] 0.1111111
#>
#> $P
#> [1] 10
#>
#> $N
#> [1] 21
#>
#> $values
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [2,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [3,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [4,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [5,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [6,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [7,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [8,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [9,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [10,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [11,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [12,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [13,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [14,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [15,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [16,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [17,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [18,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [19,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [20,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#> [21,] -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
#>
#> attr(,"class")
#> [1] "fData"
fD - array( 1, dim = c( 1, 10 ) )
#> $t0
#> [1] 0
#>
#> $tP
#> [1] 1
#>
#> $h
#> [1] 0.1111111
#>
#> $P
#> [1] 10
#>
#> $N
#> [1] 21
#>
#> $values
#> [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#> [1,] 0 1 2 3 4 5 6 7 8 9
#> [2,] 0 1 2 3 4 5 6 7 8 9
#> [3,] 0 1 2 3 4 5 6 7 8 9
#> [4,] 0 1 2 3 4 5 6 7 8 9
#> [5,] 0 1 2 3 4 5 6 7 8 9
#> [6,] 0 1 2 3 4 5 6 7 8 9
#> [7,] 0 1 2 3 4 5 6 7 8 9
#> [8,] 0 1 2 3 4 5 6 7 8 9
#> [9,] 0 1 2 3 4 5 6 7 8 9
#> [10,] 0 1 2 3 4 5 6 7 8 9
#> [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#>
#> attr(,"class")
#> [1] "fData"