Overloaded arithmetic operators for FLCore classes
Usage
# S4 method for numeric,FLArray
Arith(e1, e2)
# S4 method for FLArray,numeric
Arith(e1, e2)
# S4 method for FLArray,FLArray
Arith(e1, e2)
# S4 method for FLPar,FLPar
Arith(e1, e2)
# S4 method for FLArray,FLPar
Arith(e1, e2)
# S4 method for FLPar,FLArray
Arith(e1, e2)
Details
These methods apply the standard arithmetic operators included in the
Arith
group ("+", "-", "*", "^", "%%", "%/%", and
"/"), so that they return an object of the appropriate class.
When the operation involves objects of two classes (e.g. FLPar
and FLQuant
),
the class is the returned object is that of the more complexs object, in this
case FLQuant
.
Examples
flq <- FLQuant(rlnorm(90), dim=c(3,10), units='kg')
flp <- FLPar(a=99)
# FLQuant and numeric
flq * 25
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#>
#> year
#> quant 1 2 3 4 5 6 7 8
#> 1 6.1647 24.8611 4.0433 18.8435 197.1374 3.8801 43.0289 35.9391
#> 2 32.2718 46.5454 19.5222 14.3705 4.8934 14.8331 10.0222 6.7824
#> 3 2.1850 78.8295 19.5833 46.8925 41.7334 23.7189 39.9261 52.2820
#> year
#> quant 9 10
#> 1 165.2370 24.6044
#> 2 22.6788 10.9363
#> 3 9.8063 5.5095
#>
#> units: kg
# Two FLQuant objects
flq + flq
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#>
#> year
#> quant 1 2 3 4 5 6 7 8
#> 1 0.49317 1.98889 0.32346 1.50748 15.77099 0.31041 3.44231 2.87513
#> 2 2.58174 3.72363 1.56177 1.14964 0.39147 1.18665 0.80177 0.54259
#> 3 0.17480 6.30636 1.56666 3.75140 3.33868 1.89752 3.19409 4.18256
#> year
#> quant 9 10
#> 1 13.21896 1.96835
#> 2 1.81430 0.87490
#> 3 0.78451 0.44076
#>
#> units: kg
# FLQuant and FLPar
flq / flp
#> An object of class "FLQuant"
#> , , unit = unique, season = all, area = unique
#>
#> year
#> quant 1 2 3 4 5 6
#> 1 0.00249077 0.01004489 0.00163365 0.00761355 0.07965146 0.00156772
#> 2 0.01303910 0.01880623 0.00788774 0.00580626 0.00197713 0.00599318
#> 3 0.00088283 0.03185031 0.00791244 0.01894647 0.01686200 0.00958341
#> year
#> quant 7 8 9 10
#> 1 0.01738542 0.01452087 0.06676242 0.00994117
#> 2 0.00404937 0.00274037 0.00916315 0.00441870
#> 3 0.01613176 0.02112404 0.00396216 0.00222607
#>
#> units: NA