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

Functions for initialising Qureg into physical states. More...

Functions

void initArbitraryPureState (Qureg qureg, qcomp *amps)
 
void initBlankState (Qureg qureg)
 
void initClassicalState (Qureg qureg, qindex stateInd)
 
void initDebugState (Qureg qureg)
 
void initPlusState (Qureg qureg)
 
void initPureState (Qureg qureg, Qureg pure)
 
void initRandomMixedState (Qureg qureg, qindex numPureStates)
 
void initRandomPureState (Qureg qureg)
 
void initZeroState (Qureg qureg)
 

Detailed Description

Functions for initialising Qureg into physical states.

Function Documentation

◆ initArbitraryPureState()

void initArbitraryPureState ( Qureg qureg,
qcomp * amps )
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 95 of file initialisations.cpp.

95 {
96 validate_quregFields(qureg, __func__);
97
98 // set qureg = |amps> or |amps><amps|
99 (qureg.isDensityMatrix)?
100 localiser_densmatr_initArbitraryPureState(qureg, amps):
101 localiser_statevec_initArbitraryPureState(qureg, amps);
102}

Referenced by TEST_CASE(), and TEST_CASE().

◆ initBlankState()

void initBlankState ( 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 34 of file initialisations.cpp.

34 {
35 validate_quregFields(qureg, __func__);
36
37 // |null> = {0, 0, 0, ...}
38 qcomp amp = 0;
39 localiser_statevec_initUniformState(qureg, amp);
40}

Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().

◆ initClassicalState()

void initClassicalState ( Qureg qureg,
qindex stateInd )
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 76 of file initialisations.cpp.

76 {
77 validate_quregFields(qureg, __func__);
78 validate_basisStateIndex(qureg, ind, __func__);
79
80 // |ind><ind| = ||ind'>>
81 if (qureg.isDensityMatrix)
82 ind = util_getGlobalFlatIndex(qureg, ind, ind);
83
84 localiser_statevec_initClassicalState(qureg, ind);
85}

Referenced by TEST_CASE(), TEST_CASE(), and TEST_CASE().

◆ initDebugState()

void initDebugState ( 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 88 of file initialisations.cpp.

88 {
89 validate_quregFields(qureg, __func__);
90
91 localiser_statevec_initDebugState(qureg);
92}

Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().

◆ initPlusState()

void initPlusState ( 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 52 of file initialisations.cpp.

52 {
53 validate_quregFields(qureg, __func__);
54
55 // |+> = sum_i 1/sqrt(2^N) |i> where 2^N = numAmps
56 // |+><+| = sum_ij 1/2^N |i><j| where 2^N = sqrt(numAmps)
57 qcomp amp = 1.0 / std::sqrt(qureg.numAmps);
58 localiser_statevec_initUniformState(qureg, amp);
59}

Referenced by TEST_CASE(), TEST_CASE(), and TEST_CASE().

◆ initPureState()

void initPureState ( Qureg qureg,
Qureg pure )
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!
Warning
This function has not yet been unit tested and may contain bugs. Please use with caution!

Definition at line 62 of file initialisations.cpp.

62 {
63 validate_quregFields(qureg, __func__);
64 validate_quregFields(pure, __func__);
65 validate_quregCanBeInitialisedToPureState(qureg, pure, __func__);
66
67 // when qureg=statevec, we lazily invoke setQuregToSuperposition which
68 // invokes superfluous floating-point operations which will be happily
69 // occluded by the memory movement costs
70 (qureg.isDensityMatrix)?
71 localiser_densmatr_initPureState(qureg, pure):
72 localiser_statevec_setQuregToSuperposition(0, qureg, 1, pure, 0, pure);
73}

Referenced by TEST_CASE().

◆ initRandomMixedState()

void initRandomMixedState ( Qureg qureg,
qindex numPureStates )
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 128 of file initialisations.cpp.

128 {
129 validate_quregFields(qureg, __func__);
130 validate_quregIsDensityMatrix(qureg, __func__);
131 validate_numInitRandomPureStates(numPureStates, __func__);
132
133 localiser_densmatr_initMixtureOfUniformlyRandomPureStates(qureg, numPureStates);
134}

Referenced by TEST_CASE().

◆ initRandomPureState()

void initRandomPureState ( 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 113 of file initialisations.cpp.

113 {
114 validate_quregFields(qureg, __func__);
115
116 // these invoked localiser functions may harmlessly
117 // re-call the API and re-perform input validation
118
119 if (qureg.isDensityMatrix)
120 localiser_densmatr_initUniformlyRandomPureStateAmps(qureg);
121 else {
122 localiser_statevec_initUnnormalisedUniformlyRandomPureStateAmps(qureg);
124 }
125}
qreal setQuregToRenormalized(Qureg qureg)

Referenced by TEST_CASE().

◆ initZeroState()

void initZeroState ( 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 43 of file initialisations.cpp.

43 {
44 validate_quregFields(qureg, __func__);
45
46 // |0> = |0><0|
47 qindex ind = 0;
48 localiser_statevec_initClassicalState(qureg, ind);
49}

Referenced by TEST_CASE(), TEST_CASE(), TEST_CASE(), and TEST_CASE().