Kronecker.jl
Kronecker.jl copied to clipboard
Sum of kroneckers
Lazily working with sums of Kronecker products: A ⊗ B + C ⊗ D, in response to #76
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)
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 Report
Merging #77 (50152bc) into master (0b6bbcc) will decrease coverage by
0.55%. The diff coverage is96.15%.
@@ 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%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 8608af6...50152bc. Read the comment docs.