bc.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.

See Also

broadcast_operators

Examples

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,] 711.1 288.1 403.1
#> [2,] 335.1 368.1 396.1
#> [3,] 922.1 981.1 662.1
#> [4,] 212.1 742.1 674.1
#> 
#> , , 2
#> 
#>       [,1]  [,2]  [,3]
#> [1,] 918.1 310.1 536.1
#> [2,] 849.1 844.1 280.1
#> [3,] 957.1 838.1 868.1
#> [4,] 843.1 639.1 622.1
bc.d(x, y, "-")
#> , , 1
#> 
#>       [,1]  [,2]  [,3]
#> [1,] 709.1 286.1 401.1
#> [2,] 331.1 364.1 392.1
#> [3,] 916.1 975.1 656.1
#> [4,] 204.1 734.1 666.1
#> 
#> , , 2
#> 
#>       [,1]  [,2]  [,3]
#> [1,] 916.1 308.1 534.1
#> [2,] 845.1 840.1 276.1
#> [3,] 951.1 832.1 862.1
#> [4,] 835.1 631.1 614.1
bc.d(x, y, "*")
#> , , 1
#> 
#>        [,1]   [,2]   [,3]
#> [1,]  710.1  287.1  402.1
#> [2,]  666.2  732.2  788.2
#> [3,] 2757.3 2934.3 1977.3
#> [4,]  832.4 2952.4 2680.4
#> 
#> , , 2
#> 
#>        [,1]   [,2]   [,3]
#> [1,]  917.1  309.1  535.1
#> [2,] 1694.2 1684.2  556.2
#> [3,] 2862.3 2505.3 2595.3
#> [4,] 3356.4 2540.4 2472.4
bc.d(x, y, "/")
#> , , 1
#> 
#>          [,1]     [,2]    [,3]
#> [1,] 710.1000 287.1000 402.100
#> [2,] 166.5500 183.0500 197.050
#> [3,] 306.3667 326.0333 219.700
#> [4,]  52.0250 184.5250 167.525
#> 
#> , , 2
#> 
#>          [,1]     [,2]     [,3]
#> [1,] 917.1000 309.1000 535.1000
#> [2,] 423.5500 421.0500 139.0500
#> [3,] 318.0333 278.3667 288.3667
#> [4,] 209.7750 158.7750 154.5250
bc.d(x, y, "^")
#> , , 1
#> 
#>              [,1]         [,2]         [,3]
#> [1,]        710.1 2.871000e+02 4.021000e+02
#> [2,]     110955.6 1.340292e+05 1.553148e+05
#> [3,]  776404954.9 9.357283e+08 2.863215e+08
#> [4,] 1875375857.5 2.967979e+11 2.016315e+11
#> 
#> , , 2
#> 
#>              [,1]         [,2]         [,3]
#> [1,] 9.171000e+02 3.091000e+02 5.351000e+02
#> [2,] 7.175784e+05 7.091324e+05 7.733961e+04
#> [3,] 8.685237e+08 5.823921e+08 6.474391e+08
#> [4,] 4.957411e+11 1.626928e+11 1.459604e+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