Struct quantum::matrix::Matrix [] [src]

pub struct Matrix {
    // some 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]

fn new(size: usize) -> Matrix

Construct a new zero-initialized matrix of given size.

Panics

We panic if the given size exceeds MAX_SIZE.

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.

fn identity(size: usize) -> Matrix

Construct a new identity matrix of given size.

Panics

We panic if the given size exceeds MAX_SIZE.

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.

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

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

fn size(&self) -> usize

Size of the matrix.

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

Get the element in position (i, j).

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

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

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

Approximately equal test.

Trait Implementations

impl Debug for Matrix
[src]

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

Formats the value using the given formatter.

impl PartialEq for Matrix
[src]

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

This method tests for self and other values to be equal, and is used by ==. Read more

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

This method tests for !=.

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

type Output = Matrix

The resulting type after applying the + operator

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

The method for the + operator

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

type Output = Matrix

The resulting type after applying the * operator

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

The method for the * operator

impl<'a> Mul<&'a Vector> 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

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

The method for the * operator