pub struct DetectorErrorModel {
pub num_detectors: usize,
pub num_observables: usize,
pub errors: Vec<DEMError>,
pub coordinate_shifts: Vec<Vec<f64>>,
pub detector_coords: HashMap<usize, Vec<f64>>,
}Expand description
Detector Error Model representation
Fields§
§num_detectors: usizeNumber of detectors in the circuit
num_observables: usizeNumber of logical observables
errors: Vec<DEMError>List of error mechanisms
coordinate_shifts: Vec<Vec<f64>>Coordinate system shifts (for visualization)
detector_coords: HashMap<usize, Vec<f64>>Detector coordinates
Implementations§
Source§impl DetectorErrorModel
impl DetectorErrorModel
Sourcepub fn from_circuit(circuit: &StimCircuit) -> Result<Self>
pub fn from_circuit(circuit: &StimCircuit) -> Result<Self>
Generate a DEM from a Stim circuit
This performs error analysis by:
- Identifying all error mechanisms in the circuit
- Propagating each error through to detectors/observables
- Recording which detectors/observables are affected
Sourcepub fn to_dem_string(&self) -> String
pub fn to_dem_string(&self) -> String
Convert DEM to Stim DEM format string
Sourcepub fn from_dem_string(s: &str) -> Result<Self>
pub fn from_dem_string(s: &str) -> Result<Self>
Parse a DEM from string
Sourcepub fn sample(&self) -> (Vec<bool>, Vec<bool>)
pub fn sample(&self) -> (Vec<bool>, Vec<bool>)
Sample errors according to the DEM
Returns (detector_outcomes, observable_flips) for a single sample
Sourcepub fn sample_batch(&self, num_shots: usize) -> Vec<(Vec<bool>, Vec<bool>)>
pub fn sample_batch(&self, num_shots: usize) -> Vec<(Vec<bool>, Vec<bool>)>
Sample multiple shots
Sourcepub fn total_error_probability(&self) -> f64
pub fn total_error_probability(&self) -> f64
Get the total error probability
Sourcepub fn num_error_mechanisms(&self) -> usize
pub fn num_error_mechanisms(&self) -> usize
Get number of error mechanisms
Sourcepub fn force_error(&mut self, qubit: usize, error_type: ErrorType) -> usize
pub fn force_error(&mut self, qubit: usize, error_type: ErrorType) -> usize
Force a specific error on a qubit with probability 1.0.
This inserts a deterministic error mechanism into the DEM for debugging and testing. The error targets no detectors or observables by default (they must be wired by the caller via the returned index, or by re-analysing the circuit); however, it records the qubit, error type, and probability so that downstream samplers see it as a certain event.
§Arguments
qubit— Index of the qubit to apply the error to.error_type— The Pauli or measurement error to force.
§Returns
The index of the newly added error mechanism in self.errors.
Sourcepub fn force_error_with_targets(
&mut self,
qubit: usize,
error_type: ErrorType,
detector_targets: Vec<usize>,
observable_targets: Vec<usize>,
) -> usize
pub fn force_error_with_targets( &mut self, qubit: usize, error_type: ErrorType, detector_targets: Vec<usize>, observable_targets: Vec<usize>, ) -> usize
Force a specific error and associate it with given detector and observable targets.
Unlike force_error, this variant lets the caller
specify exactly which detectors and observables flip when the error
occurs, enabling accurate decoding tests.
Trait Implementations§
Source§impl Clone for DetectorErrorModel
impl Clone for DetectorErrorModel
Source§fn clone(&self) -> DetectorErrorModel
fn clone(&self) -> DetectorErrorModel
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DetectorErrorModel
impl RefUnwindSafe for DetectorErrorModel
impl Send for DetectorErrorModel
impl Sync for DetectorErrorModel
impl Unpin for DetectorErrorModel
impl UnsafeUnpin for DetectorErrorModel
impl UnwindSafe for DetectorErrorModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.