Naive

Struct Naive 

Source
pub struct Naive;
Expand description

Simple backend, mostly for demonstratration purposes

Trait Implementations§

Source§

impl<T: ComplexFloat<Real = T> + 'static + PartialOrd + Add<Output = T> + Mul<Output = T> + Zero + Copy> Argmax<T> for Naive

Source§

fn argmax_overwrite<Lx: Layout, S: Shape>( &self, x: &Slice<T, S, Lx>, output: &mut Vec<usize>, ) -> bool

Source§

fn argmax<Lx: Layout, S: Shape>( &self, x: &Slice<T, S, Lx>, ) -> Option<Vec<usize>>

Index of max xᵢ (argmaxᵢ xᵢ)
Source§

fn argmax_abs_overwrite<Lx: Layout, S: Shape>( &self, x: &Slice<T, S, Lx>, output: &mut Vec<usize>, ) -> bool

Source§

fn argmax_abs<Lx: Layout, S: Shape>( &self, x: &Slice<T, S, Lx>, ) -> Option<Vec<usize>>

Index of max |xᵢ| (argmaxᵢ |xᵢ|)
Source§

impl Default for Naive

Source§

fn default() -> Naive

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

impl<T> MatMul<T> for Naive
where T: ComplexFloat,

Source§

fn contract_all<'a, La, Lb>( &self, a: &'a Slice<T, DynRank, La>, b: &'a Slice<T, DynRank, Lb>, ) -> impl ContractBuilder<'a, T, La, Lb>
where T: 'a, La: Layout, Lb: Layout,

Contracts all axes of the first tensor with all axes of the second tensor.

Source§

fn contract_n<'a, La, Lb>( &self, a: &'a Slice<T, DynRank, La>, b: &'a Slice<T, DynRank, Lb>, n: usize, ) -> impl ContractBuilder<'a, T, La, Lb>
where T: 'a, La: Layout, Lb: Layout,

Contracts the last n axes of the first tensor with the first n axes of the second tensor.

§Example

For two matrices (2D tensors), contract_n(1) performs standard matrix multiplication.

Source§

fn contract<'a, La, Lb>( &self, a: &'a Slice<T, DynRank, La>, b: &'a Slice<T, DynRank, Lb>, axes_a: impl Into<Box<[usize]>>, axes_b: impl Into<Box<[usize]>>, ) -> impl ContractBuilder<'a, T, La, Lb>
where T: 'a, La: Layout, Lb: Layout,

Specifies exactly which axes to contract_all.

§Example

specific([1, 2], [3, 4]) contracts axis 1 and 2 of a with axes 3 and 4 of b.

Source§

fn matmul<'a, La, Lb>( &self, a: &'a DSlice<T, 2, La>, b: &'a DSlice<T, 2, Lb>, ) -> impl MatMulBuilder<'a, T, La, Lb>
where La: Layout, Lb: Layout,

Source§

impl<T> MatVec<T> for Naive
where T: ComplexFloat, i8: Into<T::Real>, T::Real: Into<T>,

Source§

fn matvec<'a, La, Lx>( &self, a: &'a DSlice<T, 2, La>, x: &'a DSlice<T, 1, Lx>, ) -> impl MatVecBuilder<'a, T, La, Lx>
where La: Layout, Lx: Layout,

Source§

impl<T: ComplexFloat + 'static + Add<Output = T> + Mul<Output = T> + Zero + Copy> VecOps<T> for Naive

Source§

fn add_to_scaled<Lx: Layout, Ly: Layout>( &self, _alpha: T, _x: &DSlice<T, 1, Lx>, _y: &mut DSlice<T, 1, Ly>, )

Accumulate a scaled vector: y := α·x + y
Source§

fn dot<Lx: Layout, Ly: Layout>( &self, x: &DSlice<T, 1, Lx>, y: &DSlice<T, 1, Ly>, ) -> T

Dot product: ∑xᵢyᵢ
Source§

fn dotc<Lx: Layout, Ly: Layout>( &self, _x: &DSlice<T, 1, Lx>, _y: &DSlice<T, 1, Ly>, ) -> T

Conjugated dot product: ∑(xᵢ * conj(yᵢ))
Source§

fn norm2<Lx: Layout>(&self, _x: &DSlice<T, 1, Lx>) -> T::Real

L2 norm: √(∑|xᵢ|²)
Source§

fn norm1<Lx: Layout>(&self, _x: &DSlice<T, 1, Lx>) -> T::Real
where T: ComplexFloat,

L1 norm: ∑|xᵢ|
Source§

fn copy<Lx: Layout, Ly: Layout>( &self, _x: &DSlice<T, 1, Lx>, _y: &mut DSlice<T, 1, Ly>, )

Copy vector: y := x (TODO)
Source§

fn scal<Lx: Layout>(&self, _alpha: T, _x: &mut DSlice<T, 1, Lx>)

Scale vector: x := α·xᵢ (TODO)
Source§

fn swap<Lx: Layout, Ly: Layout>( &self, _x: &mut DSlice<T, 1, Lx>, _y: &mut DSlice<T, 1, Ly>, )

Swap vectors: x ↔ y (TODO)
Source§

fn rot<Lx: Layout, Ly: Layout>( &self, _x: &mut DSlice<T, 1, Lx>, _y: &mut DSlice<T, 1, Ly>, _c: T::Real, _s: T, )
where T: ComplexFloat,

Givens rotation (TODO)

Auto Trait Implementations§

§

impl Freeze for Naive

§

impl RefUnwindSafe for Naive

§

impl Send for Naive

§

impl Sync for Naive

§

impl Unpin for Naive

§

impl UnwindSafe for Naive

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> 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> IntoCloned<T> for T

Source§

fn clone_to(self, target: &mut T)

Moves an existing object or clones from a reference to the target object.
Source§

fn into_cloned(self) -> T

Returns an existing object or a new clone from a reference.
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
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.
Source§

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

Source§

fn vzip(self) -> V