Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,29 +173,29 @@ if (env.isGpuAccelerated)

Configuring the environment is ordinarily not necessary, but convenient in certain applications.

For example, we may wish our simulations to deterministically obtain the same measurement outcomes and random states as a previous or future run, and ergo choose to [override](https://quest-kit.github.io/QuEST/group__debug__seed.html#ga9e3a6de413901afbf50690573add1587) the default seeds.
For example, we may wish our simulations to deterministically obtain the same measurement outcomes and random states as a previous or future run, and ergo choose to [override](https://quest-kit.github.io/QuEST/group__debug__seed.html#ga4fea21c26edfea5a64cbdab860dbf583) the default seeds.
```cpp
unsigned seeds[] = {123u, 1u << 10};
setSeeds(seeds, 2);
setQuESTSeeds(seeds, 2);
```

We may wish further to [adjust](https://quest-kit.github.io/QuEST/group__debug__reporting.html) how subsequent functions will display information to the screen
```cpp
int maxRows = 8;
int maxCols = 4;
setMaxNumReportedItems(maxRows, maxCols);
setMaxNumReportedSigFigs(3);
setQuESTMaxNumReportedItems(maxRows, maxCols);
setQuESTMaxNumReportedSigFigs(3);
```
or [add](https://quest-kit.github.io/QuEST/group__debug__reporting.html#ga29413703d609254244d6b13c663e6e06) extra spacing between QuEST's printed outputs
or [add](https://quest-kit.github.io/QuEST/group__debug__reporting.html#gac5fa20b24814c555eae1d77229959b5e) extra spacing between QuEST's printed outputs
```cpp
setNumReportedNewlines(3);
setQuESTNumReportedNewlines(3);
```

Perhaps we also wish to relax the [precision](https://quest-kit.github.io/QuEST/group__debug__validation.html#gae395568df6def76045ec1881fcb4e6d1) with which our future inputs will be asserted unitary or Hermitian
Perhaps we also wish to relax the [precision](https://quest-kit.github.io/QuEST/group__debug__validation.html#ga6be7e12fc056a751a03073ee6844b0eb) with which our future inputs will be asserted unitary or Hermitian
```cpp
setValidationEpsilon(0.001);
setQuESTValidationEpsilon(0.001);
```
but when unitarity _is_ violated, or we otherwise pass an invalid input, we wish to execute a [custom function](https://quest-kit.github.io/QuEST/group__debug__validation.html#ga14b6e7ce08465e36750da3acbc41062f) before exiting.
but when unitarity _is_ violated, or we otherwise pass an invalid input, we wish to execute a [custom function](https://quest-kit.github.io/QuEST/group__debug__validation.html#gaa02a39c21c770e06ff891e028fd1fe75) before exiting.
```cpp
#include <stdlib.h>

Expand All @@ -205,7 +205,7 @@ void myErrorHandler(const char *func, const char *msg) {
exit(1);
}

setInputErrorHandler(myErrorHandler);
setQuESTInputErrorHandler(myErrorHandler);
```

> [!TIP]
Expand All @@ -218,7 +218,7 @@ setInputErrorHandler(myErrorHandler);
> std::string msg(errMsg);
> throw std::runtime_error(func + ": " + msg);
> }
> setInputErrorHandler(myErrorHandler);
> setQuESTInputErrorHandler(myErrorHandler);
> ```
<!-- newlines removed above because doxygen renders them as <br> text, how stupid! -->

Expand Down Expand Up @@ -253,7 +253,7 @@ Qureg (10 qubit statevector, 1024 qcomps, 16.1 KiB):
0 |1022⟩
0 |1023⟩
```
> This printed only `8` amplitudes as per our setting of [`setMaxNumReportedItems()`](https://quest-kit.github.io/QuEST/group__debug__reporting.html#ga093c985b1970a0fd8616c01b9825979a) above.
> This printed only `8` amplitudes as per our setting of [`setQuESTMaxNumReportedItems()`](https://quest-kit.github.io/QuEST/group__debug__reporting.html#ga2f2d0258f4f7acd6bfe74a19f697d0c2) above.

Behind the scenes, the function `createQureg` did something clever; it consulted the compiled deployments and available hardware to decide whether to distribute `qureg`, or dedicate it persistent GPU memory, and marked whether or not to multithread its subsequent modification. It attempts to choose _optimally_, avoiding gratuitous parallelisation if the overheads outweigh the benefits, or if the hardware devices have insufficient memory.

Expand Down Expand Up @@ -356,7 +356,7 @@ Qureg:
globalTotal.......16 MiB
```

> The spacing between the outputs of those two consecutive QuEST functions was determined by our earlier call to [`setNumReportedNewlines()`](https://quest-kit.github.io/QuEST/group__debug__reporting.html#ga29413703d609254244d6b13c663e6e06).
> The spacing between the outputs of those two consecutive QuEST functions was determined by our earlier call to [`setQuESTNumReportedNewlines()`](https://quest-kit.github.io/QuEST/group__debug__reporting.html#gac5fa20b24814c555eae1d77229959b5e).


A density matrix `Qureg` can model classical uncertainty as results from [decoherence](https://quest-kit.github.io/QuEST/group__decoherence.html), and proves useful when simulating quantum operations on a noisy quantum computer.
Expand Down Expand Up @@ -415,7 +415,7 @@ Qureg (5 qubit density matrix, 32x32 qcomps, 16.1 KiB):
-0.00597-0.00615i -0.00207-0.00451i … 0.000509-0.00401i 0.0173+(3.12e-19)i
```

> The number of printed significant figures above results from our earlier calling of [`setMaxNumReportedSigFigs()`](https://quest-kit.github.io/QuEST/group__debug__reporting.html#ga15d46e5d813f70b587762814964e1994).
> The number of printed significant figures above results from our earlier calling of [`setQuESTMaxNumReportedSigFigs()`](https://quest-kit.github.io/QuEST/group__debug__reporting.html#ga3b4156994fdcf65eee0875316a9cc95f).



Expand Down Expand Up @@ -609,10 +609,10 @@ QuEST encountered a validation error during function 'applyCompMatr1':
The given matrix was not (approximately) unitary.
Exiting...
```
If we're satisfied our matrix _is_ sufficiently approximately unitary, we can [adjust](https://quest-kit.github.io/QuEST/group__debug__validation.html#gae395568df6def76045ec1881fcb4e6d1) or [disable](https://quest-kit.github.io/QuEST/group__debug__validation.html#ga5999824df0785ea88fb2d5b5582f2b46) the validation.
If we're satisfied our matrix _is_ sufficiently approximately unitary, we can [adjust](https://quest-kit.github.io/QuEST/group__debug__validation.html#ga6be7e12fc056a751a03073ee6844b0eb) or [disable](https://quest-kit.github.io/QuEST/group__debug__validation.html#ga0a20ca2bc35e22e914bc25671dabdb9b) the validation.
```cpp
// max(norm(m * dagger(m) - identity)) = 0.9025
setValidationEpsilon(0.903);
setQuESTValidationEpsilon(0.903);
applyCompMatr1(qureg, 0, m);
```

Expand Down Expand Up @@ -783,7 +783,7 @@ reportScalar("entanglement", calcPurity(reduced));
## Report the results


We've seen above that [scalars](https://quest-kit.github.io/QuEST/group__types.html) can be reported, handling the pretty formatting of real and complex numbers, controlled by settings like [`setMaxNumReportedSigFigs()`](https://quest-kit.github.io/QuEST/group__debug__reporting.html#ga15d46e5d813f70b587762814964e1994). But we can also report every data structure in the QuEST API, such as Pauli strings
We've seen above that [scalars](https://quest-kit.github.io/QuEST/group__types.html) can be reported, handling the pretty formatting of real and complex numbers, controlled by settings like [`setQuESTMaxNumReportedSigFigs()`](https://quest-kit.github.io/QuEST/group__debug__reporting.html#ga3b4156994fdcf65eee0875316a9cc95f). But we can also report every data structure in the QuEST API, such as Pauli strings
```cpp
reportPauliStr(
getInlinePauliStr("XXYYZZ", {5,50, 10,60, 30,40})
Expand All @@ -805,8 +805,8 @@ PauliStrSum (4 terms, 160 bytes):
```
All outputs are affected by the [reporter settings](https://quest-kit.github.io/QuEST/group__debug__reporting.html).
```cpp
setMaxNumReportedItems(4,4);
setMaxNumReportedSigFigs(1);
setQuESTMaxNumReportedItems(4,4);
setQuESTMaxNumReportedSigFigs(1);
reportCompMatr(bigmatrix);
```
```
Expand Down
2 changes: 1 addition & 1 deletion docs/v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ QuEST `v4` has completely overhauled the API, software architecture, algorithms,
The set of supported quantum operations has greatly expanded. _All_ unitaries can be effected with any number of control qubits (in any [state](https://quest-kit.github.io/QuEST/group__op__compmatr.html#ga2f4526fe3a4f96509040151f3d31535a)), diagonal matrices can be [raised to powers](https://quest-kit.github.io/QuEST/group__op__diagmatr.html#ga7e07c28332d7d89784166f82cdd26eb9), density matrices can undergo [partial tracing](https://quest-kit.github.io/QuEST/group__calc__partialtrace.html) and [inhomogeneous Pauli channels](https://quest-kit.github.io/QuEST/group__decoherence.html#ga51a7f8d5ba0b142c37a698deed07bc28) (in addition to general [Kraus maps](https://quest-kit.github.io/QuEST/group__decoherence.html#ga57753c0d2deac93d3395c5b20a0122f0) and [superoperatos](https://quest-kit.github.io/QuEST/group__decoherence.html#ga6afbb4f2bb3a9c382861feb8a7b70951)), and multi-qubit projectors can now be performed, [with](https://quest-kit.github.io/QuEST/group__op__measurement.html#ga6bd438f3ebd80cf017292bb68542ed8f) and [without](https://quest-kit.github.io/QuEST/group__op__projectors.html#gaa4bde7e5a344fb46cf3119d462b18745) renormalisation.
<br><br>
- **more control** <br>
Extensive new [debugging](https://quest-kit.github.io/QuEST/group__debug.html) facilities allow [disabling](https://quest-kit.github.io/QuEST/group__debug__validation.html#ga5999824df0785ea88fb2d5b5582f2b46) or [changing](https://quest-kit.github.io/QuEST/group__debug__validation.html#gae395568df6def76045ec1881fcb4e6d1) the validation precision and [error response](https://quest-kit.github.io/QuEST/group__debug__validation.html#ga14b6e7ce08465e36750da3acbc41062f) at runtime, and controlling how many [amplitudes](https://quest-kit.github.io/QuEST/group__debug__reporting.html#ga093c985b1970a0fd8616c01b9825979a) and [significant figures](https://quest-kit.github.io/QuEST/group__debug__reporting.html#ga15d46e5d813f70b587762814964e1994) of `Qureg` and matrices are printed.
Extensive new [debugging](https://quest-kit.github.io/QuEST/group__debug.html) facilities allow [disabling](https://quest-kit.github.io/QuEST/group__debug__validation.html#ga0a20ca2bc35e22e914bc25671dabdb9b) or [changing](https://quest-kit.github.io/QuEST/group__debug__validation.html#ga6be7e12fc056a751a03073ee6844b0eb) the validation precision and [error response](https://quest-kit.github.io/QuEST/group__debug__validation.html#gaa02a39c21c770e06ff891e028fd1fe75) at runtime, and controlling how many [amplitudes](https://quest-kit.github.io/QuEST/group__debug__reporting.html#ga2f2d0258f4f7acd6bfe74a19f697d0c2) and [significant figures](https://quest-kit.github.io/QuEST/group__debug__reporting.html#ga3b4156994fdcf65eee0875316a9cc95f) of `Qureg` and matrices are printed.
<br><br>
- **better documentation** <br>
The [documentation](/docs/) has been rewritten from the ground-up, and the [API doc](https://quest-kit.github.io/QuEST/topics.html) grouped into sub-categories and aesthetically overhauled with [Doxygen Awesome](https://jothepro.github.io/doxygen-awesome-css/). It is now more consistently structured, mathematically explicit, and is a treat on the eyes!
Expand Down
20 changes: 10 additions & 10 deletions examples/extended/dynamics.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,16 @@ PauliStrSum createMyObservable(int numQubits) {

void reportMyStructs(Qureg qureg, PauliStrSum hamil, PauliStrSum observ) {

setMaxNumReportedSigFigs(6); // sig-figs in scalars
setNumReportedNewlines(2); // spacing between reports
setReportedPauliChars(".XYZ"); // print I as .
setReportedPauliStrStyle(0); // print XYZ (0) or Z3 Y2 X1 (1)
setMaxNumReportedItems(8, 8); // show max 8 qureg amplitudes
setQuESTMaxNumReportedSigFigs(6); // sig-figs in scalars
setQuESTNumReportedNewlines(2); // spacing between reports
setQuESTReportedPauliChars(".XYZ"); // print I as .
setQuESTReportedPauliStrStyle(0); // print XYZ (0) or Z3 Y2 X1 (1)
setQuESTMaxNumReportedItems(8, 8); // show max 8 qureg amplitudes

reportStr("[Initial state]");
reportQureg(qureg);

setMaxNumReportedItems(0, 0); // show 0=all Pauli operators
setQuESTMaxNumReportedItems(0, 0); // show 0=all Pauli operators

reportStr("[Hamiltonian]");
reportPauliStrSum(hamil);
Expand Down Expand Up @@ -144,8 +144,8 @@ int main() {
reportMyStructs(qureg, hamil, observ);

// tidy reporting of below expectation values
setMaxNumReportedSigFigs(3);
setNumReportedNewlines(1);
setQuESTMaxNumReportedSigFigs(3);
setQuESTNumReportedNewlines(1);

// evolve by repeatedly (each is a "step") Trotterising
// exp(-i dt H) with the specified order and repetitions.
Expand All @@ -172,8 +172,8 @@ int main() {
reportStr("");

// preview the final state...
setNumReportedNewlines(2);
setMaxNumReportedItems(25, 25);
setQuESTNumReportedNewlines(2);
setQuESTMaxNumReportedItems(25, 25);
reportStr("[Final state]");
reportQureg(qureg);

Expand Down
20 changes: 10 additions & 10 deletions examples/extended/dynamics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ PauliStrSum createMyObservable(int numQubits) {

void reportMyStructs(Qureg qureg, PauliStrSum hamil, PauliStrSum observ) {

setMaxNumReportedSigFigs(6); // sig-figs in scalars
setNumReportedNewlines(2); // spacing between reports
setReportedPauliChars(".XYZ"); // print I as .
setReportedPauliStrStyle(0); // print XYZ (0) or Z3 Y2 X1 (1)
setMaxNumReportedItems(8, 8); // show max 8 qureg amplitudes
setQuESTMaxNumReportedSigFigs(6); // sig-figs in scalars
setQuESTNumReportedNewlines(2); // spacing between reports
setQuESTReportedPauliChars(".XYZ"); // print I as .
setQuESTReportedPauliStrStyle(0); // print XYZ (0) or Z3 Y2 X1 (1)
setQuESTMaxNumReportedItems(8, 8); // show max 8 qureg amplitudes

reportStr("[Initial state]");
reportQureg(qureg);

setMaxNumReportedItems(0, 0); // show 0=all Pauli operators
setQuESTMaxNumReportedItems(0, 0); // show 0=all Pauli operators

reportStr("[Hamiltonian]");
reportPauliStrSum(hamil);
Expand Down Expand Up @@ -141,8 +141,8 @@ int main() {
reportMyStructs(qureg, hamil, observ);

// tidy reporting of below expectation values
setMaxNumReportedSigFigs(3);
setNumReportedNewlines(1);
setQuESTMaxNumReportedSigFigs(3);
setQuESTNumReportedNewlines(1);

// evolve by repeatedly (each is a "step") Trotterising
// exp(-i dt H) with the specified order and repetitions.
Expand All @@ -166,8 +166,8 @@ int main() {
reportStr("");

// preview the final state...
setNumReportedNewlines(2);
setMaxNumReportedItems(25, 25);
setQuESTNumReportedNewlines(2);
setQuESTMaxNumReportedItems(25, 25);
reportStr("[Final state]");
reportQureg(qureg);

Expand Down
6 changes: 3 additions & 3 deletions examples/isolated/reporting_matrices.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void demo_CompMatr() {
for (int i=0; i<len; i++) {
qindex num = numReportElems[i];
rootPrint(num);
setMaxNumReportedItems(num, num);
setQuESTMaxNumReportedItems(num, num);
reportCompMatr(matr);
}
}
Expand All @@ -69,7 +69,7 @@ void demo_DiagMatr() {
for (int i=0; i<len; i++) {
qindex num = numReportElems[i];
rootPrint(num);
setMaxNumReportedItems(num, num);
setQuESTMaxNumReportedItems(num, num);
reportDiagMatr(matr);
}
}
Expand All @@ -91,7 +91,7 @@ void demo_FullStateDiagMatr() {
for (int i=0; i<6; i++) {
qindex num = numReportElems[i];
rootPrint(num);
setMaxNumReportedItems(num, num);
setQuESTMaxNumReportedItems(num, num);
reportFullStateDiagMatr(matr);
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/isolated/reporting_matrices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void demo_CompMatr() {

for (int num : {0, 12, 5, 1}) {
rootPrint(num);
setMaxNumReportedItems(num, num);
setQuESTMaxNumReportedItems(num, num);
reportCompMatr(matr);
}
}
Expand All @@ -55,7 +55,7 @@ void demo_DiagMatr() {

for (int num : {0, 10}) {
rootPrint(num);
setMaxNumReportedItems(num, num);
setQuESTMaxNumReportedItems(num, num);
reportDiagMatr(matr);
}
}
Expand All @@ -74,7 +74,7 @@ void demo_FullStateDiagMatr() {

for (int num : {0, 50, 30, 10, 5, 1}) {
rootPrint(num);
setMaxNumReportedItems(num, num);
setQuESTMaxNumReportedItems(num, num);
reportFullStateDiagMatr(matr);
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/isolated/reporting_paulis.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void demo_PauliStrSum() {
qindex num = numReportElems[i];
rootPrint(num);

setMaxNumReportedItems(num, num);
setQuESTMaxNumReportedItems(num, num);
reportPauliStrSum(sum);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/isolated/reporting_paulis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ void demo_PauliStrSum() {
for (int num : numReportElems) {
rootPrint(num);

setMaxNumReportedItems(num, num);
setQuESTMaxNumReportedItems(num, num);
reportPauliStrSum(sum);
}

Expand Down
2 changes: 1 addition & 1 deletion examples/isolated/setting_errorhandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void myErrorHandler(const char* errFunc, const char* errMsg) {

int main() {
initQuESTEnv();
setInputErrorHandler(myErrorHandler);
setQuESTInputErrorHandler(myErrorHandler);

Qureg qureg = createQureg(-123);

Expand Down
4 changes: 2 additions & 2 deletions examples/isolated/setting_errorhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ void myErrorHandlerB(const char* errFunc, const char* errMsg) {
int main() {
initQuESTEnv();

setInputErrorHandler(myErrorHandlerA);
setQuESTInputErrorHandler(myErrorHandlerA);

try {
Qureg qureg = createQureg(-123);
Expand All @@ -59,7 +59,7 @@ int main() {
<< std::endl;
}

setInputErrorHandler(myErrorHandlerB);
setQuESTInputErrorHandler(myErrorHandlerB);
initQuESTEnv(); // illegal to recall

std::cout << "this will never be reached, because myErrorHandlerB exits!" << std::endl;
Expand Down
Loading
Loading