QuantumMatrix

Trait QuantumMatrix 

Source
pub trait QuantumMatrix:
    Debug
    + Send
    + Sync {
    // Required methods
    fn dim(&self) -> usize;
    fn to_dense(&self) -> Array2<Complex64>;
    fn to_sparse(&self) -> QuantRS2Result<CsrMatrix<Complex64>>;
    fn is_unitary(&self, tolerance: f64) -> QuantRS2Result<bool>;
    fn tensor_product(
        &self,
        other: &dyn QuantumMatrix,
    ) -> QuantRS2Result<Array2<Complex64>>;
    fn apply(
        &self,
        state: &ArrayView1<'_, Complex64>,
    ) -> QuantRS2Result<Array1<Complex64>>;
}
Expand description

Trait for quantum matrix operations

Required Methods§

Source

fn dim(&self) -> usize

Get the dimension of the matrix (assumed square)

Source

fn to_dense(&self) -> Array2<Complex64>

Convert to dense representation

Source

fn to_sparse(&self) -> QuantRS2Result<CsrMatrix<Complex64>>

Convert to sparse representation

Source

fn is_unitary(&self, tolerance: f64) -> QuantRS2Result<bool>

Check if the matrix is unitary

Source

fn tensor_product( &self, other: &dyn QuantumMatrix, ) -> QuantRS2Result<Array2<Complex64>>

Compute the tensor product with another matrix

Source

fn apply( &self, state: &ArrayView1<'_, Complex64>, ) -> QuantRS2Result<Array1<Complex64>>

Apply to a state vector

Implementors§