[][src]Struct quantum2::matrix::Matrix

pub struct Matrix { /* fields omitted */ }

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.

Methods

impl Matrix[src]

pub fn new(size: usize) -> Matrix[src]

Construct a new zero-initialized matrix of given size.

Panics

We panic if the given size exceeds MAX_SIZE.

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

Construct a new matrix of given size from elements.

Panics

We panic if the given size exceeds MAX_SIZE.

pub fn identity(size: usize) -> Matrix[src]

Construct a new identity matrix of given size.

Panics

We panic if the given size exceeds MAX_SIZE.

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

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.

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

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

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

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

pub fn size(&self) -> usize[src]

Size of the matrix.

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

Get the element in position (i, j).

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

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

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

Approximately equal test.

Trait Implementations

impl PartialEq<Matrix> for Matrix[src]

impl Debug for Matrix[src]

impl<'a> Add<&'a Matrix> for &'a Matrix[src]

type Output = Matrix

The resulting type after applying the + operator.

impl<'a> Mul<&'a Matrix> for &'a Matrix[src]

type Output = Matrix

The resulting type after applying the * operator.

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

Implements standard matrix vector multiplication.

Panics

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

type Output = Vector

The resulting type after applying the * operator.

Auto Trait Implementations

impl Send for Matrix

impl Sync for Matrix

impl Unpin for Matrix

impl UnwindSafe for Matrix

impl RefUnwindSafe for Matrix

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]