Struct libmat::mat::Vector[]

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

Represents a vector.

Implementations

Trait Implementations

Vectors can be added by adding their references.

Example

let vec_a = vector![1, 2, 3];
let vec_b = vector![3, 2, 1];
assert_eq!(&vec_a + &vec_b, Vector::new(3, 4));

The resulting type after applying the + operator.

Performs the + operation. Read more

Performs the += operation. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Dividing a vector by a number is the same a multiplying by its inverse.

Example

let vec_a = Vector::new(3, 1_f32);
assert_eq!(&vec_a / 2.0, Vector::new(3, 0.5));

The resulting type after applying the / operator.

Performs the / operation. Read more

Performs the conversion.

Performs the conversion.

Indexing a vectors returns the corresponding entry.

Example

let vec_a = vector![1, 2, 3];
assert_eq!(vec_a[0], 1);
assert_eq!(vec_a[1], 2);
assert_eq!(vec_a[2], 3);

The returned type after indexing.

Performs the indexing (container[index]) operation. Read more

Single entries of a vector can be manipulated by mutating an indexed vector.

Example

let mut vec_a = Vector::new(3, 1);
vec_a[1] = 2;
vec_a[2] = 3;
assert_eq!(vec_a[0], 1);
assert_eq!(vec_a[1], 2);
assert_eq!(vec_a[2], 3);
assert_eq!(vec_a, vector![1, 2, 3]);

Performs the mutable indexing (container[index]) operation. Read more

Performs the conversion.

Vectors can also be multiplied with matrices. The result will be a vector.

Example

let mat_a = Matrix::<u32>::one(4);
let mat_b = matrix!{1, 2, 3; 4, 4, 3; 2, 1, 3; 4, 1, 2};
let vec_a = vector![4, 5, 6, 7].to_row_vector();
let vec_b = vector![64, 41, 59].to_row_vector();
assert_eq!(&vec_a * &mat_a, vec_a);
assert_eq!(&vec_a * &mat_b, vec_b);

The resulting type after applying the * operator.

Performs the * operation. Read more

Matrices can be multiplied with Vectors by multiplying their references. The dimensions of the two objects need to match like with matrix multiplication.

Example

let v_a = vector![1, 2, 3];
let mat_a = matrix!{1, 2, 3; 4, 5, 6; 7, 8, 9};
let v_b = vector![30, 36, 42].to_row_vector();
assert_eq!(&v_a.to_row_vector() * &mat_a, v_b);

The resulting type after applying the * operator.

Performs the * operation. Read more

Vectors can be multpilied by multiplying their references.

Example

let vec_a = Vector::new(4, 3);
let vec_b = vector![5, 6, 7, 8];
assert_eq!(&vec_a * &vec_b, 78);
assert_eq!(&vec_b * &vec_a, 78);

The resulting type after applying the * operator.

Performs the * operation. Read more

Vectors can be scaled by scaling a reference to a vector.

Example

let vec_a = Vector::new(3, 1);
assert_eq!(&vec_a * 2, Vector::new(3, 2));

The resulting type after applying the * operator.

Performs the * operation. Read more

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 !=.

Vectors can be subtracted by subtracting theri references.

Example

let vec_a = vector![1_i32, 2, 3];
let vec_b = vector![3_i32, 2, 1];
assert_eq!(&vec_a - &vec_b, vector![-2, 0, 2]);

The resulting type after applying the - operator.

Performs the - operation. Read more

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. 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.