[][src]Struct mathru::algebra::linear::vector::vector::Vector

pub struct Vector<T> { /* fields omitted */ }

Implementations

impl<T> Vector<T>[src]

pub fn iter(&self) -> VectorIterator<'_, T>

Notable traits for VectorIterator<'a, T>

impl<'a, T> Iterator for VectorIterator<'a, T> where
    T: Field + Scalar
type Item = &'a T;
[src]

pub fn iter_mut(&mut self) -> VectorIteratorMut<'_, T>

Notable traits for VectorIteratorMut<'a, T>

impl<'a, T> Iterator for VectorIteratorMut<'a, T> where
    T: Field + Scalar
type Item = &'a mut T;
[src]

impl<T> Vector<T> where
    T: Field + Scalar + Power
[src]

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

Computes the p norm

Arguments

p >= 1.0

Panics

p < 1.0

Example

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>[src]

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

impl<T> Vector<T> where
    T: Field + Scalar + Power + Exponential
[src]

pub fn eucl_norm(&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
[src]

pub fn new_row(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
[src]

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: Field + Scalar
[src]

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: Field + Scalar
[src]

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: Field + Scalar
[src]

pub fn dyadp(&self, rhs: &Self) -> Matrix<T>[src]

Computes the dyadic product of two vectors

Example

use mathru::algebra::linear::{Matrix, Vector};

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]

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

Returns the mutual component

Arguments

Panics

if i out of bounds

Example

use mathru::algebra::linear::Vector;

let mut a: Vector<f64> = Vector::new_row(4, vec![1.0, 0.0, 3.0, -2.0]);

*a.get_mut(1) = -4.0;

impl<T> Vector<T>[src]

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

Returns the component

Panics

if i out of bounds

Example

use mathru::algebra::linear::Vector;

let mut a: Vector<f64> = Vector::new_row(4, vec![1.0, 0.0, 3.0, -2.0]);

assert_eq!(-2.0, *a.get_mut(3))

impl<T> Vector<T> where
    T: Field + Scalar + Power
[src]

pub fn reflector(&self) -> Vector<T>[src]

impl<T> Vector<T> where
    T: Field + Scalar
[src]

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> where
    T: Field + Scalar
[src]

pub fn one(m: usize) -> Self[src]

Returns the one vector

Example

use mathru::algebra::linear::Vector;

let a: Vector<f64> = Vector::new_column(4, vec![1.0, 1.0, 1.0, 1.0]);
let b: Vector<f64> = Vector::one(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: Field + Scalar
[src]

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);

impl<T> Vector<T> where
    T: Field + Scalar
[src]

pub fn compare_neighbourhood(&self, b: &Self, epsilon: T) -> bool[src]

Trait Implementations

impl AbsDiffEq<Vector<f32>> for Vector<f32>[src]

type Epsilon = f32

Used for specifying relative comparisons.

impl AbsDiffEq<Vector<f64>> for Vector<f64>[src]

type Epsilon = f64

Used for specifying relative comparisons.

impl<'a, T, '_> Add<&'_ T> for &'a Vector<T> where
    T: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the + operator.

pub 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: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the + operator.

pub 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> Add<T> for Vector<T> where
    T: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the + operator.

pub 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<T> Add<Vector<T>> for Vector<T> where
    T: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the + operator.

pub 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: Clone> Clone for Vector<T>[src]

impl<T: Debug> Debug for Vector<T>[src]

impl<'de, T> Deserialize<'de> for Vector<T> where
    T: Deserialize<'de>, 
[src]

impl<T> Display for Vector<T> where
    T: Display
[src]

impl<'a, T, '_> Div<&'_ T> for &'a Vector<T> where
    T: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the / operator.

pub 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> Div<T> for Vector<T> where
    T: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the / operator.

pub 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<T> From<Vector<T>> for Matrix<T> where
    T: Field + Scalar
[src]

impl<T> IntoIterator for Vector<T> where
    T: Field + Scalar
[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = VectorIntoIterator<T>

Which kind of iterator are we turning this into?

impl<'a, T, '_> Mul<&'_ T> for &'a Vector<T> where
    T: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the * operator.

pub 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<'a, 'b, T> Mul<&'b Matrix<T>> for &'a Vector<T> where
    T: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the * operator.

impl<'a, 'b, T> Mul<&'b Vector<T>> for &'a Matrix<T> where
    T: Field + Scalar
[src]

Multiplies matrix by vector.

type Output = Vector<T>

The resulting type after applying the * operator.

impl<T> Mul<Matrix<T>> for Vector<T> where
    T: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the * operator.

impl<T> Mul<T> for Vector<T> where
    T: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the * operator.

pub 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<T> Mul<Vector<T>> for Matrix<T> where
    T: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the * operator.

impl<T> Neg for Vector<T> where
    T: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the - operator.

impl<T> PartialEq<Vector<T>> for Vector<T> where
    T: Scalar
[src]

pub fn eq(&self, other: &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))

impl RelativeEq<Vector<f32>> for Vector<f32>[src]

pub fn relative_eq(
    &self,
    other: &Vector<f32>,
    epsilon: Self::Epsilon,
    max_relative: Self::Epsilon
) -> bool
[src]

A test for equality that uses a relative comparison if the values are far apart.

impl RelativeEq<Vector<f64>> for Vector<f64>[src]

pub fn relative_eq(
    &self,
    other: &Vector<f64>,
    epsilon: Self::Epsilon,
    max_relative: Self::Epsilon
) -> bool
[src]

A test for equality that uses a relative comparison if the values are far apart.

impl<T> Serialize for Vector<T> where
    T: Serialize
[src]

impl<T> Sign for Vector<T> where
    T: Field + Scalar
[src]

impl<T> Solve<Vector<T>> for LUDec<T> where
    T: Field + Scalar
[src]

pub fn solve(&self, rhs: &Vector<T>) -> Result<Vector<T>, ()>[src]

Solves Ax = y where A \in R^{m * n}, x \in R^n, y \in R^m

impl<T> Solve<Vector<T>> for Matrix<T> where
    T: Field + Scalar
[src]

pub fn solve(&self, rhs: &Vector<T>) -> Result<Vector<T>, ()>[src]

Solves Ax = y where A \in R^{m * n}, x \in R^n, y \in R^m

impl<'a, T, '_> Sub<&'_ T> for &'a Vector<T> where
    T: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the - operator.

pub 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<'a, 'b, T> Sub<&'b Vector<T>> for &'a Vector<T> where
    T: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the - operator.

pub 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> Sub<T> for Vector<T> where
    T: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the - operator.

pub 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<T> Sub<Vector<T>> for Vector<T> where
    T: Field + Scalar
[src]

type Output = Vector<T>

The resulting type after applying the - operator.

pub 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<T> Substitute<Vector<T>> for Matrix<T> where
    T: Field + Scalar
[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Vector<T> where
    T: RefUnwindSafe

impl<T> Send for Vector<T> where
    T: Send

impl<T> Sync for Vector<T> where
    T: Sync

impl<T> Unpin for Vector<T> where
    T: Unpin

impl<T> UnwindSafe for Vector<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,