|
16 | 16 | We often wish to write algorithms which operate on quantum data. One can think |
17 | 17 | of quantum data types, similar to classical data types, where a collection of |
18 | 18 | qubits can be used to represent a specific quantum data type (eg: a quantum |
19 | | -integer of width 32 would comprise of 32 qubits, similar to a classical uint32 |
| 19 | +integer of width 32 would comprise 32 qubits, similar to a classical uint32 |
20 | 20 | type). More generally, many current primitives and algorithms in qualtran |
21 | 21 | implicitly expect registers which represent signed or unsigned integers, |
22 | 22 | fixed-point (fp) numbers , or “classical registers” which store some classical |
|
40 | 40 | type assuming the bitsizes match. QInt(32) == QAny(32), QInt(32) != |
41 | 41 | QFxp(32, 16). QInt(32) != QUInt(32). |
42 | 42 | 5. We assume a big endian convention for addressing QBits in registers |
43 | | -throughout qualtran. Recall that in a big endian convention the most signficant |
| 43 | +throughout qualtran. Recall that in a big endian convention the most significant |
44 | 44 | bit is at index 0. If you iterate through the bits in a register they will be |
45 | 45 | yielded from most significant to least significant. |
46 | 46 | 6. Ones' complement integers are used extensively in quantum algorithms. We have |
@@ -181,7 +181,7 @@ def __str__(self): |
181 | 181 |
|
182 | 182 | @attrs.frozen |
183 | 183 | class QAny(QDType): |
184 | | - """Opaque bag-of-qbits type.""" |
| 184 | + """Opaque bag-of-qubits type.""" |
185 | 185 |
|
186 | 186 | bitsize: SymbolicInt |
187 | 187 |
|
@@ -214,7 +214,10 @@ def assert_valid_classical_val_array(self, val_array, debug_str: str = 'val'): |
214 | 214 | class QInt(QDType): |
215 | 215 | """Signed Integer of a given width bitsize. |
216 | 216 |
|
217 | | - A two's complement representation is assumed for negative integers. |
| 217 | + A two's complement representation is used for negative integers. |
| 218 | +
|
| 219 | + Here (and throughout Qualtran), we use a big-endian bit convention. The most significant |
| 220 | + bit is at index 0. |
218 | 221 |
|
219 | 222 | Attributes: |
220 | 223 | bitsize: The number of qubits used to represent the integer. |
@@ -275,7 +278,11 @@ def __str__(self): |
275 | 278 | class QIntOnesComp(QDType): |
276 | 279 | """Signed Integer of a given width bitsize. |
277 | 280 |
|
278 | | - A ones' complement representation is assumed for negative integers. |
| 281 | + In contrast to `QInt`, this data type uses the ones' complement representation for negative |
| 282 | + integers. |
| 283 | +
|
| 284 | + Here (and throughout Qualtran), we use a big-endian bit convention. The most significant |
| 285 | + bit is at index 0. |
279 | 286 |
|
280 | 287 | Attributes: |
281 | 288 | bitsize: The number of qubits used to represent the integer. |
@@ -323,8 +330,11 @@ def assert_valid_classical_val(self, val, debug_str: str = 'val'): |
323 | 330 | class QUInt(QDType): |
324 | 331 | """Unsigned integer of a given width bitsize which wraps around upon overflow. |
325 | 332 |
|
326 | | - Similar to unsigned integer types in C. Any intended wrap around effect is |
327 | | - expected to be handled by the developer. |
| 333 | + Any intended wrap around effect is expected to be handled by the developer, similar |
| 334 | + to an unsigned integer type in C. |
| 335 | +
|
| 336 | + Here (and throughout Qualtran), we use a big-endian bit convention. The most significant |
| 337 | + bit is at index 0. |
328 | 338 |
|
329 | 339 | Attributes: |
330 | 340 | bitsize: The number of qubits used to represent the integer. |
|
0 commit comments