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());Trait Implementations§
Source§impl Clone for ContractionScalar
impl Clone for ContractionScalar
Source§fn clone(&self) -> ContractionScalar
fn clone(&self) -> ContractionScalar
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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
Tests for
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
Mutably borrows from an owned value. Read more