DenseVector

Trait DenseVector 

Source
pub trait DenseVector: Sealed {
    type Owned;
    type Scalar;

    // Required methods
    fn dim(&self) -> usize;
    fn index(&self, idx: usize) -> &Self::Scalar;
    fn zeros(dim: usize) -> Self::Owned;
    fn to_owned(&self) -> Self::Owned;
}
Expand description

A trait for types representing dense vectors, useful for expressing algorithms such as sparse-dense dot product, or linear solves.

This trait is sealed, and cannot be implemented outside of the sprs crate.

Required Associated Types§

Required Methods§

Source

fn dim(&self) -> usize

The dimension of the vector

Source

fn index(&self, idx: usize) -> &Self::Scalar

Random access to an element in the vector.

§Panics

If the index is out of bounds

Source

fn zeros(dim: usize) -> Self::Owned

Create an owned version of this dense vector type, filled with zeros

Source

fn to_owned(&self) -> Self::Owned

Copies this vector into an owned version

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a, N, S> DenseVector for &'a ArrayBase<S, Ix1>
where S: Data<Elem = N>, N: 'a + Zero + Clone,

Source§

type Owned = ArrayBase<OwnedRepr<N>, Dim<[usize; 1]>>

Source§

type Scalar = N

Source§

fn dim(&self) -> usize

Source§

fn index(&self, idx: usize) -> &N

Source§

fn zeros(dim: usize) -> Self::Owned

Source§

fn to_owned(&self) -> Self::Owned

Source§

impl<'a, N, S> DenseVector for &'a mut ArrayBase<S, Ix1>
where S: Data<Elem = N>, N: 'a + Zero + Clone,

Source§

type Owned = ArrayBase<OwnedRepr<N>, Dim<[usize; 1]>>

Source§

type Scalar = N

Source§

fn dim(&self) -> usize

Source§

fn index(&self, idx: usize) -> &N

Source§

fn zeros(dim: usize) -> Self::Owned

Source§

fn to_owned(&self) -> Self::Owned

Source§

impl<'a, N: 'a + Zero + Clone> DenseVector for &'a [N]

Source§

type Owned = Vec<N>

Source§

type Scalar = N

Source§

fn dim(&self) -> usize

Source§

fn index(&self, idx: usize) -> &N

Source§

fn zeros(dim: usize) -> Self::Owned

Source§

fn to_owned(&self) -> Self::Owned

Source§

impl<'a, N: 'a + Zero + Clone> DenseVector for &'a Vec<N>

Source§

type Owned = Vec<N>

Source§

type Scalar = N

Source§

fn dim(&self) -> usize

Source§

fn index(&self, idx: usize) -> &N

Source§

fn zeros(dim: usize) -> Self::Owned

Source§

fn to_owned(&self) -> Self::Owned

Source§

impl<'a, N: 'a + Zero + Clone> DenseVector for &'a mut [N]

Source§

type Owned = Vec<N>

Source§

type Scalar = N

Source§

fn dim(&self) -> usize

Source§

fn index(&self, idx: usize) -> &N

Source§

fn zeros(dim: usize) -> Self::Owned

Source§

fn to_owned(&self) -> Self::Owned

Source§

impl<'a, N: 'a + Zero + Clone> DenseVector for &'a mut Vec<N>

Source§

type Owned = Vec<N>

Source§

type Scalar = N

Source§

fn dim(&self) -> usize

Source§

fn index(&self, idx: usize) -> &N

Source§

fn zeros(dim: usize) -> Self::Owned

Source§

fn to_owned(&self) -> Self::Owned

Source§

impl<N, S> DenseVector for ArrayBase<S, Ix1>
where S: Data<Elem = N>, N: Zero + Clone,

Source§

type Owned = ArrayBase<OwnedRepr<N>, Dim<[usize; 1]>>

Source§

type Scalar = N

Source§

fn dim(&self) -> usize

Source§

fn index(&self, idx: usize) -> &N

Source§

fn zeros(dim: usize) -> Self::Owned

Source§

fn to_owned(&self) -> Self::Owned

Source§

impl<N: Zero + Clone> DenseVector for [N]

Source§

type Owned = Vec<N>

Source§

type Scalar = N

Source§

fn dim(&self) -> usize

Source§

fn index(&self, idx: usize) -> &N

Source§

fn zeros(dim: usize) -> Self::Owned

Source§

fn to_owned(&self) -> Self::Owned

Source§

impl<N: Zero + Clone> DenseVector for Vec<N>

Source§

type Owned = Vec<N>

Source§

type Scalar = N

Source§

fn dim(&self) -> usize

Source§

fn index(&self, idx: usize) -> &N

Source§

fn zeros(dim: usize) -> Self::Owned

Source§

fn to_owned(&self) -> Self::Owned

Implementors§