Skip to content

Sum of kroneckers#77

Open
MichielStock wants to merge 7 commits intomasterfrom
sum_of_kroneckers
Open

Sum of kroneckers#77
MichielStock wants to merge 7 commits intomasterfrom
sum_of_kroneckers

Conversation

@MichielStock
Copy link
Copy Markdown
Owner

Lazily working with sums of Kronecker products: A ⊗ B + C ⊗ D, in response to #76

@vsaase
Copy link
Copy Markdown

vsaase commented Jan 4, 2021

conceptually this works, but I am observing very low performance when nesting with another kronecker product, reproduced in the following example:

julia> A=kronecker(ones(100,100),ones(100,100))
julia> C=ones(2,2)

julia> @time kronecker(A+A,C)*ones(20000);
  3.457423 seconds (18 allocations: 469.594 KiB)
julia> @time (kronecker(A,C)+kronecker(A,C))*ones(20000);
  0.015021 seconds (27 allocations: 627.781 KiB)
julia> @time kronecker(2*A,C)*ones(20000);
  0.006633 seconds (13 allocations: 313.859 KiB)

@MichielStock
Copy link
Copy Markdown
Owner Author

Yes, it cannot access the fast multiplication this way. I have added a naive decomposition for this, so your examples is now:

julia> @time kronecker(A+A,C)*ones(20000);
  0.011665 seconds (41.67 k allocations: 2.837 MiB)

julia> @time (kronecker(A,C)+kronecker(A,C))*ones(20000);
  0.008346 seconds (41.67 k allocations: 2.837 MiB)

julia> @time kronecker(2*A,C)*ones(20000);
  0.004133 seconds (20.84 k allocations: 1.495 MiB)

Though I made a small example in the test, which throws an error. Definitely something fishy still!

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #77 (50152bc) into master (0b6bbcc) will decrease coverage by 0.55%.
The diff coverage is 96.15%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #77      +/-   ##
==========================================
- Coverage   90.76%   90.20%   -0.56%     
==========================================
  Files          11       12       +1     
  Lines         617      643      +26     
==========================================
+ Hits          560      580      +20     
- Misses         57       63       +6     
Impacted Files Coverage Δ
src/Kronecker.jl 100.00% <ø> (ø)
src/sums.jl 96.15% <96.15%> (ø)
src/vectrick.jl 90.47% <0.00%> (-3.97%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8608af6...50152bc. Read the comment docs.

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

Successfully merging this pull request may close these issues.

3 participants