Closed fieldofnodes closed 1 year ago
In C, sizeof(*array)
will return the number of bytes dedicated to each element of array
(because *
deferences array
to its first element type). Ergo,
numArrayElems * sizeof(*array)
yields the total memory size (in bytes) of the array.
Our statevector is a collection of complex amplitudes, but their real and imaginary components are stored in separate arrays. The i
-th local amplitude is ergo represented with two floating point numbers; stateVec.real[i]
and stateVec.imag[i]
.
When QuEST is run in distributed mode, each of env.numRanks
computers store a uniform subset of the full collection of amplitudes; numAmpsPerRank
.
The line
size_t arrSize = (size_t) (numAmpsPerRank * sizeof(*(qureg->stateVec.real)));
therefore evaluates the memory size (in bytes) of each of a single computer's stateVec.real
and stateVec.imag
arrays.
Yep, QuEST's measure function is destructive.
Thank you for the information. I am newish to C/C++ and there are certain fundamentals that I lack. Thank you. I am happy for this to be closed. Do you want me to do this?
I am trying to understand how the Qureg is designed, namely what is meant by a state vector. Can I think of it as a vector of states per qubit?
For example, if I call
Qureg createQureg(int numQubits, QuESTEnv env)
I understand that internally we call the following
https://github.com/QuEST-Kit/QuEST/blob/23a0a088dfd76d89f3252bffabda0387e880cda6/QuEST/src/CPU/QuEST_cpu.c#L1296
In this line we start this function:
I assume that when we call
sizeof(*(qureg->stateVec.real)))
we are getting an integer which is the number of real elements inqureg->stateVec
. Is this true?The reason why I ask is I am working on using QuEST to do MBQC simulation and I think I need to initialise my MBQC graph through a single quantum register.
This brings me to my next question, when I measure a specific qubit, does QuEST project onto the existing quantum state a subspace as a result of that measurement?
Is this the best place to ask questions to the developers?