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,] 212.1 748.1 559.1
#> [2,] 84.1 266.1 503.1
#> [3,] 95.1 727.1 874.1
#> [4,] 473.1 802.1 750.1
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] 28.1 57.1 235.1
#> [2,] 385.1 276.1 766.1
#> [3,] 598.1 817.1 50.1
#> [4,] 423.1 973.1 602.1
bc.d(x, y, "-")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] 210.1 746.1 557.1
#> [2,] 80.1 262.1 499.1
#> [3,] 89.1 721.1 868.1
#> [4,] 465.1 794.1 742.1
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] 26.1 55.1 233.1
#> [2,] 381.1 272.1 762.1
#> [3,] 592.1 811.1 44.1
#> [4,] 415.1 965.1 594.1
bc.d(x, y, "*")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] 211.1 747.1 558.1
#> [2,] 164.2 528.2 1002.2
#> [3,] 276.3 2172.3 2613.3
#> [4,] 1876.4 3192.4 2984.4
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] 27.1 56.1 234.1
#> [2,] 766.2 548.2 1528.2
#> [3,] 1785.3 2442.3 141.3
#> [4,] 1676.4 3876.4 2392.4
bc.d(x, y, "/")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] 211.100 747.1000 558.1000
#> [2,] 41.050 132.0500 250.5500
#> [3,] 30.700 241.3667 290.3667
#> [4,] 117.275 199.5250 186.5250
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] 27.1000 56.1000 234.100
#> [2,] 191.5500 137.0500 382.050
#> [3,] 198.3667 271.3667 15.700
#> [4,] 104.7750 242.2750 149.525
bc.d(x, y, "^")
#> , , 1
#>
#> [,1] [,2] [,3]
#> [1,] 2.111000e+02 7.471000e+02 5.581000e+02
#> [2,] 6.740410e+03 6.974881e+04 2.511012e+05
#> [3,] 7.812300e+05 3.796607e+08 6.610039e+08
#> [4,] 4.842412e+10 4.057226e+11 3.098762e+11
#>
#> , , 2
#>
#> [,1] [,2] [,3]
#> [1,] 2.710000e+01 5.610000e+01 2.341000e+02
#> [2,] 1.467656e+05 7.513081e+04 5.838488e+05
#> [3,] 2.107511e+08 5.395519e+08 1.044871e+05
#> [4,] 3.085110e+10 8.820118e+11 1.279662e+11
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.