Skip to main content

Matrix

Struct Matrix 

Source
pub struct Matrix { /* private fields */ }
Expand description

Represents a square matrix over C of maximum size MAX_SIZE.

Each element is an instance of Complex, and we store the elements internally in an array of size MAX_SIZE^2 * sizeof(Complex).

In practice, this means each matrix occupies around 16KiB.

Implementations§

Source§

impl Matrix

Source

pub fn new(size: usize) -> Matrix

Construct a new zero-initialized matrix of given size.

§Panics

We panic if the given size exceeds MAX_SIZE.

Source

pub fn new_from_elements(size: usize, elements: Vec<Complex>) -> Matrix

Construct a new matrix of given size from elements.

§Panics

We panic if the given size exceeds MAX_SIZE.

Source

pub fn identity(size: usize) -> Matrix

Construct a new identity matrix of given size.

§Panics

We panic if the given size exceeds MAX_SIZE.

Source

pub fn embed(&mut self, other: &Matrix, i: usize, j: usize)

Embed another matrix into this one, overrising elements.

Embed with top-left position at (i, j).

§Panics

We panic if this matrix isn’t large enough.

Source

pub fn permute_rows(&self, permutation: Vec<usize>) -> Matrix

Permute the rows to generate a new matrix.

Row i goes to row perutation[i].

§Panics

We panic if set(permutation) != {0, …, self.size - 1}.

Source

pub fn permute_columns(&self, permutation: Vec<usize>) -> Matrix

Permute the columns to generate a new matrix.

Column i goes to column perutation[i].

§Panics

We panic if set(permutation) != {0, …, self.size - 1}.

Source

pub fn size(&self) -> usize

Size of the matrix.

Source

pub fn get(&self, i: usize, j: usize) -> Complex

Get the element in position (i, j).

Source

pub fn set(&mut self, i: usize, j: usize, value: Complex)

Set the element in position (i, j) to value.

Source

pub fn approx_eq(&self, other: &Matrix) -> bool

Approximately equal test.

Trait Implementations§

Source§

impl<'a> Add for &'a Matrix

Source§

type Output = Matrix

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'a Matrix) -> Matrix

Performs the + operation. Read more
Source§

impl Debug for Matrix

Source§

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

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

impl<'a> Mul for &'a Matrix

Source§

type Output = Matrix

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Matrix) -> Matrix

Performs the * operation. Read more
Source§

impl<'a> Mul<&'a [Complex; 32]> for &'a Matrix

Implements standard matrix vector multiplication.

§Panics

We panic if the vector contains non-zero elements in positions self.size or beyond.

Source§

type Output = [Complex; 32]

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Vector) -> Vector

Performs the * operation. Read more
Source§

impl PartialEq for Matrix

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.