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,
impl<T, const S: usize> VectorRow<T, S>where
T: Copy,
Sourcepub fn new(values: [T; S]) -> Self
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());
Sourcepub fn from_value(value: T) -> Self
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());
Sourcepub fn get_values(&self) -> &[T; S]
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);
Sourcepub fn get_values_mut(&mut self) -> &mut [T; S]
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());
Sourcepub fn transpose(&self) -> VectorColumn<T, S>
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>
impl<T, const S: usize> VectorRow<Complex<T>, S>
Sourcepub fn hermitian_conjugate(&self) -> VectorColumn<Complex<T>, S>
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>
impl<TL, TR, TO, const S: usize> Add<VectorRow<TR, S>> for VectorRow<TL, S>
Source§impl<T, const S: usize> AddAssign for VectorRow<T, S>
impl<T, const S: usize> AddAssign for VectorRow<T, S>
Source§fn add_assign(&mut self, rhs: VectorRow<T, S>)
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<TL, TR, TO, const R: usize, const C: usize> Mul<Matrix<TR, R, C>> for VectorRow<TL, R>
impl<TL, TR, TO, const R: usize, const C: usize> Mul<Matrix<TR, R, C>> for VectorRow<TL, R>
Source§fn mul(self, rhs: Matrix<TR, R, C>) -> Self::Output
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§impl<TL, TR, TO, const S: usize> Mul<TR> for VectorRow<TL, S>
impl<TL, TR, TO, const S: usize> Mul<TR> for VectorRow<TL, S>
Source§impl<TL, TR, TO, const S: usize> Mul<VectorColumn<TR, S>> for VectorRow<TL, S>
impl<TL, TR, TO, const S: usize> Mul<VectorColumn<TR, S>> for VectorRow<TL, S>
Source§impl<TL, TR, TO, const R: usize, const C: usize> Mul<VectorRow<TR, C>> for VectorColumn<TL, R>
impl<TL, TR, TO, const R: usize, const C: usize> Mul<VectorRow<TR, C>> for VectorColumn<TL, R>
Source§fn mul(self, rhs: VectorRow<TR, C>) -> Self::Output
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§impl<TL, TR, TO, const S: usize> Mul<VectorRow<TR, S>> for VectorRow<TL, S>
impl<TL, TR, TO, const S: usize> Mul<VectorRow<TR, S>> for VectorRow<TL, S>
Source§impl<T, const S: usize> MulAssign<T> for VectorRow<T, S>
impl<T, const S: usize> MulAssign<T> for VectorRow<T, S>
Source§fn mul_assign(&mut self, rhs: T)
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<TL, TR, TO, const S: usize> Sub<VectorRow<TR, S>> for VectorRow<TL, S>
impl<TL, TR, TO, const S: usize> Sub<VectorRow<TR, S>> for VectorRow<TL, S>
Source§impl<T, const S: usize> SubAssign for VectorRow<T, S>
impl<T, const S: usize> SubAssign for VectorRow<T, S>
Source§fn sub_assign(&mut self, rhs: VectorRow<T, S>)
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());