devela::num::alg

Struct Vector

Source
#[repr(transparent)]
pub struct Vector<T, const D: usize> { pub coords: [T; D], }
Available on crate feature alg only.
Expand description

A static D-dimensional vector, backed by a primitive array.

Fields§

§coords: [T; D]

The vector coordinates in some basis.

Implementations§

Source§

impl<T, const D: usize> Vector<T, D>

Source

pub const fn new(coords: [T; D]) -> Self

Returns a new Vector from the given coords array.

Source§

impl<const D: usize> Vector<i8, D>

§Methods for vectors represented using i8.

Source

pub const ONE: Self

Available on crate feature _int_i8 only.

A Vector with all ones.

Source

pub const ZERO: Self

Available on crate feature _int_i8 only.

A Vector with all zeros.

Source

pub const fn c_normalize_with(self, magnitude: i8) -> Self

Available on crate feature _int_i8 only.

Returns the normalized vector, using the given vector magnitude.

$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$

Source

pub const fn c_magnitude_sq(self) -> i8

Available on crate feature _int_i8 only.

Calculates the magnitude of the vector (squared).

This is faster than calculating the magnitude, which is useful for comparisons.

§Formula

$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$

Source

pub const fn c_add(self, other: Self) -> Self

Available on crate feature _int_i8 only.

Adds two vectors together, in compile-time.

Source

pub const fn c_sub(self, other: Self) -> Self

Available on crate feature _int_i8 only.

Subtracts another vector from this vector, in compile-time.

Source

pub const fn c_dot(self, other: Self) -> i8

Available on crate feature _int_i8 only.

Computes the dot product of two vectors, in compile-time.

Source

pub const fn c_scalar_mul(self, scalar: i8) -> Self

Available on crate feature _int_i8 only.

Multiplies each element of the vector by a scalar, in compile-time.

Source

pub const fn c_scalar_div(self, scalar: i8) -> Self

Available on crate feature _int_i8 only.

Divides each element of the vector by a scalar, in compile-time.

Source§

impl Vector<i8, 3>

§Methods for 3d vectors represented using i8.

Source

pub const fn c_cross(self, other: Self) -> Self

Computes the cross product of two vectors.

That is the vector orthogonal to both vectors.

Also known as the exterior product or the vector product.

It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.

§Formula

$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$

Source§

impl<const D: usize> Vector<i8, D>

§Methods for vectors represented using i8, signed.

Source

pub const NEG_ONE: Self

Available on crate feature _int_i8 only.

A Vector with all negative ones.

Source

pub const fn c_magnitude_floor(self) -> i8

Available on crate feature _int_i8 only.

Calculates the floored magnitude of the vector.

It could underestimate the true magnitude.

§Features

This will only be const if the “_cmp_i8” feature is enabled.

Source

pub const fn c_magnitude_ceil(self) -> i8

Available on crate feature _int_i8 only.

Calculates the ceiled magnitude of the vector.

It could overestimate the true magnitude.

§Features

This will only be const if the “_cmp_i8” feature is enabled.

Source

pub const fn c_magnitude_round(self) -> i8

Available on crate feature _int_i8 only.

Calculates the rounded magnitude of the vector.

§Panics

Can panic if we reach a i128 value close to its maximum during operations.

Source§

impl<const D: usize> Vector<i16, D>

§Methods for vectors represented using i16.

Source

pub const ONE: Self

Available on crate feature _int_i16 only.

A Vector with all ones.

Source

pub const ZERO: Self

Available on crate feature _int_i16 only.

A Vector with all zeros.

Source

pub const fn c_normalize_with(self, magnitude: i16) -> Self

Available on crate feature _int_i16 only.

Returns the normalized vector, using the given vector magnitude.

$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$

Source

pub const fn c_magnitude_sq(self) -> i16

Available on crate feature _int_i16 only.

Calculates the magnitude of the vector (squared).

This is faster than calculating the magnitude, which is useful for comparisons.

§Formula

$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$

Source

pub const fn c_add(self, other: Self) -> Self

Available on crate feature _int_i16 only.

Adds two vectors together, in compile-time.

Source

pub const fn c_sub(self, other: Self) -> Self

Available on crate feature _int_i16 only.

Subtracts another vector from this vector, in compile-time.

Source

pub const fn c_dot(self, other: Self) -> i16

Available on crate feature _int_i16 only.

Computes the dot product of two vectors, in compile-time.

Source

pub const fn c_scalar_mul(self, scalar: i16) -> Self

Available on crate feature _int_i16 only.

Multiplies each element of the vector by a scalar, in compile-time.

Source

pub const fn c_scalar_div(self, scalar: i16) -> Self

Available on crate feature _int_i16 only.

Divides each element of the vector by a scalar, in compile-time.

Source§

impl Vector<i16, 3>

§Methods for 3d vectors represented using i16.

Source

pub const fn c_cross(self, other: Self) -> Self

Computes the cross product of two vectors.

That is the vector orthogonal to both vectors.

Also known as the exterior product or the vector product.

It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.

§Formula

$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$

Source§

impl<const D: usize> Vector<i16, D>

§Methods for vectors represented using i16, signed.

Source

pub const NEG_ONE: Self

Available on crate feature _int_i16 only.

A Vector with all negative ones.

Source

pub const fn c_magnitude_floor(self) -> i16

Available on crate feature _int_i16 only.

Calculates the floored magnitude of the vector.

It could underestimate the true magnitude.

§Features

This will only be const if the “_cmp_i16” feature is enabled.

Source

pub const fn c_magnitude_ceil(self) -> i16

Available on crate feature _int_i16 only.

Calculates the ceiled magnitude of the vector.

It could overestimate the true magnitude.

§Features

This will only be const if the “_cmp_i16” feature is enabled.

Source

pub const fn c_magnitude_round(self) -> i16

Available on crate feature _int_i16 only.

Calculates the rounded magnitude of the vector.

§Panics

Can panic if we reach a i128 value close to its maximum during operations.

Source§

impl<const D: usize> Vector<i32, D>

§Methods for vectors represented using i32.

Source

pub const ONE: Self

Available on crate feature _int_i32 only.

A Vector with all ones.

Source

pub const ZERO: Self

Available on crate feature _int_i32 only.

A Vector with all zeros.

Source

pub const fn c_normalize_with(self, magnitude: i32) -> Self

Available on crate feature _int_i32 only.

Returns the normalized vector, using the given vector magnitude.

$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$

Source

pub const fn c_magnitude_sq(self) -> i32

Available on crate feature _int_i32 only.

Calculates the magnitude of the vector (squared).

This is faster than calculating the magnitude, which is useful for comparisons.

§Formula

$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$

Source

pub const fn c_add(self, other: Self) -> Self

Available on crate feature _int_i32 only.

Adds two vectors together, in compile-time.

Source

pub const fn c_sub(self, other: Self) -> Self

Available on crate feature _int_i32 only.

Subtracts another vector from this vector, in compile-time.

Source

pub const fn c_dot(self, other: Self) -> i32

Available on crate feature _int_i32 only.

Computes the dot product of two vectors, in compile-time.

Source

pub const fn c_scalar_mul(self, scalar: i32) -> Self

Available on crate feature _int_i32 only.

Multiplies each element of the vector by a scalar, in compile-time.

Source

pub const fn c_scalar_div(self, scalar: i32) -> Self

Available on crate feature _int_i32 only.

Divides each element of the vector by a scalar, in compile-time.

Source§

impl Vector<i32, 3>

§Methods for 3d vectors represented using i32.

Source

pub const fn c_cross(self, other: Self) -> Self

Computes the cross product of two vectors.

That is the vector orthogonal to both vectors.

Also known as the exterior product or the vector product.

It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.

§Formula

$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$

Source§

impl<const D: usize> Vector<i32, D>

§Methods for vectors represented using i32, signed.

Source

pub const NEG_ONE: Self

Available on crate feature _int_i32 only.

A Vector with all negative ones.

Source

pub const fn c_magnitude_floor(self) -> i32

Available on crate feature _int_i32 only.

Calculates the floored magnitude of the vector.

It could underestimate the true magnitude.

§Features

This will only be const if the “_cmp_i32” feature is enabled.

Source

pub const fn c_magnitude_ceil(self) -> i32

Available on crate feature _int_i32 only.

Calculates the ceiled magnitude of the vector.

It could overestimate the true magnitude.

§Features

This will only be const if the “_cmp_i32” feature is enabled.

Source

pub const fn c_magnitude_round(self) -> i32

Available on crate feature _int_i32 only.

Calculates the rounded magnitude of the vector.

§Panics

Can panic if we reach a i128 value close to its maximum during operations.

Source§

impl<const D: usize> Vector<i64, D>

§Methods for vectors represented using i64.

Source

pub const ONE: Self

Available on crate feature _int_i64 only.

A Vector with all ones.

Source

pub const ZERO: Self

Available on crate feature _int_i64 only.

A Vector with all zeros.

Source

pub const fn c_normalize_with(self, magnitude: i64) -> Self

Available on crate feature _int_i64 only.

Returns the normalized vector, using the given vector magnitude.

$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$

Source

pub const fn c_magnitude_sq(self) -> i64

Available on crate feature _int_i64 only.

Calculates the magnitude of the vector (squared).

This is faster than calculating the magnitude, which is useful for comparisons.

§Formula

$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$

Source

pub const fn c_add(self, other: Self) -> Self

Available on crate feature _int_i64 only.

Adds two vectors together, in compile-time.

Source

pub const fn c_sub(self, other: Self) -> Self

Available on crate feature _int_i64 only.

Subtracts another vector from this vector, in compile-time.

Source

pub const fn c_dot(self, other: Self) -> i64

Available on crate feature _int_i64 only.

Computes the dot product of two vectors, in compile-time.

Source

pub const fn c_scalar_mul(self, scalar: i64) -> Self

Available on crate feature _int_i64 only.

Multiplies each element of the vector by a scalar, in compile-time.

Source

pub const fn c_scalar_div(self, scalar: i64) -> Self

Available on crate feature _int_i64 only.

Divides each element of the vector by a scalar, in compile-time.

Source§

impl Vector<i64, 3>

§Methods for 3d vectors represented using i64.

Source

pub const fn c_cross(self, other: Self) -> Self

Computes the cross product of two vectors.

That is the vector orthogonal to both vectors.

Also known as the exterior product or the vector product.

It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.

§Formula

$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$

Source§

impl<const D: usize> Vector<i64, D>

§Methods for vectors represented using i64, signed.

Source

pub const NEG_ONE: Self

Available on crate feature _int_i64 only.

A Vector with all negative ones.

Source

pub const fn c_magnitude_floor(self) -> i64

Available on crate feature _int_i64 only.

Calculates the floored magnitude of the vector.

It could underestimate the true magnitude.

§Features

This will only be const if the “_cmp_i64” feature is enabled.

Source

pub const fn c_magnitude_ceil(self) -> i64

Available on crate feature _int_i64 only.

Calculates the ceiled magnitude of the vector.

It could overestimate the true magnitude.

§Features

This will only be const if the “_cmp_i64” feature is enabled.

Source

pub const fn c_magnitude_round(self) -> i64

Available on crate feature _int_i64 only.

Calculates the rounded magnitude of the vector.

§Panics

Can panic if we reach a i128 value close to its maximum during operations.

Source§

impl<const D: usize> Vector<i128, D>

§Methods for vectors represented using i128.

Source

pub const ONE: Self

Available on crate feature _int_i128 only.

A Vector with all ones.

Source

pub const ZERO: Self

Available on crate feature _int_i128 only.

A Vector with all zeros.

Source

pub const fn c_normalize_with(self, magnitude: i128) -> Self

Available on crate feature _int_i128 only.

Returns the normalized vector, using the given vector magnitude.

$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$

Source

pub const fn c_magnitude_sq(self) -> i128

Available on crate feature _int_i128 only.

Calculates the magnitude of the vector (squared).

This is faster than calculating the magnitude, which is useful for comparisons.

§Formula

$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$

Source

pub const fn c_add(self, other: Self) -> Self

Available on crate feature _int_i128 only.

Adds two vectors together, in compile-time.

Source

pub const fn c_sub(self, other: Self) -> Self

Available on crate feature _int_i128 only.

Subtracts another vector from this vector, in compile-time.

Source

pub const fn c_dot(self, other: Self) -> i128

Available on crate feature _int_i128 only.

Computes the dot product of two vectors, in compile-time.

Source

pub const fn c_scalar_mul(self, scalar: i128) -> Self

Available on crate feature _int_i128 only.

Multiplies each element of the vector by a scalar, in compile-time.

Source

pub const fn c_scalar_div(self, scalar: i128) -> Self

Available on crate feature _int_i128 only.

Divides each element of the vector by a scalar, in compile-time.

Source§

impl Vector<i128, 3>

§Methods for 3d vectors represented using i128.

Source

pub const fn c_cross(self, other: Self) -> Self

Computes the cross product of two vectors.

That is the vector orthogonal to both vectors.

Also known as the exterior product or the vector product.

It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.

§Formula

$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$

Source§

impl<const D: usize> Vector<i128, D>

§Methods for vectors represented using i128, signed.

Source

pub const NEG_ONE: Self

Available on crate feature _int_i128 only.

A Vector with all negative ones.

Source

pub const fn c_magnitude_floor(self) -> i128

Available on crate feature _int_i128 only.

Calculates the floored magnitude of the vector.

It could underestimate the true magnitude.

§Features

This will only be const if the “_cmp_i128” feature is enabled.

Source

pub const fn c_magnitude_ceil(self) -> i128

Available on crate feature _int_i128 only.

Calculates the ceiled magnitude of the vector.

It could overestimate the true magnitude.

§Features

This will only be const if the “_cmp_i128” feature is enabled.

Source

pub const fn c_magnitude_round(self) -> i128

Available on crate feature _int_i128 only.

Calculates the rounded magnitude of the vector.

§Panics

Can panic if we reach a i128 value close to its maximum during operations.

Source§

impl<const D: usize> Vector<isize, D>

§Methods for vectors represented using isize.

Source

pub const ONE: Self

Available on crate feature _int_isize only.

A Vector with all ones.

Source

pub const ZERO: Self

Available on crate feature _int_isize only.

A Vector with all zeros.

Source

pub const fn c_normalize_with(self, magnitude: isize) -> Self

Available on crate feature _int_isize only.

Returns the normalized vector, using the given vector magnitude.

$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$

Source

pub const fn c_magnitude_sq(self) -> isize

Available on crate feature _int_isize only.

Calculates the magnitude of the vector (squared).

This is faster than calculating the magnitude, which is useful for comparisons.

§Formula

$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$

Source

pub const fn c_add(self, other: Self) -> Self

Available on crate feature _int_isize only.

Adds two vectors together, in compile-time.

Source

pub const fn c_sub(self, other: Self) -> Self

Available on crate feature _int_isize only.

Subtracts another vector from this vector, in compile-time.

Source

pub const fn c_dot(self, other: Self) -> isize

Available on crate feature _int_isize only.

Computes the dot product of two vectors, in compile-time.

Source

pub const fn c_scalar_mul(self, scalar: isize) -> Self

Available on crate feature _int_isize only.

Multiplies each element of the vector by a scalar, in compile-time.

Source

pub const fn c_scalar_div(self, scalar: isize) -> Self

Available on crate feature _int_isize only.

Divides each element of the vector by a scalar, in compile-time.

Source§

impl Vector<isize, 3>

§Methods for 3d vectors represented using isize.

Source

pub const fn c_cross(self, other: Self) -> Self

Computes the cross product of two vectors.

That is the vector orthogonal to both vectors.

Also known as the exterior product or the vector product.

It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.

§Formula

$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$

Source§

impl<const D: usize> Vector<isize, D>

§Methods for vectors represented using isize, signed.

Source

pub const NEG_ONE: Self

Available on crate feature _int_isize only.

A Vector with all negative ones.

Source

pub const fn c_magnitude_floor(self) -> isize

Available on crate feature _int_isize only.

Calculates the floored magnitude of the vector.

It could underestimate the true magnitude.

§Features

This will only be const if the “_cmp_isize” feature is enabled.

Source

pub const fn c_magnitude_ceil(self) -> isize

Available on crate feature _int_isize only.

Calculates the ceiled magnitude of the vector.

It could overestimate the true magnitude.

§Features

This will only be const if the “_cmp_isize” feature is enabled.

Source

pub const fn c_magnitude_round(self) -> isize

Available on crate feature _int_isize only.

Calculates the rounded magnitude of the vector.

§Panics

Can panic if we reach a i128 value close to its maximum during operations.

Source§

impl<const D: usize> Vector<u8, D>

§Methods for vectors represented using u8.

Source

pub const ONE: Self

Available on crate feature _int_u8 only.

A Vector with all ones.

Source

pub const ZERO: Self

Available on crate feature _int_u8 only.

A Vector with all zeros.

Source

pub const fn c_normalize_with(self, magnitude: u8) -> Self

Available on crate feature _int_u8 only.

Returns the normalized vector, using the given vector magnitude.

$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$

Source

pub const fn c_magnitude_sq(self) -> u8

Available on crate feature _int_u8 only.

Calculates the magnitude of the vector (squared).

This is faster than calculating the magnitude, which is useful for comparisons.

§Formula

$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$

Source

pub const fn c_add(self, other: Self) -> Self

Available on crate feature _int_u8 only.

Adds two vectors together, in compile-time.

Source

pub const fn c_sub(self, other: Self) -> Self

Available on crate feature _int_u8 only.

Subtracts another vector from this vector, in compile-time.

Source

pub const fn c_dot(self, other: Self) -> u8

Available on crate feature _int_u8 only.

Computes the dot product of two vectors, in compile-time.

Source

pub const fn c_scalar_mul(self, scalar: u8) -> Self

Available on crate feature _int_u8 only.

Multiplies each element of the vector by a scalar, in compile-time.

Source

pub const fn c_scalar_div(self, scalar: u8) -> Self

Available on crate feature _int_u8 only.

Divides each element of the vector by a scalar, in compile-time.

Source§

impl Vector<u8, 3>

§Methods for 3d vectors represented using u8.

Source

pub const fn c_cross(self, other: Self) -> Self

Computes the cross product of two vectors.

That is the vector orthogonal to both vectors.

Also known as the exterior product or the vector product.

It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.

§Formula

$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$

Source§

impl<const D: usize> Vector<u8, D>

§Methods for vectors represented using u8, unsigned.

Source

pub const fn c_magnitude_floor(self) -> u8

Available on crate feature _int_u8 only.

Calculates the floored magnitude of the vector.

It could underestimate the true magnitude.

§Features

This will only be const if the “_cmp_u8” feature is enabled.

Source

pub const fn c_magnitude_ceil(self) -> u8

Available on crate feature _int_u8 only.

Calculates the ceiled magnitude of the vector.

It could overestimate the true magnitude.

§Features

This will only be const if the “_cmp_u8” feature is enabled.

Source

pub const fn c_magnitude_round(self) -> u8

Available on crate feature _int_u8 only.

Calculates the rounded magnitude of the vector.

§Panics

Can panic if we reach a u128 value close to its maximum during operations.

Source§

impl<const D: usize> Vector<u16, D>

§Methods for vectors represented using u16.

Source

pub const ONE: Self

Available on crate feature _int_u16 only.

A Vector with all ones.

Source

pub const ZERO: Self

Available on crate feature _int_u16 only.

A Vector with all zeros.

Source

pub const fn c_normalize_with(self, magnitude: u16) -> Self

Available on crate feature _int_u16 only.

Returns the normalized vector, using the given vector magnitude.

$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$

Source

pub const fn c_magnitude_sq(self) -> u16

Available on crate feature _int_u16 only.

Calculates the magnitude of the vector (squared).

This is faster than calculating the magnitude, which is useful for comparisons.

§Formula

$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$

Source

pub const fn c_add(self, other: Self) -> Self

Available on crate feature _int_u16 only.

Adds two vectors together, in compile-time.

Source

pub const fn c_sub(self, other: Self) -> Self

Available on crate feature _int_u16 only.

Subtracts another vector from this vector, in compile-time.

Source

pub const fn c_dot(self, other: Self) -> u16

Available on crate feature _int_u16 only.

Computes the dot product of two vectors, in compile-time.

Source

pub const fn c_scalar_mul(self, scalar: u16) -> Self

Available on crate feature _int_u16 only.

Multiplies each element of the vector by a scalar, in compile-time.

Source

pub const fn c_scalar_div(self, scalar: u16) -> Self

Available on crate feature _int_u16 only.

Divides each element of the vector by a scalar, in compile-time.

Source§

impl Vector<u16, 3>

§Methods for 3d vectors represented using u16.

Source

pub const fn c_cross(self, other: Self) -> Self

Computes the cross product of two vectors.

That is the vector orthogonal to both vectors.

Also known as the exterior product or the vector product.

It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.

§Formula

$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$

Source§

impl<const D: usize> Vector<u16, D>

§Methods for vectors represented using u16, unsigned.

Source

pub const fn c_magnitude_floor(self) -> u16

Available on crate feature _int_u16 only.

Calculates the floored magnitude of the vector.

It could underestimate the true magnitude.

§Features

This will only be const if the “_cmp_u16” feature is enabled.

Source

pub const fn c_magnitude_ceil(self) -> u16

Available on crate feature _int_u16 only.

Calculates the ceiled magnitude of the vector.

It could overestimate the true magnitude.

§Features

This will only be const if the “_cmp_u16” feature is enabled.

Source

pub const fn c_magnitude_round(self) -> u16

Available on crate feature _int_u16 only.

Calculates the rounded magnitude of the vector.

§Panics

Can panic if we reach a u128 value close to its maximum during operations.

Source§

impl<const D: usize> Vector<u32, D>

§Methods for vectors represented using u32.

Source

pub const ONE: Self

Available on crate feature _int_u32 only.

A Vector with all ones.

Source

pub const ZERO: Self

Available on crate feature _int_u32 only.

A Vector with all zeros.

Source

pub const fn c_normalize_with(self, magnitude: u32) -> Self

Available on crate feature _int_u32 only.

Returns the normalized vector, using the given vector magnitude.

$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$

Source

pub const fn c_magnitude_sq(self) -> u32

Available on crate feature _int_u32 only.

Calculates the magnitude of the vector (squared).

This is faster than calculating the magnitude, which is useful for comparisons.

§Formula

$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$

Source

pub const fn c_add(self, other: Self) -> Self

Available on crate feature _int_u32 only.

Adds two vectors together, in compile-time.

Source

pub const fn c_sub(self, other: Self) -> Self

Available on crate feature _int_u32 only.

Subtracts another vector from this vector, in compile-time.

Source

pub const fn c_dot(self, other: Self) -> u32

Available on crate feature _int_u32 only.

Computes the dot product of two vectors, in compile-time.

Source

pub const fn c_scalar_mul(self, scalar: u32) -> Self

Available on crate feature _int_u32 only.

Multiplies each element of the vector by a scalar, in compile-time.

Source

pub const fn c_scalar_div(self, scalar: u32) -> Self

Available on crate feature _int_u32 only.

Divides each element of the vector by a scalar, in compile-time.

Source§

impl Vector<u32, 3>

§Methods for 3d vectors represented using u32.

Source

pub const fn c_cross(self, other: Self) -> Self

Computes the cross product of two vectors.

That is the vector orthogonal to both vectors.

Also known as the exterior product or the vector product.

It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.

§Formula

$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$

Source§

impl<const D: usize> Vector<u32, D>

§Methods for vectors represented using u32, unsigned.

Source

pub const fn c_magnitude_floor(self) -> u32

Available on crate feature _int_u32 only.

Calculates the floored magnitude of the vector.

It could underestimate the true magnitude.

§Features

This will only be const if the “_cmp_u32” feature is enabled.

Source

pub const fn c_magnitude_ceil(self) -> u32

Available on crate feature _int_u32 only.

Calculates the ceiled magnitude of the vector.

It could overestimate the true magnitude.

§Features

This will only be const if the “_cmp_u32” feature is enabled.

Source

pub const fn c_magnitude_round(self) -> u32

Available on crate feature _int_u32 only.

Calculates the rounded magnitude of the vector.

§Panics

Can panic if we reach a u128 value close to its maximum during operations.

Source§

impl<const D: usize> Vector<u64, D>

§Methods for vectors represented using u64.

Source

pub const ONE: Self

Available on crate feature _int_u64 only.

A Vector with all ones.

Source

pub const ZERO: Self

Available on crate feature _int_u64 only.

A Vector with all zeros.

Source

pub const fn c_normalize_with(self, magnitude: u64) -> Self

Available on crate feature _int_u64 only.

Returns the normalized vector, using the given vector magnitude.

$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$

Source

pub const fn c_magnitude_sq(self) -> u64

Available on crate feature _int_u64 only.

Calculates the magnitude of the vector (squared).

This is faster than calculating the magnitude, which is useful for comparisons.

§Formula

$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$

Source

pub const fn c_add(self, other: Self) -> Self

Available on crate feature _int_u64 only.

Adds two vectors together, in compile-time.

Source

pub const fn c_sub(self, other: Self) -> Self

Available on crate feature _int_u64 only.

Subtracts another vector from this vector, in compile-time.

Source

pub const fn c_dot(self, other: Self) -> u64

Available on crate feature _int_u64 only.

Computes the dot product of two vectors, in compile-time.

Source

pub const fn c_scalar_mul(self, scalar: u64) -> Self

Available on crate feature _int_u64 only.

Multiplies each element of the vector by a scalar, in compile-time.

Source

pub const fn c_scalar_div(self, scalar: u64) -> Self

Available on crate feature _int_u64 only.

Divides each element of the vector by a scalar, in compile-time.

Source§

impl Vector<u64, 3>

§Methods for 3d vectors represented using u64.

Source

pub const fn c_cross(self, other: Self) -> Self

Computes the cross product of two vectors.

That is the vector orthogonal to both vectors.

Also known as the exterior product or the vector product.

It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.

§Formula

$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$

Source§

impl<const D: usize> Vector<u64, D>

§Methods for vectors represented using u64, unsigned.

Source

pub const fn c_magnitude_floor(self) -> u64

Available on crate feature _int_u64 only.

Calculates the floored magnitude of the vector.

It could underestimate the true magnitude.

§Features

This will only be const if the “_cmp_u64” feature is enabled.

Source

pub const fn c_magnitude_ceil(self) -> u64

Available on crate feature _int_u64 only.

Calculates the ceiled magnitude of the vector.

It could overestimate the true magnitude.

§Features

This will only be const if the “_cmp_u64” feature is enabled.

Source

pub const fn c_magnitude_round(self) -> u64

Available on crate feature _int_u64 only.

Calculates the rounded magnitude of the vector.

§Panics

Can panic if we reach a u128 value close to its maximum during operations.

Source§

impl<const D: usize> Vector<u128, D>

§Methods for vectors represented using u128.

Source

pub const ONE: Self

Available on crate feature _int_u128 only.

A Vector with all ones.

Source

pub const ZERO: Self

Available on crate feature _int_u128 only.

A Vector with all zeros.

Source

pub const fn c_normalize_with(self, magnitude: u128) -> Self

Available on crate feature _int_u128 only.

Returns the normalized vector, using the given vector magnitude.

$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$

Source

pub const fn c_magnitude_sq(self) -> u128

Available on crate feature _int_u128 only.

Calculates the magnitude of the vector (squared).

This is faster than calculating the magnitude, which is useful for comparisons.

§Formula

$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$

Source

pub const fn c_add(self, other: Self) -> Self

Available on crate feature _int_u128 only.

Adds two vectors together, in compile-time.

Source

pub const fn c_sub(self, other: Self) -> Self

Available on crate feature _int_u128 only.

Subtracts another vector from this vector, in compile-time.

Source

pub const fn c_dot(self, other: Self) -> u128

Available on crate feature _int_u128 only.

Computes the dot product of two vectors, in compile-time.

Source

pub const fn c_scalar_mul(self, scalar: u128) -> Self

Available on crate feature _int_u128 only.

Multiplies each element of the vector by a scalar, in compile-time.

Source

pub const fn c_scalar_div(self, scalar: u128) -> Self

Available on crate feature _int_u128 only.

Divides each element of the vector by a scalar, in compile-time.

Source§

impl Vector<u128, 3>

§Methods for 3d vectors represented using u128.

Source

pub const fn c_cross(self, other: Self) -> Self

Computes the cross product of two vectors.

That is the vector orthogonal to both vectors.

Also known as the exterior product or the vector product.

It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.

§Formula

$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$

Source§

impl<const D: usize> Vector<u128, D>

§Methods for vectors represented using u128, unsigned.

Source

pub const fn c_magnitude_floor(self) -> u128

Available on crate feature _int_u128 only.

Calculates the floored magnitude of the vector.

It could underestimate the true magnitude.

§Features

This will only be const if the “_cmp_u128” feature is enabled.

Source

pub const fn c_magnitude_ceil(self) -> u128

Available on crate feature _int_u128 only.

Calculates the ceiled magnitude of the vector.

It could overestimate the true magnitude.

§Features

This will only be const if the “_cmp_u128” feature is enabled.

Source

pub const fn c_magnitude_round(self) -> u128

Available on crate feature _int_u128 only.

Calculates the rounded magnitude of the vector.

§Panics

Can panic if we reach a u128 value close to its maximum during operations.

Source§

impl<const D: usize> Vector<usize, D>

§Methods for vectors represented using usize.

Source

pub const ONE: Self

Available on crate feature _int_usize only.

A Vector with all ones.

Source

pub const ZERO: Self

Available on crate feature _int_usize only.

A Vector with all zeros.

Source

pub const fn c_normalize_with(self, magnitude: usize) -> Self

Available on crate feature _int_usize only.

Returns the normalized vector, using the given vector magnitude.

$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$

Source

pub const fn c_magnitude_sq(self) -> usize

Available on crate feature _int_usize only.

Calculates the magnitude of the vector (squared).

This is faster than calculating the magnitude, which is useful for comparisons.

§Formula

$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$

Source

pub const fn c_add(self, other: Self) -> Self

Available on crate feature _int_usize only.

Adds two vectors together, in compile-time.

Source

pub const fn c_sub(self, other: Self) -> Self

Available on crate feature _int_usize only.

Subtracts another vector from this vector, in compile-time.

Source

pub const fn c_dot(self, other: Self) -> usize

Available on crate feature _int_usize only.

Computes the dot product of two vectors, in compile-time.

Source

pub const fn c_scalar_mul(self, scalar: usize) -> Self

Available on crate feature _int_usize only.

Multiplies each element of the vector by a scalar, in compile-time.

Source

pub const fn c_scalar_div(self, scalar: usize) -> Self

Available on crate feature _int_usize only.

Divides each element of the vector by a scalar, in compile-time.

Source§

impl Vector<usize, 3>

§Methods for 3d vectors represented using usize.

Source

pub const fn c_cross(self, other: Self) -> Self

Computes the cross product of two vectors.

That is the vector orthogonal to both vectors.

Also known as the exterior product or the vector product.

It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.

§Formula

$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$

Source§

impl<const D: usize> Vector<usize, D>

§Methods for vectors represented using usize, unsigned.

Source

pub const fn c_magnitude_floor(self) -> usize

Available on crate feature _int_usize only.

Calculates the floored magnitude of the vector.

It could underestimate the true magnitude.

Source

pub const fn c_magnitude_ceil(self) -> usize

Available on crate feature _int_usize only.

Calculates the ceiled magnitude of the vector.

It could overestimate the true magnitude.

Source

pub const fn c_magnitude_round(self) -> usize

Available on crate feature _int_usize only.

Calculates the rounded magnitude of the vector.

§Panics

Can panic if we reach a u128 value close to its maximum during operations.

Source§

impl<const D: usize> Vector<f32, D>

§Methods for vectors represented using f32.

Source

pub const ONE: Self

Available on crate feature _float_f32 only.

A Vector with all ones.

Source

pub const ZERO: Self

Available on crate feature _float_f32 only.

A Vector with all zeros.

Source

pub const NEG_ONE: Self

Available on crate feature _float_f32 only.

A Vector with all negative ones.

Source

pub fn normalize(&self) -> Self

Available on crate feature _float_f32 only.

Returns the normalized vector, as a unit vector.

$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$

Source

pub fn magnitude(self) -> f32

Available on crate feature _float_f32 only.

Calculates the magnitude of the vector.

§Formula

$$ \large |\vec{V}| = \sqrt{V_0^2 + … + V_n^2} $$

Source

pub fn magnitude_sq(self) -> f32

Available on crate feature _float_f32 only.

Calculates the squared magnitude of the vector.

This is faster than calculating the magnitude, which is useful for comparisons.

§Formula

$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$

Source

pub fn add(self, other: Self) -> Self

Available on crate feature _float_f32 only.

Adds two vectors together.

Source

pub fn sub(self, other: Self) -> Self

Available on crate feature _float_f32 only.

Subtracts another vector from this vector.

Source

pub fn dot(self, other: Self) -> f32

Available on crate feature _float_f32 only.

Computes the dot product of two vectors.

That is the magnitude of one vector in the direction of another.

Also known as the inner produc or the scalar product.

§Formula

$$ \large \vec{a}\cdot\vec{b} = \begin{bmatrix} a_0 \cr … \cr a_n \end{bmatrix} \cdot \begin{bmatrix} b_0 \cr … \cr b_n \end{bmatrix} = a_0 b_0 + … + a_n b_n $$

Source§

impl Vector<f32, 3>

§Methods for 3d vectors represented using f32.

Source

pub fn cross(self, other: Self) -> Self

Computes the cross product of two vectors.

That is the vector orthogonal to both vectors.

Also known as the exterior product or the vector product.

It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.

§Formula

$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$

Source§

impl<const D: usize> Vector<f64, D>

§Methods for vectors represented using f64.

Source

pub const ONE: Self

Available on crate feature _float_f64 only.

A Vector with all ones.

Source

pub const ZERO: Self

Available on crate feature _float_f64 only.

A Vector with all zeros.

Source

pub const NEG_ONE: Self

Available on crate feature _float_f64 only.

A Vector with all negative ones.

Source

pub fn normalize(&self) -> Self

Available on crate feature _float_f64 only.

Returns the normalized vector, as a unit vector.

$$ \bm{n} = \widehat{\bm{a}} = \frac{1}{d}\thinspace\bm{a} = \frac{\bm{a}}{|\bm{a}|} $$

Source

pub fn magnitude(self) -> f64

Available on crate feature _float_f64 only.

Calculates the magnitude of the vector.

§Formula

$$ \large |\vec{V}| = \sqrt{V_0^2 + … + V_n^2} $$

Source

pub fn magnitude_sq(self) -> f64

Available on crate feature _float_f64 only.

Calculates the squared magnitude of the vector.

This is faster than calculating the magnitude, which is useful for comparisons.

§Formula

$$ \large |\vec{V}|^2 = V_0^2 + … + V_n^2 $$

Source

pub fn add(self, other: Self) -> Self

Available on crate feature _float_f64 only.

Adds two vectors together.

Source

pub fn sub(self, other: Self) -> Self

Available on crate feature _float_f64 only.

Subtracts another vector from this vector.

Source

pub fn dot(self, other: Self) -> f64

Available on crate feature _float_f64 only.

Computes the dot product of two vectors.

That is the magnitude of one vector in the direction of another.

Also known as the inner produc or the scalar product.

§Formula

$$ \large \vec{a}\cdot\vec{b} = \begin{bmatrix} a_0 \cr … \cr a_n \end{bmatrix} \cdot \begin{bmatrix} b_0 \cr … \cr b_n \end{bmatrix} = a_0 b_0 + … + a_n b_n $$

Source§

impl Vector<f64, 3>

§Methods for 3d vectors represented using f64.

Source

pub fn cross(self, other: Self) -> Self

Computes the cross product of two vectors.

That is the vector orthogonal to both vectors.

Also known as the exterior product or the vector product.

It is only defined for 3-dimensional vectors, and it is not commutative: $\vec{a}\times\vec{b} = -(\vec{b}\times\vec{a})$.

§Formula

$$ \bm{a} \times \bm{b} = \begin{bmatrix} a_x \cr a_y \cr a_z \end{bmatrix} \times \begin{bmatrix} b_x \cr b_y \cr b_z \end{bmatrix} = \begin{bmatrix} a_y b_z - a_z b_y \cr a_z b_x - a_x b_z \cr a_x b_y - a_y b_x \end{bmatrix} $$

Source§

impl<T: Clone + Add<Output = T>, const D: usize> Vector<T, D>

Source

pub fn clone_add(&self, other: &Self) -> Self

Adds two vectors together

Source§

impl<T: Clone + Sub<Output = T>, const D: usize> Vector<T, D>

Source

pub fn clone_sub(&self, other: &Self) -> Self

Subtracts two vectors together.

Source§

impl<T: Clone + Mul<Output = T>, const D: usize> Vector<T, D>

Source

pub fn clone_mul_scalar(&self, scalar: &T) -> Self

Multiplies a vector by a scalar.

Source§

impl<T: Clone + Div<Output = T>, const D: usize> Vector<T, D>

Source

pub fn clone_div_scalar(&self, scalar: &T) -> Self

Divides a vector by a scalar.

Trait Implementations§

Source§

impl<T: Clone + Add<Output = T>, const D: usize> Add for Vector<T, D>

Source§

type Output = Vector<T, D>

The resulting type after applying the + operator.
Source§

fn add(self, other: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: Clone + Add<Output = T>, const D: usize> AddAssign<&Vector<T, D>> for Vector<T, D>

Source§

fn add_assign(&mut self, other: &Self)

Performs the += operation. Read more
Source§

impl<T: Clone, const D: usize> Clone for Vector<T, D>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: ConstDefault, const D: usize> ConstDefault for Vector<T, D>

Source§

const DEFAULT: Self

Returns a Vector, allocated in the stack, using the default value to fill the data.

Source§

impl<T: Debug, const D: usize> Debug for Vector<T, D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default, const D: usize> Default for Vector<T, D>

Source§

fn default() -> Self

Returns a Vector, allocated in the stack, using the default value to fill the data.

Source§

impl<T: Clone + Div<Output = T>, const D: usize> Div<&T> for Vector<T, D>

Source§

type Output = Vector<T, D>

The resulting type after applying the / operator.
Source§

fn div(self, scalar: &T) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: Clone + Div<Output = T>, const D: usize> Div<T> for Vector<T, D>

Source§

type Output = Vector<T, D>

The resulting type after applying the / operator.
Source§

fn div(self, scalar: T) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: Clone + Div<Output = T>, const D: usize> DivAssign<&T> for Vector<T, D>

Source§

fn div_assign(&mut self, scalar: &T)

Performs the /= operation. Read more
Source§

impl<T: Clone + Div<Output = T>, const D: usize> DivAssign<T> for Vector<T, D>

Source§

fn div_assign(&mut self, scalar: T)

Performs the /= operation. Read more
Source§

impl<T: Hash, const D: usize> Hash for Vector<T, D>

Source§

fn hash<HR: Hasher>(&self, state: &mut HR)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: Clone + Mul<Output = T>, const D: usize> Mul<&T> for Vector<T, D>

Source§

type Output = Vector<T, D>

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: &T) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: Clone + Mul<Output = T>, const D: usize> Mul<T> for Vector<T, D>

Source§

type Output = Vector<T, D>

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: T) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: Clone + Mul<Output = T>, const D: usize> MulAssign<&T> for Vector<T, D>

Source§

fn mul_assign(&mut self, scalar: &T)

Performs the *= operation. Read more
Source§

impl<T: Clone + Mul<Output = T>, const D: usize> MulAssign<T> for Vector<T, D>

Source§

fn mul_assign(&mut self, scalar: T)

Performs the *= operation. Read more
Source§

impl<T: Num, const D: usize> Num for Vector<T, D>

Source§

type Inner = [T; D]

The internal representation of this numeric type.
Source§

type Out = Vector<T, D>

The output type for operations.
Source§

type Rhs = Vector<T, D>

The right hand side type for operations.
Source§

fn num_into(self) -> Self::Inner

Returns the inner self representation.
Source§

fn num_from(value: Self::Inner) -> Result<Self>
where Self: Sized,

Returns Self if given a valid value.
Source§

fn num_from_ref(value: &Self::Inner) -> Result<Self>
where Self: Sized,

Returns Self if given a valid &value.
Source§

fn num_set(&mut self, value: Self::Inner) -> Result<()>

Sets self to the given valid value.
Source§

fn num_set_ref(&mut self, value: &Self::Inner) -> Result<()>

Sets self to the given valid &value.
Source§

fn num_is_zero(&self) -> Result<bool>

Returns true if self is zero.
Source§

fn num_get_zero() -> Result<Self>
where Self: Sized,

Returns the number zero.
Source§

fn num_set_zero(&mut self) -> Result<()>

Sets self to 0.
Source§

fn num_is_one(&self) -> Result<bool>

Returns true if self is one.
Source§

fn num_get_one() -> Result<Self>
where Self: Sized,

Returns the number one.
Source§

fn num_set_one(&mut self) -> Result<()>

Sets the number to one.
Source§

fn num_add(self, rhs: Self::Rhs) -> Result<Self::Out>
where Self: Sized,

Computes self + rhs (addition).
Source§

fn num_ref_add(&self, rhs: &Self::Rhs) -> Result<Self::Out>

Like num_add but takes the arguments by reference.
Source§

fn num_ref_add_assign(&mut self, rhs: &Self::Rhs) -> Result<()>

Computes &mut self += rhs; (addition).
Source§

fn num_sub(self, rhs: Self::Rhs) -> Result<Self::Out>
where Self: Sized,

Computes self - rhs (subtraction).
Source§

fn num_ref_sub(&self, rhs: &Self::Rhs) -> Result<Self::Out>

Like num_sub but takes the arguments by reference.
Source§

fn num_ref_sub_assign(&mut self, rhs: &Self::Rhs) -> Result<()>

Computes &mut self -= rhs; (subtraction).
Source§

fn num_mul(self, rhs: Self::Rhs) -> Result<Self::Out>
where Self: Sized,

Computes self * rhs (multiplication).
Source§

fn num_ref_mul(&self, rhs: &Self::Rhs) -> Result<Self::Out>

Like num_mul but takes the arguments by reference.
Source§

fn num_ref_mul_assign(&mut self, rhs: &Self::Rhs) -> Result<()>

Computes &mut self *= rhs; (multiplication).
Source§

fn num_div(self, rhs: Self::Rhs) -> Result<Self::Out>
where Self: Sized,

Computes self / rhs (division).
Source§

fn num_ref_div(&self, rhs: &Self::Rhs) -> Result<Self::Out>

Like num_div but takes the arguments by reference.
Source§

fn num_ref_div_assign(&mut self, rhs: &Self::Rhs) -> Result<()>

Computes &mut self /= rhs; (division).
Source§

fn num_rem(self, rhs: Self::Rhs) -> Result<Self::Out>
where Self: Sized,

Computes self % rhs (remainder).
Source§

fn num_ref_rem(&self, rhs: &Self::Rhs) -> Result<Self::Out>

Like num_rem but takes the arguments by reference.
Source§

fn num_ref_rem_assign(&mut self, rhs: &Self::Rhs) -> Result<()>

Computes &mut self %= rhs; (remainder).
Source§

fn num_neg(self) -> Result<Self::Out>
where Self: Sized,

Computes -self (additive inverse).
Source§

fn num_ref_neg(&self) -> Result<Self::Out>

Like num_neg but takes the arguments by reference.
Source§

fn num_abs(self) -> Result<Self::Out>
where Self: Sized,

Computes |self| (absolute value).
Source§

fn num_ref_abs(&self) -> Result<Self::Out>

Like num_abs but takes the arguments by reference.
Source§

impl<T: Num, const D: usize> NumVector for Vector<T, D>

Source§

type Scalar = T

The associated scalar type.
Source§

impl<T: PartialEq, const D: usize> PartialEq for Vector<T, D>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Clone + Sub<Output = T>, const D: usize> Sub for Vector<T, D>

Source§

type Output = Vector<T, D>

The resulting type after applying the - operator.
Source§

fn sub(self, other: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<T: Clone + Sub<Output = T>, const D: usize> SubAssign<&Vector<T, D>> for Vector<T, D>

Source§

fn sub_assign(&mut self, other: &Self)

Performs the -= operation. Read more
Source§

impl<T: Num + 'static, const D: usize> TryInto<Box<dyn NumVector<Rhs = Vector<T, D>, Out = Vector<T, D>, Scalar = T, Inner = [T; D]>>> for Vector<T, D>

Available on crate feature alloc only.
Source§

type Error = NumError

The type returned in the event of a conversion error.
Source§

fn try_into( self, ) -> Result<Box<dyn NumVector<Scalar = T, Rhs = Self, Inner = [T; D], Out = Self>>>

Performs the conversion.
Source§

impl<T: Copy, const D: usize> Copy for Vector<T, D>

Source§

impl<T: Eq, const D: usize> Eq for Vector<T, D>

Auto Trait Implementations§

§

impl<T, const D: usize> Freeze for Vector<T, D>
where T: Freeze,

§

impl<T, const D: usize> RefUnwindSafe for Vector<T, D>
where T: RefUnwindSafe,

§

impl<T, const D: usize> Send for Vector<T, D>
where T: Send,

§

impl<T, const D: usize> Sync for Vector<T, D>
where T: Sync,

§

impl<T, const D: usize> Unpin for Vector<T, D>
where T: Unpin,

§

impl<T, const D: usize> UnwindSafe for Vector<T, D>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByteSized for T

Source§

const BYTE_ALIGN: usize = _

The alignment of this type in bytes.
Source§

const BYTE_SIZE: usize = _

The size of this type in bytes.
Source§

fn byte_align(&self) -> usize

Returns the alignment of this type in bytes.
Source§

fn byte_size(&self) -> usize

Returns the size of this type in bytes. Read more
Source§

fn ptr_size_ratio(&self) -> [usize; 2]

Returns the size ratio between Ptr::BYTES and BYTE_SIZE. Read more
Source§

impl<T, R> Chain<R> for T
where T: ?Sized,

Source§

fn chain<F>(self, f: F) -> R
where F: FnOnce(Self) -> R, Self: Sized,

Chain a function which takes the parameter by value.
Source§

fn chain_ref<F>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Chain a function which takes the parameter by shared reference.
Source§

fn chain_mut<F>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Chain a function which takes the parameter by exclusive reference.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> ExtAny for T
where T: Any + ?Sized,

Source§

fn type_id() -> TypeId

Returns the TypeId of Self. Read more
Source§

fn type_of(&self) -> TypeId

Returns the TypeId of self. Read more
Source§

fn type_name(&self) -> &'static str

Returns the type name of self. Read more
Source§

fn type_is<T: 'static>(&self) -> bool

Returns true if Self is of type T. Read more
Source§

fn as_any_ref(&self) -> &dyn Any
where Self: Sized,

Upcasts &self as &dyn Any. Read more
Source§

fn as_any_mut(&mut self) -> &mut dyn Any
where Self: Sized,

Upcasts &mut self as &mut dyn Any. Read more
Source§

fn as_any_box(self: Box<Self>) -> Box<dyn Any>
where Self: Sized,

Upcasts Box<self> as Box<dyn Any>. Read more
Source§

fn downcast_ref<T: 'static>(&self) -> Option<&T>

Available on crate feature unsafe_layout only.
Returns some shared reference to the inner value if it is of type T. Read more
Source§

fn downcast_mut<T: 'static>(&mut self) -> Option<&mut T>

Available on crate feature unsafe_layout only.
Returns some exclusive reference to the inner value if it is of type T. Read more
Source§

impl<T> ExtMem for T
where T: ?Sized,

Source§

const NEEDS_DROP: bool = _

Know whether dropping values of this type matters, in compile-time.
Source§

fn mem_align_of<T>() -> usize

Returns the minimum alignment of the type in bytes. Read more
Source§

fn mem_align_of_val(&self) -> usize

Returns the alignment of the pointed-to value in bytes. Read more
Source§

fn mem_size_of<T>() -> usize

Returns the size of a type in bytes. Read more
Source§

fn mem_size_of_val(&self) -> usize

Returns the size of the pointed-to value in bytes. Read more
Source§

fn mem_copy(&self) -> Self
where Self: Copy,

Bitwise-copies a value. Read more
Source§

fn mem_needs_drop(&self) -> bool

Returns true if dropping values of this type matters. Read more
Source§

fn mem_drop(self)
where Self: Sized,

Drops self by running its destructor. Read more
Source§

fn mem_forget(self)
where Self: Sized,

Forgets about self without running its destructor. Read more
Source§

fn mem_replace(&mut self, other: Self) -> Self
where Self: Sized,

Replaces self with other, returning the previous value of self. Read more
Source§

fn mem_take(&mut self) -> Self
where Self: Default,

Replaces self with its default value, returning the previous value of self. Read more
Source§

fn mem_swap(&mut self, other: &mut Self)
where Self: Sized,

Swaps the value of self and other without deinitializing either one. Read more
Source§

unsafe fn mem_zeroed<T>() -> T

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Source§

unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst

Available on crate feature unsafe_layout only.
Returns the value of type T represented by the all-zero byte-pattern. Read more
Source§

fn mem_as_bytes(&self) -> &[u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &[u8]. Read more
Source§

fn mem_as_bytes_mut(&mut self) -> &mut [u8]
where Self: Sync + Unpin,

Available on crate feature unsafe_slice only.
View a Sync + Unpin self as &mut [u8]. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

Source§

impl<T> Hook for T

Source§

fn hook_ref<F>(self, f: F) -> Self
where F: FnOnce(&Self),

Applies a function which takes the parameter by shared reference, and then returns the (possibly) modified owned value. Read more
Source§

fn hook_mut<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Applies a function which takes the parameter by exclusive reference, and then returns the (possibly) modified owned value. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

§

impl<T> Ungil for T
where T: Send,