Arithmetic (+, -, *, /), relational (==, <, >), logical (&, |, ~, xor), bitwise (bitand, bitshift), and transpose operations. More...
Files | |
| file | ops.hpp |
| Fundamental arithmetic, relational, logical, and array operator functions. | |
Enumerations | |
| enum class | nk::builtin::TranspOp { TranspOp::None , TranspOp::Transpose , TranspOp::CTranspose } |
| Transposition operator for page-wise matrix multiplication. More... | |
Functions | |
| Value | nk::builtin::plus (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise addition (y = a + b). | |
| Value | nk::builtin::minus (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise subtraction (y = a - b). | |
| Value | nk::builtin::times (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise multiplication (y = a .
| |
| Value | nk::builtin::mtimes (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Matrix multiplication (Y = A * B). | |
| Value | nk::builtin::rdivide (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise right division (y = a .
| |
| Value | nk::builtin::ldivide (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise left division (y = a .
| |
| Value | nk::builtin::mrdivide (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Matrix right division / slash (y = A / B). | |
| Value | nk::builtin::mldivide (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Matrix left division / backslash (y = A \\ B). | |
| Value | nk::builtin::power (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise power (y = a .
| |
| Value | nk::builtin::elementPower (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise power alias (y = a .^ b). | |
| Value | nk::builtin::mpower (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Matrix power (Y = A ^ B). | |
| Value | nk::builtin::uplus (const Value &a, std::pmr::memory_resource *mr=nullptr) |
| Unary plus (y = +a). | |
| Value | nk::builtin::uminus (const Value &a, std::pmr::memory_resource *mr=nullptr) |
| Unary minus / negation (y = -a). | |
| Value | nk::builtin::pagemtimes (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Page-wise matrix multiplication (pagemtimes(a, b)). | |
| Value | nk::builtin::pagemtimes (const Value &x, TranspOp tx, const Value &y, TranspOp ty, std::pmr::memory_resource *mr=nullptr) |
| Page-wise matrix multiplication with transpositions (pagemtimes(x, tx, y, ty)). | |
| Value | nk::builtin::eq (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise equality (y = a == b). | |
| Value | nk::builtin::ne (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise inequality (y = a ~= b). | |
| Value | nk::builtin::lt (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise less than (y = a < b). | |
| Value | nk::builtin::le (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise less than or equal (y = a <= b). | |
| Value | nk::builtin::gt (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise greater than (y = a > b). | |
| Value | nk::builtin::ge (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise greater than or equal (y = a >= b). | |
| Value | nk::builtin::logical_and (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise logical AND (y = a & b). | |
| Value | nk::builtin::and_op (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Alias for logical_and (y = a & b). | |
| Value | nk::builtin::logical_or (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise logical OR (y = a | b). | |
| Value | nk::builtin::or_op (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Alias for logical_or (y = a | b). | |
| Value | nk::builtin::logical_not (const Value &a, std::pmr::memory_resource *mr=nullptr) |
| Elementwise logical NOT (y = ~a). | |
| Value | nk::builtin::not_op (const Value &a, std::pmr::memory_resource *mr=nullptr) |
| Alias for logical_not (y = ~a). | |
| Value | nk::builtin::logical_xor (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Elementwise logical exclusive OR (y = xor(a, b)). | |
| Value | nk::builtin::xor_op (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Alias for logical_xor (y = xor(a, b)). | |
| Value | nk::builtin::any (const Value &x, int dim=0, std::pmr::memory_resource *mr=nullptr) |
| True if any element of array is non-zero (y = any(x, dim)). | |
| Value | nk::builtin::all (const Value &x, int dim=0, std::pmr::memory_resource *mr=nullptr) |
| True if all elements of array are non-zero (y = all(x, dim)). | |
| Value | nk::builtin::ctranspose (const Value &a, std::pmr::memory_resource *mr=nullptr) |
| Complex conjugate transpose (y = a'). | |
| Value | nk::builtin::transpose (const Value &a, std::pmr::memory_resource *mr=nullptr) |
| Non-conjugate array transpose (y = a.
| |
| Value | nk::builtin::logicalAnd (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Alias for logical_and. | |
| Value | nk::builtin::logicalOr (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Alias for logical_or. | |
| Value | nk::builtin::logicalNot (const Value &a, std::pmr::memory_resource *mr=nullptr) |
| Alias for logical_not. | |
| Value | nk::builtin::logicalXor (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Alias for logical_xor. | |
| Value | nk::builtin::transposeNC (const Value &a, std::pmr::memory_resource *mr=nullptr) |
| Value | nk::builtin::bitand_ (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Bitwise AND of integer arrays (bitand(a, b)). | |
| Value | nk::builtin::bitor_ (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Bitwise OR of integer arrays (bitor(a, b)). | |
| Value | nk::builtin::bitxor_ (const Value &a, const Value &b, std::pmr::memory_resource *mr=nullptr) |
| Bitwise XOR of integer arrays (bitxor(a, b)). | |
| Value | nk::builtin::bitshift (const Value &a, const Value &k, std::pmr::memory_resource *mr=nullptr) |
| Bitwise shift of integer values (bitshift(a, k)). | |
| Value | nk::builtin::bitcmp (const Value &a, int width=64, std::pmr::memory_resource *mr=nullptr) |
| Bitwise complement (bitcmp(a, width)). | |
| Value | nk::builtin::bitset (const Value &a, const Value &n, const Value &val=Value(), std::pmr::memory_resource *mr=nullptr) |
| Sets specified bit in integer array (bitset(a, n, val)). | |
| Value | nk::builtin::bitget (const Value &a, const Value &n, std::pmr::memory_resource *mr=nullptr) |
| Gets bit value at specified bit position in integer array (bitget(a, n)). | |
Arithmetic (+, -, *, /), relational (==, <, >), logical (&, |, ~, xor), bitwise (bitand, bitshift), and transpose operations.
|
strong |
True if all elements of array are non-zero (y = all(x, dim)).
Tests whether all elements along the specified dimension are non-zero.
| x | Input array. |
| dim | Dimension along which to operate (0 = first non-singleton dimension). |
| mr | Memory resource for allocations (nullptr for default). |
|
inline |
Alias for logical_and (y = a & b).
True if any element of array is non-zero (y = any(x, dim)).
Tests whether any elements along the specified dimension are non-zero.
| x | Input array. |
| dim | Dimension along which to operate (0 = first non-singleton dimension). |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::bitand_ | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Bitwise AND of integer arrays (bitand(a, b)).
| a | First integer operand. |
| b | Second integer operand. |
| mr | Memory resource. |
| Value nk::builtin::bitcmp | ( | const Value & | a, |
| int | width = 64, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Bitwise complement (bitcmp(a, width)).
| a | Input integer array. |
| width | Number of bits in unsigned bit representation (default: 64). |
| mr | Memory resource. |
| Value nk::builtin::bitget | ( | const Value & | a, |
| const Value & | n, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Gets bit value at specified bit position in integer array (bitget(a, n)).
| a | Input integer array. |
| n | 1-based bit position index. |
| mr | Memory resource. |
| Value nk::builtin::bitor_ | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Bitwise OR of integer arrays (bitor(a, b)).
| a | First integer operand. |
| b | Second integer operand. |
| mr | Memory resource. |
| Value nk::builtin::bitset | ( | const Value & | a, |
| const Value & | n, | ||
| const Value & | val = Value(), | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Sets specified bit in integer array (bitset(a, n, val)).
| a | Input integer array. |
| n | 1-based bit position index. |
| val | Bit value (0 or 1, default 1). |
| mr | Memory resource. |
| Value nk::builtin::bitshift | ( | const Value & | a, |
| const Value & | k, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Bitwise shift of integer values (bitshift(a, k)).
| a | Input integer array. |
| k | Shift amount (positive for left shift, negative for right shift). |
| mr | Memory resource. |
| Value nk::builtin::bitxor_ | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Bitwise XOR of integer arrays (bitxor(a, b)).
| a | First integer operand. |
| b | Second integer operand. |
| mr | Memory resource. |
Complex conjugate transpose (y = a').
Transposes 2-D matrix a and conjugates complex elements.
| a | Input 2-D matrix. |
| mr | Memory resource for allocations (nullptr for default). |
| std::runtime_error | If a is N-D with >2 dimensions. |
| Value nk::builtin::eq | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Elementwise equality (y = a == b).
Compares corresponding elements for equality with automatic singleton expansion.
| a | Left operand array or scalar. |
| b | Right operand array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::ge | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Elementwise greater than or equal (y = a >= b).
Compares whether elements of a are greater than or equal to elements of b.
| a | Left operand array or scalar. |
| b | Right operand array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::gt | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Elementwise greater than (y = a > b).
Compares whether elements of a are strictly greater than elements of b.
| a | Left operand array or scalar. |
| b | Right operand array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::ldivide | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Elementwise left division (y = a .
\\ b == b ./ a).
Divides each element of b by the corresponding element of a with singleton expansion.
| a | Denominator array or scalar. |
| b | Numerator array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::le | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Elementwise less than or equal (y = a <= b).
Compares whether elements of a are less than or equal to elements of b.
| a | Left operand array or scalar. |
| b | Right operand array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::logical_and | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Elementwise logical AND (y = a & b).
Converts non-zero values to true and performs elementwise AND with singleton expansion.
| a | Left operand array or scalar. |
| b | Right operand array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
Elementwise logical NOT (y = ~a).
Converts zeros to true and non-zeros to false.
| a | Input array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::logical_or | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Elementwise logical OR (y = a | b).
Converts non-zero values to true and performs elementwise OR with singleton expansion.
| a | Left operand array or scalar. |
| b | Right operand array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::logical_xor | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Elementwise logical exclusive OR (y = xor(a, b)).
Returns true where exactly one of a or b is non-zero.
| a | Left operand array or scalar. |
| b | Right operand array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
|
inline |
Alias for logical_and.
Alias for logical_not.
|
inline |
Alias for logical_or.
|
inline |
Alias for logical_xor.
| Value nk::builtin::lt | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Elementwise less than (y = a < b).
Compares whether elements of a are strictly less than elements of b.
| a | Left operand array or scalar. |
| b | Right operand array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::minus | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Elementwise subtraction (y = a - b).
Computes numeric subtraction with automatic singleton expansion (broadcasting).
| a | Left operand array or scalar. |
| b | Right operand array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::mldivide | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Matrix left division / backslash (y = A \\ B).
Solves the linear system A * Y = B (or for scalar A, equivalent to B ./ A).
| a | Coefficient matrix A or scalar. |
| b | Right-hand side matrix B or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::mpower | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Matrix power (Y = A ^ B).
Computes square matrix A raised to the scalar power B.
| a | Square base matrix or scalar. |
| b | Exponent scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::mrdivide | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Matrix right division / slash (y = A / B).
Solves the linear system Y * B = A (or for scalar B, equivalent to A ./ B).
| a | Numerator matrix or scalar. |
| b | Denominator matrix or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::mtimes | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Matrix multiplication (Y = A * B).
Performs standard 2-D matrix multiplication (M x K * K x N -> M x N). If either operand is a scalar, automatically falls back to elementwise multiplication.
| a | Left matrix (M x K) or scalar. |
| b | Right matrix (K x N) or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| std::runtime_error | If inner matrix dimensions do not agree. |
| Value nk::builtin::ne | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Elementwise inequality (y = a ~= b).
Compares corresponding elements for inequality with automatic singleton expansion.
| a | Left operand array or scalar. |
| b | Right operand array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
Alias for logical_not (y = ~a).
|
inline |
Alias for logical_or (y = a | b).
| Value nk::builtin::pagemtimes | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Page-wise matrix multiplication (pagemtimes(a, b)).
Multiplies slices (pages) of N-D arrays along the first two dimensions with broadcasting.
| a | Left N-D matrix operand. |
| b | Right N-D matrix operand. |
| mr | Memory resource for allocations. |
| Value nk::builtin::pagemtimes | ( | const Value & | x, |
| TranspOp | tx, | ||
| const Value & | y, | ||
| TranspOp | ty, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Page-wise matrix multiplication with transpositions (pagemtimes(x, tx, y, ty)).
| x | Left operand. |
| tx | Transposition operator for left operand (None, Transpose, CTranspose). |
| y | Right operand. |
| ty | Transposition operator for right operand (None, Transpose, CTranspose). |
| mr | Memory resource. |
| Value nk::builtin::plus | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Elementwise addition (y = a + b).
Computes numeric addition with automatic singleton expansion (broadcasting). For string and character arrays, performs concatenation or character promotion.
| a | Left operand array or scalar. |
| b | Right operand array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::power | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Elementwise power (y = a .
^ b).
Computes a raised to the power b element-by-element with singleton expansion. Yields complex output when negative reals are raised to non-integer exponents.
| a | Base array or scalar. |
| b | Exponent array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::rdivide | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Elementwise right division (y = a .
/ b).
Divides each element of a by the corresponding element of b with singleton expansion.
| a | Numerator array or scalar. |
| b | Denominator array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
| Value nk::builtin::times | ( | const Value & | a, |
| const Value & | b, | ||
| std::pmr::memory_resource * | mr = nullptr ) |
Elementwise multiplication (y = a .
).
Multiplies arrays element-by-element with singleton expansion broadcasting.
| a | Left operand array or scalar. |
| b | Right operand array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |
Non-conjugate array transpose (y = a.
').
Transposes 2-D matrix a without conjugating complex elements.
| a | Input 2-D matrix. |
| mr | Memory resource for allocations (nullptr for default). |
| std::runtime_error | If a is N-D with >2 dimensions. |
Unary minus / negation (y = -a).
Negates each element in array a. For signed integers, saturates at minimum value. For logicals and characters, converts to double before negation.
| a | Input array or scalar. |
| mr | Memory resource for allocations (nullptr for default). |