Struct rusty_machine::linalg::vector::Vector
[−]
[src]
pub struct Vector<T> { pub size: usize, pub data: Vec<T>, }
The Vector struct.
Can be instantiated with any type.
Fields
size: usize
data: Vec<T>
Methods
impl<T: Zero + One + Copy> Vector<T>
[src]
fn new(data: Vec<T>) -> Vector<T>
Constructor for Vector struct.
Requires the vector data.
Examples
use rusty_machine::linalg::vector::Vector; let vec = Vector::new(vec![1.0,2.0,3.0,4.0]);
fn zeros(size: usize) -> Vector<T>
Constructs Vector of all zeros.
Requires the size of the vector.
Examples
use rusty_machine::linalg::vector::Vector; let vec = Vector::<f64>::zeros(10);
fn ones(size: usize) -> Vector<T>
Constructs Vector of all ones.
Requires the size of the vector.
Examples
use rusty_machine::linalg::vector::Vector; let vec = Vector::<f64>::ones(10);
impl<T: Copy + One + Zero + Mul<T, Output=T> + Add<T, Output=T>> Vector<T>
[src]
fn dot(&self, v: &Vector<T>) -> T
Compute dot product with specified Vector.
Examples
use rusty_machine::linalg::vector::Vector; let a = Vector::new(vec![1.0,2.0,3.0,4.0]); let b = Vector::new(vec![2.0; 4]); let c = a.dot(&b); assert_eq!(c, 20.0);
impl<T: Copy + Zero + Add<T, Output=T>> Vector<T>
[src]
fn sum(&self) -> T
The sum of the vector.
Returns the sum of all elements in the vector.
Examples
use rusty_machine::linalg::vector::Vector; let a = Vector::new(vec![1.0,2.0,3.0,4.0]); let c = a.sum(); assert_eq!(c, 10.0);
impl<T: Copy + Zero + Add<T, Output=T> + Div<T, Output=T> + FromPrimitive> Vector<T>
[src]
fn mean(&self) -> T
The mean of the vector.
Returns the arithmetic mean of the vector.
Examples
use rusty_machine::linalg::vector::Vector; let a = Vector::<f32>::new(vec![1.0,2.0,3.0,4.0]); let c = a.mean(); assert_eq!(c, 2.5);
Trait Implementations
impl<T: Copy + One + Zero + Mul<T, Output=T>> Mul<T> for Vector<T>
[src]
Multiplies vector by scalar.
type Output = Vector<T>
The resulting type after applying the *
operator
fn mul(self, f: T) -> Vector<T>
The method for the *
operator
impl<'a, T: Copy + One + Zero + Mul<T, Output=T>> Mul<T> for &'a Vector<T>
[src]
Multiplies vector by scalar.
type Output = Vector<T>
The resulting type after applying the *
operator
fn mul(self, f: T) -> Vector<T>
The method for the *
operator
impl<'a, T: Copy + One + Zero + Mul<T, Output=T>> Mul<&'a T> for Vector<T>
[src]
Multiplies vector by scalar.
type Output = Vector<T>
The resulting type after applying the *
operator
fn mul(self, f: &T) -> Vector<T>
The method for the *
operator
impl<'a, 'b, T: Copy + One + Zero + Mul<T, Output=T>> Mul<&'b T> for &'a Vector<T>
[src]
Multiplies vector by scalar.
type Output = Vector<T>
The resulting type after applying the *
operator
fn mul(self, f: &T) -> Vector<T>
The method for the *
operator
impl<T: Copy + One + Zero + PartialEq + Div<T, Output=T>> Div<T> for Vector<T>
[src]
Divides vector by scalar.
type Output = Vector<T>
The resulting type after applying the /
operator
fn div(self, f: T) -> Vector<T>
The method for the /
operator
impl<'a, T: Copy + One + Zero + PartialEq + Div<T, Output=T>> Div<T> for &'a Vector<T>
[src]
Divides vector by scalar.
type Output = Vector<T>
The resulting type after applying the /
operator
fn div(self, f: T) -> Vector<T>
The method for the /
operator
impl<'a, T: Copy + One + Zero + PartialEq + Div<T, Output=T>> Div<&'a T> for Vector<T>
[src]
Divides vector by scalar.
type Output = Vector<T>
The resulting type after applying the /
operator
fn div(self, f: &T) -> Vector<T>
The method for the /
operator
impl<'a, 'b, T: Copy + One + Zero + PartialEq + Div<T, Output=T>> Div<&'b T> for &'a Vector<T>
[src]
Divides vector by scalar.
type Output = Vector<T>
The resulting type after applying the /
operator
fn div(self, f: &T) -> Vector<T>
The method for the /
operator
impl<T: Copy + One + Zero + Add<T, Output=T>> Add<T> for Vector<T>
[src]
Adds scalar to vector.
type Output = Vector<T>
The resulting type after applying the +
operator
fn add(self, f: T) -> Vector<T>
The method for the +
operator
impl<'a, T: Copy + One + Zero + Add<T, Output=T>> Add<T> for &'a Vector<T>
[src]
Adds scalar to vector.
type Output = Vector<T>
The resulting type after applying the +
operator
fn add(self, f: T) -> Vector<T>
The method for the +
operator
impl<'a, T: Copy + One + Zero + Add<T, Output=T>> Add<&'a T> for Vector<T>
[src]
Adds scalar to vector.
type Output = Vector<T>
The resulting type after applying the +
operator
fn add(self, f: &T) -> Vector<T>
The method for the +
operator
impl<'a, 'b, T: Copy + One + Zero + Add<T, Output=T>> Add<&'b T> for &'a Vector<T>
[src]
Adds scalar to vector.
type Output = Vector<T>
The resulting type after applying the +
operator
fn add(self, f: &T) -> Vector<T>
The method for the +
operator
impl<T: Copy + One + Zero + Add<T, Output=T>> Add<Vector<T>> for Vector<T>
[src]
Adds vector to vector.
type Output = Vector<T>
The resulting type after applying the +
operator
fn add(self, v: Vector<T>) -> Vector<T>
The method for the +
operator
impl<'a, T: Copy + One + Zero + Add<T, Output=T>> Add<Vector<T>> for &'a Vector<T>
[src]
Adds vector to vector.
type Output = Vector<T>
The resulting type after applying the +
operator
fn add(self, v: Vector<T>) -> Vector<T>
The method for the +
operator
impl<'a, T: Copy + One + Zero + Add<T, Output=T>> Add<&'a Vector<T>> for Vector<T>
[src]
Adds vector to vector.
type Output = Vector<T>
The resulting type after applying the +
operator
fn add(self, v: &Vector<T>) -> Vector<T>
The method for the +
operator
impl<'a, 'b, T: Copy + One + Zero + Add<T, Output=T>> Add<&'b Vector<T>> for &'a Vector<T>
[src]
Adds vector to vector.
type Output = Vector<T>
The resulting type after applying the +
operator
fn add(self, v: &Vector<T>) -> Vector<T>
The method for the +
operator
impl<T: Copy + One + Zero + Sub<T, Output=T>> Sub<T> for Vector<T>
[src]
Subtracts scalar from vector.
type Output = Vector<T>
The resulting type after applying the -
operator
fn sub(self, f: T) -> Vector<T>
The method for the -
operator
impl<'a, T: Copy + One + Zero + Sub<T, Output=T>> Sub<T> for &'a Vector<T>
[src]
Subtracts scalar from vector.
type Output = Vector<T>
The resulting type after applying the -
operator
fn sub(self, f: T) -> Vector<T>
The method for the -
operator
impl<'a, T: Copy + One + Zero + Sub<T, Output=T>> Sub<&'a T> for Vector<T>
[src]
Subtracts scalar from vector.
type Output = Vector<T>
The resulting type after applying the -
operator
fn sub(self, f: &T) -> Vector<T>
The method for the -
operator
impl<'a, 'b, T: Copy + One + Zero + Sub<T, Output=T>> Sub<&'b T> for &'a Vector<T>
[src]
Subtracts scalar from vector.
type Output = Vector<T>
The resulting type after applying the -
operator
fn sub(self, f: &T) -> Vector<T>
The method for the -
operator
impl<T: Copy + One + Zero + Sub<T, Output=T>> Sub<Vector<T>> for Vector<T>
[src]
Subtracts vector from vector.
type Output = Vector<T>
The resulting type after applying the -
operator
fn sub(self, v: Vector<T>) -> Vector<T>
The method for the -
operator
impl<'a, T: Copy + One + Zero + Sub<T, Output=T>> Sub<Vector<T>> for &'a Vector<T>
[src]
Subtracts vector from vector.
type Output = Vector<T>
The resulting type after applying the -
operator
fn sub(self, v: Vector<T>) -> Vector<T>
The method for the -
operator
impl<'a, T: Copy + One + Zero + Sub<T, Output=T>> Sub<&'a Vector<T>> for Vector<T>
[src]
Subtracts vector from vector.
type Output = Vector<T>
The resulting type after applying the -
operator
fn sub(self, v: &Vector<T>) -> Vector<T>
The method for the -
operator
impl<'a, 'b, T: Copy + One + Zero + Sub<T, Output=T>> Sub<&'b Vector<T>> for &'a Vector<T>
[src]
Subtracts vector from vector.
type Output = Vector<T>
The resulting type after applying the -
operator
fn sub(self, v: &Vector<T>) -> Vector<T>
The method for the -
operator
impl<T> Index<usize> for Vector<T>
[src]
Indexes vector.
type Output = T
The returned type after indexing
fn index(&self, idx: usize) -> &T
The method for the indexing (Foo[Bar]
) operation