[−][src]Struct quest_rs::ComplexMatrix2
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]
fn clone(&self) -> ComplexMatrix2
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for ComplexMatrix2
[src]
impl Debug for ComplexMatrix2
[src]
Auto Trait Implementations
impl RefUnwindSafe for ComplexMatrix2
impl Send for ComplexMatrix2
impl Sync for ComplexMatrix2
impl Unpin for ComplexMatrix2
impl UnwindSafe for ComplexMatrix2
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,