library("broadcast")
x.dim <- c(4:2)
x.len <- prod(x.dim)
x.data <- sample(c(NA, 1.1:1000.1), x.len, TRUE)
x <- array(x.data, x.dim)
y <- array(1:50, c(4,1,1))
bc.d(x, y, "+")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] 372.1 95.1 495.1
#> [2,] 169.1 597.1 927.1
#> [3,] 331.1 526.1 225.1
#> [4,] 714.1 90.1 721.1
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] 345.1 379.1 7.1
#> [2,] 370.1 308.1 813.1
#> [3,] 377.1 40.1 744.1
#> [4,] 399.1 223.1 208.1
bc.d(x, y, "-")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] 370.1 93.1 493.1
#> [2,] 165.1 593.1 923.1
#> [3,] 325.1 520.1 219.1
#> [4,] 706.1 82.1 713.1
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] 343.1 377.1 5.1
#> [2,] 366.1 304.1 809.1
#> [3,] 371.1 34.1 738.1
#> [4,] 391.1 215.1 200.1
bc.d(x, y, "*")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] 371.1 94.1 494.1
#> [2,] 334.2 1190.2 1850.2
#> [3,] 984.3 1569.3 666.3
#> [4,] 2840.4 344.4 2868.4
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] 344.1 378.1 6.1
#> [2,] 736.2 612.2 1622.2
#> [3,] 1122.3 111.3 2223.3
#> [4,] 1580.4 876.4 816.4
bc.d(x, y, "/")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] 371.1000 94.1000 494.10000
#> [2,] 83.5500 297.5500 462.55000
#> [3,] 109.3667 174.3667 74.03333
#> [4,] 177.5250 21.5250 179.27500
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] 344.100 378.10000 6.1000
#> [2,] 184.050 153.05000 405.5500
#> [3,] 124.700 12.36667 247.0333
#> [4,] 98.775 54.77500 51.0250
bc.d(x, y, "^")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] 3.711000e+02 94.1 4.941000e+02
#> [2,] 2.792241e+04 354144.0 8.558100e+05
#> [3,] 3.531984e+07 143137741.4 1.095584e+07
#> [4,] 2.542600e+11 54955682.5 2.644350e+11
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] 3.441000e+02 3.781000e+02 6.1
#> [2,] 1.354976e+05 9.369721e+04 657883.2
#> [3,] 5.235560e+07 5.106481e+04 407033767.5
#> [4,] 2.436846e+10 2.304462e+09 1735289819.4
bc.d(x, y, "==")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] FALSE FALSE FALSE
#> [2,] FALSE FALSE FALSE
#> [3,] FALSE FALSE FALSE
#> [4,] FALSE FALSE FALSE
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] FALSE FALSE FALSE
#> [2,] FALSE FALSE FALSE
#> [3,] FALSE FALSE FALSE
#> [4,] FALSE FALSE FALSE
bc.d(x, y, "!=")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] TRUE TRUE TRUE
#> [2,] TRUE TRUE TRUE
#> [3,] TRUE TRUE TRUE
#> [4,] TRUE TRUE TRUE
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] TRUE TRUE TRUE
#> [2,] TRUE TRUE TRUE
#> [3,] TRUE TRUE TRUE
#> [4,] TRUE TRUE TRUE
bc.d(x, y, "<")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] FALSE FALSE FALSE
#> [2,] FALSE FALSE FALSE
#> [3,] FALSE FALSE FALSE
#> [4,] FALSE FALSE FALSE
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] FALSE FALSE FALSE
#> [2,] FALSE FALSE FALSE
#> [3,] FALSE FALSE FALSE
#> [4,] FALSE FALSE FALSE
bc.d(x, y, ">")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] TRUE TRUE TRUE
#> [2,] TRUE TRUE TRUE
#> [3,] TRUE TRUE TRUE
#> [4,] TRUE TRUE TRUE
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] TRUE TRUE TRUE
#> [2,] TRUE TRUE TRUE
#> [3,] TRUE TRUE TRUE
#> [4,] TRUE TRUE TRUE
bc.d(x, y, "<=")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] FALSE FALSE FALSE
#> [2,] FALSE FALSE FALSE
#> [3,] FALSE FALSE FALSE
#> [4,] FALSE FALSE FALSE
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] FALSE FALSE FALSE
#> [2,] FALSE FALSE FALSE
#> [3,] FALSE FALSE FALSE
#> [4,] FALSE FALSE FALSE
bc.d(x, y, ">=")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] TRUE TRUE TRUE
#> [2,] TRUE TRUE TRUE
#> [3,] TRUE TRUE TRUE
#> [4,] TRUE TRUE TRUE
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] TRUE TRUE TRUE
#> [2,] TRUE TRUE TRUE
#> [3,] TRUE TRUE TRUE
#> [4,] TRUE TRUE TRUEbc.d
Broadcasted Decimal Numeric Operations
Description
The bc.d() method performs broadcasted decimal numeric operations on 2 numeric or logical arrays.
Usage
bc.d(x, y, op, ...)
## S4 method for signature 'ANY'
bc.d(x, y, op, tol = sqrt(.Machine$double.eps))
Arguments
x, y
|
conformable vectors/arrays of type logical or numeric. |
op
|
a single string, giving the operator. Supported arithmetic operators: +, -, *, /, ^, pmin, pmax. Supported relational operators: ==, !=, <, >, <=, >=, d==, d!=, d<, d>, d<=, d>=. |
…
|
further arguments passed to or from methods. |
tol
|
a single number between 0 and 0.1, giving the machine tolerance to use for the relational operators. Only relevant for the following operators: d==, d!=, d<, d>, d<=, d>= See the %d==%, %d!=%, %d<%, %d>%, %d<=%, %d>=% operators from the ‘tinycodet’ package for details. |
Value
For arithmetic operators:
A numeric array as a result of the broadcasted decimal arithmetic operation.
For relational operators:
A logical array as a result of the broadcasted decimal relational comparison.