pub struct Vector<T> { /* private fields */ }
Expand description

The Vector struct.

Can be instantiated with any type.

Implementations

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

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

Returns the size of the Vector.

Returns a non-mutable reference to the underlying data.

Returns a mutable slice of the underlying data.

Consumes the Vector and returns the Vec of data.

Returns an iterator over the Vector’s data.

Returns an iterator over mutable references to the Vector’s data.

Returns a pointer to the element at the given index, without doing bounds checking.

Returns an unsafe mutable pointer to the element at the given index, without doing bounds checking.

Applies a function to each element in the vector.

Examples
use rulinalg::vector::Vector;
fn add_two(a: f64) -> f64 {
    a + 2f64
}

let a = vector![0.; 4];

let b = a.apply(&add_two);

assert_eq!(b, vector![2.0; 4]);

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

Find the argmin of the Vector.

Returns the index of the smallest value in the vector.

Examples
use rulinalg::vector::Vector;

let a = vector![1.0, 2.0, 0.0, 5.0];
let b = a.argmin();
assert_eq!(b.0, 2);
assert_eq!(b.1, 0.0);

Select elements from the Vector and form a new Vector from them.

Examples
use rulinalg::vector::Vector;

let a = vector![1.0, 2.0, 3.0, 4.0, 5.0];

let a_lower = a.select(&[2, 3, 4]);

// Prints [3,4,5]
assert_eq!(a_lower, vector![3.0, 4.0, 5.0]);

Constructs Vector of all zeros.

Requires the size of the vector.

Examples
use rulinalg::vector::Vector;

let vec = Vector::<f64>::zeros(10);

Constructs Vector of all ones.

Requires the size of the vector.

Examples
use rulinalg::vector::Vector;

let vec = Vector::<f64>::ones(10);

Compute dot product with specified Vector.

Examples
use rulinalg::vector::Vector;

let a = vector![1.0, 2.0, 3.0, 4.0];
let b = vector![2.0; 4];

let c = a.dot(&b);
assert_eq!(c, 20.0);

The sum of the vector.

Returns the sum of all elements in the vector.

Examples
use rulinalg::vector::Vector;

let a = vector![1.0, 2.0, 3.0, 4.0];

let c = a.sum();
assert_eq!(c, 10.0);

The elementwise product of two vectors.

Examples
use rulinalg::vector::Vector;

let a = vector![1.0, 2.0, 3.0, 4.0];
let b = vector![1.0, 2.0, 3.0, 4.0];

let c = &a.elemul(&b);
assert_eq!(c, &vector![1.0, 4.0, 9.0, 16.0]);

The elementwise division of two vectors.

Examples
use rulinalg::vector::Vector;

let a = vector![1.0, 2.0, 3.0, 4.0];
let b = vector![1.0, 2.0, 3.0, 4.0];

let c = &a.elediv(&b);
assert_eq!(c, &vector![1.0; 4]);

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

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

The mean of the vector.

Returns the arithmetic mean of the vector.

Examples
use rulinalg::vector::Vector;

let a = vector![1.0, 2.0, 3.0, 4.0];

let c = a.mean();
assert_eq!(c, 2.5);

The variance of the vector.

Returns the unbiased sample variance of the vector.

Examples
use rulinalg::vector::Vector;

let a = vector![1.0, 2.0, 3.0, 4.0];

let c = a.variance();
assert_eq!(c, 5.0 / 3.0);

Trait Implementations

Scalar addition with Vector reusing current memory.

The resulting type after applying the + operator.
Performs the + operation. Read more

Vector addition with Vector reusing current memory.

The resulting type after applying the + operator.
Performs the + operation. Read more

Scalar addition with Vector allocating new memory.

The resulting type after applying the + operator.
Performs the + operation. Read more

Vector addition with Vector allocating new memory.

The resulting type after applying the + operator.
Performs the + operation. Read more

Scalar addition with Vector allocating new memory.

The resulting type after applying the + operator.
Performs the + operation. Read more

Scalar addition with Vector reusing current memory.

The resulting type after applying the + operator.
Performs the + operation. Read more

Vector addition with Vector reusing current memory.

The resulting type after applying the + operator.
Performs the + operation. Read more

Vector addition with Vector reusing current memory.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs addition assignment between a vector and a scalar.

Performs the += operation. Read more

Performs elementwise addition assignment between two vectors.

Performs the += operation. Read more

Performs addition assignment between a vector and a scalar.

Performs the += operation. Read more

Performs elementwise addition assignment between two vectors.

Performs the += operation. Read more

Scalar bitwise-and with Vector reusing current memory.

The resulting type after applying the & operator.
Performs the & operation. Read more

Vector bitwise-and with Vector reusing current memory.

The resulting type after applying the & operator.
Performs the & operation. Read more

Scalar bitwise-and with Vector allocating new memory.

The resulting type after applying the & operator.
Performs the & operation. Read more

Vector bitwise-and with Vector allocating new memory.

The resulting type after applying the & operator.
Performs the & operation. Read more

Scalar bitwise-and with Vector allocating new memory.

The resulting type after applying the & operator.
Performs the & operation. Read more

Scalar bitwise-and with Vector reusing current memory.

The resulting type after applying the & operator.
Performs the & operation. Read more

Vector bitwise-and with Vector reusing current memory.

The resulting type after applying the & operator.
Performs the & operation. Read more

Vector bitwise-and with Vector reusing current memory.

The resulting type after applying the & operator.
Performs the & operation. Read more

Performs bitwise-and assignment between a vector and a scalar.

Performs the &= operation. Read more

Performs elementwise bitwise-and assignment between two vectors.

Performs the &= operation. Read more

Performs bitwise-and assignment between a vector and a scalar.

Performs the &= operation. Read more

Performs elementwise bitwise-and assignment between two vectors.

Performs the &= operation. Read more

Scalar bitwise-or with Vector reusing current memory.

The resulting type after applying the | operator.
Performs the | operation. Read more

Vector bitwise-or with Vector reusing current memory.

The resulting type after applying the | operator.
Performs the | operation. Read more

Scalar bitwise-or with Vector allocating new memory.

The resulting type after applying the | operator.
Performs the | operation. Read more

Vector bitwise-or with Vector allocating new memory.

The resulting type after applying the | operator.
Performs the | operation. Read more

Scalar bitwise-or with Vector allocating new memory.

The resulting type after applying the | operator.
Performs the | operation. Read more

Scalar bitwise-or with Vector reusing current memory.

The resulting type after applying the | operator.
Performs the | operation. Read more

Vector bitwise-or with Vector reusing current memory.

The resulting type after applying the | operator.
Performs the | operation. Read more

Vector bitwise-or with Vector reusing current memory.

The resulting type after applying the | operator.
Performs the | operation. Read more

Performs bitwise-or assignment between a vector and a scalar.

Performs the |= operation. Read more

Performs elementwise bitwise-or assignment between two vectors.

Performs the |= operation. Read more

Performs bitwise-or assignment between a vector and a scalar.

Performs the |= operation. Read more

Performs elementwise bitwise-or assignment between two vectors.

Performs the |= operation. Read more

Scalar bitwise-xor with Vector reusing current memory.

The resulting type after applying the ^ operator.
Performs the ^ operation. Read more

Vector bitwise-xor with Vector reusing current memory.

The resulting type after applying the ^ operator.
Performs the ^ operation. Read more

Scalar bitwise-xor with Vector allocating new memory.

The resulting type after applying the ^ operator.
Performs the ^ operation. Read more

Vector bitwise-xor with Vector allocating new memory.

The resulting type after applying the ^ operator.
Performs the ^ operation. Read more

Scalar bitwise-xor with Vector allocating new memory.

The resulting type after applying the ^ operator.
Performs the ^ operation. Read more

Scalar bitwise-xor with Vector reusing current memory.

The resulting type after applying the ^ operator.
Performs the ^ operation. Read more

Vector bitwise-xor with Vector reusing current memory.

The resulting type after applying the ^ operator.
Performs the ^ operation. Read more

Vector bitwise-xor with Vector reusing current memory.

The resulting type after applying the ^ operator.
Performs the ^ operation. Read more

Performs bitwise-xor assignment between a vector and a scalar.

Performs the ^= operation. Read more

Performs elementwise bitwise-xor assignment between two vectors.

Performs the ^= operation. Read more

Performs bitwise-xor assignment between a vector and a scalar.

Performs the ^= operation. Read more

Performs elementwise bitwise-xor assignment between two vectors.

Performs the ^= operation. Read more

Clones the Vector.

Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Displays the Vector.

Scalar division with Vector reusing current memory.

The resulting type after applying the / operator.
Performs the / operation. Read more

Scalar division with Vector allocating new memory.

The resulting type after applying the / operator.
Performs the / operation. Read more

Scalar division with Vector allocating new memory.

The resulting type after applying the / operator.
Performs the / operation. Read more

Scalar division with Vector reusing current memory.

The resulting type after applying the / operator.
Performs the / operation. Read more

Performs division assignment between a vector and a scalar.

Performs the /= operation. Read more

Performs division assignment between a vector and a scalar.

Performs the /= operation. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Creates a value from an iterator. Read more
Feeds this value into the given [Hasher]. Read more
Feeds a slice of this type into the given [Hasher]. Read more

Indexes vector.

The returned type after indexing.
Performs the indexing (container[index]) operation. Read more

Indexes mutable vector.

Performs the mutable indexing (container[index]) operation. Read more
Converts this type into the (usually inferred) input type.
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more

Scalar multiplication with Vector reusing current memory.

The resulting type after applying the * operator.
Performs the * operation. Read more

Left-multiply a vector by a permutation matrix.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies matrix by vector.

The resulting type after applying the * operator.
Performs the * operation. Read more

Left-multiply a vector by a permutation matrix.

The resulting type after applying the * operator.
Performs the * operation. Read more

Scalar multiplication with Vector allocating new memory.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies matrix by vector.

The resulting type after applying the * operator.
Performs the * operation. Read more

Scalar multiplication with Vector allocating new memory.

The resulting type after applying the * operator.
Performs the * operation. Read more

Scalar multiplication with Vector reusing current memory.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies matrix by vector.

The resulting type after applying the * operator.
Performs the * operation. Read more

Left-multiply a vector by a permutation matrix.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies matrix by vector.

The resulting type after applying the * operator.
Performs the * operation. Read more

Left-multiply a vector by a permutation matrix.

The resulting type after applying the * operator.
Performs the * operation. Read more

Performs multiplication assignment between a vector and a scalar.

Performs the *= operation. Read more

Performs multiplication assignment between a vector and a scalar.

Performs the *= operation. Read more

Gets negative of vector.

The resulting type after applying the - operator.
Performs the unary - operation. Read more

Gets negative of vector.

The resulting type after applying the - operator.
Performs the unary - operation. Read more

Gets not of vector.

The resulting type after applying the ! operator.
Performs the unary ! operation. Read more

Gets not of vector.

The resulting type after applying the ! operator.
Performs the unary ! operation. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Scalar remainder with Vector reusing current memory.

The resulting type after applying the % operator.
Performs the % operation. Read more

Vector remainder with Vector reusing current memory.

The resulting type after applying the % operator.
Performs the % operation. Read more

Scalar remainder with Vector allocating new memory.

The resulting type after applying the % operator.
Performs the % operation. Read more

Vector remainder with Vector allocating new memory.

The resulting type after applying the % operator.
Performs the % operation. Read more

Scalar remainder with Vector allocating new memory.

The resulting type after applying the % operator.
Performs the % operation. Read more

Scalar remainder with Vector reusing current memory.

The resulting type after applying the % operator.
Performs the % operation. Read more

Vector remainder with Vector reusing current memory.

The resulting type after applying the % operator.
Performs the % operation. Read more

Vector remainder with Vector reusing current memory.

The resulting type after applying the % operator.
Performs the % operation. Read more

Performs reminder assignment between a vector and a scalar.

Performs the %= operation. Read more

Performs elementwise remainder assignment between two vectors.

Performs the %= operation. Read more

Performs reminder assignment between a vector and a scalar.

Performs the %= operation. Read more

Performs elementwise remainder assignment between two vectors.

Performs the %= operation. Read more

Scalar subtraction with Vector reusing current memory.

The resulting type after applying the - operator.
Performs the - operation. Read more

Vector subtraction with Vector reusing current memory.

The resulting type after applying the - operator.
Performs the - operation. Read more

Scalar subtraction with Vector allocating new memory.

The resulting type after applying the - operator.
Performs the - operation. Read more

Vector subtraction with Vector allocating new memory.

The resulting type after applying the - operator.
Performs the - operation. Read more

Scalar subtraction with Vector allocating new memory.

The resulting type after applying the - operator.
Performs the - operation. Read more

Scalar subtraction with Vector reusing current memory.

The resulting type after applying the - operator.
Performs the - operation. Read more

Vector subtraction with Vector reusing current memory.

The resulting type after applying the - operator.
Performs the - operation. Read more

Vector subtraction with Vector reusing current memory.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs subtraction assignment between a vector and a scalar.

Performs the -= operation. Read more

Performs elementwise subtraction assignment between two vectors.

Performs the -= operation. Read more

Performs subtraction assignment between a vector and a scalar.

Performs the -= operation. Read more

Performs elementwise subtraction assignment between two vectors.

Performs the -= operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.