Struct rusty_machine::linalg::Vector
source · [−]pub struct Vector<T> { /* private fields */ }
Expand description
The Vector struct.
Can be instantiated with any type.
Implementations
sourceimpl<T> Vector<T>
impl<T> Vector<T>
sourcepub fn new<U>(data: U) -> Vector<T>where
U: Into<Vec<T, Global>>,
pub fn new<U>(data: U) -> Vector<T>where
U: Into<Vec<T, Global>>,
Constructor for Vector struct.
Requires the vector data.
Examples
use rulinalg::vector::Vector;
let vec = Vector::new(vec![1.0,2.0,3.0,4.0]);
sourcepub fn from_fn<F>(size: usize, f: F) -> Vector<T>where
F: FnMut(usize) -> T,
pub fn from_fn<F>(size: usize, f: F) -> Vector<T>where
F: FnMut(usize) -> T,
Constructor for Vector struct that takes a function f
and constructs a new vector such that V_i = f(i)
,
where i
is the index.
Examples
use rulinalg::vector::Vector;
let v = Vector::from_fn(4, |x| x * 3);
assert_eq!(v, vector![0, 3, 6, 9]);
sourcepub fn iter_mut(&mut self) -> IterMut<'_, T>
pub fn iter_mut(&mut self) -> IterMut<'_, T>
Returns an iterator over mutable references to the Vector’s data.
sourcepub unsafe fn get_unchecked(&self, index: usize) -> &T
pub unsafe fn get_unchecked(&self, index: usize) -> &T
Returns a pointer to the element at the given index, without doing bounds checking.
sourcepub unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T
pub unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut T
Returns an unsafe mutable pointer to the element at the given index, without doing bounds checking.
sourceimpl<T> Vector<T>where
T: Copy + PartialOrd<T>,
impl<T> Vector<T>where
T: Copy + PartialOrd<T>,
sourcepub fn argmax(&self) -> (usize, T)
pub fn argmax(&self) -> (usize, T)
Find the argmax of the Vector.
Returns the index of the largest value in the vector.
Examples
use rulinalg::vector::Vector;
let a = vector![1.0,2.0,0.0,5.0];
let b = a.argmax();
assert_eq!(b.0, 3);
assert_eq!(b.1, 5.0);
sourceimpl<T> Vector<T>where
T: Float,
impl<T> Vector<T>where
T: Float,
sourcepub fn norm<N>(&self, norm: N) -> Twhere
N: VectorNorm<T>,
pub fn norm<N>(&self, norm: N) -> Twhere
N: VectorNorm<T>,
Compute vector norm for vector.
Examples
use rulinalg::vector::Vector;
use rulinalg::norm::Euclidean;
let a = vector![3.0, 4.0];
let c = a.norm(Euclidean);
assert_eq!(c, 5.0);
sourcepub fn metric<M>(&self, v: &Vector<T>, m: M) -> Twhere
M: VectorMetric<T>,
pub fn metric<M>(&self, v: &Vector<T>, m: M) -> Twhere
M: VectorMetric<T>,
Compute metric distance between two vectors.
Examples
use rulinalg::vector::Vector;
use rulinalg::norm::Euclidean;
let a = vector![3.0, 4.0];
let b = vector![0.0, 8.0];
// Compute the square root of the sum of
// elementwise squared-differences
let c = a.metric(&b, Euclidean);
assert_eq!(c, 5.0);
Trait Implementations
sourceimpl<'a, T> Add<&'a T> for Vector<T>where
T: Copy + Add<T, Output = T>,
impl<'a, T> Add<&'a T> for Vector<T>where
T: Copy + Add<T, Output = T>,
Scalar addition with Vector reusing current memory.
sourceimpl<'a, T> Add<&'a Vector<T>> for Vector<T>where
T: Copy + Add<T, Output = T>,
impl<'a, T> Add<&'a Vector<T>> for Vector<T>where
T: Copy + Add<T, Output = T>,
Vector addition with Vector reusing current memory.
sourceimpl<'a, 'b, T> Add<&'b T> for &'a Vector<T>where
T: Copy + Add<T, Output = T>,
impl<'a, 'b, T> Add<&'b T> for &'a Vector<T>where
T: Copy + Add<T, Output = T>,
Scalar addition with Vector allocating new memory.
sourceimpl<'a, 'b, T> Add<&'b Vector<T>> for &'a Vector<T>where
T: Copy + Add<T, Output = T>,
impl<'a, 'b, T> Add<&'b Vector<T>> for &'a Vector<T>where
T: Copy + Add<T, Output = T>,
Vector addition with Vector allocating new memory.
sourceimpl<'a, T> Add<T> for &'a Vector<T>where
T: Copy + Add<T, Output = T>,
impl<'a, T> Add<T> for &'a Vector<T>where
T: Copy + Add<T, Output = T>,
Scalar addition with Vector allocating new memory.
sourceimpl<T> Add<T> for Vector<T>where
T: Copy + Add<T, Output = T>,
impl<T> Add<T> for Vector<T>where
T: Copy + Add<T, Output = T>,
Scalar addition with Vector reusing current memory.
sourceimpl<'a, T> Add<Vector<T>> for &'a Vector<T>where
T: Copy + Add<T, Output = T>,
impl<'a, T> Add<Vector<T>> for &'a Vector<T>where
T: Copy + Add<T, Output = T>,
Vector addition with Vector reusing current memory.
sourceimpl<T> Add<Vector<T>> for Vector<T>where
T: Copy + Add<T, Output = T>,
impl<T> Add<Vector<T>> for Vector<T>where
T: Copy + Add<T, Output = T>,
Vector addition with Vector reusing current memory.
sourceimpl<'a, T> AddAssign<&'a T> for Vector<T>where
T: Copy + Add<T, Output = T>,
impl<'a, T> AddAssign<&'a T> for Vector<T>where
T: Copy + Add<T, Output = T>,
Performs addition assignment between a vector and a scalar.
sourcefn add_assign(&mut self, _rhs: &T)
fn add_assign(&mut self, _rhs: &T)
+=
operation. Read moresourceimpl<'a, T> AddAssign<&'a Vector<T>> for Vector<T>where
T: Copy + Add<T, Output = T>,
impl<'a, T> AddAssign<&'a Vector<T>> for Vector<T>where
T: Copy + Add<T, Output = T>,
Performs elementwise addition assignment between two vectors.
sourcefn add_assign(&mut self, _rhs: &Vector<T>)
fn add_assign(&mut self, _rhs: &Vector<T>)
+=
operation. Read moresourceimpl<T> AddAssign<T> for Vector<T>where
T: Copy + Add<T, Output = T>,
impl<T> AddAssign<T> for Vector<T>where
T: Copy + Add<T, Output = T>,
Performs addition assignment between a vector and a scalar.
sourcefn add_assign(&mut self, _rhs: T)
fn add_assign(&mut self, _rhs: T)
+=
operation. Read moresourceimpl<T> AddAssign<Vector<T>> for Vector<T>where
T: Copy + Add<T, Output = T>,
impl<T> AddAssign<Vector<T>> for Vector<T>where
T: Copy + Add<T, Output = T>,
Performs elementwise addition assignment between two vectors.
sourcefn add_assign(&mut self, _rhs: Vector<T>)
fn add_assign(&mut self, _rhs: Vector<T>)
+=
operation. Read moresourceimpl<'a, T> BitAnd<&'a T> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
impl<'a, T> BitAnd<&'a T> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
Scalar bitwise-and with Vector reusing current memory.
sourceimpl<'a, T> BitAnd<&'a Vector<T>> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
impl<'a, T> BitAnd<&'a Vector<T>> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
Vector bitwise-and with Vector reusing current memory.
sourceimpl<'a, 'b, T> BitAnd<&'b T> for &'a Vector<T>where
T: Copy + BitAnd<T, Output = T>,
impl<'a, 'b, T> BitAnd<&'b T> for &'a Vector<T>where
T: Copy + BitAnd<T, Output = T>,
Scalar bitwise-and with Vector allocating new memory.
sourceimpl<'a, 'b, T> BitAnd<&'b Vector<T>> for &'a Vector<T>where
T: Copy + BitAnd<T, Output = T>,
impl<'a, 'b, T> BitAnd<&'b Vector<T>> for &'a Vector<T>where
T: Copy + BitAnd<T, Output = T>,
Vector bitwise-and with Vector allocating new memory.
sourceimpl<'a, T> BitAnd<T> for &'a Vector<T>where
T: Copy + BitAnd<T, Output = T>,
impl<'a, T> BitAnd<T> for &'a Vector<T>where
T: Copy + BitAnd<T, Output = T>,
Scalar bitwise-and with Vector allocating new memory.
sourceimpl<T> BitAnd<T> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
impl<T> BitAnd<T> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
Scalar bitwise-and with Vector reusing current memory.
sourceimpl<'a, T> BitAnd<Vector<T>> for &'a Vector<T>where
T: Copy + BitAnd<T, Output = T>,
impl<'a, T> BitAnd<Vector<T>> for &'a Vector<T>where
T: Copy + BitAnd<T, Output = T>,
Vector bitwise-and with Vector reusing current memory.
sourceimpl<T> BitAnd<Vector<T>> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
impl<T> BitAnd<Vector<T>> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
Vector bitwise-and with Vector reusing current memory.
sourceimpl<'a, T> BitAndAssign<&'a T> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
impl<'a, T> BitAndAssign<&'a T> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
Performs bitwise-and assignment between a vector and a scalar.
sourcefn bitand_assign(&mut self, _rhs: &T)
fn bitand_assign(&mut self, _rhs: &T)
&=
operation. Read moresourceimpl<'a, T> BitAndAssign<&'a Vector<T>> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
impl<'a, T> BitAndAssign<&'a Vector<T>> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
Performs elementwise bitwise-and assignment between two vectors.
sourcefn bitand_assign(&mut self, _rhs: &Vector<T>)
fn bitand_assign(&mut self, _rhs: &Vector<T>)
&=
operation. Read moresourceimpl<T> BitAndAssign<T> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
impl<T> BitAndAssign<T> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
Performs bitwise-and assignment between a vector and a scalar.
sourcefn bitand_assign(&mut self, _rhs: T)
fn bitand_assign(&mut self, _rhs: T)
&=
operation. Read moresourceimpl<T> BitAndAssign<Vector<T>> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
impl<T> BitAndAssign<Vector<T>> for Vector<T>where
T: Copy + BitAnd<T, Output = T>,
Performs elementwise bitwise-and assignment between two vectors.
sourcefn bitand_assign(&mut self, _rhs: Vector<T>)
fn bitand_assign(&mut self, _rhs: Vector<T>)
&=
operation. Read moresourceimpl<'a, T> BitOr<&'a T> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
impl<'a, T> BitOr<&'a T> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
Scalar bitwise-or with Vector reusing current memory.
sourceimpl<'a, T> BitOr<&'a Vector<T>> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
impl<'a, T> BitOr<&'a Vector<T>> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
Vector bitwise-or with Vector reusing current memory.
sourceimpl<'a, 'b, T> BitOr<&'b T> for &'a Vector<T>where
T: Copy + BitOr<T, Output = T>,
impl<'a, 'b, T> BitOr<&'b T> for &'a Vector<T>where
T: Copy + BitOr<T, Output = T>,
Scalar bitwise-or with Vector allocating new memory.
sourceimpl<'a, 'b, T> BitOr<&'b Vector<T>> for &'a Vector<T>where
T: Copy + BitOr<T, Output = T>,
impl<'a, 'b, T> BitOr<&'b Vector<T>> for &'a Vector<T>where
T: Copy + BitOr<T, Output = T>,
Vector bitwise-or with Vector allocating new memory.
sourceimpl<'a, T> BitOr<T> for &'a Vector<T>where
T: Copy + BitOr<T, Output = T>,
impl<'a, T> BitOr<T> for &'a Vector<T>where
T: Copy + BitOr<T, Output = T>,
Scalar bitwise-or with Vector allocating new memory.
sourceimpl<T> BitOr<T> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
impl<T> BitOr<T> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
Scalar bitwise-or with Vector reusing current memory.
sourceimpl<'a, T> BitOr<Vector<T>> for &'a Vector<T>where
T: Copy + BitOr<T, Output = T>,
impl<'a, T> BitOr<Vector<T>> for &'a Vector<T>where
T: Copy + BitOr<T, Output = T>,
Vector bitwise-or with Vector reusing current memory.
sourceimpl<T> BitOr<Vector<T>> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
impl<T> BitOr<Vector<T>> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
Vector bitwise-or with Vector reusing current memory.
sourceimpl<'a, T> BitOrAssign<&'a T> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
impl<'a, T> BitOrAssign<&'a T> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
Performs bitwise-or assignment between a vector and a scalar.
sourcefn bitor_assign(&mut self, _rhs: &T)
fn bitor_assign(&mut self, _rhs: &T)
|=
operation. Read moresourceimpl<'a, T> BitOrAssign<&'a Vector<T>> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
impl<'a, T> BitOrAssign<&'a Vector<T>> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
Performs elementwise bitwise-or assignment between two vectors.
sourcefn bitor_assign(&mut self, _rhs: &Vector<T>)
fn bitor_assign(&mut self, _rhs: &Vector<T>)
|=
operation. Read moresourceimpl<T> BitOrAssign<T> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
impl<T> BitOrAssign<T> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
Performs bitwise-or assignment between a vector and a scalar.
sourcefn bitor_assign(&mut self, _rhs: T)
fn bitor_assign(&mut self, _rhs: T)
|=
operation. Read moresourceimpl<T> BitOrAssign<Vector<T>> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
impl<T> BitOrAssign<Vector<T>> for Vector<T>where
T: Copy + BitOr<T, Output = T>,
Performs elementwise bitwise-or assignment between two vectors.
sourcefn bitor_assign(&mut self, _rhs: Vector<T>)
fn bitor_assign(&mut self, _rhs: Vector<T>)
|=
operation. Read moresourceimpl<'a, T> BitXor<&'a T> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
impl<'a, T> BitXor<&'a T> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
Scalar bitwise-xor with Vector reusing current memory.
sourceimpl<'a, T> BitXor<&'a Vector<T>> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
impl<'a, T> BitXor<&'a Vector<T>> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
Vector bitwise-xor with Vector reusing current memory.
sourceimpl<'a, 'b, T> BitXor<&'b T> for &'a Vector<T>where
T: Copy + BitXor<T, Output = T>,
impl<'a, 'b, T> BitXor<&'b T> for &'a Vector<T>where
T: Copy + BitXor<T, Output = T>,
Scalar bitwise-xor with Vector allocating new memory.
sourceimpl<'a, 'b, T> BitXor<&'b Vector<T>> for &'a Vector<T>where
T: Copy + BitXor<T, Output = T>,
impl<'a, 'b, T> BitXor<&'b Vector<T>> for &'a Vector<T>where
T: Copy + BitXor<T, Output = T>,
Vector bitwise-xor with Vector allocating new memory.
sourceimpl<'a, T> BitXor<T> for &'a Vector<T>where
T: Copy + BitXor<T, Output = T>,
impl<'a, T> BitXor<T> for &'a Vector<T>where
T: Copy + BitXor<T, Output = T>,
Scalar bitwise-xor with Vector allocating new memory.
sourceimpl<T> BitXor<T> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
impl<T> BitXor<T> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
Scalar bitwise-xor with Vector reusing current memory.
sourceimpl<'a, T> BitXor<Vector<T>> for &'a Vector<T>where
T: Copy + BitXor<T, Output = T>,
impl<'a, T> BitXor<Vector<T>> for &'a Vector<T>where
T: Copy + BitXor<T, Output = T>,
Vector bitwise-xor with Vector reusing current memory.
sourceimpl<T> BitXor<Vector<T>> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
impl<T> BitXor<Vector<T>> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
Vector bitwise-xor with Vector reusing current memory.
sourceimpl<'a, T> BitXorAssign<&'a T> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
impl<'a, T> BitXorAssign<&'a T> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
Performs bitwise-xor assignment between a vector and a scalar.
sourcefn bitxor_assign(&mut self, _rhs: &T)
fn bitxor_assign(&mut self, _rhs: &T)
^=
operation. Read moresourceimpl<'a, T> BitXorAssign<&'a Vector<T>> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
impl<'a, T> BitXorAssign<&'a Vector<T>> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
Performs elementwise bitwise-xor assignment between two vectors.
sourcefn bitxor_assign(&mut self, _rhs: &Vector<T>)
fn bitxor_assign(&mut self, _rhs: &Vector<T>)
^=
operation. Read moresourceimpl<T> BitXorAssign<T> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
impl<T> BitXorAssign<T> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
Performs bitwise-xor assignment between a vector and a scalar.
sourcefn bitxor_assign(&mut self, _rhs: T)
fn bitxor_assign(&mut self, _rhs: T)
^=
operation. Read moresourceimpl<T> BitXorAssign<Vector<T>> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
impl<T> BitXorAssign<Vector<T>> for Vector<T>where
T: Copy + BitXor<T, Output = T>,
Performs elementwise bitwise-xor assignment between two vectors.
sourcefn bitxor_assign(&mut self, _rhs: Vector<T>)
fn bitxor_assign(&mut self, _rhs: Vector<T>)
^=
operation. Read moresourceimpl<T> Clone for Vector<T>where
T: Clone,
impl<T> Clone for Vector<T>where
T: Clone,
1.0.0const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl CostFunc<Vector<f64>> for CrossEntropyError
impl CostFunc<Vector<f64>> for CrossEntropyError
sourceimpl CostFunc<Vector<f64>> for MeanSqError
impl CostFunc<Vector<f64>> for MeanSqError
sourceimpl<'a, T> Div<&'a T> for Vector<T>where
T: Copy + Div<T, Output = T>,
impl<'a, T> Div<&'a T> for Vector<T>where
T: Copy + Div<T, Output = T>,
Scalar division with Vector reusing current memory.
sourceimpl<'a, 'b, T> Div<&'b T> for &'a Vector<T>where
T: Copy + Div<T, Output = T>,
impl<'a, 'b, T> Div<&'b T> for &'a Vector<T>where
T: Copy + Div<T, Output = T>,
Scalar division with Vector allocating new memory.
sourceimpl<'a, T> Div<T> for &'a Vector<T>where
T: Copy + Div<T, Output = T>,
impl<'a, T> Div<T> for &'a Vector<T>where
T: Copy + Div<T, Output = T>,
Scalar division with Vector allocating new memory.
sourceimpl<T> Div<T> for Vector<T>where
T: Copy + Div<T, Output = T>,
impl<T> Div<T> for Vector<T>where
T: Copy + Div<T, Output = T>,
Scalar division with Vector reusing current memory.
sourceimpl<'a, T> DivAssign<&'a T> for Vector<T>where
T: Copy + Div<T, Output = T>,
impl<'a, T> DivAssign<&'a T> for Vector<T>where
T: Copy + Div<T, Output = T>,
Performs division assignment between a vector and a scalar.
sourcefn div_assign(&mut self, _rhs: &T)
fn div_assign(&mut self, _rhs: &T)
/=
operation. Read moresourceimpl<T> DivAssign<T> for Vector<T>where
T: Copy + Div<T, Output = T>,
impl<T> DivAssign<T> for Vector<T>where
T: Copy + Div<T, Output = T>,
Performs division assignment between a vector and a scalar.
sourcefn div_assign(&mut self, _rhs: T)
fn div_assign(&mut self, _rhs: T)
/=
operation. Read moresourceimpl<T> Hash for Vector<T>where
T: Hash,
impl<T> Hash for Vector<T>where
T: Hash,
sourcefn hash<__H>(&self, state: &mut __H)where
__H: Hasher,
fn hash<__H>(&self, state: &mut __H)where
__H: Hasher,
Hasher
]. Read more1.3.0fn hash_slice<H>(data: &[Self], state: &mut H)where
H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H)where
H: Hasher,
Hasher
]. Read moresourceimpl<'a, T> Mul<&'a T> for Vector<T>where
T: Copy + Mul<T, Output = T>,
impl<'a, T> Mul<&'a T> for Vector<T>where
T: Copy + Mul<T, Output = T>,
Scalar multiplication with Vector reusing current memory.
sourceimpl<'a, T> Mul<&'a Vector<T>> for Matrix<T>where
T: Zero<Output = T> + Mul<T, Output = T> + Add<T> + Copy,
impl<'a, T> Mul<&'a Vector<T>> for Matrix<T>where
T: Zero<Output = T> + Mul<T, Output = T> + Add<T> + Copy,
Multiplies matrix by vector.
sourceimpl<'a, 'b, T> Mul<&'b T> for &'a Vector<T>where
T: Copy + Mul<T, Output = T>,
impl<'a, 'b, T> Mul<&'b T> for &'a Vector<T>where
T: Copy + Mul<T, Output = T>,
Scalar multiplication with Vector allocating new memory.
sourceimpl<'a, 'b, T> Mul<&'b Vector<T>> for &'a Matrix<T>where
T: Zero<Output = T> + Mul<T, Output = T> + Add<T> + Copy,
impl<'a, 'b, T> Mul<&'b Vector<T>> for &'a Matrix<T>where
T: Zero<Output = T> + Mul<T, Output = T> + Add<T> + Copy,
Multiplies matrix by vector.
sourceimpl<'a, T> Mul<T> for &'a Vector<T>where
T: Copy + Mul<T, Output = T>,
impl<'a, T> Mul<T> for &'a Vector<T>where
T: Copy + Mul<T, Output = T>,
Scalar multiplication with Vector allocating new memory.
sourceimpl<T> Mul<T> for Vector<T>where
T: Copy + Mul<T, Output = T>,
impl<T> Mul<T> for Vector<T>where
T: Copy + Mul<T, Output = T>,
Scalar multiplication with Vector reusing current memory.
sourceimpl<'a, T> Mul<Vector<T>> for &'a Matrix<T>where
T: Zero<Output = T> + Mul<T, Output = T> + Add<T> + Copy,
impl<'a, T> Mul<Vector<T>> for &'a Matrix<T>where
T: Zero<Output = T> + Mul<T, Output = T> + Add<T> + Copy,
Multiplies matrix by vector.
sourceimpl<T> Mul<Vector<T>> for Matrix<T>where
T: Zero<Output = T> + Mul<T, Output = T> + Add<T> + Copy,
impl<T> Mul<Vector<T>> for Matrix<T>where
T: Zero<Output = T> + Mul<T, Output = T> + Add<T> + Copy,
Multiplies matrix by vector.
sourceimpl<'a, T> MulAssign<&'a T> for Vector<T>where
T: Copy + Mul<T, Output = T>,
impl<'a, T> MulAssign<&'a T> for Vector<T>where
T: Copy + Mul<T, Output = T>,
Performs multiplication assignment between a vector and a scalar.
sourcefn mul_assign(&mut self, _rhs: &T)
fn mul_assign(&mut self, _rhs: &T)
*=
operation. Read moresourceimpl<T> MulAssign<T> for Vector<T>where
T: Copy + Mul<T, Output = T>,
impl<T> MulAssign<T> for Vector<T>where
T: Copy + Mul<T, Output = T>,
Performs multiplication assignment between a vector and a scalar.
sourcefn mul_assign(&mut self, _rhs: T)
fn mul_assign(&mut self, _rhs: T)
*=
operation. Read moresourceimpl<T> PartialEq<Vector<T>> for Vector<T>where
T: PartialEq<T>,
impl<T> PartialEq<Vector<T>> for Vector<T>where
T: PartialEq<T>,
sourceimpl<'a, T> Rem<&'a T> for Vector<T>where
T: Copy + Rem<T, Output = T>,
impl<'a, T> Rem<&'a T> for Vector<T>where
T: Copy + Rem<T, Output = T>,
Scalar remainder with Vector reusing current memory.
sourceimpl<'a, T> Rem<&'a Vector<T>> for Vector<T>where
T: Copy + Rem<T, Output = T>,
impl<'a, T> Rem<&'a Vector<T>> for Vector<T>where
T: Copy + Rem<T, Output = T>,
Vector remainder with Vector reusing current memory.
sourceimpl<'a, 'b, T> Rem<&'b T> for &'a Vector<T>where
T: Copy + Rem<T, Output = T>,
impl<'a, 'b, T> Rem<&'b T> for &'a Vector<T>where
T: Copy + Rem<T, Output = T>,
Scalar remainder with Vector allocating new memory.
sourceimpl<'a, 'b, T> Rem<&'b Vector<T>> for &'a Vector<T>where
T: Copy + Rem<T, Output = T>,
impl<'a, 'b, T> Rem<&'b Vector<T>> for &'a Vector<T>where
T: Copy + Rem<T, Output = T>,
Vector remainder with Vector allocating new memory.
sourceimpl<'a, T> Rem<T> for &'a Vector<T>where
T: Copy + Rem<T, Output = T>,
impl<'a, T> Rem<T> for &'a Vector<T>where
T: Copy + Rem<T, Output = T>,
Scalar remainder with Vector allocating new memory.
sourceimpl<T> Rem<T> for Vector<T>where
T: Copy + Rem<T, Output = T>,
impl<T> Rem<T> for Vector<T>where
T: Copy + Rem<T, Output = T>,
Scalar remainder with Vector reusing current memory.
sourceimpl<'a, T> Rem<Vector<T>> for &'a Vector<T>where
T: Copy + Rem<T, Output = T>,
impl<'a, T> Rem<Vector<T>> for &'a Vector<T>where
T: Copy + Rem<T, Output = T>,
Vector remainder with Vector reusing current memory.
sourceimpl<T> Rem<Vector<T>> for Vector<T>where
T: Copy + Rem<T, Output = T>,
impl<T> Rem<Vector<T>> for Vector<T>where
T: Copy + Rem<T, Output = T>,
Vector remainder with Vector reusing current memory.
sourceimpl<'a, T> RemAssign<&'a T> for Vector<T>where
T: Copy + Rem<T, Output = T>,
impl<'a, T> RemAssign<&'a T> for Vector<T>where
T: Copy + Rem<T, Output = T>,
Performs reminder assignment between a vector and a scalar.
sourcefn rem_assign(&mut self, _rhs: &T)
fn rem_assign(&mut self, _rhs: &T)
%=
operation. Read moresourceimpl<'a, T> RemAssign<&'a Vector<T>> for Vector<T>where
T: Copy + Rem<T, Output = T>,
impl<'a, T> RemAssign<&'a Vector<T>> for Vector<T>where
T: Copy + Rem<T, Output = T>,
Performs elementwise remainder assignment between two vectors.
sourcefn rem_assign(&mut self, _rhs: &Vector<T>)
fn rem_assign(&mut self, _rhs: &Vector<T>)
%=
operation. Read moresourceimpl<T> RemAssign<T> for Vector<T>where
T: Copy + Rem<T, Output = T>,
impl<T> RemAssign<T> for Vector<T>where
T: Copy + Rem<T, Output = T>,
Performs reminder assignment between a vector and a scalar.
sourcefn rem_assign(&mut self, _rhs: T)
fn rem_assign(&mut self, _rhs: T)
%=
operation. Read moresourceimpl<T> RemAssign<Vector<T>> for Vector<T>where
T: Copy + Rem<T, Output = T>,
impl<T> RemAssign<Vector<T>> for Vector<T>where
T: Copy + Rem<T, Output = T>,
Performs elementwise remainder assignment between two vectors.
sourcefn rem_assign(&mut self, _rhs: Vector<T>)
fn rem_assign(&mut self, _rhs: Vector<T>)
%=
operation. Read moresourceimpl<'a, T> Sub<&'a T> for Vector<T>where
T: Copy + Sub<T, Output = T>,
impl<'a, T> Sub<&'a T> for Vector<T>where
T: Copy + Sub<T, Output = T>,
Scalar subtraction with Vector reusing current memory.
sourceimpl<'a, T> Sub<&'a Vector<T>> for Vector<T>where
T: Copy + Sub<T, Output = T>,
impl<'a, T> Sub<&'a Vector<T>> for Vector<T>where
T: Copy + Sub<T, Output = T>,
Vector subtraction with Vector reusing current memory.
sourceimpl<'a, 'b, T> Sub<&'b T> for &'a Vector<T>where
T: Copy + Sub<T, Output = T>,
impl<'a, 'b, T> Sub<&'b T> for &'a Vector<T>where
T: Copy + Sub<T, Output = T>,
Scalar subtraction with Vector allocating new memory.
sourceimpl<'a, 'b, T> Sub<&'b Vector<T>> for &'a Vector<T>where
T: Copy + Sub<T, Output = T>,
impl<'a, 'b, T> Sub<&'b Vector<T>> for &'a Vector<T>where
T: Copy + Sub<T, Output = T>,
Vector subtraction with Vector allocating new memory.
sourceimpl<'a, T> Sub<T> for &'a Vector<T>where
T: Copy + Sub<T, Output = T>,
impl<'a, T> Sub<T> for &'a Vector<T>where
T: Copy + Sub<T, Output = T>,
Scalar subtraction with Vector allocating new memory.
sourceimpl<T> Sub<T> for Vector<T>where
T: Copy + Sub<T, Output = T>,
impl<T> Sub<T> for Vector<T>where
T: Copy + Sub<T, Output = T>,
Scalar subtraction with Vector reusing current memory.
sourceimpl<'a, T> Sub<Vector<T>> for &'a Vector<T>where
T: Copy + Sub<T, Output = T>,
impl<'a, T> Sub<Vector<T>> for &'a Vector<T>where
T: Copy + Sub<T, Output = T>,
Vector subtraction with Vector reusing current memory.
sourceimpl<T> Sub<Vector<T>> for Vector<T>where
T: Copy + Sub<T, Output = T>,
impl<T> Sub<Vector<T>> for Vector<T>where
T: Copy + Sub<T, Output = T>,
Vector subtraction with Vector reusing current memory.
sourceimpl<'a, T> SubAssign<&'a T> for Vector<T>where
T: Copy + Sub<T, Output = T>,
impl<'a, T> SubAssign<&'a T> for Vector<T>where
T: Copy + Sub<T, Output = T>,
Performs subtraction assignment between a vector and a scalar.
sourcefn sub_assign(&mut self, _rhs: &T)
fn sub_assign(&mut self, _rhs: &T)
-=
operation. Read moresourceimpl<'a, T> SubAssign<&'a Vector<T>> for Vector<T>where
T: Copy + Sub<T, Output = T>,
impl<'a, T> SubAssign<&'a Vector<T>> for Vector<T>where
T: Copy + Sub<T, Output = T>,
Performs elementwise subtraction assignment between two vectors.
sourcefn sub_assign(&mut self, _rhs: &Vector<T>)
fn sub_assign(&mut self, _rhs: &Vector<T>)
-=
operation. Read moresourceimpl<T> SubAssign<T> for Vector<T>where
T: Copy + Sub<T, Output = T>,
impl<T> SubAssign<T> for Vector<T>where
T: Copy + Sub<T, Output = T>,
Performs subtraction assignment between a vector and a scalar.
sourcefn sub_assign(&mut self, _rhs: T)
fn sub_assign(&mut self, _rhs: T)
-=
operation. Read moresourceimpl<T> SubAssign<Vector<T>> for Vector<T>where
T: Copy + Sub<T, Output = T>,
impl<T> SubAssign<Vector<T>> for Vector<T>where
T: Copy + Sub<T, Output = T>,
Performs elementwise subtraction assignment between two vectors.
sourcefn sub_assign(&mut self, _rhs: Vector<T>)
fn sub_assign(&mut self, _rhs: Vector<T>)
-=
operation. Read moresourceimpl<T: Kernel, U: MeanFunc> SupModel<Matrix<f64>, Vector<f64>> for GaussianProcess<T, U>
impl<T: Kernel, U: MeanFunc> SupModel<Matrix<f64>, Vector<f64>> for GaussianProcess<T, U>
sourcefn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<f64>>
fn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<f64>>
Predict output from inputs.
sourcefn train(
&mut self,
inputs: &Matrix<f64>,
targets: &Vector<f64>
) -> LearningResult<()>
fn train(
&mut self,
inputs: &Matrix<f64>,
targets: &Vector<f64>
) -> LearningResult<()>
Train the model using data and outputs.
sourceimpl<C: Criterion> SupModel<Matrix<f64>, Vector<f64>> for GenLinearModel<C>
impl<C: Criterion> SupModel<Matrix<f64>, Vector<f64>> for GenLinearModel<C>
Supervised model trait for the GLM.
Predictions are made from the model by computing g^-1(Xb).
The model is trained using Iteratively Re-weighted Least Squares.
sourcefn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<f64>>
fn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<f64>>
Predict output from inputs.
sourcefn train(
&mut self,
inputs: &Matrix<f64>,
targets: &Vector<f64>
) -> LearningResult<()>
fn train(
&mut self,
inputs: &Matrix<f64>,
targets: &Vector<f64>
) -> LearningResult<()>
Train the model using inputs and targets.
sourceimpl SupModel<Matrix<f64>, Vector<f64>> for LinRegressor
impl SupModel<Matrix<f64>, Vector<f64>> for LinRegressor
sourcefn train(
&mut self,
inputs: &Matrix<f64>,
targets: &Vector<f64>
) -> LearningResult<()>
fn train(
&mut self,
inputs: &Matrix<f64>,
targets: &Vector<f64>
) -> LearningResult<()>
Train the linear regression model.
Takes training data and output values as input.
Examples
use rusty_machine::learning::lin_reg::LinRegressor;
use rusty_machine::linalg::Matrix;
use rusty_machine::linalg::Vector;
use rusty_machine::learning::SupModel;
let mut lin_mod = LinRegressor::default();
let inputs = Matrix::new(3,1, vec![2.0, 3.0, 4.0]);
let targets = Vector::new(vec![5.0, 6.0, 7.0]);
lin_mod.train(&inputs, &targets).unwrap();
sourcefn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<f64>>
fn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<f64>>
Predict output value from input data.
Model must be trained before prediction can be made.
sourceimpl<A> SupModel<Matrix<f64>, Vector<f64>> for LogisticRegressor<A>where
A: OptimAlgorithm<BaseLogisticRegressor>,
impl<A> SupModel<Matrix<f64>, Vector<f64>> for LogisticRegressor<A>where
A: OptimAlgorithm<BaseLogisticRegressor>,
sourcefn train(
&mut self,
inputs: &Matrix<f64>,
targets: &Vector<f64>
) -> LearningResult<()>
fn train(
&mut self,
inputs: &Matrix<f64>,
targets: &Vector<f64>
) -> LearningResult<()>
Train the logistic regression model.
Takes training data and output values as input.
Examples
use rusty_machine::learning::logistic_reg::LogisticRegressor;
use rusty_machine::linalg::Matrix;
use rusty_machine::linalg::Vector;
use rusty_machine::learning::SupModel;
let mut logistic_mod = LogisticRegressor::default();
let inputs = Matrix::new(3,2, vec![1.0, 2.0, 1.0, 3.0, 1.0, 4.0]);
let targets = Vector::new(vec![5.0, 6.0, 7.0]);
logistic_mod.train(&inputs, &targets).unwrap();
sourcefn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<f64>>
fn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<f64>>
Predict output value from input data.
Model must be trained before prediction can be made.
sourceimpl<K: Kernel> SupModel<Matrix<f64>, Vector<f64>> for SVM<K>
impl<K: Kernel> SupModel<Matrix<f64>, Vector<f64>> for SVM<K>
Train the model using the Pegasos algorithm and predict the model output from new data.
sourcefn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<f64>>
fn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<f64>>
sourcefn train(
&mut self,
inputs: &Matrix<f64>,
targets: &Vector<f64>
) -> LearningResult<()>
fn train(
&mut self,
inputs: &Matrix<f64>,
targets: &Vector<f64>
) -> LearningResult<()>
sourceimpl<S: KNearestSearch> SupModel<Matrix<f64>, Vector<usize>> for KNNClassifier<S>
impl<S: KNearestSearch> SupModel<Matrix<f64>, Vector<usize>> for KNNClassifier<S>
sourcefn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<usize>>
fn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<usize>>
sourcefn train(
&mut self,
inputs: &Matrix<f64>,
targets: &Vector<usize>
) -> LearningResult<()>
fn train(
&mut self,
inputs: &Matrix<f64>,
targets: &Vector<usize>
) -> LearningResult<()>
sourceimpl UnSupModel<Matrix<f64>, Vector<Option<usize>>> for DBSCAN
impl UnSupModel<Matrix<f64>, Vector<Option<usize>>> for DBSCAN
sourcefn train(&mut self, inputs: &Matrix<f64>) -> LearningResult<()>
fn train(&mut self, inputs: &Matrix<f64>) -> LearningResult<()>
Train the classifier using input data.
sourcefn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<Option<usize>>>
fn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<Option<usize>>>
sourceimpl<InitAlg: Initializer> UnSupModel<Matrix<f64>, Vector<usize>> for KMeansClassifier<InitAlg>
impl<InitAlg: Initializer> UnSupModel<Matrix<f64>, Vector<usize>> for KMeansClassifier<InitAlg>
sourcefn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<usize>>
fn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Vector<usize>>
Predict classes from data.
Model must be trained.
sourcefn train(&mut self, inputs: &Matrix<f64>) -> LearningResult<()>
fn train(&mut self, inputs: &Matrix<f64>) -> LearningResult<()>
Train the classifier using input data.