-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CQT-360] QX simulator outputs invalid states #205
[CQT-360] QX simulator outputs invalid states #205
Conversation
…seems not to erase previous elements of 'state', thus we force 'state.data_.clear()' in SparseArray::operator=(const SparseArray& other). Add fmt::formatters for qx::Measurement and qx::SuperposedState. Implement rule of 5 for SparseArray and QuantumState. Implement SparseArray::operator=(const SparseArray& other). Implement operator<< for qx::Measurement and qx::SuperposedState. Fix SparseComplex::SparseComplex(SparseComplex&& other). Remove SparseArray::operator=(MapBasisVectorToSparseComplex map).
… which was not always performing the assignment (only when a check was true, and that check was wrong). Remove rule of 5 for QuantumState, SparseArray and SparseComplex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for checking this out, figuring out the bug, and making a fix!!
Was the rule of 5 for SparseComplex
added by you recently?
Should we still add the test circuit to this PR (i.e. the one that showed the bug, that started with H q[1]
)?
Testcase: Circuit
Results
The results would be the same for the circuit where |
Thanks!
I think I added it a few weeks ago with the following idea: whenever the source of the assignment is below epsilon, i.e., not really null but could be considered null, we just set null in the destination. But the code to do the check for null was wrong. I could have fixed that code, but I decided to remove everything altogether. So now an assignment really makes a copy.
Yes, please. I have already prepared it. But I need the expected results. |
Oh beautiful, thanks so much. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks!
The problem came from
SparseComplex::operator=
, which was not always performing the assignment (only when a check was true, and that check was wrong).Implement
operator<<
forqx::Measurement
andqx::SuperposedState
.Add
fmt::formatter
s forqx::Measurement
andqx::SuperposedState
.Remove rule of 5 for SparseComplex.
Remove
SparseArray::operator=(MapBasisVectorToSparseComplex)
.