1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! Safe Rust bindings for the vendored PyMatching decoder.
//!
//! The crate exposes the current Rust surface of the workspace's
//! `pymatching-cxx` bridge, with explicit support types for graph construction,
//! decoding options, and optional ecosystem adapters.
//!
//! # Quick start
//!
//! ```
//! use ndarray::array;
//! use pymatching::{CheckMatrixOptions, Matching};
//!
//! let check_matrix = array![[1_u8, 1, 0], [0, 1, 1]];
//! let matching = Matching::from_check_matrix(
//! check_matrix.view(),
//! CheckMatrixOptions::new(),
//! )?;
//!
//! let prediction = matching.decode(array![1_u8, 0].view())?;
//! assert_eq!(prediction.len(), 3);
//! # Ok::<(), pymatching::MatchingError>(())
//! ```
//!
//! # Building graphs directly
//!
//! ```
//! use pymatching::{EdgeData, Matching};
//!
//! let mut matching = Matching::default();
//! matching.add_edge(0, 1, EdgeData::new(vec![0]).with_weight(2.0))?;
//! matching.add_boundary_edge(1, EdgeData::new(vec![1]))?;
//!
//! assert!(matching.has_edge(0, 1));
//! assert!(matching.has_boundary_edge(1));
//! assert_eq!(matching.num_edges(), 2);
//! # Ok::<(), pymatching::MatchingError>(())
//! ```
//!
//! # Decoder modes
//!
//! | Mode | Construction | Single syndrome | Batch |
//! | --- | --- | --- | --- |
//! | Raw matching | Any graph | [`Matching::decode`] | [`Matching::decode_batch`] |
//! | Correlated matching | Stim model with correlations enabled | [`Matching::decode_with_options`] | [`Matching::decode_batch_with_options`] |
//! | Raw GAP | Stim model, correlations disabled | [`Matching::decode_gap`] | [`Matching::decode_gap_batch`] |
//! | Correlated GAP | Stim model, correlations enabled | [`Matching::decode_gap`] | [`Matching::decode_gap_batch`] |
//!
//! Native correlated hard decoding is selected with
//! [`DecodeOptions::with_enable_correlations`]. GAP follows the construction
//! setting automatically and remains basis agnostic: logical cuts are inferred
//! from graph fault ids.
//!
//! # Stim interop
//!
//! Stim-backed constructors accept the safe Rust [`stim::Circuit`] and
//! [`stim::DetectorErrorModel`] types directly. Their C++ representation stays
//! private to the FFI boundary.
pub use ;
pub use Matching;
pub use ;
/// Returns the pinned upstream PyMatching Git commit used by the C++ bridge.