[][src]Trait smartcore::linalg::BaseVector

pub trait BaseVector<T: RealNumber>: Clone + Debug {
    pub fn get(&self, i: usize) -> T;
pub fn set(&mut self, i: usize, x: T);
pub fn len(&self) -> usize;
pub fn to_vec(&self) -> Vec<T>;
pub fn zeros(len: usize) -> Self;
pub fn ones(len: usize) -> Self;
pub fn fill(len: usize, value: T) -> Self;
pub fn dot(&self, other: &Self) -> T;
pub fn approximate_eq(&self, other: &Self, error: T) -> bool;
pub fn norm2(&self) -> T;
pub fn norm(&self, p: T) -> T;
pub fn div_element_mut(&mut self, pos: usize, x: T);
pub fn mul_element_mut(&mut self, pos: usize, x: T);
pub fn add_element_mut(&mut self, pos: usize, x: T);
pub fn sub_element_mut(&mut self, pos: usize, x: T);
pub fn add_mut(&mut self, other: &Self) -> &Self;
pub fn sub_mut(&mut self, other: &Self) -> &Self;
pub fn mul_mut(&mut self, other: &Self) -> &Self;
pub fn div_mut(&mut self, other: &Self) -> &Self;
pub fn sum(&self) -> T;
pub fn unique(&self) -> Vec<T>;
pub fn copy_from(&mut self, other: &Self); pub fn is_empty(&self) -> bool { ... }
pub fn from_array(f: &[T]) -> Self { ... }
pub fn sub_scalar_mut(&mut self, x: T) -> &Self { ... }
pub fn add_scalar_mut(&mut self, x: T) -> &Self { ... }
pub fn mul_scalar_mut(&mut self, x: T) -> &Self { ... }
pub fn div_scalar_mut(&mut self, x: T) -> &Self { ... }
pub fn add_scalar(&self, x: T) -> Self { ... }
pub fn sub_scalar(&self, x: T) -> Self { ... }
pub fn mul_scalar(&self, x: T) -> Self { ... }
pub fn div_scalar(&self, x: T) -> Self { ... }
pub fn add(&self, other: &Self) -> Self { ... }
pub fn sub(&self, other: &Self) -> Self { ... }
pub fn mul(&self, other: &Self) -> Self { ... }
pub fn div(&self, other: &Self) -> Self { ... }
pub fn mean(&self) -> T { ... }
pub fn var(&self) -> T { ... }
pub fn std(&self) -> T { ... }
pub fn take(&self, index: &[usize]) -> Self { ... } }

Column or row vector

Required methods

pub fn get(&self, i: usize) -> T[src]

Get an element of a vector

  • i - index of an element

pub fn set(&mut self, i: usize, x: T)[src]

Set an element at i to x

  • i - index of an element
  • x - new value

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

Get number of elevemnt in the vector

pub fn to_vec(&self) -> Vec<T>[src]

Return a vector with the elements of the one-dimensional array.

pub fn zeros(len: usize) -> Self[src]

Create new vector with zeros of size len.

pub fn ones(len: usize) -> Self[src]

Create new vector with ones of size len.

pub fn fill(len: usize, value: T) -> Self[src]

Create new vector of size len where each element is set to value.

pub fn dot(&self, other: &Self) -> T[src]

Vector dot product

pub fn approximate_eq(&self, other: &Self, error: T) -> bool[src]

Returns True if matrices are element-wise equal within a tolerance error.

pub fn norm2(&self) -> T[src]

Returns [L2 norm] of the vector(https://en.wikipedia.org/wiki/Matrix_norm).

pub fn norm(&self, p: T) -> T[src]

Returns vectors norm of order p.

pub fn div_element_mut(&mut self, pos: usize, x: T)[src]

Divide single element of the vector by x, write result to original vector.

pub fn mul_element_mut(&mut self, pos: usize, x: T)[src]

Multiply single element of the vector by x, write result to original vector.

pub fn add_element_mut(&mut self, pos: usize, x: T)[src]

Add single element of the vector to x, write result to original vector.

pub fn sub_element_mut(&mut self, pos: usize, x: T)[src]

Subtract x from single element of the vector, write result to original vector.

pub fn add_mut(&mut self, other: &Self) -> &Self[src]

Add vectors, element-wise, overriding original vector with result.

pub fn sub_mut(&mut self, other: &Self) -> &Self[src]

Subtract vectors, element-wise, overriding original vector with result.

pub fn mul_mut(&mut self, other: &Self) -> &Self[src]

Multiply vectors, element-wise, overriding original vector with result.

pub fn div_mut(&mut self, other: &Self) -> &Self[src]

Divide vectors, element-wise, overriding original vector with result.

pub fn sum(&self) -> T[src]

Calculates sum of all elements of the vector.

pub fn unique(&self) -> Vec<T>[src]

Returns unique values from the vector.

use smartcore::linalg::naive::dense_matrix::*;
let a = vec!(1., 2., 2., -2., -6., -7., 2., 3., 4.);

assert_eq!(a.unique(), vec![-7., -6., -2., 1., 2., 3., 4.]);

pub fn copy_from(&mut self, other: &Self)[src]

Copies content of other vector.

Loading content...

Provided methods

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

Returns true if the vector is empty.

pub fn from_array(f: &[T]) -> Self[src]

Create a new vector from a &[T]

use smartcore::linalg::naive::dense_matrix::*;
let a: [f64; 5] = [0., 0.5, 2., 3., 4.];
let v: Vec<f64> = BaseVector::from_array(&a);
assert_eq!(v, vec![0., 0.5, 2., 3., 4.]);

pub fn sub_scalar_mut(&mut self, x: T) -> &Self[src]

Subtract scalar

pub fn add_scalar_mut(&mut self, x: T) -> &Self[src]

Subtract scalar

pub fn mul_scalar_mut(&mut self, x: T) -> &Self[src]

Subtract scalar

pub fn div_scalar_mut(&mut self, x: T) -> &Self[src]

Subtract scalar

pub fn add_scalar(&self, x: T) -> Self[src]

Add vectors, element-wise

pub fn sub_scalar(&self, x: T) -> Self[src]

Subtract vectors, element-wise

pub fn mul_scalar(&self, x: T) -> Self[src]

Multiply vectors, element-wise

pub fn div_scalar(&self, x: T) -> Self[src]

Divide vectors, element-wise

pub fn add(&self, other: &Self) -> Self[src]

Add vectors, element-wise

pub fn sub(&self, other: &Self) -> Self[src]

Subtract vectors, element-wise

pub fn mul(&self, other: &Self) -> Self[src]

Multiply vectors, element-wise

pub fn div(&self, other: &Self) -> Self[src]

Divide vectors, element-wise

pub fn mean(&self) -> T[src]

Computes the arithmetic mean.

pub fn var(&self) -> T[src]

Computes variance.

pub fn std(&self) -> T[src]

Computes the standard deviation.

pub fn take(&self, index: &[usize]) -> Self[src]

Take elements from an array.

Loading content...

Implementations on Foreign Types

impl<T: RealNumber> BaseVector<T> for Vec<T>[src]

Loading content...

Implementors

Loading content...