Learn R Programming

broadcast (version 0.1.7)

bc.cplx: Broadcasted Complex Numeric Operations

Description

The bc.cplx() function performs broadcasted complex numeric operations on pairs of arrays.

Note that bc.cplx() uses more strict NA checks than base 'R':
If for an element of either x or y, either the real or imaginary part is NA or NaN, than the result of the operation for that element is necessarily NA.


Usage

bc.cplx(x, y, op, ...)

# S4 method for ANY bc.cplx(x, y, op)

Value

For arithmetic operators:

A complex array as a result of the broadcasted arithmetic operation.


For relational operators:

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


Arguments

x, y

conformable vectors/arrays of type complex.

op

a single string, giving the operator.
Supported arithmetic operators: +, -, *, /.
Supported relational operators: ==, !=.

...

further arguments passed to or from methods.

See Also

broadcast_operators

Examples

Run this code
x.dim <- c(4:2)
x.len <- prod(x.dim)
gen <- function() sample(c(rnorm(20), NA, NaN, Inf, -Inf))
x <- array(gen() + gen() * -1i, x.dim)
y <- array(gen() + gen() * -1i, c(4,1,1))

bc.cplx(x, y, "==")
bc.cplx(x, y, "!=")

bc.cplx(x, y, "+")

bc.cplx(array(gen() + gen() * -1i), array(gen() + gen() * -1i), "==")
bc.cplx(array(gen() + gen() * -1i), array(gen() + gen() * -1i), "!=")

x <- array(gen() + gen() * -1i)
y <- array(gen() + gen() * -1i)
bcr(x) <- bcr(y) <- TRUE
out <- x * y
bind_array(list(x = x, y = y, `x*y` = x*y, out = out), 2L)

Run the code above in your browser using DataLab