stabilizer-ch-form-rust 0.1.0

A Rust library implementing CH form representation of stabilizer states for quantum computing simulations.
Documentation
use crate::StabilizerCHForm;
use ndarray::{Zip, s};

impl StabilizerCHForm {
    /// Performs a bitwise XOR operation on two rows of a boolean matrix.
    /// i.e., matrix[target, :] ^= matrix[source, :].
    pub(crate) fn xor_rows(matrix: &mut ndarray::Array2<bool>, target: usize, source: usize) {
        // Split view to allow simultaneous mutable borrows
        let (mut row_target, row_source) = matrix.multi_slice_mut((s![target, ..], s![source, ..]));

        Zip::from(&mut row_target)
            .and(&row_source)
            .for_each(|t, &s| {
                *t ^= s;
            });
    }

    /// Performs a bitwise XOR operation on two columns of a boolean matrix.
    /// i.e., matrix[:, target] ^= matrix[:, source].
    pub(crate) fn xor_columns(matrix: &mut ndarray::Array2<bool>, target: usize, source: usize) {
        // Split view to allow simultaneous mutable borrows
        let (mut col_target, col_source) = matrix.multi_slice_mut((s![.., target], s![.., source]));

        Zip::from(&mut col_target)
            .and(&col_source)
            .for_each(|t, &s| {
                *t ^= s;
            });
    }
}