pub enum ContractionScalar {
F32(f32),
F64(f64),
C32(Complex32),
C64(Complex64),
}Expand description
Scalar coefficient accepted by contraction accumulation backends.
ContractionScalar is intentionally narrower than crate::TensorScalar:
dot-general accumulation is only defined for floating and complex tensor
dtypes.
§Examples
use tenferro_tensor::{ContractionScalar, DType};
let alpha = ContractionScalar::F64(2.0);
assert_eq!(alpha.dtype(), DType::F64);Variants§
Implementations§
Source§impl ContractionScalar
impl ContractionScalar
Sourcepub fn dtype(self) -> DType
pub fn dtype(self) -> DType
Return this scalar’s tensor dtype.
§Examples
use tenferro_tensor::{ContractionScalar, DType};
assert_eq!(ContractionScalar::F32(1.0).dtype(), DType::F32);Sourcepub fn one(dtype: DType) -> Result<Self>
pub fn one(dtype: DType) -> Result<Self>
Return the multiplicative identity for a supported contraction dtype.
§Examples
use tenferro_tensor::{ContractionScalar, DType};
assert_eq!(ContractionScalar::one(DType::F64).unwrap(), ContractionScalar::F64(1.0));
assert!(ContractionScalar::one(DType::I32).is_err());§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Sourcepub fn zero(dtype: DType) -> Result<Self>
pub fn zero(dtype: DType) -> Result<Self>
Return the additive identity for a supported contraction dtype.
§Examples
use tenferro_tensor::{ContractionScalar, DType};
assert_eq!(ContractionScalar::zero(DType::F64).unwrap(), ContractionScalar::F64(0.0));§Errors
Returns crate::Error::Validation with a typed ValidationError source
for invalid shapes, ranks, axes, dtypes, or output metadata. It returns
crate::Error::BackendFailure or crate::Error::BackendSource when
backend execution or storage access cannot provide the requested result.
Trait Implementations§
Source§impl Clone for ContractionScalar
impl Clone for ContractionScalar
Source§fn clone(&self) -> ContractionScalar
fn clone(&self) -> ContractionScalar
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ContractionScalar
impl Debug for ContractionScalar
Source§impl PartialEq for ContractionScalar
impl PartialEq for ContractionScalar
Source§fn eq(&self, other: &ContractionScalar) -> bool
fn eq(&self, other: &ContractionScalar) -> bool
self and other values to be equal, and is used by ==.impl Copy for ContractionScalar
impl StructuralPartialEq for ContractionScalar
Auto Trait Implementations§
impl Freeze for ContractionScalar
impl RefUnwindSafe for ContractionScalar
impl Send for ContractionScalar
impl Sync for ContractionScalar
impl Unpin for ContractionScalar
impl UnsafeUnpin for ContractionScalar
impl UnwindSafe for ContractionScalar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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