library("broadcast")
<- c(4:2)
x.dim <- prod(x.dim)
x.len <- sample(c(NA, 1.1:1000.1), x.len, TRUE)
x.data <- array(x.data, x.dim)
x <- array(1:50, c(4,1,1))
y
bc.d(x, y, "+")
## , , 1
##
## [,1] [,2] [,3]
## [1,] 447.1 449.1 534.1
## [2,] 983.1 179.1 874.1
## [3,] 268.1 959.1 94.1
## [4,] 382.1 81.1 968.1
##
## , , 2
##
## [,1] [,2] [,3]
## [1,] 826.1 721.1 279.1
## [2,] 115.1 763.1 858.1
## [3,] 638.1 803.1 529.1
## [4,] 624.1 982.1 703.1
bc.d(x, y, "-")
## , , 1
##
## [,1] [,2] [,3]
## [1,] 445.1 447.1 532.1
## [2,] 979.1 175.1 870.1
## [3,] 262.1 953.1 88.1
## [4,] 374.1 73.1 960.1
##
## , , 2
##
## [,1] [,2] [,3]
## [1,] 824.1 719.1 277.1
## [2,] 111.1 759.1 854.1
## [3,] 632.1 797.1 523.1
## [4,] 616.1 974.1 695.1
bc.d(x, y, "*")
## , , 1
##
## [,1] [,2] [,3]
## [1,] 446.1 448.1 533.1
## [2,] 1962.2 354.2 1744.2
## [3,] 795.3 2868.3 273.3
## [4,] 1512.4 308.4 3856.4
##
## , , 2
##
## [,1] [,2] [,3]
## [1,] 825.1 720.1 278.1
## [2,] 226.2 1522.2 1712.2
## [3,] 1905.3 2400.3 1578.3
## [4,] 2480.4 3912.4 2796.4
bc.d(x, y, "/")
## , , 1
##
## [,1] [,2] [,3]
## [1,] 446.10000 448.100 533.10000
## [2,] 490.55000 88.550 436.05000
## [3,] 88.36667 318.700 30.36667
## [4,] 94.52500 19.275 241.02500
##
## , , 2
##
## [,1] [,2] [,3]
## [1,] 825.100 720.100 278.1000
## [2,] 56.550 380.550 428.0500
## [3,] 211.700 266.700 175.3667
## [4,] 155.025 244.525 174.7750
bc.d(x, y, "^")
## , , 1
##
## [,1] [,2] [,3]
## [1,] 4.461000e+02 448.10 5.331000e+02
## [2,] 9.625572e+05 31364.41 7.605584e+05
## [3,] 1.863070e+07 873997025.48 7.560580e+05
## [4,] 2.043745e+10 35336010.25 8.639494e+11
##
## , , 2
##
## [,1] [,2] [,3]
## [1,] 8.251000e+02 7.201000e+02 2.781000e+02
## [2,] 1.279161e+04 5.792732e+05 7.329072e+05
## [3,] 2.561689e+08 5.121920e+08 1.456146e+08
## [4,] 1.478587e+11 9.152359e+11 2.388676e+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 TRUE
bc.d
Broadcasted Decimal Numeric Operations
Description
The bc.d()
function 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 logical or numeric arrays. |
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. 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.