Files | Enumerations | Functions
Binary Operations

Files

file  binaryop.hpp
 Column APIs for binary ops.
 

Enumerations

enum  cudf::binary_operator : int32_t {
  cudf::binary_operator::ADD, cudf::binary_operator::SUB, cudf::binary_operator::MUL, cudf::binary_operator::DIV,
  cudf::binary_operator::TRUE_DIV, cudf::binary_operator::FLOOR_DIV, cudf::binary_operator::MOD, cudf::binary_operator::PYMOD,
  cudf::binary_operator::POW, cudf::binary_operator::EQUAL, cudf::binary_operator::NOT_EQUAL, cudf::binary_operator::LESS,
  cudf::binary_operator::GREATER, cudf::binary_operator::LESS_EQUAL, cudf::binary_operator::GREATER_EQUAL, cudf::binary_operator::BITWISE_AND,
  cudf::binary_operator::BITWISE_OR, cudf::binary_operator::BITWISE_XOR, cudf::binary_operator::LOGICAL_AND, cudf::binary_operator::LOGICAL_OR,
  cudf::binary_operator::COALESCE, cudf::binary_operator::GENERIC_BINARY, cudf::binary_operator::SHIFT_LEFT, cudf::binary_operator::SHIFT_RIGHT,
  cudf::binary_operator::SHIFT_RIGHT_UNSIGNED, cudf::binary_operator::LOG_BASE, cudf::binary_operator::ATAN2, cudf::binary_operator::PMOD,
  cudf::binary_operator::NULL_EQUALS, cudf::binary_operator::NULL_MAX, cudf::binary_operator::NULL_MIN, cudf::binary_operator::INVALID_BINARY
}
 Types of binary operations that can be performed on data. More...
 

Functions

std::unique_ptr< columncudf::binary_operation (scalar const &lhs, column_view const &rhs, binary_operator op, data_type output_type, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Performs a binary operation between a scalar and a column. More...
 
std::unique_ptr< columncudf::binary_operation (column_view const &lhs, scalar const &rhs, binary_operator op, data_type output_type, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Performs a binary operation between a column and a scalar. More...
 
std::unique_ptr< columncudf::binary_operation (column_view const &lhs, column_view const &rhs, binary_operator op, data_type output_type, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Performs a binary operation between two columns. More...
 
std::unique_ptr< columncudf::binary_operation (column_view const &lhs, column_view const &rhs, std::string const &ptx, data_type output_type, rmm::mr::device_memory_resource *mr=rmm::mr::get_current_device_resource())
 Performs a binary operation between two columns using a user-defined PTX function. More...
 
int32_t cudf::binary_operation_fixed_point_scale (binary_operator op, int32_t left_scale, int32_t right_scale)
 Computes the scale for a fixed_point number based on given binary operator op More...
 
cudf::data_type cudf::binary_operation_fixed_point_output_type (binary_operator op, cudf::data_type const &lhs, cudf::data_type const &rhs)
 Computes the data_type for a fixed_point number based on given binary operator op More...
 

Detailed Description

Enumeration Type Documentation

◆ binary_operator

enum cudf::binary_operator : int32_t
strong

Types of binary operations that can be performed on data.

Enumerator
ADD 

operator +

SUB 

operator -

MUL 

operator *

DIV 

operator / using common type of lhs and rhs

TRUE_DIV 

operator / after promoting type to floating point

FLOOR_DIV 

operator / after promoting to 64 bit floating point and then flooring the result

MOD 

operator %

PYMOD 

operator % but following python's sign rules for negatives

POW 

lhs ^ rhs

EQUAL 

operator ==

NOT_EQUAL 

operator !=

LESS 

operator <

GREATER 

operator >

LESS_EQUAL 

operator <=

GREATER_EQUAL 

operator >=

BITWISE_AND 

operator &

BITWISE_OR 

operator |

BITWISE_XOR 

operator ^

LOGICAL_AND 

operator &&

LOGICAL_OR 

operator ||

COALESCE 

operator x,y x is null ? y : x

GENERIC_BINARY 

generic binary operator to be generated with input ptx code

SHIFT_LEFT 

operator <<

SHIFT_RIGHT 

operator >>

SHIFT_RIGHT_UNSIGNED 

operator >>> (from Java) Logical right shift. Casts to an unsigned value before shifting.

LOG_BASE 

logarithm to the base

ATAN2 

2-argument arctangent

PMOD 

positive modulo operator If remainder is negative, this returns (remainder + divisor) % divisor else, it returns (dividend % divisor)

NULL_EQUALS 

Returns true when both operands are null; false when one is null; the result of equality when both are non-null

NULL_MAX 

Returns max of operands when both are non-null; returns the non-null operand when one is null; or invalid when both are null

NULL_MIN 

Returns min of operands when both are non-null; returns the non-null operand when one is null; or invalid when both are null

INVALID_BINARY 

invalid operation

Definition at line 36 of file binaryop.hpp.

Function Documentation

◆ binary_operation() [1/4]

std::unique_ptr<column> cudf::binary_operation ( column_view const &  lhs,
column_view const &  rhs,
binary_operator  op,
data_type  output_type,
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Performs a binary operation between two columns.

The output contains the result of op(lhs[i], rhs[i]) for all 0 <= i < lhs.size()

Regardless of the operator, the validity of the output value is the logical AND of the validity of the two operands

Parameters
lhsThe left operand column
rhsThe right operand column
output_typeThe desired data type of the output column
mrDevice memory resource used to allocate the returned column's device memory
Returns
Output column of output_type type containing the result of the binary operation
Exceptions
cudf::logic_errorif lhs and rhs are different sizes
cudf::logic_errorif output_type dtype isn't fixed-width

◆ binary_operation() [2/4]

std::unique_ptr<column> cudf::binary_operation ( column_view const &  lhs,
column_view const &  rhs,
std::string const &  ptx,
data_type  output_type,
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Performs a binary operation between two columns using a user-defined PTX function.

The output contains the result of op(lhs[i], rhs[i]) for all 0 <= i < lhs.size()

Regardless of the operator, the validity of the output value is the logical AND of the validity of the two operands

Parameters
lhsThe left operand column
rhsThe right operand column
ptxString containing the PTX of a binary function
output_typeThe desired data type of the output column. It is assumed that output_type is compatible with the output data type of the function in the PTX code
mrDevice memory resource used to allocate the returned column's device memory
Returns
Output column of output_type type containing the result of the binary operation
Exceptions
cudf::logic_errorif lhs and rhs are different sizes
cudf::logic_errorif lhs and rhs dtypes aren't numeric
cudf::logic_errorif output_type dtype isn't numeric

◆ binary_operation() [3/4]

std::unique_ptr<column> cudf::binary_operation ( column_view const &  lhs,
scalar const &  rhs,
binary_operator  op,
data_type  output_type,
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Performs a binary operation between a column and a scalar.

The output contains the result of op(lhs[i], rhs) for all 0 <= i < lhs.size() The column elements are the left operand and the scalar is the right operand. This distinction is significant in case of non-commutative binary operations

Regardless of the operator, the validity of the output value is the logical AND of the validity of the two operands

Parameters
lhsThe left operand column
rhsThe right operand scalar
output_typeThe desired data type of the output column
mrDevice memory resource used to allocate the returned column's device memory
Returns
Output column of output_type type containing the result of the binary operation
Exceptions
cudf::logic_errorif output_type dtype isn't fixed-width

◆ binary_operation() [4/4]

std::unique_ptr<column> cudf::binary_operation ( scalar const &  lhs,
column_view const &  rhs,
binary_operator  op,
data_type  output_type,
rmm::mr::device_memory_resource mr = rmm::mr::get_current_device_resource() 
)

Performs a binary operation between a scalar and a column.

The output contains the result of op(lhs, rhs[i]) for all 0 <= i < rhs.size() The scalar is the left operand and the column elements are the right operand. This distinction is significant in case of non-commutative binary operations

Regardless of the operator, the validity of the output value is the logical AND of the validity of the two operands

Parameters
lhsThe left operand scalar
rhsThe right operand column
output_typeThe desired data type of the output column
mrDevice memory resource used to allocate the returned column's device memory
Returns
Output column of output_type type containing the result of the binary operation
Exceptions
cudf::logic_errorif output_type dtype isn't fixed-width

◆ binary_operation_fixed_point_output_type()

cudf::data_type cudf::binary_operation_fixed_point_output_type ( binary_operator  op,
cudf::data_type const &  lhs,
cudf::data_type const &  rhs 
)

Computes the data_type for a fixed_point number based on given binary operator op

Parameters
opThe binary_operator used for two fixed_point numbers
lhscudf::data_type of left fixed_point number
rhscudf::data_type of right fixed_point number
Returns
The resulting cudf::data_type of the computed fixed_point number

◆ binary_operation_fixed_point_scale()

int32_t cudf::binary_operation_fixed_point_scale ( binary_operator  op,
int32_t  left_scale,
int32_t  right_scale 
)

Computes the scale for a fixed_point number based on given binary operator op

Parameters
opThe binary_operator used for two fixed_point numbers
left_scaleScale of left fixed_point number
right_scaleScale of right fixed_point number
Returns
The resulting scale of the computed fixed_point number