Struct VectorRow

Source
pub struct VectorRow<T, const S: usize>
where T: Copy,
{ /* private fields */ }
Expand description

A static row vector type

Size must be known at compile time but operations are checked for size compatibility at compile time too

S: The length of the vector

Implementations§

Source§

impl<T, const S: usize> VectorRow<T, S>
where T: Copy,

Source

pub fn new(values: [T; S]) -> Self

Initializes a new row vector with the given values

§Examples
let x = static_linear_algebra::VectorRow::new([0, 1, 2]);
 
assert_eq!(&[0, 1, 2], x.get_values());
Source

pub fn from_value(value: T) -> Self

Initializes a new row vector filled with a single value

§Examples
let x = static_linear_algebra::VectorRow::<f32, 2>::from_value(1.);
 
assert_eq!(&[1., 1.], x.get_values());
Source

pub fn get_values(&self) -> &[T; S]

Retrieves a reference to the data of the row vector

§Examples
let x = static_linear_algebra::VectorRow::new([0, 1]);
let data = x.get_values();
 
assert_eq!(&[0, 1], data);
Source

pub fn get_values_mut(&mut self) -> &mut [T; S]

Retrieves a mutable reference to the data of the row vector

§Examples
let mut x = static_linear_algebra::VectorRow::new([0, 1]);
let data = x.get_values_mut();
data[0] = 5;
 
assert_eq!(&[5, 1], x.get_values());
Source

pub fn transpose(&self) -> VectorColumn<T, S>

Transposes the row vector into a column vector

§Examples
let x = static_linear_algebra::VectorRow::new([0, 1, 2]);
let y = x.transpose();
 
assert_eq!(&[0, 1, 2], y.get_values());
Source§

impl<T, const S: usize> VectorRow<Complex<T>, S>
where T: Copy + Num + Neg<Output = T>,

Source

pub fn hermitian_conjugate(&self) -> VectorColumn<Complex<T>, S>

Takes the hermitian conjugate of the row vector (transpose the vector and complex conjugate each element (change the sign of the imaginary part))

§Examples
use num::Complex;
 
let x = static_linear_algebra::VectorRow::new([Complex::new(1, 0), Complex::new(0, 2)]);
let y = x.hermitian_conjugate();
 
assert_eq!(&[Complex::new(1, 0), Complex::new(0, -2)], y.get_values())

Trait Implementations§

Source§

impl<TL, TR, TO, const S: usize> Add<VectorRow<TR, S>> for VectorRow<TL, S>
where TL: Copy + Add<TR, Output = TO>, TR: Copy, TO: Copy,

Source§

fn add(self, rhs: VectorRow<TR, S>) -> Self::Output

Normal elementwise addition of two row vectors

§Examples
let x = static_linear_algebra::VectorRow::new([0, 1]);
let y = static_linear_algebra::VectorRow::new([0, 10]);
 
let z = x + y;
 
assert_eq!(&[0, 11], z.get_values());
Source§

type Output = VectorRow<TO, S>

The resulting type after applying the + operator.
Source§

impl<T, const S: usize> AddAssign for VectorRow<T, S>
where T: Copy + Add<T, Output = T>,

Source§

fn add_assign(&mut self, rhs: VectorRow<T, S>)

Normal elementwise addition of two row vectors

§Examples
let mut x = static_linear_algebra::VectorRow::new([0, 1]);
let y = static_linear_algebra::VectorRow::new([0, 10]);
 
x += y;
 
assert_eq!(&[0, 11], x.get_values());
Source§

impl<T, const S: usize> Clone for VectorRow<T, S>
where T: Copy + Clone,

Source§

fn clone(&self) -> VectorRow<T, S>

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, const S: usize> Debug for VectorRow<T, S>
where T: Copy + Debug,

Source§

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

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

impl<T, const S: usize> Index<usize> for VectorRow<T, S>
where T: Copy,

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, idx: usize) -> &Self::Output

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

impl<T, const S: usize> IndexMut<usize> for VectorRow<T, S>
where T: Copy,

Source§

fn index_mut(&mut self, idx: usize) -> &mut Self::Output

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

impl<TL, TR, TO, const R: usize, const C: usize> Mul<Matrix<TR, R, C>> for VectorRow<TL, R>
where TL: Copy + Mul<TR, Output = TO>, TR: Copy, TO: Copy + Sum,

Source§

fn mul(self, rhs: Matrix<TR, R, C>) -> Self::Output

Multiplication between a row vector and a matrix

§Examples
let x = static_linear_algebra::VectorRow::new([0, 1]);
let y = static_linear_algebra::Matrix::new([[0, 10, 20], [30, 40, 50]]);
 
let z = x * y;
 
assert_eq!(&[30, 40, 50], z.get_values());
Source§

type Output = VectorRow<TO, C>

The resulting type after applying the * operator.
Source§

impl<TL, TR, TO, const S: usize> Mul<TR> for VectorRow<TL, S>
where TL: Copy + Mul<TR, Output = TO>, TR: Copy + Num, TO: Copy,

Source§

fn mul(self, rhs: TR) -> Self::Output

Scalar multiplication from the right, this is preferable from lhs scalar multiplication

§Examples
let x = static_linear_algebra::VectorRow::new([0, 1]);
let y = 10;
 
let z = x * y;
 
assert_eq!(&[0, 10], z.get_values());
Source§

type Output = VectorRow<TO, S>

The resulting type after applying the * operator.
Source§

impl<TL, TR, TO, const S: usize> Mul<VectorColumn<TR, S>> for VectorRow<TL, S>
where TL: Copy + Mul<TR, Output = TO>, TR: Copy, TO: Copy + Sum,

Source§

fn mul(self, rhs: VectorColumn<TR, S>) -> Self::Output

Inner product between a row vector and a column vector

§Examples
let x = static_linear_algebra::VectorRow::new([0, 1]);
let y = static_linear_algebra::VectorColumn::new([10, 20]);
 
let z = x * y;
 
assert_eq!(20, z);
Source§

type Output = TO

The resulting type after applying the * operator.
Source§

impl<TL, TR, TO, const R: usize, const C: usize> Mul<VectorRow<TR, C>> for VectorColumn<TL, R>
where TL: Copy + Mul<TR, Output = TO>, TR: Copy, TO: Copy + Sum,

Source§

fn mul(self, rhs: VectorRow<TR, C>) -> Self::Output

Outer product between a column vector and a row vector

§Examples
let x = static_linear_algebra::VectorColumn::new([0, 1]);
let y = static_linear_algebra::VectorRow::new([10, 20]);
 
let z = x * y;
 
assert_eq!(&[[0, 0], [10, 20]], z.get_values());
Source§

type Output = Matrix<TO, R, C>

The resulting type after applying the * operator.
Source§

impl<TL, TR, TO, const S: usize> Mul<VectorRow<TR, S>> for VectorRow<TL, S>
where TL: Copy + Mul<TR, Output = TO>, TR: Copy, TO: Copy + Sum,

Source§

fn mul(self, rhs: VectorRow<TR, S>) -> Self::Output

Inner product (dot product) between two row vectors

§Examples
let x = static_linear_algebra::VectorRow::new([0, 1]);
let y = static_linear_algebra::VectorRow::new([0, 10]);
 
let z = x * y;
 
assert_eq!(10, z);
Source§

type Output = TO

The resulting type after applying the * operator.
Source§

impl<T, const S: usize> MulAssign<T> for VectorRow<T, S>
where T: Copy + Mul<T, Output = T> + Num,

Source§

fn mul_assign(&mut self, rhs: T)

Scalar multiplication from the right, this is preferable from lhs scalar multiplication

§Examples
let mut x = static_linear_algebra::VectorRow::new([0, 1]);
let y = 10;
 
x *= y;
 
assert_eq!(&[0, 10], x.get_values());
Source§

impl<T, const S: usize> PartialEq for VectorRow<T, S>
where T: Copy + PartialEq,

Source§

fn eq(&self, other: &VectorRow<T, S>) -> 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<TL, TR, TO, const S: usize> Sub<VectorRow<TR, S>> for VectorRow<TL, S>
where TL: Copy + Sub<TR, Output = TO>, TR: Copy, TO: Copy,

Source§

fn sub(self, rhs: VectorRow<TR, S>) -> Self::Output

Normal elementwise subtraction of two row vectors

§Examples
let x = static_linear_algebra::VectorRow::new([0, 1]);
let y = static_linear_algebra::VectorRow::new([0, 10]);
 
let z = x - y;
 
assert_eq!(&[0, -9], z.get_values());
Source§

type Output = VectorRow<TO, S>

The resulting type after applying the - operator.
Source§

impl<T, const S: usize> SubAssign for VectorRow<T, S>
where T: Copy + Sub<T, Output = T>,

Source§

fn sub_assign(&mut self, rhs: VectorRow<T, S>)

Normal elementwise subtraction of two row vectors

§Examples
let mut x = static_linear_algebra::VectorRow::new([0, 1]);
let y = static_linear_algebra::VectorRow::new([0, 10]);
 
x -= y;
 
assert_eq!(&[0, -9], x.get_values());
Source§

impl<'a, T, const S: usize> Sum<&'a VectorRow<T, S>> for VectorRow<T, S>
where T: Copy + Zero + Add<T, Output = T> + PartialEq,

Source§

fn sum<I: Iterator<Item = &'a Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<T, const S: usize> Sum for VectorRow<T, S>
where T: Copy + Zero + Add<T, Output = T> + PartialEq,

Source§

fn sum<I: Iterator<Item = Self>>(iter: I) -> Self

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<T, const S: usize> Zero for VectorRow<T, S>
where T: Copy + Zero + PartialEq,

Source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl<T, const S: usize> Copy for VectorRow<T, S>
where T: Copy + Copy,

Source§

impl<T, const S: usize> StructuralPartialEq for VectorRow<T, S>
where T: Copy,

Auto Trait Implementations§

§

impl<T, const S: usize> Freeze for VectorRow<T, S>
where T: Freeze,

§

impl<T, const S: usize> RefUnwindSafe for VectorRow<T, S>
where T: RefUnwindSafe,

§

impl<T, const S: usize> Send for VectorRow<T, S>
where T: Send,

§

impl<T, const S: usize> Sync for VectorRow<T, S>
where T: Sync,

§

impl<T, const S: usize> Unpin for VectorRow<T, S>
where T: Unpin,

§

impl<T, const S: usize> UnwindSafe for VectorRow<T, S>
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
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> CloneToUninit for T
where T: Clone,

Source§

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

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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