ShorFactor
QuICT.algorithm.quantum_algorithm.ShorFactor ¶
Shor's factoring algorithm
References
[1]: "Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer" by Peter W. Shor https://arxiv.org/abs/quant-ph/9508027.
[2]: Nielsen, M.A., & Chuang, I.L. (2010). Quantum Computation and Quantum Information, p.232.
Parameters:
-
N(int) –The number to be factored.
-
c_mod_multiplier(str, default:'bea') –Modular multiplication method to be used when constructing the circuit for Shor's algorithm, choose from "bea" and "hrs".
-
qpe_method(str, default:'normal') –Quantum phase estimation implementation to be used when constructing the order finding circuit, choose from "normal" and "iterative".
Source code in QuICT/algorithm/quantum_algorithm/shor/shor_factor.py
running_data
property
¶
Return historical data of all the qpe circuits that has been used by run in (base, qpe_algorithm) key and value pairs.
SRData ¶
For storing (s, r) pair when running order finding for multiple times.
Source code in QuICT/algorithm/quantum_algorithm/shor/shor_factor.py
add ¶
Add new (s, r) pair.
Source code in QuICT/algorithm/quantum_algorithm/shor/shor_factor.py
is_valid ¶
Return whether the incoming s-r pair can be added.
circuit ¶
Construct the order finding quantum circuit for Shor's algorithm,
Parameters:
-
base(int, default:None) –The base for calculating the order r mod N. Has to be coprime to N. If not provided, will choose randomly in [2, N - 1].
Returns:
-
Circuit(Circuit) –An order finding circuit.
Source code in QuICT/algorithm/quantum_algorithm/shor/shor_factor.py
reset ¶
run ¶
run(base: int = None, *, max_it: int = 1, forced_quantum_approach: bool = False, backend=StateVectorSimulator(ignore_last_measure=False)) -> Tuple[int, int]
Run Shor's factoring algorithm.
Parameters:
-
base(int, default:None) –The base for calculating the order r mod N. Has to be coprime to N. If not provided, will choose randomly in [2, N - 1].
-
max_it(int, default:1) –The maximum number of order finding iteration.
-
forced_quantum_approach(bool, default:False) –If true, the order finding part is forced to use the quantum approach.
-
backend(Any, default:StateVectorSimulator(ignore_last_measure=False)) –Device to run the circuit.
Returns:
-
Tuple[int, int]–Tuple[int, int]: The two factors that multiply to N.
Source code in QuICT/algorithm/quantum_algorithm/shor/shor_factor.py
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |