The Quantum Exact Simulation Toolkit v4.1.0
Loading...
Searching...
No Matches
initialisations.h
1/** @file
2 * API signatures for initialising Quregs into
3 * particular states. Note when a Qureg is GPU-
4 * accelerated, these functions only update the
5 * state in GPU memory; the CPU amps are unchanged.
6 *
7 * @author Tyson Jones
8 *
9 * @defgroup initialisations Initialisations
10 * @ingroup api
11 * @brief Functions for preparing Quregs in particular states.
12 * @{
13 */
14
15#ifndef INITIALISATIONS_H
16#define INITIALISATIONS_H
17
18#include "quest/include/types.h"
19#include "quest/include/qureg.h"
20#include "quest/include/paulis.h"
21
22
23
24/*
25 * C AND C++ AGNOSTIC FUNCTIONS
26 */
27
28// enable invocation by both C and C++ binaries
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33
34
35/**
36 * @defgroup init_states States
37 * @brief Functions for initialising Qureg into physical states.
38 * @{
39 */
40
41
42/// @notyetdoced
43/// @notyetvalidated
44void initBlankState(Qureg qureg);
45
46
47/// @notyetdoced
48/// @notyetvalidated
49void initZeroState(Qureg qureg);
50
51
52/// @notyetdoced
53/// @notyetvalidated
54void initPlusState(Qureg qureg);
55
56
57/// @notyetdoced
58/// @notyetvalidated
59/// @notyettested
60void initPureState(Qureg qureg, Qureg pure);
61
62
63/// @notyetdoced
64/// @notyetvalidated
65void initClassicalState(Qureg qureg, qindex stateInd);
66
67
68/// @notyetdoced
69/// @notyetvalidated
70void initDebugState(Qureg qureg);
71
72
73/// @notyetdoced
74/// @notyetvalidated
75void initArbitraryPureState(Qureg qureg, qcomp* amps);
76
77
78/// @notyetdoced
79/// @notyetvalidated
80void initRandomPureState(Qureg qureg);
81
82
83/// @notyetdoced
84/// @notyetvalidated
85void initRandomMixedState(Qureg qureg, qindex numPureStates);
86
87
88/** @} */
89
90
91
92/**
93 * @defgroup init_amps Amplitudes
94 * @brief Functions for overwriting Qureg amplitudes.
95 * @{
96 */
97
98
99/// @notyetdoced
100/// @notyetvalidated
101void setQuregAmps(Qureg qureg, qindex startInd, qcomp* amps, qindex numAmps);
102
103
104/// @notyetdoced
105/// @notyetvalidated
106void setDensityQuregAmps(Qureg qureg, qindex startRow, qindex startCol, qcomp** amps, qindex numRows, qindex numCols);
107
108
109/// @notyetdoced
110/// @notyetvalidated
111void setDensityQuregFlatAmps(Qureg qureg, qindex startInd, qcomp* amps, qindex numAmps);
112
113
114/// @notyetdoced
115/// @notyettested
116void setQuregToClone(Qureg targetQureg, Qureg copyQureg);
117
118
119/** @notyetdoced
120 * @notyettested
121 *
122 * @formulae
123 *
124 * Let @f$ f_{\text{out}} = @f$ @p facOut, @f$ f_1 = @f$ @p fac1 and @f$ f_2 = @f$ @p fac2.
125 * Similarly, let @f$ \psi_{\text{out}} = @f$ @p out, @f$ \psi_{1} = @f$ @p qureg1 and @f$ \psi_{2} = @f$ @p qureg2.
126 *
127 * This function modifies only @p facOut to become
128 * @f[
129 |\psi_{\text{out}}\rangle \; \rightarrow \;
130 f_{\text{out}} |\psi_{\text{out}}\rangle \, + \,
131 f_1 |\psi_1\rangle \, + \,
132 f_2 |\psi_2\rangle.
133 * @f]
134 *
135 * All factors are unconstrained and are permitted to be zero, and the same @p Qureg can be duplicated among
136 * all arguments.
137 */
138void setQuregToSuperposition(qcomp facOut, Qureg out, qcomp fac1, Qureg qureg1, qcomp fac2, Qureg qureg2);
139
140
141/// @notyetdoced
142/// @notyetvalidated
143qreal setQuregToRenormalized(Qureg qureg);
144
145
146/// @notyetdoced
147/// @notyetvalidated
149
150
151/// @notyetdoced
152/// @notyettested
153void setQuregToPartialTrace(Qureg out, Qureg in, int* traceOutQubits, int numTraceQubits);
154
155
156/// @notyetdoced
157/// @notyettested
158void setQuregToReducedDensityMatrix(Qureg out, Qureg in, int* retainQubits, int numRetainQubits);
159
160
161/** @} */
162
163
164
165// end de-mangler
166#ifdef __cplusplus
167}
168#endif
169
170
171
172/*
173 * C++ OVERLOADS
174 *
175 * which are only accessible to C++ binaries, and accept
176 * arguments more natural to C++ (e.g. std::vector). We
177 * manually add these to their respective Doxygen doc groups.
178 */
179
180#ifdef __cplusplus
181
182#include <vector>
183
184
185/// @ingroup init_amps
186/// @notyettested
187/// @notyetdoced
188/// @notyetvalidated
189/// @cpponly
190/// @see setQuregAmps()
191void setQuregAmps(Qureg qureg, qindex startInd, std::vector<qcomp> amps);
192
193
194/// @ingroup init_amps
195/// @notyettested
196/// @notyetdoced
197/// @notyetvalidated
198/// @cpponly
199/// @see setDensityQuregAmps()
200void setDensityQuregAmps(Qureg qureg, qindex startRow, qindex startCol, std::vector<std::vector<qcomp>> amps);
201
202
203/// @ingroup init_amps
204/// @notyettested
205/// @notyetdoced
206/// @notyetvalidated
207/// @cpponly
208/// @see setDensityQuregFlatAmps()
209void setDensityQuregFlatAmps(Qureg qureg, qindex startInd, std::vector<qcomp> amps);
210
211
212/// @ingroup init_amps
213/// @notyettested
214/// @notyetdoced
215/// @notyetvalidated
216/// @cpponly
217/// @see setQuregToPartialTrace()
218void setQuregToPartialTrace(Qureg out, Qureg in, std::vector<int> traceOutQubits);
219
220
221/// @ingroup init_amps
222/// @notyettested
223/// @notyetdoced
224/// @notyetvalidated
225/// @cpponly
226/// @see setQuregToReducedDensityMatrix()
227void setQuregToReducedDensityMatrix(Qureg out, Qureg in, std::vector<int> retainQubits);
228
229
230#endif // __cplusplus
231
232
233
234#endif // INITIALISATIONS_H
235
236/** @} */ // (end file-wide doxygen defgroup)
void setDensityQuregFlatAmps(Qureg qureg, qindex startInd, qcomp *amps, qindex numAmps)
void setQuregToReducedDensityMatrix(Qureg out, Qureg in, int *retainQubits, int numRetainQubits)
void setQuregToPauliStrSum(Qureg qureg, PauliStrSum sum)
void setQuregAmps(Qureg qureg, qindex startInd, qcomp *amps, qindex numAmps)
void setQuregToPartialTrace(Qureg out, Qureg in, int *traceOutQubits, int numTraceQubits)
qreal setQuregToRenormalized(Qureg qureg)
void setQuregToClone(Qureg targetQureg, Qureg copyQureg)
void setDensityQuregAmps(Qureg qureg, qindex startRow, qindex startCol, qcomp **amps, qindex numRows, qindex numCols)
void setQuregToSuperposition(qcomp facOut, Qureg out, qcomp fac1, Qureg qureg1, qcomp fac2, Qureg qureg2)
void initArbitraryPureState(Qureg qureg, qcomp *amps)
void initRandomPureState(Qureg qureg)
void initPlusState(Qureg qureg)
void initZeroState(Qureg qureg)
void initPureState(Qureg qureg, Qureg pure)
void initDebugState(Qureg qureg)
void initRandomMixedState(Qureg qureg, qindex numPureStates)
void initClassicalState(Qureg qureg, qindex stateInd)
void initBlankState(Qureg qureg)
Definition qureg.h:49