[−][src]Struct mathru::algebra::linear::vector::vector::Vector
Methods
impl<T> Vector<T> where
T: AddAssign + Mul<T, Output = T> + Zero + One + Clone + Exponential + Div<T, Output = T> + Power + PartialOrd,
[src]
T: AddAssign + Mul<T, Output = T> + Zero + One + Clone + Exponential + Div<T, Output = T> + Power + PartialOrd,
pub fn p_norm<'a, 'b>(&'a self, p: &'b T) -> T
[src]
Computes the p norm
Arguments
p >= 1.0
Panics
p < 1.0
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 0.0, 3.0, -2.0]); let p: f64 = 2.0; let norm_ref: f64 = a.eucl_norm(); let norm: f64 = a.p_norm(&p); assert_eq!(norm_ref, norm);
impl<T> Vector<T> where
T: Power + Zero + One + Exponential + AddAssign + Add<T, Output = T> + Clone + Copy + FromPrimitive + Div<T, Output = T> + PartialOrd,
[src]
T: Power + Zero + One + Exponential + AddAssign + Add<T, Output = T> + Clone + Copy + FromPrimitive + Div<T, Output = T> + PartialOrd,
pub fn eucl_norm<'a, 'b>(&'a self) -> T
[src]
Computes the euclidean norm
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 0.0, 3.0, -2.0]); let norm_ref: f64 = 3.7416573867739413; let norm: f64 = a.eucl_norm(); assert_eq!(norm_ref, norm);
impl<T> Vector<T> where
T: Clone + Copy + Zero + One,
[src]
T: Clone + Copy + Zero + One,
pub fn new_row<'a, 'b>(n: usize, data: Vec<T>) -> Self
[src]
Returns a row vector
Panics
n != data.len()
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_row(4, vec![1.0, 0.0, 3.0, -2.0]);
pub fn new_column(m: usize, data: Vec<T>) -> Self
[src]
Returns a column vector
Panics
m != data.len()
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 0.0, 3.0, -2.0]);
pub fn apply(self: Vector<T>, f: &dyn Fn(&T) -> T) -> Self
[src]
impl<T> Vector<T> where
T: Number + Clone + Copy + Zero + One,
[src]
T: Number + Clone + Copy + Zero + One,
pub fn new_row_random(n: usize) -> Self
[src]
Returns a row vector initialized with random numbers
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_row_random(4);
pub fn new_column_random(m: usize) -> Self
[src]
Returns a column vector initialized with random numbers
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column_random(4);
impl<T> Vector<T> where
T: Real,
[src]
T: Real,
pub fn transpose<'a>(&'a self) -> Self
[src]
Returns the transposed vector
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 0.0, 3.0, -2.0]); let b: Vector<f64> = a.transpose();
impl<T> Vector<T> where
T: Real,
[src]
T: Real,
pub fn dotp<'a, 'b>(&'a self, rhs: &'b Self) -> T
[src]
Computes the dot product of two vectors
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 0.0, 3.0, -2.0]); let b: Vector<f64> = Vector::new_column(4, vec![-1.0, 2.0, 3.0, 5.0]); let dotp_ref: f64 = -2.0; let dotp: f64 = a.dotp(&b); assert_eq!(dotp_ref, dotp);
pub fn argmax(&self) -> usize
[src]
Find the argmax of the vector.
Returns the index of the largest value in the vector.
Examples
extern crate mathru; use mathru::algebra::linear::Vector; let a = Vector::new_column(4, vec![1.0, 2.0, -3.0, 5.0]); let idx = a.argmax(); assert_eq!(idx, 3);
pub fn argmin(&self) -> usize
[src]
Find the argmin of the vector.
Returns the index of the smallest value in the vector.
Examples
extern crate mathru; use mathru::algebra::linear::Vector; let a = Vector::new_column(4, vec![1.0, -2.0, -6.0, 75.0]); let b = a.argmin(); assert_eq!(b, 2);
impl<T> Vector<T> where
T: Zero + Mul<T, Output = T> + Clone + One + Display,
[src]
T: Zero + Mul<T, Output = T> + Clone + One + Display,
pub fn dyadp<'a, 'b>(&'a self, rhs: &'b Self) -> Matrix<T>
[src]
Computes the dyadic product of two vectors
Example
extern crate mathru; use mathru::algebra::linear::{Vector, Matrix}; let a: Vector<f64> = Vector::new_row(4, vec![1.0, 0.0, 3.0, -2.0]); let b: Vector<f64> = Vector::new_column(4, vec![-1.0, 2.0, 3.0, 5.0]); let m: Matrix<f64> = a.dyadp(&b);
impl<T> Vector<T> where
T: One + Zero,
[src]
T: One + Zero,
impl<T> Vector<T> where
T: One + Zero,
[src]
T: One + Zero,
impl<T> Vector<T> where
T: Real,
[src]
T: Real,
impl<T> Vector<T> where
T: Zero + Clone + Copy,
[src]
T: Zero + Clone + Copy,
pub fn zero(m: usize) -> Self
[src]
Returns the zero vector
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![0.0, 0.0, 0.0, 0.0]); let b: Vector<f64> = Vector::zero(4); assert_eq!(a, b)
impl<T> Vector<T>
[src]
pub fn dim(&self) -> (usize, usize)
[src]
Returns the vector dimension
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 2.0, 3.0, 4.0]); let (m, n): (usize, usize) = a.dim(); assert_eq!(4, m); assert_eq!(1, n);
impl<T> Vector<T> where
T: Real,
[src]
T: Real,
pub fn get_slice(&self, s: usize, e: usize) -> Vector<T>
[src]
Returns a slice of the vector
Arugments
0 <= s < m
0 <= e < m
s: start
e: end
Panics
iff s and e are out of bounds
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let mut a: Vector<f64> = Vector::new_column(4, vec![1.0, -2.0, 3.0, -7.0]); a = a.get_slice(1, 2); let a_ref: Vector<f64> = Vector::new_column(2, vec![-2.0, 3.0]); assert_eq!(a_ref, a);
pub fn set_slice<'a>(&mut self, rhs: &Self, s: usize)
[src]
Overwrite a slice of the vector with the given values
Arugments
0 <= s < m
s: start
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let mut a: Vector<f64> = Vector::new_column(4, vec![1.0, -2.0, 3.0, -7.0]); let b: Vector<f64> = Vector::new_column(2, vec![-5.0, 4.0]); a.set_slice(&b, 1); let a_ref: Vector<f64> = Vector::new_column(4, vec![1.0, -5.0, 4.0, -7.0]); assert_eq!(a_ref, a);
Trait Implementations
impl<T> PartialEq<Vector<T>> for Vector<T> where
T: Number,
[src]
T: Number,
fn eq<'a, 'b>(&'a self, other: &'b Self) -> bool
[src]
Compares if two vectors are equal
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![0.0, 0.0, 0.0, 0.0]); let b: Vector<f64> = Vector::zero(4); assert_eq!(true, a.eq(&b))
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl<T: Clone> Clone for Vector<T>
[src]
fn clone(&self) -> Vector<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<T: Debug> Debug for Vector<T>
[src]
impl<T> Display for Vector<T> where
T: Display,
[src]
T: Display,
impl<T> Sub<T> for Vector<T> where
T: Real,
[src]
T: Real,
type Output = Vector<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: T) -> Self::Output
[src]
Subtracts a scalar value from all vector elements
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 2.0, 3.0, 4.0]); let res_ref: Vector<f64> = Vector::new_column(4, vec![6.0, 7.0, 8.0, 9.0]); assert_eq!(res_ref, a - -5.0)
impl<'a, T, '_> Sub<&'_ T> for &'a Vector<T> where
T: Real,
[src]
T: Real,
type Output = Vector<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: &T) -> Self::Output
[src]
Subtract a scalar from vector elements
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 2.0, 3.0, 4.0]); let res_ref: Vector<f64> = Vector::new_column(4, vec![-4.0, -3.0, -2.0, -1.0]); assert_eq!(res_ref, a - 5.0)
impl<T> Sub<Vector<T>> for Vector<T> where
T: Real,
[src]
T: Real,
type Output = Vector<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: Vector<T>) -> Self::Output
[src]
Subtracts two vectors
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 2.0, 3.0, 4.0]); let b: Vector<f64> = Vector::new_column(4, vec![3.0, -4.0, 5.0, 4.0]); let res_ref: Vector<f64> = Vector::new_column(4, vec![-2.0, 6.0, -2.0, 0.0]); assert_eq!(res_ref, a - b)
impl<'a, 'b, T> Sub<&'b Vector<T>> for &'a Vector<T> where
T: Real,
[src]
T: Real,
type Output = Vector<T>
The resulting type after applying the -
operator.
fn sub(self, rhs: &'b Vector<T>) -> Self::Output
[src]
Subtracts two vectors
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 2.0, 3.0, 4.0]); let b: Vector<f64> = Vector::new_column(4, vec![3.0, -4.0, 5.0, 4.0]); let res_ref: Vector<f64> = Vector::new_column(4, vec![-2.0, 6.0, -2.0, 0.0]); assert_eq!(res_ref, &a - &b)
impl<T> Add<Vector<T>> for Vector<T> where
T: Real,
[src]
T: Real,
type Output = Vector<T>
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self::Output
[src]
Adds two vectors
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 2.0, 3.0, 4.0]); let b: Vector<f64> = Vector::new_column(4, vec![3.0, -4.0, 5.0, 4.0]); let res_ref: Vector<f64> = Vector::new_column(4, vec![4.0, -2.0, 8.0, 8.0]); assert_eq!(res_ref, a + b)
impl<T> Add<T> for Vector<T> where
T: Real,
[src]
T: Real,
type Output = Vector<T>
The resulting type after applying the +
operator.
fn add(self, rhs: T) -> Self::Output
[src]
Adds a scalar to the vector
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 2.0, 3.0, 4.0]); let res_ref: Vector<f64> = Vector::new_column(4, vec![-4.0, -3.0, -2.0, -1.0]); assert_eq!(res_ref, a + -5.0)
impl<'a, T, '_> Add<&'_ T> for &'a Vector<T> where
T: Real,
[src]
T: Real,
type Output = Vector<T>
The resulting type after applying the +
operator.
fn add(self, rhs: &T) -> Self::Output
[src]
Adds a scalar to the vector
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 2.0, 3.0, 4.0]); let res_ref: Vector<f64> = Vector::new_column(4, vec![-4.0, -3.0, -2.0, -1.0]); assert_eq!(res_ref, a + -5.0)
impl<'a, 'b, T> Add<&'b Vector<T>> for &'a Vector<T> where
T: Real,
[src]
T: Real,
type Output = Vector<T>
The resulting type after applying the +
operator.
fn add(self, rhs: &'b Vector<T>) -> Self::Output
[src]
Adds two vectors
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 2.0, 3.0, 4.0]); let b: Vector<f64> = Vector::new_column(4, vec![3.0, -4.0, 5.0, 4.0]); let res_ref: Vector<f64> = Vector::new_column(4, vec![4.0, -2.0, 8.0, 8.0]); assert_eq!(res_ref, &a + &b)
impl<T> Mul<T> for Vector<T> where
T: Real,
[src]
T: Real,
type Output = Vector<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: T) -> Self::Output
[src]
Multiplies the vector elements with a scalar value
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 2.0, 3.0, 4.0]); let res_ref: Vector<f64> = Vector::new_column(4, vec![-5.0, -10.0, -15.0, -20.0]); assert_eq!(res_ref, a * -5.0)
impl<'a, T, '_> Mul<&'_ T> for &'a Vector<T> where
T: Real,
[src]
T: Real,
type Output = Vector<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: &T) -> Self::Output
[src]
Multiplies the vector elements with the scalar value
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![1.0, 2.0, 3.0, 4.0]); let res_ref: Vector<f64> = Vector::new_column(4, vec![5.0, 10.0, 15.0, 20.0]); assert_eq!(res_ref, a * 5.0)
impl<T> Mul<Matrix<T>> for Vector<T> where
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + Display,
[src]
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + Display,
type Output = Vector<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: Matrix<T>) -> Self::Output
[src]
impl<'a, 'b, T> Mul<&'b Matrix<T>> for &'a Vector<T> where
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + Display,
[src]
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + Display,
type Output = Vector<T>
The resulting type after applying the *
operator.
fn mul(self, rhs: &'b Matrix<T>) -> Self::Output
[src]
impl<'a, 'b, T> Mul<&'b Vector<T>> for &'a Matrix<T> where
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + AddAssign,
[src]
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + AddAssign,
Multiplies matrix by vector.
type Output = Vector<T>
The resulting type after applying the *
operator.
fn mul(self, v: &'b Vector<T>) -> Vector<T>
[src]
impl<T> Mul<Vector<T>> for Matrix<T> where
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + AddAssign,
[src]
T: Copy + Zero + Mul<T, Output = T> + Add<T, Output = T> + One + AddAssign,
type Output = Vector<T>
The resulting type after applying the *
operator.
fn mul(self, m: Vector<T>) -> Vector<T>
[src]
impl<T> Div<T> for Vector<T> where
T: Real,
[src]
T: Real,
type Output = Vector<T>
The resulting type after applying the /
operator.
fn div(self, rhs: T) -> Self::Output
[src]
Divides the vector elements with scalar values
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![-5.0, -10.0, -15.0, -20.0]); let res_ref: Vector<f64> = Vector::new_column(4, vec![1.0, 2.0, 3.0, 4.0]); assert_eq!(res_ref, a / -5.0)
impl<'a, T, '_> Div<&'_ T> for &'a Vector<T> where
T: Real,
[src]
T: Real,
type Output = Vector<T>
The resulting type after applying the /
operator.
fn div(self, rhs: &T) -> Self::Output
[src]
Divides the elements of a vector with the scalar value
Example
extern crate mathru; use mathru::algebra::linear::{Vector}; let a: Vector<f64> = Vector::new_column(4, vec![5.0, 10.0, 15.0, 20.0]); let res_ref: Vector<f64> = Vector::new_column(4, vec![1.0, 2.0, 3.0, 4.0]); assert_eq!(res_ref, a / 5.0)
impl<T> Serialize for Vector<T> where
T: Serialize,
[src]
T: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de, T> Deserialize<'de> for Vector<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,