bc.cplx: Broadcasted Complex Numeric Operations

bc.cplxR Documentation

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 signature 'ANY'
bc.cplx(x, y, op)

Arguments

x, y

conformable atomic arrays of type complex.

op

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

...

further arguments passed to or from methods.

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.

See Also

broadcast_operators

Examples

x.dim <- c(4:2)
x.len <- prod(x.dim)
gen <- function() sample(c(rnorm(10), NA, NA, NaN, NaN, Inf, Inf, -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 <- gen() + gen() * -1i
y <- gen() + gen() * -1i
out <- bc.cplx(array(x), array(y), "*")
cbind(x, y, x*y, out)

broadcast documentation built on Sept. 15, 2025, 5:08 p.m.

Related to bc.cplx in broadcast...