Skip to main content

ScalarSet

Trait ScalarSet 

Source
pub trait ScalarSet:
    Clone
    + Debug
    + 'static {
    type Tag: Copy + Eq + Debug + 'static;

    const TAGS: &'static [Self::Tag];

    // Required methods
    fn tag(&self) -> Self::Tag;
    fn promote(lhs: Self::Tag, rhs: Self::Tag) -> Self::Tag;
}
Expand description

A closed set of scalar types carried by one tensor value type.

A set is represented by one value type: the default set’s payload is opaque and a downstream set defines its own value enum, and ScalarSet::tag reports which member a value currently holds.

§Examples

use tenferro_tensor::{DefaultScalars, ScalarSet};

let value = DefaultScalars::from_vec_col_major(vec![1], vec![1.0_f64])?;
assert_eq!(value.tag(), tenferro_tensor_core::DType::F64);

Required Associated Constants§

Source

const TAGS: &'static [Self::Tag]

Tags of every member, in declaration order.

Required Associated Types§

Source

type Tag: Copy + Eq + Debug + 'static

Tag identifying one member of this set.

Required Methods§

Source

fn tag(&self) -> Self::Tag

Tag of the member this value currently holds.

§Examples
use tenferro_tensor::{DefaultScalars, DType, ScalarSet};

let value = DefaultScalars::from_vec_col_major(vec![1], vec![1.0_f64])?;
assert_eq!(value.tag(), DType::F64);
Source

fn promote(lhs: Self::Tag, rhs: Self::Tag) -> Self::Tag

Promote two members of this set to the member that represents both.

§Examples
use tenferro_tensor::{DefaultScalars, DType, ScalarSet};

assert_eq!(
    <DefaultScalars as ScalarSet>::promote(DType::I32, DType::F32),
    DType::F64
);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl ScalarSet for DefaultScalars

Source§

const TAGS: &'static [Self::Tag] = <DefaultScalarsValue as ScalarSet>::TAGS

Source§

type Tag = DType