Skip to main content

TropicalBitwise

Struct TropicalBitwise 

Source
#[repr(transparent)]
pub struct TropicalBitwise<T: BitwiseScalar>(pub T);
Expand description

TropicalBitwise semiring: (uint, |, &, 0, ~0) — bit-packed boolean.

Each bit-lane of the wrapped word is an independent boolean problem (bit-slicing): one GEMM computes 32 (u32) or 64 (u64) boolean matmuls at once. ⊕ = |, ⊗ = &, zero = 0, one = !0.

CPU dispatch uses AVX2 or NEON where available, with a portable fallback. There is no single argmax index for a packed word: each bit lane can have a different winner. Per-lane argmax is not implemented, so this type does not implement TropicalWithArgmax.

This is for many independent dense boolean problems. For a single large (sparse) boolean graph, use a sparse GraphBLAS tool (GraphBLAST / cuBool / Bit-GraphBLAS) — that is out of scope for this dense library.

Tuple Fields§

§0: T

Implementations§

Source§

impl<T: BitwiseScalar> TropicalBitwise<T>

Source

pub fn new(value: T) -> Self

Create a new TropicalBitwise value from a packed word.

Trait Implementations§

Source§

impl<T: BitwiseScalar> Add for TropicalBitwise<T>

Source§

type Output = TropicalBitwise<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: Clone + BitwiseScalar> Clone for TropicalBitwise<T>

Source§

fn clone(&self) -> TropicalBitwise<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Copy + BitwiseScalar> Copy for TropicalBitwise<T>

Source§

impl<T: BitwiseScalar> Debug for TropicalBitwise<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: BitwiseScalar> Default for TropicalBitwise<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T: BitwiseScalar> Display for TropicalBitwise<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Eq + BitwiseScalar> Eq for TropicalBitwise<T>

Source§

impl<T: BitwiseScalar> From<T> for TropicalBitwise<T>

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl KernelDispatch for TropicalBitwise<u32>

Source§

unsafe fn dispatch_gemm( m: usize, n: usize, k: usize, a: *const Self::Scalar, lda: usize, trans_a: Transpose, b: *const Self::Scalar, ldb: usize, trans_b: Transpose, c: *mut Self, ldc: usize, )

Dispatch to the appropriate kernel based on CPU features.
Source§

unsafe fn dispatch_gemm_with_workspace( m: usize, n: usize, k: usize, a: *const u32, lda: usize, trans_a: Transpose, b: *const u32, ldb: usize, trans_b: Transpose, c: *mut Self, ldc: usize, workspace: &mut GemmWorkspace<u32>, )

Dispatch using reusable packing storage. Custom implementations retain their existing dispatch unless they override this method to use workspace. Read more
Source§

impl KernelDispatch for TropicalBitwise<u64>

Source§

unsafe fn dispatch_gemm( m: usize, n: usize, k: usize, a: *const Self::Scalar, lda: usize, trans_a: Transpose, b: *const Self::Scalar, ldb: usize, trans_b: Transpose, c: *mut Self, ldc: usize, )

Dispatch to the appropriate kernel based on CPU features.
Source§

unsafe fn dispatch_gemm_with_workspace( m: usize, n: usize, k: usize, a: *const u64, lda: usize, trans_a: Transpose, b: *const u64, ldb: usize, trans_b: Transpose, c: *mut Self, ldc: usize, workspace: &mut GemmWorkspace<u64>, )

Dispatch using reusable packing storage. Custom implementations retain their existing dispatch unless they override this method to use workspace. Read more
Source§

impl<T: BitwiseScalar> Mul for TropicalBitwise<T>

Source§

type Output = TropicalBitwise<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: PartialEq + BitwiseScalar> PartialEq for TropicalBitwise<T>

Source§

fn eq(&self, other: &TropicalBitwise<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: BitwiseScalar> SimdTropical for TropicalBitwise<T>

Source§

const SIMD_AVAILABLE: bool = true

Whether SIMD operations are available for this type.
Source§

const SIMD_WIDTH: usize

The SIMD width in elements.
Source§

impl<T: PartialEq + BitwiseScalar> StructuralPartialEq for TropicalBitwise<T>

Source§

impl<T: BitwiseScalar> TropicalSemiring for TropicalBitwise<T>

Source§

type Scalar = T

The underlying scalar type.
Source§

fn scalar_slice(values: &[Self]) -> Option<&[Self::Scalar]>

Borrow scalar storage when the representation permits it. The default uses a cached value projection in owned matrix views.
Source§

fn tropical_zero() -> Self

Returns the additive identity (zero element for ⊕).
Source§

fn tropical_one() -> Self

Returns the multiplicative identity (one element for ⊗).
Source§

fn tropical_add(self, rhs: Self) -> Self

Tropical addition (⊕).
Source§

fn tropical_mul(self, rhs: Self) -> Self

Tropical multiplication (⊗).
Source§

fn value(&self) -> T

Get the underlying scalar value.
Source§

fn from_scalar(s: T) -> Self

Create from a scalar value.

Auto Trait Implementations§

§

impl<T> Freeze for TropicalBitwise<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for TropicalBitwise<T>
where T: RefUnwindSafe,

§

impl<T> Send for TropicalBitwise<T>

§

impl<T> Sync for TropicalBitwise<T>

§

impl<T> Unpin for TropicalBitwise<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for TropicalBitwise<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for TropicalBitwise<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.