Trait relp::data::linear_algebra::vector::Vector[][src]

pub trait Vector<F>: PartialEq + Display + Debug {
    type Inner;
    fn new(data: Vec<Self::Inner>, len: usize) -> Self;
fn sparse_inner_product<'a, H, G: 'a, V: Iterator<Item = &'a SparseTuple<G>>>(
        &self,
        column: V
    ) -> H
    where
        H: Zero + AddAssign<F>,
        &'r F: Mul<&'r G, Output = F>
;
fn push_value(&mut self, value: F)
    where
        F: NotZero
;
fn set(&mut self, index: usize, value: F)
    where
        F: NotZero
;
fn get(&self, index: usize) -> Option<&F>;
fn remove_indices(&mut self, indices: &[usize]);
fn iter_values(&self) -> Iter<'_, Self::Inner>;
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
fn size(&self) -> usize; }
Expand description

Defines basic ways to create or change a vector, regardless of back-end.

Associated Types

type Inner[src]

Expand description

Items stored internally.

Loading content...

Required methods

fn new(data: Vec<Self::Inner>, len: usize) -> Self[src]

Expand description

Create a new instance.

Arguments

  • data: Internal data values. Will not be changed and directly used for creation.
  • len: Length of the vector represented (and not necessarily of the internal data struct ure).

Return value

Input data wrapped inside a vector.

fn sparse_inner_product<'a, H, G: 'a, V: Iterator<Item = &'a SparseTuple<G>>>(
    &self,
    column: V
) -> H where
    H: Zero + AddAssign<F>,
    &'r F: Mul<&'r G, Output = F>, 
[src]

Expand description

Compute the inner product with a column vector from a matrix.

fn push_value(&mut self, value: F) where
    F: NotZero
[src]

Expand description

Make a vector longer by one, by adding an extra value at the end of this vector.

fn set(&mut self, index: usize, value: F) where
    F: NotZero
[src]

Expand description

Set the value at an index.

Depending on internal representation, this can be an expensive operation (for SparseVector ’s, the cost depends on the (lack of) sparsity.

fn get(&self, index: usize) -> Option<&F>[src]

Expand description

Retrieve the value at an index.

Returns

None if the representation is Sparse and the value at the index is zero.

fn remove_indices(&mut self, indices: &[usize])[src]

Expand description

Remove the items at the specified indices.

fn iter_values(&self) -> Iter<'_, Self::Inner>[src]

Expand description

Iterate over the internal values.

fn len(&self) -> usize[src]

Expand description

Number of items represented by the vector.

fn is_empty(&self) -> bool[src]

Expand description

Whether the vector is empty.

fn size(&self) -> usize[src]

Expand description

Get the size of the internal data structure (and not of the represented vector).

Loading content...

Implementors

impl<F, C> Vector<F> for Sparse<F, C> where
    F: SparseElement<C>,
    C: SparseComparator
[src]

fn new(data: Vec<Self::Inner>, len: usize) -> Self[src]

Create a vector of length len from data.

Requires that values close to zero are already filtered.

fn push_value(&mut self, value: F)[src]

Append a non-zero value.

fn set(&mut self, i: usize, value: F)[src]

Set the value at index i to value.

Arguments

  • i: Index of the value. New tuple will be inserted, potentially causing many values to be shifted.
  • value: Value to be taken at index i. Should not be very close to zero to avoid memory usage and numerical error build-up.

fn remove_indices(&mut self, indices: &[usize])[src]

Remove elements.

Arguments

  • indices is assumed sorted.

fn len(&self) -> usize[src]

The length of this vector.

fn is_empty(&self) -> bool[src]

Whether this vector has zero size.

fn size(&self) -> usize[src]

The size of this vector in memory.

type Inner = SparseTuple<F>

fn sparse_inner_product<'a, H, G: 'a, I: Iterator<Item = &'a SparseTuple<G>>>(
    &self,
    column: I
) -> H where
    H: Zero + AddAssign<F>,
    &'r F: Mul<&'r G, Output = F>, 
[src]

fn get(&self, index: usize) -> Option<&F>[src]

fn iter_values(&self) -> Iter<'_, Self::Inner>[src]

impl<F: PartialEq + Display + Debug> Vector<F> for Dense<F>[src]

fn new(data: Vec<Self::Inner>, len: usize) -> Self[src]

Create a DenseVector from the provided data.

fn push_value(&mut self, value: F)[src]

Append a value to this vector.

Arguments

  • value: The value to append.

fn set(&mut self, i: usize, value: F)[src]

Set the value at index i to value.

fn remove_indices(&mut self, indices: &[usize])[src]

Reduce the size of the vector by removing values.

Arguments

  • indices: A set of indices to remove from the vector, assumed sorted.

fn iter_values(&self) -> Iter<'_, Self::Inner>[src]

Iterate over the values of this vector.

fn len(&self) -> usize[src]

The length of this vector.

fn is_empty(&self) -> bool[src]

Whether this vector is empty.

fn size(&self) -> usize[src]

The size of this vector in memory.

type Inner = F

fn sparse_inner_product<'a, H, G: 'a, V: Iterator<Item = &'a SparseTuple<G>>>(
    &self,
    column: V
) -> H where
    H: Zero + AddAssign<F>,
    &'r F: Mul<&'r G, Output = F>, 
[src]

fn get(&self, i: usize) -> Option<&F>[src]

Loading content...