Stratax 0.4.0rc1
Loading...
Searching...
No Matches
Bitwise.hpp File Reference

Integral bitwise operations and validated shift counts. More...

#include <stratax/core/dtypes/Concepts.hpp>
#include <stratax/core/validation/NumericValidation.hpp>
#include <stratax/ops/Broadcasting.hpp>
#include <stratax/ops/detail/Compound.hpp>
#include <functional>
#include <type_traits>
Include dependency graph for Bitwise.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<Array A, Integral Count, typename Op >
requires Integral<typename A::value_type>
auto stratax::core::bitwise_detail::shift_scalar_op (const A &lhs, const Count &rhs, Op op)
 Applies a validated scalar shift to every array element.
 
template<Array L, Array R, typename Op >
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
auto stratax::core::bitwise_detail::shift_array_op (const L &lhs, const R &rhs, Op op)
 Applies broadcasted per-element shift counts to an array.
 
template<Integral Scalar, Array A, typename Op >
requires Integral<typename A::value_type>
auto stratax::core::bitwise_detail::scalar_shift_array_op (const Scalar &lhs, const A &rhs, Op op)
 Shifts a scalar by every count stored in an array.
 
template<Array L, Array R, typename Op >
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
L & stratax::core::bitwise_detail::compound_bitwise_op (L &lhs, const R &rhs, Op op)
 Applies a broadcasted bitwise operation to lhs in place.
 
template<Array A, Integral Scalar, typename Op >
requires Integral<typename A::value_type>
A & stratax::core::bitwise_detail::compound_scalar_bitwise_op (A &lhs, const Scalar &rhs, Op op)
 Applies a scalar bitwise operation to lhs in place.
 
template<Array L, Array R, typename Op >
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
L & stratax::core::bitwise_detail::compound_shift_op (L &lhs, const R &rhs, Op op)
 Applies validated broadcasted shift counts to lhs in place.
 
template<Array L, Array R, typename Op >
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
auto stratax::core::bitwise_detail::binary_bitwise_op (const L &lhs, const R &rhs, Op op)
 Applies a bitwise callable to two broadcast-compatible integer arrays.
 
template<Array A, Integral Scalar, typename Op >
auto stratax::core::bitwise_detail::binary_scalar_bitwise_op (const A &arr, const Scalar &scalar, Op op)
 Applies a callable to every integer array element and a right scalar.
 
template<Integral Scalar, Array A, typename Op >
auto stratax::core::bitwise_detail::binary_scalar_bitwise_op (const Scalar &scalar, const A &arr, Op op)
 Applies a callable to a left scalar and every integer array element.
 
template<Array A, Integral Count, typename Op >
requires Integral<typename A::value_type>
A & stratax::core::bitwise_detail::compound_scalar_shift_op (A &lhs, const Count &rhs, Op op)
 Applies a validated scalar shift to an array in place.
 
template<Array A>
requires Integral<typename A::value_type>
A operator~ (const A &value)
 Applies bitwise NOT to each element of an integer array.
 
template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
auto operator& (const L &lhs, const R &rhs)
 Computes the broadcasted element-wise bitwise AND.
 
template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
auto operator| (const L &lhs, const R &rhs)
 Computes the broadcasted element-wise bitwise OR.
 
template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
auto operator^ (const L &lhs, const R &rhs)
 Computes the broadcasted element-wise bitwise XOR.
 
template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
auto operator<< (const L &lhs, const R &rhs)
 Left-shifts broadcasted left values by corresponding right counts.
 
template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
auto operator>> (const L &lhs, const R &rhs)
 Right-shifts broadcasted left values by corresponding right counts.
 
template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
auto operator& (const A &lhs, const Scalar &rhs)
 Applies bitwise AND between each array element and a scalar.
 
template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
auto operator| (const A &lhs, const Scalar &rhs)
 Applies bitwise OR between each array element and a scalar.
 
template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
auto operator^ (const A &lhs, const Scalar &rhs)
 Applies bitwise XOR between each array element and a scalar.
 
template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
auto operator<< (const A &lhs, const Scalar &rhs)
 Left-shifts every array element by a validated scalar count.
 
template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
auto operator>> (const A &lhs, const Scalar &rhs)
 Right-shifts every array element by a validated scalar count.
 
template<Integral Scalar, Array A>
requires Integral<typename A::value_type>
auto operator& (const Scalar &lhs, const A &rhs)
 Applies bitwise AND between a scalar and each array element.
 
template<Integral Scalar, Array A>
requires Integral<typename A::value_type>
auto operator| (const Scalar &lhs, const A &rhs)
 Applies bitwise OR between a scalar and each array element.
 
template<Integral Scalar, Array A>
requires Integral<typename A::value_type>
auto operator^ (const Scalar &lhs, const A &rhs)
 Applies bitwise XOR between a scalar and each array element.
 
template<Integral Scalar, Array A>
requires Integral<typename A::value_type>
auto operator<< (const Scalar &lhs, const A &rhs)
 Left-shifts a scalar by every validated count in an array.
 
template<Integral Scalar, Array A>
requires Integral<typename A::value_type>
auto operator>> (const Scalar &lhs, const A &rhs)
 Right-shifts a scalar by every validated count in an array.
 
template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
L & operator&= (L &lhs, const R &rhs)
 Applies broadcasted bitwise AND assignment.
 
template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
L & operator|= (L &lhs, const R &rhs)
 Applies broadcasted bitwise OR assignment.
 
template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
L & operator^= (L &lhs, const R &rhs)
 Applies broadcasted bitwise XOR assignment.
 
template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
L & operator<<= (L &lhs, const R &rhs)
 Applies broadcasted left-shift assignment after validating every count.
 
template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
L & operator>>= (L &lhs, const R &rhs)
 Applies broadcasted right-shift assignment after validating every count.
 
template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
A & operator&= (A &lhs, const Scalar &rhs)
 Applies bitwise AND assignment with a scalar to every element.
 
template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
A & operator|= (A &lhs, const Scalar &rhs)
 Applies bitwise OR assignment with a scalar to every element.
 
template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
A & operator^= (A &lhs, const Scalar &rhs)
 Applies bitwise XOR assignment with a scalar to every element.
 
template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
A & operator<<= (A &lhs, const Scalar &rhs)
 Applies left-shift assignment with a scalar to every element.
 
template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
A & operator>>= (A &lhs, const Scalar &rhs)
 Applies right-shift assignment with a scalar to every element.
 

Detailed Description

Integral bitwise operations and validated shift counts.

Operations that allocate results require owning-container result trait specializations. Element operators receive the original operand types; the result is converted afterward. Native C++ arithmetic and conversion rules apply, including representability requirements. Compound operations use the operands' initial values, including aliased scalars and overlapping views. Repeated destination offsets receive the last logical write. Operations involving views stage O(n) results. Allocation failures propagate.

Definition in file Bitwise.hpp.

Function Documentation

◆ binary_bitwise_op()

template<Array L, Array R, typename Op >
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
auto stratax::core::bitwise_detail::binary_bitwise_op ( const L &  lhs,
const R &  rhs,
Op  op 
)

Applies a bitwise callable to two broadcast-compatible integer arrays.

Matching container families are preserved and mixed families promote to Tensor. The result uses the promoted dtype of the operands.

Template Parameters
LLeft integral-valued Stratax array type.
RRight integral-valued Stratax array type.
OpBinary bitwise callable.
Parameters
lhsLeft array operand.
rhsRight array operand.
opCallable invoked in flat iterator order.
Returns
Owning promoted array with the common broadcasted shape.
Invariant
Both operands remain unchanged.
Exceptions
Exceptions::BroadcastErrorIf shapes are incompatible or an empty operand would supply values to a nonempty result.
Anyexception propagated by result allocation or op.
Complexity
O((n + 1) * r), where n is result size and r is result rank.

Definition at line 299 of file Bitwise.hpp.

◆ binary_scalar_bitwise_op() [1/2]

template<Array A, Integral Scalar, typename Op >
auto stratax::core::bitwise_detail::binary_scalar_bitwise_op ( const A &  arr,
const Scalar &  scalar,
Op  op 
)

Applies a callable to every integer array element and a right scalar.

Template Parameters
AIntegral-valued owning Stratax array.
ScalarIntegral scalar type.
OpBinary bitwise or shift callable.
Parameters
arrArray supplying every left argument.
scalarScalar supplied as every right argument.
opCallable invoked in flat iterator order.
Returns
Owning array with the promoted dtype and the same shape as arr.
Invariant
The operands remain unchanged and the result preserves the array container.
Exceptions
Anyexception propagated by result allocation or op.
Complexity
O(arr.size()).

Definition at line 329 of file Bitwise.hpp.

◆ binary_scalar_bitwise_op() [2/2]

template<Integral Scalar, Array A, typename Op >
auto stratax::core::bitwise_detail::binary_scalar_bitwise_op ( const Scalar &  scalar,
const A &  arr,
Op  op 
)

Applies a callable to a left scalar and every integer array element.

Template Parameters
ScalarIntegral scalar type.
AIntegral-valued owning Stratax array.
OpBinary bitwise or shift callable.
Parameters
scalarScalar supplied as every left argument.
arrArray supplying every right argument.
opCallable invoked in flat iterator order.
Returns
Owning array with the promoted dtype and the same shape as arr.
Invariant
The operands remain unchanged and the result preserves the array container.
Exceptions
Anyexception propagated by result allocation or op.
Complexity
O(arr.size()).

Definition at line 365 of file Bitwise.hpp.

◆ compound_bitwise_op()

template<Array L, Array R, typename Op >
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
L & stratax::core::bitwise_detail::compound_bitwise_op ( L &  lhs,
const R &  rhs,
Op  op 
)

Applies a broadcasted bitwise operation to lhs in place.

Returns
Reference to lhs, whose shape and dtype remain unchanged.
Invariant
The left array retains its original shape and dtype.
Note
Operands use their initial values; repeated destinations use the last logical result.
Precondition
The callable does not modify either operand or its metadata.
Exceptions
Exceptions::BroadcastErrorIf broadcasting is impossible or would change the shape of lhs.
Complexity
O((lhs.size() + 1) * lhs.rank()).

Definition at line 170 of file Bitwise.hpp.

◆ compound_scalar_bitwise_op()

template<Array A, Integral Scalar, typename Op >
requires Integral<typename A::value_type>
A & stratax::core::bitwise_detail::compound_scalar_bitwise_op ( A &  lhs,
const Scalar &  rhs,
Op  op 
)

Applies a scalar bitwise operation to lhs in place.

Returns
Reference to lhs.
Invariant
The left array retains its original shape and dtype.
Note
Operands use their initial values; repeated destinations use the last logical result.
Precondition
The callable does not modify either operand or its metadata.
Complexity
O(n) for owning arrays, O((n + 1) * r) for views.

Definition at line 205 of file Bitwise.hpp.

◆ compound_scalar_shift_op()

template<Array A, Integral Count, typename Op >
requires Integral<typename A::value_type>
A & stratax::core::bitwise_detail::compound_scalar_shift_op ( A &  lhs,
const Count &  rhs,
Op  op 
)

Applies a validated scalar shift to an array in place.

Returns
Reference to lhs.
Invariant
The left array is unchanged if validation fails and otherwise retains its shape and dtype.
Note
Operands use their initial values; repeated destinations use the last logical result.
Precondition
The callable does not modify either operand or its metadata.

Definition at line 397 of file Bitwise.hpp.

◆ compound_shift_op()

template<Array L, Array R, typename Op >
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
L & stratax::core::bitwise_detail::compound_shift_op ( L &  lhs,
const R &  rhs,
Op  op 
)

Applies validated broadcasted shift counts to lhs in place.

All used counts are validated before mutation, so an invalid count leaves lhs unchanged.

Returns
Reference to lhs, whose shape and dtype remain unchanged.
Invariant
The left array is unchanged if validation fails and otherwise retains its shape and dtype.
Note
Operands use their initial values; repeated destinations use the last logical result.
Precondition
The callable does not modify either operand or its metadata.
Exceptions
Exceptions::BroadcastErrorIf broadcasting is impossible or would change the shape of lhs.
Exceptions::ValueErrorIf any used shift count is invalid.
Complexity
O((lhs.size() + 1) * lhs.rank()).

Definition at line 239 of file Bitwise.hpp.

◆ operator&() [1/3]

template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
auto operator& ( const A &  lhs,
const Scalar &  rhs 
)

Applies bitwise AND between each array element and a scalar.

Definition at line 513 of file Bitwise.hpp.

◆ operator&() [2/3]

template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
auto operator& ( const L &  lhs,
const R &  rhs 
)

Computes the broadcasted element-wise bitwise AND.

Returns
Owning promoted array with the common broadcasted shape.
Exceptions
Exceptions::BroadcastErrorIf shapes are incompatible or an empty operand would supply values to a nonempty result.
Complexity
O((n + 1) * r).

Definition at line 444 of file Bitwise.hpp.

◆ operator&() [3/3]

template<Integral Scalar, Array A>
requires Integral<typename A::value_type>
auto operator& ( const Scalar &  lhs,
const A &  rhs 
)

Applies bitwise AND between a scalar and each array element.

Definition at line 570 of file Bitwise.hpp.

◆ operator&=() [1/2]

template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
A & operator&= ( A &  lhs,
const Scalar &  rhs 
)

Applies bitwise AND assignment with a scalar to every element.

Returns
Reference to lhs; shape and dtype are preserved.
Complexity
O(lhs.size()) for owning arrays; O(lhs.size() * lhs.rank()) for views.

Definition at line 697 of file Bitwise.hpp.

◆ operator&=() [2/2]

template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
L & operator&= ( L &  lhs,
const R &  rhs 
)

Applies broadcasted bitwise AND assignment.

Returns
Reference to lhs.
Exceptions
Exceptions::BroadcastErrorIf broadcasting is impossible or would change the left shape.
Complexity
O(lhs.size() * lhs.rank()).

Definition at line 630 of file Bitwise.hpp.

◆ operator<<() [1/3]

template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
auto operator<< ( const A &  lhs,
const Scalar &  rhs 
)

Left-shifts every array element by a validated scalar count.

Definition at line 540 of file Bitwise.hpp.

◆ operator<<() [2/3]

template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
auto operator<< ( const L &  lhs,
const R &  rhs 
)

Left-shifts broadcasted left values by corresponding right counts.

Returns
Owning array with the promoted container and left dtype.
Exceptions
Exceptions::BroadcastErrorIf shapes are incompatible or an empty operand would supply values to a nonempty result.
Exceptions::ValueErrorIf a used count is invalid.
Complexity
O((n + 1) * r).

Definition at line 480 of file Bitwise.hpp.

◆ operator<<() [3/3]

template<Integral Scalar, Array A>
requires Integral<typename A::value_type>
auto operator<< ( const Scalar &  lhs,
const A &  rhs 
)

Left-shifts a scalar by every validated count in an array.

Returns
Owning result with the array container and scalar dtype.
Exceptions
Exceptions::ValueErrorIf any count is invalid.
Complexity
O(rhs.size()).

Definition at line 597 of file Bitwise.hpp.

◆ operator<<=() [1/2]

template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
A & operator<<= ( A &  lhs,
const Scalar &  rhs 
)

Applies left-shift assignment with a scalar to every element.

Returns
Reference to lhs; shape and dtype are preserved.
Exceptions
Exceptions::ValueErrorIf the count is invalid, including for an empty array; validation precedes writes.
Complexity
O(lhs.size()) for owning arrays; O(lhs.size() * lhs.rank()) for views.

Definition at line 724 of file Bitwise.hpp.

◆ operator<<=() [2/2]

template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
L & operator<<= ( L &  lhs,
const R &  rhs 
)

Applies broadcasted left-shift assignment after validating every count.

Returns
Reference to lhs.
Exceptions
Exceptions::BroadcastErrorIf broadcasting is impossible or would change the left shape.
Exceptions::ValueErrorIf a used count is invalid.
Complexity
O(lhs.size() * lhs.rank()).

Definition at line 666 of file Bitwise.hpp.

◆ operator>>() [1/3]

template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
auto operator>> ( const A &  lhs,
const Scalar &  rhs 
)

Right-shifts every array element by a validated scalar count.

Definition at line 554 of file Bitwise.hpp.

◆ operator>>() [2/3]

template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
auto operator>> ( const L &  lhs,
const R &  rhs 
)

Right-shifts broadcasted left values by corresponding right counts.

Returns
Owning array with the promoted container and left dtype.
Exceptions
Exceptions::BroadcastErrorIf shapes are incompatible or an empty operand would supply values to a nonempty result.
Exceptions::ValueErrorIf a used count is invalid.
Complexity
O((n + 1) * r).

Definition at line 497 of file Bitwise.hpp.

◆ operator>>() [3/3]

template<Integral Scalar, Array A>
requires Integral<typename A::value_type>
auto operator>> ( const Scalar &  lhs,
const A &  rhs 
)

Right-shifts a scalar by every validated count in an array.

Returns
Owning result with the array container and scalar dtype.
Exceptions
Exceptions::ValueErrorIf any count is invalid.
Complexity
O(rhs.size()).

Definition at line 611 of file Bitwise.hpp.

◆ operator>>=() [1/2]

template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
A & operator>>= ( A &  lhs,
const Scalar &  rhs 
)

Applies right-shift assignment with a scalar to every element.

Returns
Reference to lhs; shape and dtype are preserved.
Exceptions
Exceptions::ValueErrorIf the count is invalid, including for an empty array; validation precedes writes.
Complexity
O(lhs.size()) for owning arrays; O(lhs.size() * lhs.rank()) for views.

Definition at line 738 of file Bitwise.hpp.

◆ operator>>=() [2/2]

template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
L & operator>>= ( L &  lhs,
const R &  rhs 
)

Applies broadcasted right-shift assignment after validating every count.

Returns
Reference to lhs.
Exceptions
Exceptions::BroadcastErrorIf broadcasting is impossible or would change the left shape.
Exceptions::ValueErrorIf a used count is invalid.
Complexity
O(lhs.size() * lhs.rank()).

Definition at line 682 of file Bitwise.hpp.

◆ operator^() [1/3]

template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
auto operator^ ( const A &  lhs,
const Scalar &  rhs 
)

Applies bitwise XOR between each array element and a scalar.

Definition at line 531 of file Bitwise.hpp.

◆ operator^() [2/3]

template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
auto operator^ ( const L &  lhs,
const R &  rhs 
)

Computes the broadcasted element-wise bitwise XOR.

Returns
Owning promoted array with the common broadcasted shape.
Exceptions
Exceptions::BroadcastErrorIf shapes are incompatible or an empty operand would supply values to a nonempty result.
Complexity
O((n + 1) * r).

Definition at line 468 of file Bitwise.hpp.

◆ operator^() [3/3]

template<Integral Scalar, Array A>
requires Integral<typename A::value_type>
auto operator^ ( const Scalar &  lhs,
const A &  rhs 
)

Applies bitwise XOR between a scalar and each array element.

Definition at line 588 of file Bitwise.hpp.

◆ operator^=() [1/2]

template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
A & operator^= ( A &  lhs,
const Scalar &  rhs 
)

Applies bitwise XOR assignment with a scalar to every element.

Returns
Reference to lhs; shape and dtype are preserved.
Complexity
O(lhs.size()) for owning arrays; O(lhs.size() * lhs.rank()) for views.

Definition at line 715 of file Bitwise.hpp.

◆ operator^=() [2/2]

template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
L & operator^= ( L &  lhs,
const R &  rhs 
)

Applies broadcasted bitwise XOR assignment.

Returns
Reference to lhs.
Exceptions
Exceptions::BroadcastErrorIf broadcasting is impossible or would change the left shape.
Complexity
O(lhs.size() * lhs.rank()).

Definition at line 654 of file Bitwise.hpp.

◆ operator|() [1/3]

template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
auto operator| ( const A &  lhs,
const Scalar &  rhs 
)

Applies bitwise OR between each array element and a scalar.

Definition at line 522 of file Bitwise.hpp.

◆ operator|() [2/3]

template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
auto operator| ( const L &  lhs,
const R &  rhs 
)

Computes the broadcasted element-wise bitwise OR.

Returns
Owning promoted array with the common broadcasted shape.
Exceptions
Exceptions::BroadcastErrorIf shapes are incompatible or an empty operand would supply values to a nonempty result.
Complexity
O((n + 1) * r).

Definition at line 456 of file Bitwise.hpp.

◆ operator|() [3/3]

template<Integral Scalar, Array A>
requires Integral<typename A::value_type>
auto operator| ( const Scalar &  lhs,
const A &  rhs 
)

Applies bitwise OR between a scalar and each array element.

Definition at line 579 of file Bitwise.hpp.

◆ operator|=() [1/2]

template<Array A, Integral Scalar>
requires Integral<typename A::value_type>
A & operator|= ( A &  lhs,
const Scalar &  rhs 
)

Applies bitwise OR assignment with a scalar to every element.

Returns
Reference to lhs; shape and dtype are preserved.
Complexity
O(lhs.size()) for owning arrays; O(lhs.size() * lhs.rank()) for views.

Definition at line 706 of file Bitwise.hpp.

◆ operator|=() [2/2]

template<Array L, Array R>
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
L & operator|= ( L &  lhs,
const R &  rhs 
)

Applies broadcasted bitwise OR assignment.

Returns
Reference to lhs.
Exceptions
Exceptions::BroadcastErrorIf broadcasting is impossible or would change the left shape.
Complexity
O(lhs.size() * lhs.rank()).

Definition at line 642 of file Bitwise.hpp.

◆ operator~()

template<Array A>
requires Integral<typename A::value_type>
A operator~ ( const A &  value)

Applies bitwise NOT to each element of an integer array.

Parameters
valueSource array.
Returns
Owning array with the same shape containing ~value[i].
Complexity
O(value.size()).

Definition at line 423 of file Bitwise.hpp.

◆ scalar_shift_array_op()

template<Integral Scalar, Array A, typename Op >
requires Integral<typename A::value_type>
auto stratax::core::bitwise_detail::scalar_shift_array_op ( const Scalar &  lhs,
const A &  rhs,
Op  op 
)

Shifts a scalar by every count stored in an array.

Returns
Owning array with rhs's container and shape and the scalar dtype.
Invariant
The operands remain unchanged and the result dtype equals the scalar dtype.
Exceptions
Exceptions::ValueErrorIf any shift count is invalid.
Complexity
O(rhs.size()).

Definition at line 127 of file Bitwise.hpp.

◆ shift_array_op()

template<Array L, Array R, typename Op >
requires ( Integral<typename L::value_type> && Integral<typename R::value_type> )
auto stratax::core::bitwise_detail::shift_array_op ( const L &  lhs,
const R &  rhs,
Op  op 
)

Applies broadcasted per-element shift counts to an array.

Returns
Owning promoted container with the left operand's dtype and the common broadcasted shape.
Invariant
Both operands remain unchanged and the result dtype equals the left dtype.
Exceptions
Exceptions::BroadcastErrorIf shapes are incompatible or an empty operand would supply values to a nonempty result.
Exceptions::ValueErrorIf any used shift count is invalid.
Complexity
O((n + 1) * r), where n is result size and r is result rank.

Definition at line 74 of file Bitwise.hpp.

◆ shift_scalar_op()

template<Array A, Integral Count, typename Op >
requires Integral<typename A::value_type>
auto stratax::core::bitwise_detail::shift_scalar_op ( const A &  lhs,
const Count &  rhs,
Op  op 
)

Applies a validated scalar shift to every array element.

Returns
Owning array with the same container, dtype, and shape as lhs.
Invariant
The source array remains unchanged and the result shape equals its shape.
Exceptions
Exceptions::ValueErrorIf rhs is not a valid shift count.
Complexity
O(lhs.size()).

Definition at line 34 of file Bitwise.hpp.