Skip to content
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

Less eagerly transform FillArray data (e.g. identityoperator()) into sparse arrays (e.g. 2*identityoperator() should be FillArray, not sparse) #109

Open
Krastanov opened this issue Jun 21, 2023 · 2 comments

Comments

@Krastanov
Copy link
Collaborator

Since 0.4 we have Eye+sparse=dense. We should keep the sparsity in situations like this.

Regression reported over slack by Satya Bade:

Hi Stefan, Thanks, I think the problem is with the addition between Eye and a sparse operator, it gives a dense operator! For example, the following code gives an out of memory error (depending on the available RAM)

using QuantumOpticsBase
bs = SpinBasis(1//2)
op = identityoperator(bs) + sigmaz(bs)
tensor([op for _ in 1:16]...)

this is possible with the older versions

@Krastanov
Copy link
Collaborator Author

This is fixed in #110, but there are still things that can be improved. Namely, the large block of methods with a TODO left in it can be improved by leaning a bit harder into using FillArray and lazy embeds, for scaled identities and for tensor products with identities. Leaving open but renaming

@Krastanov Krastanov changed the title regression in identityoperator()+sparse_matrix due to the move to Eye Less eagerly transform FillArray data (e.g. identityoperator()) into sparse arrays (e.g. 2*identityoperator() should be FillArray, not sparse) Jun 22, 2023
Krastanov added a commit that referenced this issue Jun 22, 2023
…o Eye #109 (#110)

* Overloaded common operations between Eye and sparse operators

* tensor, unary minus, and bump version number

* forgot the cases where they are both IEye

* non-square tests

---------

Co-authored-by: Stefan Krastanov <[email protected]>
@amilsted
Copy link
Collaborator

amilsted commented Jul 5, 2023

Noting here that FillArrays 1.3 improves on this: JuliaArrays/FillArrays.jl#265

kron is fixed upstream, but addition still gives us dense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants