Default constructor of `QubitRegister` not working properly
- Dominant language
- C++
- Stars
- 264
- Forks
- 76
- Avg merge
- 8d 11h
- Merged PRs (30d)
- 2
Description
I'm trying to simulate a quantum system with Intel QS and need to declare a `QubitRegister` before initializing it with the number of qubits. However, the default constructor of `QubitRegister` does not seem to work properly. After including ``, simply doing
```c++
iqs::QubitRegister psi;
```
will throw an error. The error occurs at the checking statement `if(GlobalSize()) assert(GlobalSize() * 2UL == new_num_amplitudes);`, but after disabling this checking statement other errors come up in `num_qubits` and in using `state` vs `state_storage`.
I'd like to propose the following changes: we should comment out Line 60 of [qureg_init.cpp](https://github.com/intel/intel-qs/blob/master/src/qureg_init.cpp) and change Line 38-39 from
```c++
Resize(1UL);
state_storage[0] = {1., 0.};
```
to
```c++
Resize(2UL);
state[0] = {1., 0.};
```
Changing these three lines and rebuilding the library worked for me. These changes also seem consistent with the rest of the `QubitRegister` class.
Contributor guide
Assessment
This issue has not been assessed yet.