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
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]
&self,
column: V
) -> H where
H: Zero + AddAssign<F>,
&'r F: Mul<&'r G, Output = F>,
Expand description
Compute the inner product with a column vector from a matrix.
fn push_value(&mut self, value: F) where
F: NotZero,
[src]
F: NotZero,
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]
F: NotZero,
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).
Implementors
impl<F, C> Vector<F> for Sparse<F, C> where
F: SparseElement<C>,
C: SparseComparator,
[src]
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]
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]
fn push_value(&mut self, value: F)
[src]Append a non-zero value.
fn set(&mut self, i: usize, value: F)
[src]
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 indexi
. Should not be very close to zero to avoid memory usage and numerical error build-up.
fn remove_indices(&mut self, indices: &[usize])
[src]
fn remove_indices(&mut self, indices: &[usize])
[src]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]
&self,
column: I
) -> H where
H: Zero + AddAssign<F>,
&'r F: Mul<&'r G, Output = F>,
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]
impl<F: PartialEq + Display + Debug> Vector<F> for Dense<F>
[src]fn push_value(&mut self, value: F)
[src]
fn push_value(&mut self, value: F)
[src]fn remove_indices(&mut self, indices: &[usize])
[src]
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]
fn iter_values(&self) -> Iter<'_, Self::Inner>
[src]Iterate over the values of this vector.