DiagonalGate
QuICT.core.gate.DiagonalGate ¶
Bases: object
Diagonal gate
Reference
https://arxiv.org/abs/2108.06150
Parameters:
-
target(int) –number of target qubits
-
aux(int, default:0) –number of auxiliary qubits
-
opt(bool, default:True) –optimizer switch, enabled by default
-
keep_phase(bool, default:True) –global phase switch
Source code in QuICT/core/gate/diagonal_gate.py
S_x
classmethod
¶
Implement the Appendix H, also the construction of sets \(S_x\).
Parameters:
-
x(int) –the number from \(0\) to \(2^n-1\)
-
n(int) –the length of these binary strings
return
str: an array \(S_x = [x \otimes e_1,x \otimes e_2,...,x \otimes e_n]\)
Source code in QuICT/core/gate/diagonal_gate.py
__call__ ¶
Parameters:
-
theta(List[float]) –list of (2 ** target) angles of rotation in the diagonal gate
Returns:
-
CompositeGate(CompositeGate) –diagonal gate
Source code in QuICT/core/gate/diagonal_gate.py
alpha_s
classmethod
¶
Solve Equation 6 \(\sum_s \alpha_s <s, x> = \theta(x)\)
Parameters:
-
theta(List[float]) –phase angles of the diagonal gate
-
s(int) –key of the solution component
-
n(int) –number of qubits in the diagonal gate
Returns:
-
float(float) –\(\alpha_s\) in Equation 6
Source code in QuICT/core/gate/diagonal_gate.py
binary_addition
classmethod
¶
Implement the function: \(x \otimes y = (x1 \otimes y1, x2 \otimes y2, · · · , xn \otimes yn)^T\)
Parameters:
-
binary_string1(str) –binary string like x
-
binary_string2(str) –binary string like y
-
n(int) –the length of the binary strings
return
str: a string with bitwise binary addition
Source code in QuICT/core/gate/diagonal_gate.py
binary_inner_prod
staticmethod
¶
Calculate the binary inner product of s_bin and x_bin, where s_bin and x_bin are binary representation of s and x respectively of width n
Parameters:
-
s(int) –s in
-
x(int) –x in
-
width(int) –the width of s_bin and x_bin
Returns:
-
int(int) –the binary inner product of s and x
Source code in QuICT/core/gate/diagonal_gate.py
construct_T
classmethod
¶
Realize the construction of a two-dimensional string array T, each row of the array constitutes a matrix with diagonal elements of 1.
Parameters:
-
n(int) –size of the prefixes c
Returns:
-
Tuple[List[List[str]], int]–Tuple[List[List[str]], int]: 2-dimension T string array, with the number of rows: ell
Source code in QuICT/core/gate/diagonal_gate.py
disjoint_families_F
classmethod
¶
Implement the Eq(15),disjoint families F_1,...,F_ell
Parameters:
-
r_c(int) –size of the prefixes c
-
r_t(int) –size of the suffix t
Returns:
-
List[Set[str]]–List[Set[str]]: 2-dimension (r_c + r_t)-bit string array, also the linear independent set F with ell rows and not fixed columns
Source code in QuICT/core/gate/diagonal_gate.py
int_to_binary
classmethod
¶
Parameters:
-
num(int) –the number from 0 to 2^n-1
-
n(int) –the length of the binary strings
return
str: numeric num converted binary string
Source code in QuICT/core/gate/diagonal_gate.py
ket_fjk
classmethod
¶
Implement the part of unitary U1 for every j: \(|0\rangle -> |<s(j, k), x>\rangle\) by adding the CNOT gates
Parameters:
-
j(int) –j is the label of n-bit strings s(j,k)
-
k(int) –k is the label of n-bit strings s(j,k)
-
n(int) –length of 0-1 string to be partitioned
-
t(int) –length of the shared prefix of each row
-
target_num(int) –the target label connecting the CNOT gate
Returns:
-
CompositeGate(CompositeGate) –\(|0\rangle -> |<s(j, k), x>\rangle\)
Source code in QuICT/core/gate/diagonal_gate.py
linear_fjk
classmethod
¶
Implement the linear functions \(f_{jk}(x) = <s(j, k), x>\)
Parameters:
-
j(int) –j is the label of n-bit strings s(j, k)
-
k(int) –k is the label of n-bit strings s(j, k)
-
n(int) –length of 0-1 string to be partitioned
-
t(int) –length of the shared prefix of each row
-
x(int) –the independent variables of the function \(f_{jk}\)
Returns:
-
int(int) –\(f_{jk}(x)\)
Source code in QuICT/core/gate/diagonal_gate.py
linearly_independent_sets_T
classmethod
¶
Implement the Appendix H, also the construction of sets T.
Parameters:
-
n(int) –the size of each sublist T^(i),i = 1,2,...,ell
return
Tuple[List[List[str]], int]: 2-dimension n-bit string array, also the linear independent set T with ell rows and n columns and the number of T, ell.
Source code in QuICT/core/gate/diagonal_gate.py
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 | |
lucal_gray_code
staticmethod
¶
Generate the (k, n)-Gray code defined in and following Lemma 7
Parameters:
-
k(int) –start the circular modification from the k-th binary code
-
n(int) –the length of binary code, that is, the length of Gray code would be 2^n
Returns:
-
List[str]–List[str]: the (k, n)-Gray code
Source code in QuICT/core/gate/diagonal_gate.py
no_aux_qubit ¶
Parameters:
-
n(int) –number of qubits in the diagonal gate
-
theta(List[float]) –list of (2 ** target) angles of rotation in the diagonal gate
Returns:
-
CompositeGate(CompositeGate) –diagonal gate without auxiliary qubit
Source code in QuICT/core/gate/diagonal_gate.py
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 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 | |
partitioned_gray_code
classmethod
¶
Lemma 15 by the construction in Appendix E
Parameters:
-
n(int) –length of 0-1 string to be partitioned
-
t(int) –length of the shared prefix of each row
Returns:
-
List[List[str]]–List[List[str]]: partitioned gray code
Source code in QuICT/core/gate/diagonal_gate.py
phase_shift
classmethod
¶
Implement the phase shift \(|x\rangle -> \exp(i \theta(x)) |x\rangle\) by solving Equation 6 \(\sum_s \alpha_s <s, x> = \theta(x)\)
Parameters:
-
theta(List[float]) –phase angles of the diagonal gate
-
seq(Iterable, default:None) –sequence of s application, numerical order if not assigned
-
aux(int, default:None) –key of auxiliary qubit (if exists)
Returns:
-
CompositeGate(CompositeGate) –CompositeGate of the diagonal gate
Source code in QuICT/core/gate/diagonal_gate.py
phase_shift_s
classmethod
¶
Implement the phase shift for a certain s defined in Equation 5 as Figure 8 \(|x\rangle -> \exp(i \alpha_s <s, x>) |x\rangle\)
Parameters:
-
s(int) –whose binary representation stands for the 0-1 string s
-
n(int) –the number of qubits in \(|x\rangle\)
-
alpha(float) –\(\alpha_s\) in the equation
-
aux(int, default:None) –key of auxiliary qubit (if exists)
-
j(int, default:None) –if no auxiliary qubit, the j-th smallest element in s_idx would be the target qubit
Returns:
-
CompositeGate(CompositeGate) –CompositeGate for Equation 5 as Figure 8
Source code in QuICT/core/gate/diagonal_gate.py
with_aux_qubit ¶
Parameters:
-
theta(List[float]) –list of (2 ** target) angles of rotation in the diagonal gate
Returns:
-
CompositeGate(CompositeGate) –diagonal gate with auxiliary qubit at the end of qubits
Source code in QuICT/core/gate/diagonal_gate.py
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 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | |