[−][src]Struct mathru::algebra::linear::vector::vector::Vector
Methods
impl<T> Vector<T>
[src]
ⓘImportant traits for VectorIterator<'a, T>pub fn iter(&self) -> VectorIterator<T>
[src]
ⓘImportant traits for VectorIteratorMut<'a, T>pub fn iter_mut(&mut self) -> VectorIteratorMut<T>
[src]
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,
impl<T> Vector<T>
[src]
pub fn convert_to_vec(self) -> Vec<T>
[src]
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
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
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
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: Scalar + Clone + Copy + Zero + One,
[src]
T: Scalar + Clone + Copy + Zero + One,
pub fn new_row_random(n: usize) -> Self
[src]
Returns a row vector initialized with random numbers
Example
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
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(self) -> Self
[src]
Returns the transposed vector
Example
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
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
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
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
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>
[src]
impl<T> Vector<T>
[src]
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
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
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
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
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> Sign for Vector<T> where
T: Real,
[src]
T: Real,
impl Discrete<Vector<u32>, Vector<f64>> for Multinomial
[src]
fn pmf<'a>(&'a self, x: Vector<u32>) -> f64
[src]
Probability mass function
Arguments
x
Random variable x &isin ࡃ
Example
use mathru::*; use mathru::statistics::distrib::{Discrete, Multinomial}; use mathru::algebra::linear::Vector; let p: Vector<f64> = vector![0.3; 0.7]; let distrib: Multinomial = Multinomial::new(p); let x: Vector<u32> = vector![1; 2]; let p: f64 = distrib.pmf(x);
fn cdf<'a>(&'a self, _x: Vector<f64>) -> f64
[src]
Cumulative distribution function
Arguments
x
Random variable
Example
use mathru::statistics::distrib::{Discrete, Binomial}; let distrib: Binomial = Binomial::new(&5, &0.3); let x: f64 = 0.4; let p: f64 = distrib.cdf(x);
fn mean<'a>(&'a self) -> f64
[src]
Expected value
Example
use mathru::statistics::distrib::{Discrete, Binomial}; let distrib: Binomial = Binomial::new(&5, &0.3); let mean: f64 = distrib.mean();
fn variance<'a>(&'a self) -> f64
[src]
Variance
Example
use mathru::statistics::distrib::{Discrete, Binomial}; let distrib: Binomial = Binomial::new(&5, &0.3); let var: f64 = distrib.variance();
impl<T> IntoIterator for Vector<T> where
T: Real,
[src]
T: Real,
type Item = T
The type of the elements being iterated over.
type IntoIter = VectorIntoIterator<T>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<T: Clone> Clone for Vector<T>
[src]
impl<T> PartialEq<Vector<T>> for Vector<T> where
T: Scalar,
[src]
T: Scalar,
fn eq<'a, 'b>(&'a self, other: &'b Self) -> bool
[src]
Compares if two vectors are equal
Example
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]
impl<T> Display for Vector<T> where
T: Display,
[src]
T: Display,
impl<T: Debug> Debug for 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
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
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> 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
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
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
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
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
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
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
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
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
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
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> Neg for Vector<T> where
T: Real,
[src]
T: Real,
type Output = Vector<T>
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
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
impl<T> Send for Vector<T> where
T: Send,
T: Send,
impl<T> Sync for Vector<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Vector<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Vector<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for Vector<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
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> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
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> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
fn vzip(self) -> V
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,