The Quantum Exact Simulation Toolkit v4.0.0
Loading...
Searching...
No Matches

Functions for overwriting Qureg amplitudes. More...

Functions

void setDensityQuregAmps (Qureg qureg, qindex startRow, qindex startCol, qcomp **amps, qindex numRows, qindex numCols)
 
void setDensityQuregFlatAmps (Qureg qureg, qindex startInd, qcomp *amps, qindex numAmps)
 
void setQuregAmps (Qureg qureg, qindex startInd, qcomp *amps, qindex numAmps)
 
void setQuregToClone (Qureg targetQureg, Qureg copyQureg)
 
void setQuregToPartialTrace (Qureg out, Qureg in, int *traceOutQubits, int numTraceQubits)
 
void setQuregToPauliStrSum (Qureg qureg, PauliStrSum sum)
 
void setQuregToReducedDensityMatrix (Qureg out, Qureg in, int *retainQubits, int numRetainQubits)
 
qreal setQuregToRenormalized (Qureg qureg)
 
void setQuregToSuperposition (qcomp facOut, Qureg out, qcomp fac1, Qureg qureg1, qcomp fac2, Qureg qureg2)
 

Detailed Description

Functions for overwriting Qureg amplitudes.

Function Documentation

◆ setDensityQuregAmps()

void setDensityQuregAmps ( Qureg qureg,
qindex startRow,
qindex startCol,
qcomp ** amps,
qindex numRows,
qindex numCols )
Note
Documentation for this function or struct is under construction!
Attention
This function's input validation has not yet been tested, so erroneous usage may produce unexpected output. Please use with caution!

Definition at line 152 of file initialisations.cpp.

152 {
153 validate_quregFields(qureg, __func__);
154 validate_quregIsDensityMatrix(qureg, __func__);
155 validate_basisStateRowCols(qureg, startRow, startCol, numRows, numCols, __func__);
156
157 localiser_densmatr_setAmps(amps, qureg, startRow, startCol, numRows, numCols);
158}

Referenced by TEST_CASE().

◆ setDensityQuregFlatAmps()

void setDensityQuregFlatAmps ( Qureg qureg,
qindex startInd,
qcomp * amps,
qindex numAmps )
Note
Documentation for this function or struct is under construction!
Attention
This function's input validation has not yet been tested, so erroneous usage may produce unexpected output. Please use with caution!

Definition at line 161 of file initialisations.cpp.

161 {
162 validate_quregFields(qureg, __func__);
163 validate_quregIsDensityMatrix(qureg, __func__);
164 validate_basisStateIndices(qureg, startInd, numAmps, __func__); // validation msg correct for density-matrix
165
166 localiser_statevec_setAmps(amps, qureg, startInd, numAmps);
167}

Referenced by TEST_CASE().

◆ setQuregAmps()

void setQuregAmps ( Qureg qureg,
qindex startInd,
qcomp * amps,
qindex numAmps )
Note
Documentation for this function or struct is under construction!
Attention
This function's input validation has not yet been tested, so erroneous usage may produce unexpected output. Please use with caution!

Definition at line 143 of file initialisations.cpp.

143 {
144 validate_quregFields(qureg, __func__);
145 validate_quregIsStateVector(qureg, __func__);
146 validate_basisStateIndices(qureg, startInd, numAmps, __func__);
147
148 localiser_statevec_setAmps(amps, qureg, startInd, numAmps);
149}

Referenced by TEST_CASE(), and TEST_CASE().

◆ setQuregToClone()

void setQuregToClone ( Qureg targetQureg,
Qureg copyQureg )
Note
Documentation for this function or struct is under construction!
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!

Definition at line 170 of file initialisations.cpp.

170 {
171 validate_quregFields(targetQureg, __func__);
172 validate_quregFields(copyQureg, __func__);
173 validate_quregsCanBeCloned(targetQureg, copyQureg, __func__);
174
175 // we invoke mixing/superposing, which involves superfluous
176 // floating-point operators but is not expected to cause an
177 // appreciable slowdown since simulation is memory-bound
178 (targetQureg.isDensityMatrix)?
179 localiser_densmatr_mixQureg(0, targetQureg, 1, copyQureg):
180 localiser_statevec_setQuregToSuperposition(0, targetQureg, 1, copyQureg, 0, copyQureg);
181}

Referenced by createCloneQureg().

◆ setQuregToPartialTrace()

void setQuregToPartialTrace ( Qureg out,
Qureg in,
int * traceOutQubits,
int numTraceQubits )
Note
Documentation for this function or struct is under construction!
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!

Definition at line 221 of file initialisations.cpp.

221 {
222 validate_quregFields(in, __func__);
223 validate_quregFields(out, __func__);
224 validate_quregIsDensityMatrix(in, __func__);
225 validate_quregIsDensityMatrix(out, __func__);
226 validate_targets(in, traceOutQubits, numTraceQubits, __func__);
227 validate_quregCanBeSetToReducedDensMatr(out, in, numTraceQubits, __func__);
228
229 auto targets = util_getVector(traceOutQubits, numTraceQubits);
230 localiser_densmatr_partialTrace(in, out, targets);
231}

◆ setQuregToPauliStrSum()

void setQuregToPauliStrSum ( Qureg qureg,
PauliStrSum sum )
Note
Documentation for this function or struct is under construction!
Attention
This function's input validation has not yet been tested, so erroneous usage may produce unexpected output. Please use with caution!

Definition at line 208 of file initialisations.cpp.

208 {
209 validate_quregFields(qureg, __func__);
210 validate_quregIsDensityMatrix(qureg, __func__);
211 validate_pauliStrSumFields(sum, __func__);
212 validate_pauliStrSumTargets(sum, qureg, __func__);
213
214 // sum is permitted to be non-Hermitian, since Hermiticity
215 // is insufficient to ensure qureg would be physical/valid
216
217 localiser_densmatr_setAmpsToPauliStrSum(qureg, sum);
218}

Referenced by TEST_CASE().

◆ setQuregToReducedDensityMatrix()

void setQuregToReducedDensityMatrix ( Qureg out,
Qureg in,
int * retainQubits,
int numRetainQubits )
Note
Documentation for this function or struct is under construction!
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!

Definition at line 234 of file initialisations.cpp.

234 {
235 validate_quregFields(in, __func__);
236 validate_quregFields(out, __func__);
237 validate_quregIsDensityMatrix(in, __func__);
238 validate_quregIsDensityMatrix(out, __func__);
239 validate_targets(in, retainQubits, numRetainQubits, __func__);
240 validate_quregCanBeSetToReducedDensMatr(out, in, in.numQubits - numRetainQubits, __func__);
241
242 auto traceQubits = util_getNonTargetedQubits(retainQubits, numRetainQubits, in.numQubits);
243 localiser_densmatr_partialTrace(in, out, traceQubits);
244}

◆ setQuregToRenormalized()

qreal setQuregToRenormalized ( Qureg qureg)
Note
Documentation for this function or struct is under construction!
Attention
This function's input validation has not yet been tested, so erroneous usage may produce unexpected output. Please use with caution!

Definition at line 194 of file initialisations.cpp.

194 {
195 validate_quregFields(qureg, __func__);
196
197 qreal prob = calcTotalProb(qureg); // harmlessly re-validates
198 validate_quregRenormProbIsNotZero(prob, __func__);
199
200 qreal norm = (qureg.isDensityMatrix)? prob : std::sqrt(prob);
201 qreal fac = 1 / norm;
202 localiser_statevec_setQuregToSuperposition(fac, qureg, 0, qureg, 0, qureg);
203
204 return fac;
205}
qreal calcTotalProb(Qureg qureg)

Referenced by initRandomPureState(), and TEST_CASE().

◆ setQuregToSuperposition()

void setQuregToSuperposition ( qcomp facOut,
Qureg out,
qcomp fac1,
Qureg qureg1,
qcomp fac2,
Qureg qureg2 )
Note
Documentation for this function or struct is under construction!
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!

Definition at line 184 of file initialisations.cpp.

184 {
185 validate_quregFields(out, __func__);
186 validate_quregFields(qureg1, __func__);
187 validate_quregFields(qureg2, __func__);
188 validate_quregsCanBeSuperposed(out, qureg1, qureg2, __func__); // asserts statevectors
189
190 localiser_statevec_setQuregToSuperposition(facOut, out, fac1, qureg1, fac2, qureg2);
191}