Skip to content

Commit 040d36e

Browse files
Sync docs for SDK version 1.3.0
1 parent eec6278 commit 040d36e

38 files changed

+119
-31
lines changed

.internal/docs/qmod-reference/api-reference/classical-functions.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

.internal/docs/qmod-reference/language-reference/classical-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,10 @@ and populates `MyStruct` in its call to `foo`.
197197
## Hamiltonians
198198

199199
Qmod's Python embedding offers a specialized syntax for creating
200-
[sparse Hamiltonian](https://docs.classiq.io/latest/qmod-reference/api-reference/classical-types/#classiq.qmod.builtins.structs.SparsePauliOp)
200+
[sparse Hamiltonian](../../../sdk-reference/qmod/classical-types/#classiq.qmod.builtins.structs.SparsePauliOp)
201201
objects.
202202
Calling a
203-
[Pauli](https://docs.classiq.io/latest/qmod-reference/api-reference/classical-types/#classiq.qmod.builtins.enums.Pauli)
203+
[Pauli](../../../sdk-reference/qmod/classical-types/#classiq.qmod.builtins.enums.Pauli)
204204
enum value (e.g., `Pauli.X`) with an index (e.g., `Pauli.X(3)`) creates a
205205
single-qubit Pauli operator.
206206
The multiplication of single-qubit Pauli operators (e.g.,

.internal/docs/qmod-reference/language-reference/expressions.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ search:
88
Expressions in Qmod have syntax, semantics, and use, similar to expressions in
99
conventional programming languages.
1010
They comprise literal values, variables, and operators applied to them.
11-
However, Qmod is unique in that variables can be of either [classical](https://docs.classiq.io/latest/qmod-reference/api-reference/classical-types) or
12-
[quantum](https://docs.classiq.io/latest/qmod-reference/language-reference/quantum-types) types, and quantum variables have states that can be a
11+
However, Qmod is unique in that variables can be of either [classical](../../../sdk-reference/qmod/classical-types) or
12+
[quantum](../quantum-types) types, and quantum variables have states that can be a
1313
superposition of values, entangled with the states of other variables.
1414
Expressions over quantum variables evaluate to a superposition of correlated
1515
values.
16-
For example, if `x` is a [classical variable](https://docs.classiq.io/latest/qmod-reference/language-reference/classical-variables)
16+
For example, if `x` is a [classical variable](../classical-variables)
1717
of type `CInt` (an integer), then `x + 1` is a classical expression of type
1818
`CInt` comprising the operator `+` (plus) applied to `x` and the literal `1`.
19-
Similarly, if `qarr` is a [quantum variable](https://docs.classiq.io/latest/qmod-reference/language-reference/quantum-variables)
19+
Similarly, if `qarr` is a [quantum variable](../quantum-variables)
2020
of type `QArray[QNum[3]]`, then `qarr[0] > x` is a quantum expression of type
2121
`QBit`.
2222

@@ -170,7 +170,7 @@ Classical variables may have known values at [compile time, link time, or runtim
170170
Classical expressions with only compile-time variables are evaluated and
171171
simplified during compilation.
172172
This applies sub-expressions of quantum expressions too.
173-
Qmod supports several built-in classical [constants and functions](https://docs.classiq.io/latest/qmod-reference/api-reference/symbolic-functions/),
173+
Qmod supports several built-in classical [constants and functions](../../../sdk-reference/qmod/symbolic-functions/),
174174
such as `pi` and `sin`.
175175

176176
### Example

.internal/docs/qmod-reference/language-reference/statements/classical-control-flow.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,91 @@ in the Classiq open-library.
114114
}
115115
}
116116
```
117+
118+
## Classical Foreach
119+
120+
The _foreach_ statement iterates through the elements of a classical array.
121+
Its compilation and simulation are more efficient.
122+
123+
<!-- prettier-ignore-start -->
124+
!!! warning
125+
The `foreach` statement is an experimental feature. It is only supported in
126+
Qmod Python.
127+
<!-- prettier-ignore-end -->
128+
129+
### Syntax
130+
131+
=== "Python"
132+
133+
[comment]: DO_NOT_TEST
134+
```python
135+
def foreach(values: CArray | list, iteration: Callable) -> None:
136+
pass
137+
```
138+
139+
The `iteration` callable accepts one or more iteration variables.
140+
141+
### Semantics
142+
143+
- Invoke the _iteration_ block once for every element of _values_.
144+
- If the _iteration_ block accepts a single iteration variable, the elements
145+
of _values_ will be bound to it sequentially.
146+
- If _values_ is a nested array (`CArray[CArray]`), the length of _values_'
147+
elements is $n$, $n>=2$, and the _iteration_ block has $n$ iteration
148+
variables, then _values_' elements will be unpacked into the iteration
149+
variables in each iteration.
150+
- Inside the statement block, use of quantum variables declared outside it is restricted
151+
to contexts where the variable is initialized and remains initialized (see [Quantum Variables](../quantum-variables.md))
152+
- _values_ must be a value of type `CArray[CReal]` or `CArray[CArray[CReal]]`.
153+
154+
### Examples
155+
156+
In the following example, the `foreach` statement iterates through the elements
157+
of the classical list `[0.1, 0.2]` and assigns its elements into the iteration
158+
variable `i`.
159+
This is equivalent to calling `RX` and `Y` twice, once with angle `0.1` and
160+
once with `0.2`.
161+
162+
=== "Python"
163+
164+
```python
165+
from classiq import *
166+
167+
168+
@qfunc
169+
def main(q: Output[QBit]) -> None:
170+
allocate(q)
171+
foreach(
172+
[0.1, 0.2],
173+
lambda i: [
174+
RX(i, q),
175+
Y(q),
176+
],
177+
)
178+
```
179+
180+
In the following example, the `foreach` statement iterates through the elements
181+
of the classical list `[[0.1, 0.2], [0.3, 0.4]]` and assigns its elements into the iteration
182+
variables `i` and `j`.
183+
In each iteration, the elements of the nested arrays are "unpacked" into the
184+
iteration variables.
185+
The first iteration assigns `0.1` into `i` and `0.2` into `j`, and the second
186+
iteration assigns `0.3` into `i` and `0.4` into `j`.
187+
188+
=== "Python"
189+
190+
```python
191+
from classiq import *
192+
193+
194+
@qfunc
195+
def main(q: Output[QBit]) -> None:
196+
allocate(q)
197+
foreach(
198+
[[0.1, 0.2], [0.3, 0.4]],
199+
lambda i, j: [
200+
RX(i, q),
201+
RY(j, q),
202+
],
203+
)
204+
```

.internal/docs/sdk-reference/cudaq.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ These functions require the `cudaq` extra (install `classiq[cudaq]`).
1010
Note that the `cudaq` extra is only available in Classiq Studio and on any Linux
1111
Machine.
1212

13-
::: classiq.qprog_to_cudaq
13+
::: classiq.cudaq.qprog_to_cudaq.qprog_to_cudaq_kernel
14+
::: classiq.cudaq.pauli_op_to_cudaq.pauli_operator_to_cudaq_spin_op

.internal/docs/sdk-reference/modeling.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

.internal/docs/qmod-reference/api-reference/classical-types.md renamed to .internal/docs/sdk-reference/qmod/classical-types.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,17 @@ search:
44
---
55

66
This is a list of the classical types that are built-in in `Qmod`.
7-
For more information regarding classical types see: [classical types](../language-reference/classical-types.md).
7+
For more information regarding classical types see: [classical types](../../../qmod-reference/language-reference/classical-types/).
88

99
::: classiq.qmod.builtins.structs
10+
options:
11+
show_source: false
12+
show_if_no_docstring: false
1013
::: classiq.qmod.builtins.constants
14+
options:
15+
show_source: false
16+
show_if_no_docstring: false
1117
::: classiq.qmod.builtins.enums
18+
options:
19+
show_source: false
20+
show_if_no_docstring: false

.internal/docs/qmod-reference/api-reference/functions/core_library/allocation.md renamed to .internal/docs/sdk-reference/qmod/functions/core_library/allocation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ search:
1414
- prepare_amplitudes
1515
- inplace_prepare_state
1616
- inplace_prepare_amplitudes
17+
- assign_phase_table
1718
<!-- prettier-ignore-end -->
1819
<!-- spell-checker: enable -->

.internal/docs/qmod-reference/api-reference/functions/core_library/arithmetic.md renamed to .internal/docs/sdk-reference/qmod/functions/core_library/arithmetic.md

File renamed without changes.

.internal/docs/qmod-reference/api-reference/functions/core_library/exponentiation.md renamed to .internal/docs/sdk-reference/qmod/functions/core_library/exponentiation.md

File renamed without changes.

0 commit comments

Comments
 (0)