pub struct Probability(/* private fields */);
Implementations§
Source§impl Probability
impl Probability
Sourcepub fn new(probability: f64) -> Self
pub fn new(probability: f64) -> Self
Examples found in repository?
examples/random_linear_code.rs (line 14)
5fn main() {
6 let code = LinearCode::random_regular_code()
7 .num_bits(4)
8 .num_checks(3)
9 .bit_degree(3)
10 .check_degree(4)
11 .sample_with(&mut thread_rng())
12 .unwrap();
13
14 let noise = BinarySymmetricChannel::with_probability(Probability::new(0.2));
15 let error = code.random_error(&noise, &mut thread_rng());
16 println!("{}", error);
17}
More examples
examples/css_decoding.rs (line 9)
7fn main() {
8 let max_iterations = 100;
9 let probability = Probability::new(0.01);
10 let code = code();
11 let decoder = decoder(&code, probability, max_iterations);
12 let noise = DepolarizingNoise::with_probability(probability);
13 let mut failures = 0;
14 for _ in 0..1000 {
15 let error = code.random_error(&noise, &mut thread_rng());
16 let syndrome = code.syndrome_of(&error);
17 let correction: PauliOperator = decoder.correction_for(syndrome.as_view()).into();
18 if !code.has_stabilizer(&(&error * &correction)) {
19 failures += 1;
20 }
21 }
22 println!("{}", failures);
23}
pub fn try_new(probability: f64) -> Option<Self>
pub fn value(&self) -> f64
Trait Implementations§
Source§impl Clone for Probability
impl Clone for Probability
Source§fn clone(&self) -> Probability
fn clone(&self) -> Probability
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Probability
impl Debug for Probability
Source§impl Display for Probability
impl Display for Probability
Source§impl PartialEq for Probability
impl PartialEq for Probability
impl Copy for Probability
impl StructuralPartialEq for Probability
Auto Trait Implementations§
impl Freeze for Probability
impl RefUnwindSafe for Probability
impl Send for Probability
impl Sync for Probability
impl Unpin for Probability
impl UnwindSafe for Probability
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.