These methods provide operators * and / to perform products or divisions between an fData object and either a number or a compliant 1D data structure, like numeric vector, array or matrix. The operation is computed by performing the element-wise product or division between fD's observations and the provided value(s).

# S3 method for fData
*(fD, a)

# S3 method for fData
/(fD, a)

Arguments

fD

the univariate functional dataset in form of fData object.

a

either a single number or a 1D data structure (such as numeric raw vector, matrix or array) specifying the factor(s) to use in the multiplication/division of fD elements' values. In the latter case, each factor is used with the corresponding element in fD, hence a must have length N, number of observations in fD.

Value

The function returns an fData object, whose function values have undergone the product/division.

Details

If the second argument is a 1D data structure, it must have length N equal to the number of observations in fD.

Examples


N = 11
fD = fData( seq( 0, 1, length.out = 10 ),
            values = matrix( seq( 1, 10 ),
                             nrow = N, ncol = 10, byrow = TRUE ) )
fD * 2
#> $t0
#> [1] 0
#> 
#> $tP
#> [1] 1
#> 
#> $h
#> [1] 0.1111111
#> 
#> $P
#> [1] 10
#> 
#> $N
#> [1] 11
#> 
#> $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
#> 
#> attr(,"class")
#> [1] "fData"

fD * seq( 1, N )
#> $t0
#> [1] 0
#> 
#> $tP
#> [1] 1
#> 
#> $h
#> [1] 0.1111111
#> 
#> $P
#> [1] 10
#> 
#> $N
#> [1] 11
#> 
#> $values
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#>  [1,]    1    2    3    4    5    6    7    8    9    10
#>  [2,]    2    4    6    8   10   12   14   16   18    20
#>  [3,]    3    6    9   12   15   18   21   24   27    30
#>  [4,]    4    8   12   16   20   24   28   32   36    40
#>  [5,]    5   10   15   20   25   30   35   40   45    50
#>  [6,]    6   12   18   24   30   36   42   48   54    60
#>  [7,]    7   14   21   28   35   42   49   56   63    70
#>  [8,]    8   16   24   32   40   48   56   64   72    80
#>  [9,]    9   18   27   36   45   54   63   72   81    90
#> [10,]   10   20   30   40   50   60   70   80   90   100
#> [11,]   11   22   33   44   55   66   77   88   99   110
#> 
#> attr(,"class")
#> [1] "fData"


N = 11
fD = fData( seq( 0, 1, length.out = 10 ),
            values = matrix( seq( 1, 10 ),
                             nrow = N, ncol = 10, byrow = TRUE ) )
fD / 2
#> $t0
#> [1] 0
#> 
#> $tP
#> [1] 1
#> 
#> $h
#> [1] 0.1111111
#> 
#> $P
#> [1] 10
#> 
#> $N
#> [1] 11
#> 
#> $values
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#>  [1,]  0.5    1  1.5    2  2.5    3  3.5    4  4.5     5
#>  [2,]  0.5    1  1.5    2  2.5    3  3.5    4  4.5     5
#>  [3,]  0.5    1  1.5    2  2.5    3  3.5    4  4.5     5
#>  [4,]  0.5    1  1.5    2  2.5    3  3.5    4  4.5     5
#>  [5,]  0.5    1  1.5    2  2.5    3  3.5    4  4.5     5
#>  [6,]  0.5    1  1.5    2  2.5    3  3.5    4  4.5     5
#>  [7,]  0.5    1  1.5    2  2.5    3  3.5    4  4.5     5
#>  [8,]  0.5    1  1.5    2  2.5    3  3.5    4  4.5     5
#>  [9,]  0.5    1  1.5    2  2.5    3  3.5    4  4.5     5
#> [10,]  0.5    1  1.5    2  2.5    3  3.5    4  4.5     5
#> [11,]  0.5    1  1.5    2  2.5    3  3.5    4  4.5     5
#> 
#> attr(,"class")
#> [1] "fData"

fD / rep( 10, N )
#> $t0
#> [1] 0
#> 
#> $tP
#> [1] 1
#> 
#> $h
#> [1] 0.1111111
#> 
#> $P
#> [1] 10
#> 
#> $N
#> [1] 11
#> 
#> $values
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#>  [1,]  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9     1
#>  [2,]  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9     1
#>  [3,]  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9     1
#>  [4,]  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9     1
#>  [5,]  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9     1
#>  [6,]  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9     1
#>  [7,]  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9     1
#>  [8,]  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9     1
#>  [9,]  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9     1
#> [10,]  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9     1
#> [11,]  0.1  0.2  0.3  0.4  0.5  0.6  0.7  0.8  0.9     1
#> 
#> attr(,"class")
#> [1] "fData"