[][src]Struct quest_rs::ComplexMatrix2

pub struct ComplexMatrix2 {
    pub real: [[f64; 2]; 2],
    pub imag: [[f64; 2]; 2],
}

Represents a 2x2 matrix of complex numbers.

Examples

use quest_rs::{Complex, ComplexMatrix2};

let pauli_x = ComplexMatrix2::new([
    [0.0, 1.0],
    [1.0, 0.0],
], [
    [0.0, 0.0],
    [0.0, 0.0],
]);
assert_eq!(pauli_x.real, [
    [0.0, 1.0],
    [1.0, 0.0],
]);
assert_eq!(pauli_x.imag, [
    [0.0, 0.0],
    [0.0, 0.0],
]);

let phase = ComplexMatrix2::compact([
    [Complex::real(1.0), Complex::zero()],
    [Complex::zero(), Complex::imag(1.0)],
]);
assert_eq!(phase.real, [
    [1.0, 0.0],
    [0.0, 0.0],
]);
assert_eq!(phase.imag, [
    [0.0, 0.0],
    [0.0, 1.0],
]);

let pauli_z = ComplexMatrix2::real([
    [1.0, 0.0],
    [0.0, -1.0],
]);
assert_eq!(pauli_z.real, [
    [1.0, 0.0],
    [0.0, -1.0],
]);
assert_eq!(pauli_z.imag, [
    [0.0, 0.0],
    [0.0, 0.0],
]);

let pauli_y = ComplexMatrix2::imag([
    [0.0, -1.0],
    [1.0, 0.0],
]);
assert_eq!(pauli_y.real, [
    [0.0, 0.0],
    [0.0, 0.0],
]);
assert_eq!(pauli_y.imag, [
    [0.0, -1.0],
    [1.0, 0.0],
]);

Fields

real: [[f64; 2]; 2]imag: [[f64; 2]; 2]

Methods

impl ComplexMatrix2[src]

pub fn new(real: [[QReal; 2]; 2], imag: [[QReal; 2]; 2]) -> Self[src]

pub fn compact(values: [[Complex; 2]; 2]) -> Self[src]

pub fn real(real: [[QReal; 2]; 2]) -> Self[src]

pub fn imag(imag: [[QReal; 2]; 2]) -> Self[src]

Trait Implementations

impl Clone for ComplexMatrix2[src]

impl Copy for ComplexMatrix2[src]

impl Debug for ComplexMatrix2[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.