Skip to content

Commit

Permalink
Specialize view for a BandSlice (#429)
Browse files Browse the repository at this point in the history
* Specialize view for a BandSlice

* Add test
  • Loading branch information
jishnub committed Mar 10, 2024
1 parent ddf6ab5 commit a44ab1d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "BandedMatrices"
uuid = "aae01518-5342-5314-be14-df237901396f"
version = "1.5.0"
version = "1.6.0"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
3 changes: 2 additions & 1 deletion src/generic/Band.jl
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ for f in (:indices, :unsafe_indices, :axes1, :first, :last, :size, :length,
@eval $f(S::BandSlice) = $f(S.indices)
end

@propagate_inbounds getindex(S::BandSlice, i::Union{Int, AbstractRange}) = getindex(S.indices, i)
@propagate_inbounds getindex(S::BandSlice, i::Union{Int, AbstractRange{<:Integer}}) = getindex(S.indices, i)
@propagate_inbounds view(S::BandSlice, i::AbstractRange{<:Integer}) = view(S.indices, i)
show(io::IO, r::BandSlice) = print(io, BandSlice, "(", r.band, ", ", r.indices, ")")

to_index(::Band) = throw(ArgumentError("Block must be converted by to_indices(...)"))
Expand Down
1 change: 1 addition & 0 deletions test/test_indexing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ import BandedMatrices: rowstart, rowstop, colstart, colstop,
@test bs.indices == diagind(A, k)
@test bs.band == Band(k)
@test collect(bs) == collect(diagind(A, k))
@test view(bs, 1:length(bs)) === view(diagind(A, k), 1:length(bs))
@test Vector{eltype(A)}(V) == collect(V) == A[diagind(A,k)] == A[band(k)]
@test Vector{ComplexF64}(V) == Vector{ComplexF64}(A[diagind(A,k)]) ==
convert(AbstractVector{ComplexF64}, V) == convert(AbstractArray{ComplexF64}, V)
Expand Down

2 comments on commit a44ab1d

@jishnub
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request updated: JuliaRegistries/General/100260

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.6.0 -m "<description of version>" a44ab1d220b351984e6f5d87db6d73ebfa7103bf
git push origin v1.6.0

Please sign in to comment.