You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _sources/language/types.rst.txt
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,7 +65,7 @@ declares a reference to a quantum bit. These qubits are referred
65
65
to as "virtual qubits" (in distinction to "physical qubits" on
66
66
actual hardware; see below). The statement ``qubit[size] name;``
67
67
declares a quantum register with ``size`` qubits.
68
-
Sizes must always be :ref:`compile-time constant <const-expression>` positive
68
+
Sizes must always be :ref:`compile-time constant <const-expression>` non-negative
69
69
integers.
70
70
Quantum registers cannot be resized after declaration.
71
71
@@ -237,6 +237,7 @@ There are n-bit signed and unsigned integers. The statements ``int[size] name;``
237
237
signed 1:n-1:0 and unsigned 0:n:0 integers of the given size. The sizes
238
238
and the surrounding brackets can be omitted (*e.g.* ``int name;``) to use
239
239
a precision that is specified by the particular target architecture.
240
+
If provided, the ``size`` of an integer must be at least 1.
240
241
Bit-level operations cannot be used on types without a specified width, and
241
242
unspecified-width types are different to *all* specified-width types for
242
243
the purposes of casting.
@@ -310,8 +311,8 @@ multiplication and division by unsigned integers is defined by standard
310
311
unsigned-integer arithmetic, with more details found in :ref:`the section on
311
312
classical instructions <classical-instructions>`.
312
313
313
-
The statement ``angle[size] name;`` statement declares a new angle called
314
-
``name`` with ``size`` bits in its representation. Angles can be assigned
314
+
The statement ``angle[size] name;`` declares a new angle called
315
+
``name`` with ``size`` bits in its representation, where ``size`` must be a positive integer. Angles can be assigned
315
316
values using the constant ``π`` or ``pi``, such as::
316
317
317
318
// Declare a 20-bit angle with the value of "π/2"
@@ -805,6 +806,8 @@ and for multi-dimensional arrays subarray accesses can be specified using a
805
806
comma-delimited list of indices (*e.g.* ``myArr[1, 2, 3]``), with the outer
806
807
dimension specified first.
807
808
809
+
One or more dimension(s) of an array can be zero, in which case the array has size zero. An array of size zero cannot be indexed, e.g. given ``array[float[32], 0] myArray;``, it is an error to access either ``myArray[0]`` or ``myArray[-1]``.
810
+
808
811
Assignment to elements of arrays, as in the examples above, acts as expected,
809
812
with the left-hand side of the assignment operating as a reference, thereby
810
813
updating the values inside the original array. For multi-dimensional arrays,
Copy file name to clipboardExpand all lines: language/types.html
+5-3Lines changed: 5 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -84,7 +84,7 @@ <h3>Qubits<a class="headerlink" href="#qubits" title="Link to this heading">¶</
84
84
to as “virtual qubits” (in distinction to “physical qubits” on
85
85
actual hardware; see below). The statement <codeclass="docutils literal notranslate"><spanclass="pre">qubit[size]</span><spanclass="pre">name;</span></code>
86
86
declares a quantum register with <codeclass="docutils literal notranslate"><spanclass="pre">size</span></code> qubits.
87
-
Sizes must always be <aclass="reference internal" href="#const-expression"><spanclass="std std-ref">compile-time constant</span></a>positive
87
+
Sizes must always be <aclass="reference internal" href="#const-expression"><spanclass="std std-ref">compile-time constant</span></a>non-negative
88
88
integers.
89
89
Quantum registers cannot be resized after declaration.</p>
90
90
<p>The label <codeclass="docutils literal notranslate"><spanclass="pre">name[j]</span></code> refers to a qubit of this register, where
@@ -225,6 +225,7 @@ <h3>Integers<a class="headerlink" href="#integers" title="Link to this heading">
225
225
signed 1:n-1:0 and unsigned 0:n:0 integers of the given size. The sizes
226
226
and the surrounding brackets can be omitted (<em>e.g.</em><codeclass="docutils literal notranslate"><spanclass="pre">int</span><spanclass="pre">name;</span></code>) to use
227
227
a precision that is specified by the particular target architecture.
228
+
If provided, the <codeclass="docutils literal notranslate"><spanclass="pre">size</span></code> of an integer must be at least 1.
228
229
Bit-level operations cannot be used on types without a specified width, and
229
230
unspecified-width types are different to <em>all</em> specified-width types for
230
231
the purposes of casting.
@@ -286,8 +287,8 @@ <h3>Floating point numbers<a class="headerlink" href="#floating-point-numbers" t
286
287
multiplication and division by unsigned integers is defined by standard
287
288
unsigned-integer arithmetic, with more details found in <aclass="reference internal" href="classical.html#classical-instructions"><spanclass="std std-ref">the section on
288
289
classical instructions</span></a>.</p>
289
-
<p>The statement <codeclass="docutils literal notranslate"><spanclass="pre">angle[size]</span><spanclass="pre">name;</span></code>statement declares a new angle called
290
-
<codeclass="docutils literal notranslate"><spanclass="pre">name</span></code> with <codeclass="docutils literal notranslate"><spanclass="pre">size</span></code> bits in its representation. Angles can be assigned
290
+
<p>The statement <codeclass="docutils literal notranslate"><spanclass="pre">angle[size]</span><spanclass="pre">name;</span></code> declares a new angle called
291
+
<codeclass="docutils literal notranslate"><spanclass="pre">name</span></code> with <codeclass="docutils literal notranslate"><spanclass="pre">size</span></code> bits in its representation, where <codeclass="docutils literal notranslate"><spanclass="pre">size</span></code> must be a positive integer. Angles can be assigned
291
292
values using the constant <codeclass="docutils literal notranslate"><spanclass="pre">π</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">pi</span></code>, such as:</p>
292
293
<divclass="highlight-qasm3 notranslate"><divclass="highlight"><pre><span></span><spanclass="c1">// Declare a 20-bit angle with the value of "π/2"</span>
@@ -804,6 +805,7 @@ <h2>Literals<a class="headerlink" href="#literals" title="Link to this heading">
804
805
and for multi-dimensional arrays subarray accesses can be specified using a
805
806
comma-delimited list of indices (<em>e.g.</em><codeclass="docutils literal notranslate"><spanclass="pre">myArr[1,</span><spanclass="pre">2,</span><spanclass="pre">3]</span></code>), with the outer
806
807
dimension specified first.</p>
808
+
<p>One or more dimension(s) of an array can be zero, in which case the array has size zero. An array of size zero cannot be indexed, e.g. given <codeclass="docutils literal notranslate"><spanclass="pre">array[float[32],</span><spanclass="pre">0]</span><spanclass="pre">myArray;</span></code>, it is an error to access either <codeclass="docutils literal notranslate"><spanclass="pre">myArray[0]</span></code> or <codeclass="docutils literal notranslate"><spanclass="pre">myArray[-1]</span></code>.</p>
807
809
<p>Assignment to elements of arrays, as in the examples above, acts as expected,
808
810
with the left-hand side of the assignment operating as a reference, thereby
809
811
updating the values inside the original array. For multi-dimensional arrays,
Copy file name to clipboardExpand all lines: release_notes.html
+11-6Lines changed: 11 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -34,10 +34,10 @@
34
34
35
35
<sectionid="release-notes">
36
36
<h1>Release Notes<aclass="headerlink" href="#release-notes" title="Link to this heading">¶</a></h1>
37
-
<sectionid="spec-v3-1-0-21">
38
-
<spanid="release-notes-spec-v3-1-0-21"></span><h2>spec/v3.1.0-21<aclass="headerlink" href="#spec-v3-1-0-21" title="Link to this heading">¶</a></h2>
37
+
<sectionid="spec-v3-1-0-22">
38
+
<spanid="release-notes-spec-v3-1-0-22"></span><h2>spec/v3.1.0-22<aclass="headerlink" href="#spec-v3-1-0-22" title="Link to this heading">¶</a></h2>
39
39
<sectionid="new-features">
40
-
<spanid="release-notes-spec-v3-1-0-21-new-features"></span><h3>New Features<aclass="headerlink" href="#new-features" title="Link to this heading">¶</a></h3>
40
+
<spanid="release-notes-spec-v3-1-0-22-new-features"></span><h3>New Features<aclass="headerlink" href="#new-features" title="Link to this heading">¶</a></h3>
41
41
<ulclass="simple">
42
42
<li><p>The types <codeclass="docutils literal notranslate"><spanclass="pre">bool</span></code> and (scalar) <codeclass="docutils literal notranslate"><spanclass="pre">bit</span></code> are now explicitly described as being completely
43
43
interchangeable in expression (r-value) positions, and that <codeclass="docutils literal notranslate"><spanclass="pre">bit</span></code> and <codeclass="docutils literal notranslate"><spanclass="pre">bit[1]</span></code> are distinct
@@ -49,7 +49,12 @@ <h1>Release Notes<a class="headerlink" href="#release-notes" title="Link to this
49
49
</ul>
50
50
</section>
51
51
<sectionid="upgrade-notes">
52
-
<spanid="release-notes-spec-v3-1-0-21-upgrade-notes"></span><h3>Upgrade Notes<aclass="headerlink" href="#upgrade-notes" title="Link to this heading">¶</a></h3>
52
+
<spanid="release-notes-spec-v3-1-0-22-upgrade-notes"></span><h3>Upgrade Notes<aclass="headerlink" href="#upgrade-notes" title="Link to this heading">¶</a></h3>
53
+
<ulclass="simple">
54
+
<li><p>It has been clarified that arrays and registers of size zero are
55
+
allowed; however, integers and angles must have size greater than
56
+
zero.</p></li>
57
+
</ul>
53
58
<ulclass="simple">
54
59
<li><p>The <codeclass="docutils literal notranslate"><spanclass="pre">qubit</span></code> type is no longer a valid base type for an <codeclass="docutils literal notranslate"><spanclass="pre">array</span></code>, and it is no longer stated
55
60
that the register type <codeclass="docutils literal notranslate"><spanclass="pre">qubit[n]</span></code> is equivalent to an <codeclass="docutils literal notranslate"><spanclass="pre">array</span></code>; there is no need for these
@@ -58,7 +63,7 @@ <h1>Release Notes<a class="headerlink" href="#release-notes" title="Link to this
58
63
</ul>
59
64
</section>
60
65
<sectionid="bug-fixes">
61
-
<spanid="release-notes-spec-v3-1-0-21-bug-fixes"></span><h3>Bug Fixes<aclass="headerlink" href="#bug-fixes" title="Link to this heading">¶</a></h3>
66
+
<spanid="release-notes-spec-v3-1-0-22-bug-fixes"></span><h3>Bug Fixes<aclass="headerlink" href="#bug-fixes" title="Link to this heading">¶</a></h3>
62
67
<ulclass="simple">
63
68
<li><p>Some minor mathematical errors in the descriptions of the explicit gate
64
69
actions in <aclass="reference internal" href="language/standard_library.html#sdg" title="language/standard_library"><codeclass="xref oq oq-gate docutils literal notranslate"><spanclass="pre">sdg</span></code></a>, <aclass="reference internal" href="language/standard_library.html#rx" title="language/standard_library"><codeclass="xref oq oq-gate docutils literal notranslate"><spanclass="pre">rx</span></code></a>, <aclass="reference internal" href="language/standard_library.html#ry" title="language/standard_library"><codeclass="xref oq oq-gate docutils literal notranslate"><spanclass="pre">ry</span></code></a>, <aclass="reference internal" href="language/standard_library.html#rz" title="language/standard_library"><codeclass="xref oq oq-gate docutils literal notranslate"><spanclass="pre">rz</span></code></a>, <aclass="reference internal" href="language/standard_library.html#crx" title="language/standard_library"><codeclass="xref oq oq-gate docutils literal notranslate"><spanclass="pre">crx</span></code></a> and
0 commit comments