3
3
4
4
use crate :: estimates:: { Error , ErrorCorrection } ;
5
5
6
- use std:: {
7
- fmt:: { Debug , Display } ,
8
- rc:: Rc ,
9
- } ;
6
+ use std:: rc:: Rc ;
10
7
11
- /// Logical qubit model.
8
+ /// A logical patch from an error correction code
12
9
///
13
- /// A logical qubit is derived from a physical qubit and a fault-tolerance
14
- /// protocol. Construction methods are provided that take as additional input
15
- /// the code distance, or alternatively the target error rate from which the
16
- /// code distance is computed .
17
- pub struct LogicalQubit < E : ErrorCorrection > {
10
+ /// A logical patch is an instantiation of an error correcting code for some
11
+ /// assignment to the code parameters. It stores all computed information such
12
+ /// as the number of physical and logical qubits, cycle time, and logical error
13
+ /// rate .
14
+ pub struct LogicalPatch < E : ErrorCorrection > {
18
15
physical_qubit : Rc < E :: Qubit > ,
19
16
code_parameter : E :: Parameter ,
20
17
physical_qubits : u64 ,
18
+ logical_qubits : u64 ,
21
19
logical_cycle_time : u64 ,
22
20
logical_error_rate : f64 ,
23
21
}
24
22
25
- impl < E : ErrorCorrection > LogicalQubit < E > {
23
+ impl < E : ErrorCorrection > LogicalPatch < E > {
26
24
pub fn new ( ftp : & E , code_parameter : E :: Parameter , qubit : Rc < E :: Qubit > ) -> Result < Self , Error > {
27
25
// safe to convert here because we check for negative values before
28
26
let physical_qubits = ftp
29
- . physical_qubits_per_logical_qubit ( & code_parameter)
27
+ . physical_qubits ( & code_parameter)
30
28
. map_err ( Error :: PhysicalQubitComputationFailed ) ?;
29
+ let logical_qubits = ftp
30
+ . logical_qubits ( & code_parameter)
31
+ . map_err ( Error :: LogicalQubitComputationFailed ) ?;
31
32
let logical_cycle_time = ftp
32
33
. logical_cycle_time ( & qubit, & code_parameter)
33
34
. map_err ( Error :: LogicalCycleTimeComputationFailed ) ?;
@@ -39,6 +40,7 @@ impl<E: ErrorCorrection> LogicalQubit<E> {
39
40
physical_qubit : qubit,
40
41
code_parameter,
41
42
physical_qubits,
43
+ logical_qubits,
42
44
logical_cycle_time,
43
45
logical_error_rate,
44
46
} )
@@ -49,11 +51,16 @@ impl<E: ErrorCorrection> LogicalQubit<E> {
49
51
& self . physical_qubit
50
52
}
51
53
52
- /// Returns the code distance .
54
+ /// Returns the code parameter .
53
55
pub fn code_parameter ( & self ) -> & E :: Parameter {
54
56
& self . code_parameter
55
57
}
56
58
59
+ /// Returns the number of logical qubits in the patch.
60
+ pub fn logical_qubits ( & self ) -> u64 {
61
+ self . logical_qubits
62
+ }
63
+
57
64
/// Returns the number of physical qubits to encode the logical qubit.
58
65
pub fn physical_qubits ( & self ) -> u64 {
59
66
self . physical_qubits
@@ -74,12 +81,3 @@ impl<E: ErrorCorrection> LogicalQubit<E> {
74
81
1e9 / ( self . logical_cycle_time as f64 )
75
82
}
76
83
}
77
-
78
- impl < E : ErrorCorrection > Debug for LogicalQubit < E >
79
- where
80
- E :: Parameter : Display ,
81
- {
82
- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
83
- write ! ( f, "LQubit(d={})" , self . code_parameter( ) )
84
- }
85
- }
0 commit comments