Trait VectorOps

Source
pub trait VectorOps<T> {
    // Required methods
    fn add_vec(&self, other: &Vector<T>) -> Vector<T>;
    fn sub_vec(&self, other: &Vector<T>) -> Vector<T>;
    fn mul_vec(&self, other: &Vector<T>) -> Vector<T>;
    fn div_vec(&self, other: &Vector<T>) -> Vector<T>;
    fn rem_vec(&self, other: &Vector<T>) -> Vector<T>;
    fn add_scalar(&self, scalar: T) -> Vector<T>;
    fn sub_scalar(&self, scalar: T) -> Vector<T>;
    fn mul_scalar(&self, scalar: T) -> Vector<T>;
    fn div_scalar(&self, scalar: T) -> Vector<T>;
    fn rem_scalar(&self, scalar: T) -> Vector<T>;
}
Expand description

Trait providing arithmetic operations for Vector<T>.

Required Methods§

Source

fn add_vec(&self, other: &Vector<T>) -> Vector<T>

Adds another vector to this vector and returns a new vector.

Source

fn sub_vec(&self, other: &Vector<T>) -> Vector<T>

Subtracts another vector from this vector and returns a new vector.

Source

fn mul_vec(&self, other: &Vector<T>) -> Vector<T>

Multiplies this vector with another vector element-wise and returns a new vector.

Source

fn div_vec(&self, other: &Vector<T>) -> Vector<T>

Divides this vector by another vector element-wise and returns a new vector.

Source

fn rem_vec(&self, other: &Vector<T>) -> Vector<T>

Computes the modulus of this vector by another vector element-wise and returns a new vector.

Source

fn add_scalar(&self, scalar: T) -> Vector<T>

Adds a scalar to each element of the vector and returns a new vector.

Source

fn sub_scalar(&self, scalar: T) -> Vector<T>

Subtracts a scalar from each element of the vector and returns a new vector.

Source

fn mul_scalar(&self, scalar: T) -> Vector<T>

Multiplies each element of the vector by a scalar and returns a new vector.

Source

fn div_scalar(&self, scalar: T) -> Vector<T>

Divides each element of the vector by a scalar and returns a new vector.

Source

fn rem_scalar(&self, scalar: T) -> Vector<T>

Computes the modulus of each element of the vector by a scalar and returns a new vector.

Implementors§

Source§

impl<T> VectorOps<T> for Vector<T>
where T: Num + Copy + PartialOrd + Float,