[−][src]Struct quest_rs::ComplexMatrix4
Represents a 4x4 matrix of complex numbers.
Examples
use quest_rs::{Complex, ComplexMatrix4}; let sqrt_swap = ComplexMatrix4::new([ [1.0, 0.0, 0.0, 0.0], [0.0, 0.5, 0.5, 0.0], [0.0, 0.5, 0.5, 0.0], [0.0, 0.0, 0.0, 1.0], ], [ [0.0, 0.0, 0.0, 0.0], [0.0, 0.5, -0.5, 0.0], [0.0, -0.5, 0.5, 0.0], [0.0, 0.0, 0.0, 0.0], ]); assert_eq!(sqrt_swap.real, [ [1.0, 0.0, 0.0, 0.0], [0.0, 0.5, 0.5, 0.0], [0.0, 0.5, 0.5, 0.0], [0.0, 0.0, 0.0, 1.0], ]); assert_eq!(sqrt_swap.imag, [ [0.0, 0.0, 0.0, 0.0], [0.0, 0.5, -0.5, 0.0], [0.0, -0.5, 0.5, 0.0], [0.0, 0.0, 0.0, 0.0], ]); let sqrt_swap_compact = ComplexMatrix4::compact([ [Complex::real(1.0), Complex::zero(), Complex::zero(), Complex::zero()], [Complex::zero(), Complex::new(0.5, 0.5), Complex::new(0.5, -0.5), Complex::zero()], [Complex::zero(), Complex::new(0.5, -0.5), Complex::new(0.5, 0.5), Complex::zero()], [Complex::zero(), Complex::zero(), Complex::zero(), Complex::real(1.0)], ]); assert_eq!(sqrt_swap.real, sqrt_swap_compact.real); assert_eq!(sqrt_swap.imag, sqrt_swap_compact.imag); let controlled_z = ComplexMatrix4::real([ [1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, -1.0], ]); assert_eq!(controlled_z.real, [ [1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, -1.0], ]); assert_eq!(controlled_z.imag, [ [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], ]); let imaginary_cnot = ComplexMatrix4::imag([ [1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 0.0, 1.0], [0.0, 0.0, 1.0, 0.0], ]); assert_eq!(imaginary_cnot.real, [ [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], [0.0, 0.0, 0.0, 0.0], ]); assert_eq!(imaginary_cnot.imag, [ [1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 0.0, 1.0], [0.0, 0.0, 1.0, 0.0], ]);
Fields
real: [[f64; 4]; 4]imag: [[f64; 4]; 4]Methods
impl ComplexMatrix4[src]
pub fn new(real: [[QReal; 4]; 4], imag: [[QReal; 4]; 4]) -> Self[src]
pub fn compact(values: [[Complex; 4]; 4]) -> Self[src]
pub fn real(real: [[QReal; 4]; 4]) -> Self[src]
pub fn imag(imag: [[QReal; 4]; 4]) -> Self[src]
Trait Implementations
impl Clone for ComplexMatrix4[src]
fn clone(&self) -> ComplexMatrix4[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Copy for ComplexMatrix4[src]
impl Debug for ComplexMatrix4[src]
Auto Trait Implementations
impl RefUnwindSafe for ComplexMatrix4
impl Send for ComplexMatrix4
impl Sync for ComplexMatrix4
impl Unpin for ComplexMatrix4
impl UnwindSafe for ComplexMatrix4
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>,