bc.raw

Broadcasted Byte and Relational Operations on Raw Arrays

Description

The bc.raw() function performs broadcasted byte- and relational operations on arrays of type raw.

For bit-wise operations, use bc.bit.
For logical operations, use bc.b

Usage

bc.raw(x, y, op)

Arguments

x, y conformable raw vectors or arrays.
op a single string, giving the operator.
Supported byte operators: pmin, pmax, diff.
The "diff" operator performs the byte equivalent of abs(x - y).
Supported relational operators: ==, !=, <, >, <=, >=.

Value

For the byte operators:
A array of type raw, as a result of the broadcasted byte operation.

For relational operators:
A logical array as a result of the broadcasted relational comparison.

Examples

library("broadcast")

x.dim <- c(4:2)
x.len <- prod(x.dim)
x.data <- as.raw(0:10)
y.data <- as.raw(10:0)
x <- array(x.data, x.dim)
y <- array(y.data, c(4,1,1))

bc.raw(x, y, "==")
## , , 1
## 
##       [,1]  [,2]  [,3]
## [1,] FALSE FALSE FALSE
## [2,] FALSE FALSE  TRUE
## [3,] FALSE FALSE FALSE
## [4,] FALSE  TRUE FALSE
## 
## , , 2
## 
##       [,1]  [,2]  [,3]
## [1,] FALSE FALSE FALSE
## [2,] FALSE FALSE FALSE
## [3,] FALSE FALSE FALSE
## [4,] FALSE FALSE FALSE
bc.raw(x, y, "!=")
## , , 1
## 
##      [,1]  [,2]  [,3]
## [1,] TRUE  TRUE  TRUE
## [2,] TRUE  TRUE FALSE
## [3,] TRUE  TRUE  TRUE
## [4,] TRUE FALSE  TRUE
## 
## , , 2
## 
##      [,1] [,2] [,3]
## [1,] TRUE TRUE TRUE
## [2,] TRUE TRUE TRUE
## [3,] TRUE TRUE TRUE
## [4,] TRUE TRUE TRUE
bc.raw(x, y, "<")
## , , 1
## 
##      [,1]  [,2]  [,3]
## [1,] TRUE  TRUE  TRUE
## [2,] TRUE  TRUE FALSE
## [3,] TRUE  TRUE FALSE
## [4,] TRUE FALSE  TRUE
## 
## , , 2
## 
##      [,1]  [,2]  [,3]
## [1,] TRUE  TRUE  TRUE
## [2,] TRUE  TRUE FALSE
## [3,] TRUE  TRUE  TRUE
## [4,] TRUE FALSE  TRUE
bc.raw(x, y, ">")
## , , 1
## 
##       [,1]  [,2]  [,3]
## [1,] FALSE FALSE FALSE
## [2,] FALSE FALSE FALSE
## [3,] FALSE FALSE  TRUE
## [4,] FALSE FALSE FALSE
## 
## , , 2
## 
##       [,1]  [,2]  [,3]
## [1,] FALSE FALSE FALSE
## [2,] FALSE FALSE  TRUE
## [3,] FALSE FALSE FALSE
## [4,] FALSE  TRUE FALSE
bc.raw(x, y, "<=")
## , , 1
## 
##      [,1] [,2]  [,3]
## [1,] TRUE TRUE  TRUE
## [2,] TRUE TRUE  TRUE
## [3,] TRUE TRUE FALSE
## [4,] TRUE TRUE  TRUE
## 
## , , 2
## 
##      [,1]  [,2]  [,3]
## [1,] TRUE  TRUE  TRUE
## [2,] TRUE  TRUE FALSE
## [3,] TRUE  TRUE  TRUE
## [4,] TRUE FALSE  TRUE
bc.raw(x, y, ">=")
## , , 1
## 
##       [,1]  [,2]  [,3]
## [1,] FALSE FALSE FALSE
## [2,] FALSE FALSE  TRUE
## [3,] FALSE FALSE  TRUE
## [4,] FALSE  TRUE FALSE
## 
## , , 2
## 
##       [,1]  [,2]  [,3]
## [1,] FALSE FALSE FALSE
## [2,] FALSE FALSE  TRUE
## [3,] FALSE FALSE FALSE
## [4,] FALSE  TRUE FALSE