JuliaArrays / BlockDiagonals.jl

Functionality for working efficiently with block diagonal matrices.
MIT License
49 stars 11 forks source link

implement faster subtraction #113

Closed mzgubic closed 2 years ago

mzgubic commented 2 years ago

Closes #112

julia> bd = BlockDiagonal([rand(5, 5) for _ in 1:100]);

julia> dense1 = rand(500, 500);

julia> dense2 = rand(500, 500);

julia> @time bd - dense1;
  0.002135 seconds (104 allocations: 3.839 MiB)

julia> @time dense2 - dense1;
  0.001174 seconds (2 allocations: 1.907 MiB)

The default implementation fell back on

julia> @which bd - dense1
-(A::AbstractArray, B::AbstractArray) in Base at arraymath.jl:37

which did the inefficient eachindex loop to do the subtraction.

codecov[bot] commented 2 years ago

Codecov Report

Merging #113 (e754c0f) into master (6223d3f) will decrease coverage by 0.16%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #113      +/-   ##
==========================================
- Coverage   96.17%   96.01%   -0.17%     
==========================================
  Files           5        5              
  Lines         340      326      -14     
==========================================
- Hits          327      313      -14     
  Misses         13       13              
Impacted Files Coverage Δ
src/base_maths.jl 100.00% <100.00%> (ø)
src/blockdiagonal.jl 86.76% <0.00%> (-0.56%) :arrow_down:
src/linalg.jl 95.34% <0.00%> (-0.21%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us.