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

implement bandwidths for OneElement #447

Merged

Conversation

max-vassili3v
Copy link
Contributor

No description provided.

Copy link

codecov bot commented Jul 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.81%. Comparing base (47c15ab) to head (9332222).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #447      +/-   ##
==========================================
+ Coverage   89.61%   89.81%   +0.20%     
==========================================
  Files          25       25              
  Lines        3571     3642      +71     
==========================================
+ Hits         3200     3271      +71     
  Misses        371      371              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

src/interfaceimpl.jl Outdated Show resolved Hide resolved
src/interfaceimpl.jl Outdated Show resolved Hide resolved
src/interfaceimpl.jl Outdated Show resolved Hide resolved
@test bandwidths(o) == (2,-2)
n,m = rand(1:10,2)
o = OneElement(1, (rand(1:n),rand(1:m)), (n, m))
@test bandwidths(o) == bandwidths(BandedMatrix(o))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is a tautology since BandedMatrix calls bandwidths(o) to determine its bandwidths. I think the following will be better:

Suggested change
@test bandwidths(o) == bandwidths(BandedMatrix(o))
@test bandwidths(o) == bandwidths(sparse(o))

You'll need to add SparseArrays to the using statement

@max-vassili3v
Copy link
Contributor Author

julia> o = OneElement(1,5,5)
5-element OneElement{Int64, 1, Tuple{Int64}, Tuple{Base.OneTo{Int64}}}:
 ⋅
 ⋅
 ⋅
 ⋅
 1

julia> bandwidths(sparse(o))
(4, 0)

Shouldn't it be (4, -4) or am I mistaken?

@dlfivefifty
Copy link
Member

Ah probably it’s not overridden yet for SparseVector . You could add that too if you want

@max-vassili3v
Copy link
Contributor Author

julia> o = OneElement(1,(5,1),(5,2))
5×2 OneElement{Int64, 2, Tuple{Int64, Int64}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}:
 ⋅  ⋅
 ⋅  ⋅
 ⋅  ⋅
 ⋅  ⋅
 1  ⋅

julia> bandwidths(sparse(o))
(4, -2)

julia> o = OneElement(1,(5,1),(5,3))
5×3 OneElement{Int64, 2, Tuple{Int64, Int64}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}:
 ⋅  ⋅  ⋅
 ⋅  ⋅  ⋅
 ⋅  ⋅  ⋅
 ⋅  ⋅  ⋅
 1  ⋅  ⋅

julia> bandwidths(sparse(o))
(4, -3)

There seems to be a similar behaviour for matrices where the width bottlenecks the negative bandwidth.

@dlfivefifty
Copy link
Member

OK. I don't think I wrote that code so it must be a bug. Do you think you can fix it?

It should be here:

https://github.com/JuliaLinearAlgebra/BandedMatrices.jl/blob/master/ext/BandedMatricesSparseArraysExt.jl

@dlfivefifty dlfivefifty merged commit a2649ce into JuliaLinearAlgebra:master Jul 23, 2024
16 checks passed
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.

2 participants