Description
Describe the bug
When I use HContainer to save data, following the step below to allocate:
- Create HContainer;
- Find all atom pairs and repeat:
- Use AtomPair to represent them;
- Insert AtomPair to HContainer;
- Allocate using member function of HContainer.
Normally, it will create several BaseMatrix objects for each atom pair (i, j, R), with size nw1*nw2 (number of orbitals for each atom).
However, when I want to save some other matrices instead of Hamiltonian and the size if different, I should set size before allocating, the step will change into:
- Create HContainer;
- Find all atom pairs and repeat:
- Use AtomPair to represent them;
- Use set_size member function of Atompair to set the matrix size;
- Insert AtomPair to HContainer;
- Allocate using member function of HContainer.
It will create several BaseMatrix objects for each atom pair (i, j, R) with size I set.
The allocation will run correctly, but when I use H.get_atom_pair(i, j).get_HR_values(Rx, Ry, Rz)
to get the BaseMatrix and print the size by using get_row_size()
and get_col_size()
, it will return the BaseMatrix with the size nw1*nw2 (number of orbitals for each atom).
That is to say, if we use pointer to get/set the value, everything will goes correctly (since the memory is allocated correctly). But when we use BaseMatrix, it will be wrong!
Expected behavior
When we set size of matrix by hand, BaseMatrix should be refreshed automatically. It should be safe to use BaseMatrix to access the data.
To Reproduce
No response
Environment
No response
Additional Context
No response
Task list for Issue attackers (only for developers)
- Verify the issue is not a duplicate.
- Describe the bug.
- Steps to reproduce.
- Expected behavior.
- Error message.
- Environment details.
- Additional context.
- Assign a priority level (low, medium, high, urgent).
- Assign the issue to a team member.
- Label the issue with relevant tags.
- Identify possible related issues.
- Create a unit test or automated test to reproduce the bug (if applicable).
- Fix the bug.
- Test the fix.
- Update documentation (if necessary).
- Close the issue and inform the reporter (if applicable).