Standard

Struct Standard 

Source
pub struct Standard<T>(/* private fields */);
Expand description

Typed standard arithmetic algebra (add = +, mul = *).

The type parameter T carries the scalar type, making the algebra Alg::Scalar-centric. This is the canonical core model — HasAlgebra provides UX sugar for automatic inference (e.g., f64Standard<f64>).

This is the default algebra for built-in numeric types (f32, f64, Complex32, Complex64).

§Examples

use tenferro_algebra::{HasAlgebra, Standard};

// f64 maps to Standard<f64> algebra automatically
fn check_algebra<T: HasAlgebra<Algebra = Standard<T>>>() {}
check_algebra::<f64>();
check_algebra::<f32>();

Trait Implementations§

Source§

impl<T> Algebra for Standard<T>
where T: Scalar,

Source§

type Scalar = T

The scalar element type for tensors under this algebra.
Source§

impl<T> Semiring for Standard<T>
where T: Scalar + Zero + One,

Standard arithmetic implements Semiring with + and *.

§Examples

use tenferro_algebra::{Semiring, Standard};

let z = <Standard<f64> as Semiring>::zero();
let o = <Standard<f64> as Semiring>::one();
assert_eq!(z, 0.0);
assert_eq!(o, 1.0);
Source§

fn zero() -> T

Additive identity element.
Source§

fn one() -> T

Multiplicative identity element.
Source§

fn add(a: T, b: T) -> T

Semiring addition.
Source§

fn mul(a: T, b: T) -> T

Semiring multiplication.
Source§

impl<S> TensorAnalyticPrims<Standard<S>> for CpuBackend
where S: Scalar + 'static,

Source§

type Plan = CpuAnalyticPlan

Source§

type Context = CpuContext

Source§

fn plan( _ctx: &mut <CpuBackend as TensorAnalyticPrims<Standard<S>>>::Context, desc: &AnalyticPrimsDescriptor, shapes: &[&[usize]], ) -> Result<<CpuBackend as TensorAnalyticPrims<Standard<S>>>::Plan, Error>

Plan an analytic-family operation for the given input/output shapes. Read more
Source§

fn execute( _ctx: &mut <CpuBackend as TensorAnalyticPrims<Standard<S>>>::Context, plan: &<CpuBackend as TensorAnalyticPrims<Standard<S>>>::Plan, alpha: S, inputs: &[&Tensor<S>], beta: S, output: &mut Tensor<S>, ) -> Result<(), Error>

Execute a previously planned analytic-family operation. Read more
Source§

fn has_analytic_support(desc: AnalyticPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor. Read more
Source§

impl<S> TensorIndexingPrims<Standard<S>> for CpuBackend
where S: Scalar + 'static,

Source§

type Plan = CpuIndexingPlan

Backend-specific execution plan.
Source§

type Context = CpuContext

Backend execution context.
Source§

fn plan( _ctx: &mut <CpuBackend as TensorIndexingPrims<Standard<S>>>::Context, desc: &IndexingPrimsDescriptor, shapes: &[&[usize]], ) -> Result<<CpuBackend as TensorIndexingPrims<Standard<S>>>::Plan, Error>

Plan an indexing operation for the given input/index/output shapes. Read more
Source§

fn execute( _ctx: &mut <CpuBackend as TensorIndexingPrims<Standard<S>>>::Context, plan: &<CpuBackend as TensorIndexingPrims<Standard<S>>>::Plan, inputs: &[&Tensor<S>], indices: &Tensor<i64>, output: &mut Tensor<S>, ) -> Result<(), Error>

Execute a previously planned indexing operation. Read more
Source§

fn has_indexing_support(_desc: IndexingPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor.
Source§

impl TensorRngPrims<Standard<f64>> for CpuBackend

Source§

type Plan = (RngPrimsDescriptor, Vec<usize>)

Backend-specific execution plan.
Source§

type Context = CpuContext

Backend execution context.
Source§

fn plan( _ctx: &mut <CpuBackend as TensorRngPrims<Standard<f64>>>::Context, desc: &RngPrimsDescriptor, shapes: &[&[usize]], ) -> Result<<CpuBackend as TensorRngPrims<Standard<f64>>>::Plan, Error>

Plan a tensor RNG operation for the given output shape.
Source§

fn execute( _ctx: &mut <CpuBackend as TensorRngPrims<Standard<f64>>>::Context, plan: &<CpuBackend as TensorRngPrims<Standard<f64>>>::Plan, generator: &mut Generator, output: &mut Tensor<f64>, ) -> Result<(), Error>

Execute a previously planned RNG operation.
Source§

fn has_rng_support(desc: RngPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor.
Source§

impl TensorRngPrims<Standard<i32>> for CpuBackend

Source§

type Plan = (RngPrimsDescriptor, Vec<usize>)

Backend-specific execution plan.
Source§

type Context = CpuContext

Backend execution context.
Source§

fn plan( _ctx: &mut <CpuBackend as TensorRngPrims<Standard<i32>>>::Context, desc: &RngPrimsDescriptor, shapes: &[&[usize]], ) -> Result<<CpuBackend as TensorRngPrims<Standard<i32>>>::Plan, Error>

Plan a tensor RNG operation for the given output shape.
Source§

fn execute( _ctx: &mut <CpuBackend as TensorRngPrims<Standard<i32>>>::Context, plan: &<CpuBackend as TensorRngPrims<Standard<i32>>>::Plan, generator: &mut Generator, output: &mut Tensor<i32>, ) -> Result<(), Error>

Execute a previously planned RNG operation.
Source§

fn has_rng_support(desc: RngPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor.
Source§

impl<S> TensorScalarPrims<Standard<S>> for CpuBackend
where S: Scalar + 'static,

Source§

type Plan = CpuScalarPlan

Source§

type Context = CpuContext

Source§

fn plan( _ctx: &mut <CpuBackend as TensorScalarPrims<Standard<S>>>::Context, desc: &ScalarPrimsDescriptor, shapes: &[&[usize]], ) -> Result<<CpuBackend as TensorScalarPrims<Standard<S>>>::Plan, Error>

Plan a scalar-family operation for the given input/output shapes. Read more
Source§

fn execute( _ctx: &mut <CpuBackend as TensorScalarPrims<Standard<S>>>::Context, plan: &<CpuBackend as TensorScalarPrims<Standard<S>>>::Plan, alpha: S, inputs: &[&Tensor<S>], beta: S, output: &mut Tensor<S>, ) -> Result<(), Error>

Execute a previously planned scalar-family operation. Read more
Source§

fn has_scalar_support(desc: ScalarPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor. Read more
Source§

impl<S> TensorSemiringCore<Standard<S>> for CpuBackend
where S: Scalar,

Source§

type Plan = CpuPlan<S>

Backend-specific plan type.
Source§

type Context = CpuContext

Backend-specific execution context.
Source§

fn plan( ctx: &mut CpuContext, desc: &SemiringCoreDescriptor, shapes: &[&[usize]], ) -> Result<CpuPlan<S>, Error>

Plan a semiring-core operation.
Source§

fn execute( ctx: &mut CpuContext, plan: &CpuPlan<S>, alpha: S, inputs: &[&Tensor<S>], beta: S, output: &mut Tensor<S>, ) -> Result<(), Error>

Execute a semiring-core operation.
Source§

impl<S> TensorSemiringFastPath<Standard<S>> for CpuBackend
where S: Scalar,

Source§

type Plan = CpuPlan<S>

Backend-specific plan type.
Source§

type Context = CpuContext

Backend-specific execution context.
Source§

fn plan( ctx: &mut CpuContext, desc: &SemiringFastPathDescriptor, shapes: &[&[usize]], ) -> Result<CpuPlan<S>, Error>

Plan an optional semiring fast path.
Source§

fn execute( ctx: &mut CpuContext, plan: &CpuPlan<S>, alpha: S, inputs: &[&Tensor<S>], beta: S, output: &mut Tensor<S>, ) -> Result<(), Error>

Execute an optional semiring fast path.
Source§

fn has_fast_path(desc: SemiringFastPathDescriptor) -> bool

Query whether the optional path is available.
Source§

impl<S> TensorSortPrims<Standard<S>> for CpuBackend
where S: Scalar + PartialOrd + 'static,

Source§

type Plan = CpuSortPlan

Backend-specific execution plan.
Source§

type Context = CpuContext

Backend execution context.
Source§

fn plan( _ctx: &mut <CpuBackend as TensorSortPrims<Standard<S>>>::Context, desc: &SortPrimsDescriptor, shapes: &[&[usize]], ) -> Result<<CpuBackend as TensorSortPrims<Standard<S>>>::Plan, Error>

Plan a sort operation for the given input shape. Read more
Source§

fn execute( _ctx: &mut <CpuBackend as TensorSortPrims<Standard<S>>>::Context, plan: &<CpuBackend as TensorSortPrims<Standard<S>>>::Plan, input: &Tensor<S>, values_out: &mut Tensor<S>, indices_out: &mut Tensor<i64>, ) -> Result<(), Error>

Execute a previously planned sort operation. Read more
Source§

fn has_sort_support(_desc: &SortPrimsDescriptor) -> bool

Report whether the backend advertises support for the given descriptor.

Auto Trait Implementations§

§

impl<T> Freeze for Standard<T>

§

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

§

impl<T> Send for Standard<T>
where T: Send,

§

impl<T> Sync for Standard<T>
where T: Sync,

§

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

§

impl<T> UnwindSafe for Standard<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
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

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

§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

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, 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

§

impl<T> MaybeSend for T

§

impl<T> MaybeSendSync for T

§

impl<T> MaybeSync for T