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

v1.0 #255

Merged
merged 25 commits into from
May 17, 2024
Merged

v1.0 #255

Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ef6234d
Compact show for `BlockRange` (#248)
jishnub Apr 3, 2023
27bc4e1
Merge branch 'master' into release-1.0
jishnub Mar 22, 2024
3fb6573
Fetch changes to convert for BlockedUnitRange
jishnub Mar 22, 2024
ab3dce9
Merge branch 'master' into release-1.0
jishnub Mar 28, 2024
aab5fa8
Merge branch 'master' into release-1.0
jishnub Apr 1, 2024
222a79a
Merge branch 'master' into release-1.0
jishnub Apr 1, 2024
9d8a552
Bump version to v1.0.0-dev
jishnub Apr 1, 2024
3c352fa
Merge branch 'master' into release-1.0
jishnub Apr 2, 2024
c89df62
Merge branch 'master' into release-1.0
jishnub Apr 3, 2024
7766ac9
Merge branch 'master' into release-1.0
jishnub Apr 4, 2024
4ee907e
Add `BlockedOneTo` as the axis type for a `BlockedArray` (#348)
jishnub Apr 4, 2024
94e7ca3
Infinite broadcast tests (#383)
jishnub Apr 4, 2024
4a7b1df
Specialize blockedrange BroadcastStyle for LazyArrayStyle (#384)
jishnub Apr 7, 2024
6987f0b
Merge branch 'master' into release-1.0
jishnub Apr 7, 2024
b361279
Define dataids for PseudoBlockArrays (#364) (#385)
jishnub Apr 7, 2024
d02efe6
Banded Matrix extension (#388)
dlfivefifty Apr 23, 2024
8639776
Generalize the element type of `BlockedUnitRange` (#337)
mtfishman Apr 23, 2024
465569a
Allow non-Int eltypes in BlockedOneTo (#395)
jishnub Apr 27, 2024
e3e69c7
Move LazyArrays extension to LazyArrays.jl (#393)
dlfivefifty May 1, 2024
928dea7
Use FillArrays accumulate overloads (#397)
dlfivefifty May 7, 2024
ee57d11
Redefine blocksizes (#399)
mtfishman May 14, 2024
3c9abe3
Rename PseudoBlockArray to BlockedArray (#401)
mtfishman May 16, 2024
8621223
v1.0, add README
dlfivefifty May 16, 2024
11e1f26
rename files
dlfivefifty May 16, 2024
70e6e02
Update README.md
dlfivefifty May 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
run: which julia
continue-on-error: true
- name: Install Julia, but only if it is not already available in the PATH
uses: julia-actions/setup-julia@v1
uses: julia-actions/setup-julia@v2
with:
version: '1'
arch: ${{ runner.arch }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- x64
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: '1.10'
- uses: julia-actions/cache@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/downstream.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.julia-version }}
arch: x64
Expand Down
13 changes: 11 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
name = "BlockArrays"
uuid = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
version = "0.16.44-dev"
version = "1.0.0-dev"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

[weakdeps]
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"

[extensions]
BlockArraysBandedMatricesExt = "BandedMatrices"

[compat]
Aqua = "0.8"
ArrayLayouts = "1.0.8"
BandedMatrices = "1.0"
Documenter = "1"
FillArrays = "1"
LinearAlgebra = "1.6"
Expand All @@ -22,6 +30,7 @@ julia = "1.6"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -30,4 +39,4 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "Documenter", "OffsetArrays", "SparseArrays", "StaticArrays", "Test", "Random"]
test = ["Aqua", "BandedMatrices", "Documenter", "OffsetArrays", "SparseArrays", "StaticArrays", "Test", "Random"]
2 changes: 2 additions & 0 deletions docs/src/lib/internals.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Pages = ["internals.md"]
```@docs
blockcolsupport
blockrowsupport
blockedrange
BlockedOneTo
BlockedUnitRange
BlockRange
BlockIndexRange
Expand Down
6 changes: 3 additions & 3 deletions docs/src/man/abstractblockarrayinterface.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# The block axis interface

A block array's block structure is dictated by its axes, which
are typically a `BlockedUnitRange` but may also be a `UnitRange`,
which is assumed to be a single block, or other type that implements
A block array's block structure is dictated by its axes. These
are typically `BlockedOneTo`s, but may also be standard and non-blocked `AbstractUnitRange`s
(which are assumed to correspond to a single block), or other type that implements
the block axis interface.


Expand Down
8 changes: 4 additions & 4 deletions docs/src/man/blockarrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ julia> BlockArray(Array(reshape(1:16, 4, 4)), [2,2], [1,1,2])
julia> S = spzeros(4,5); S[1,2] = S[4,3] = 1;

julia> block_array_sparse = BlockArray(S, [1,3], [2,3])
2×2-blocked 4×5 BlockMatrix{Float64, Matrix{SparseMatrixCSC{Float64, Int64}}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}}:
2×2-blocked 4×5 BlockMatrix{Float64, Matrix{SparseMatrixCSC{Float64, Int64}}, Tuple{BlockedOneTo{Int64, Vector{Int64}}, BlockedOneTo{Int64, Vector{Int64}}}}:
⋅ 1.0 │ ⋅ ⋅ ⋅
──────────┼───────────────
⋅ ⋅ │ ⋅ ⋅ ⋅
Expand Down Expand Up @@ -67,7 +67,7 @@ The `block_type` should be an array type. It specifies the internal block type,

```jldoctest
julia> BlockArray(undef_blocks, SparseVector{Float64, Int}, [1,2])
2-blocked 3-element BlockVector{Float64, Vector{SparseVector{Float64, Int64}}, Tuple{BlockedUnitRange{Vector{Int64}}}}:
2-blocked 3-element BlockVector{Float64, Vector{SparseVector{Float64, Int64}}, Tuple{BlockedOneTo{Int64, Vector{Int64}}}}:
#undef
──────
#undef
Expand Down Expand Up @@ -151,7 +151,7 @@ julia> view(A, Block(2)) .= [3,4]; A[Block(2)]
4.0

julia> view(A, Block.(1:2))
3-element view(::BlockVector{Float64, Vector{Vector{Float64}}, Tuple{BlockedUnitRange{ArrayLayouts.RangeCumsum{Int64, UnitRange{Int64}}}}}, BlockSlice(BlockRange(1:2),1:1:3)) with eltype Float64 with indices 1:1:3:
3-element view(::BlockVector{Float64, Vector{Vector{Float64}}, Tuple{BlockedOneTo{Int64, ArrayLayouts.RangeCumsum{Int64, UnitRange{Int64}}}}}, BlockSlice(BlockRange(1:2),1:1:3)) with eltype Float64 with indices BlockedOneTo([1, 3]):
1.0
3.0
4.0
Expand All @@ -167,7 +167,7 @@ An array can be repacked into a `BlockArray` with `BlockArray(array, block_sizes
julia> S = spzeros(4,5); S[1,2] = S[4,3] = 1;

julia> block_array_sparse = BlockArray(S, [1,3], [2,3])
2×2-blocked 4×5 BlockMatrix{Float64, Matrix{SparseMatrixCSC{Float64, Int64}}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}}:
2×2-blocked 4×5 BlockMatrix{Float64, Matrix{SparseMatrixCSC{Float64, Int64}}, Tuple{BlockedOneTo{Int64, Vector{Int64}}, BlockedOneTo{Int64, Vector{Int64}}}}:
⋅ 1.0 │ ⋅ ⋅ ⋅
──────────┼───────────────
⋅ ⋅ │ ⋅ ⋅ ⋅
Expand Down
30 changes: 30 additions & 0 deletions ext/BlockArraysBandedMatricesExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module BlockArraysBandedMatricesExt

using BandedMatrices, BlockArrays
using BlockArrays.ArrayLayouts
import BandedMatrices: isbanded, AbstractBandedLayout, bandeddata, bandwidths
import BlockArrays: blockcolsupport, blockrowsupport, AbstractBlockedUnitRange
import ArrayLayouts: sub_materialize


bandeddata(P::PseudoBlockMatrix) = bandeddata(P.blocks)
bandwidths(P::PseudoBlockMatrix) = bandwidths(P.blocks)

function blockcolsupport(::AbstractBandedLayout, B, j)
m,n = axes(B)
cs = colsupport(B,n[j])
findblock(m,first(cs)):findblock(m,last(cs))
end

function blockrowsupport(::AbstractBandedLayout, B, k)
m,n = axes(B)
rs = rowsupport(B,m[k])
findblock(n,first(rs)):findblock(n,last(rs))
end

# ambiguity
sub_materialize(::AbstractBandedLayout, V, ::Tuple{AbstractBlockedUnitRange,Base.OneTo{Int}}) = BandedMatrix(V)
sub_materialize(::AbstractBandedLayout, V, ::Tuple{Base.OneTo{Int},AbstractBlockedUnitRange}) = BandedMatrix(V)


end
7 changes: 5 additions & 2 deletions src/BlockArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export AbstractBlockArray, AbstractBlockMatrix, AbstractBlockVector, AbstractBlo
export Block, getblock, getblock!, setblock!, eachblock, blocks
export blockaxes, blocksize, blocklength, blockcheckbounds, BlockBoundsError, BlockIndex
export blocksizes, blocklengths, blocklasts, blockfirsts, blockisequal
export BlockRange, blockedrange, BlockedUnitRange
export BlockRange, blockedrange, BlockedUnitRange, BlockedOneTo

export BlockArray, BlockMatrix, BlockVector, BlockVecOrMat, mortar
export PseudoBlockArray, PseudoBlockMatrix, PseudoBlockVector, PseudoBlockVecOrMat
Expand Down Expand Up @@ -69,11 +69,14 @@ include("show.jl")
include("blockreduce.jl")
include("blockdeque.jl")
include("blockarrayinterface.jl")
include("blockbanded.jl")

@deprecate getblock(A::AbstractBlockArray{T,N}, I::Vararg{Integer, N}) where {T,N} view(A, Block(I))
@deprecate getblock!(X, A::AbstractBlockArray{T,N}, I::Vararg{Integer, N}) where {T,N} copyto!(X, view(A, Block(I)))
@deprecate setblock!(A::AbstractBlockArray{T,N}, v, I::Vararg{Integer, N}) where {T,N} (A[Block(I...)] = v)


if !isdefined(Base, :get_extension)
include("../ext/BlockArraysBandedMatricesExt.jl")
end

end # module
23 changes: 13 additions & 10 deletions src/blockarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,16 @@ struct BlockArray{T, N, R <: AbstractArray{<:AbstractArray{T,N},N}, BS<:NTuple{N
blocks::R
axes::BS

global @inline _BlockArray(blocks::R, block_sizes::BS) where {T, N, R<:AbstractArray{<:AbstractArray{T,N},N}, BS<:NTuple{N,AbstractUnitRange{Int}}} =
new{T, N, R, BS}(blocks, block_sizes)
global @inline function _BlockArray(blocks::R, block_axes::BS) where {T, N, R<:AbstractArray{<:AbstractArray{T,N},N}, BS<:NTuple{N,AbstractUnitRange{Int}}}
Base.require_one_based_indexing(block_axes...)
Base.require_one_based_indexing(blocks)
new{T, N, R, BS}(blocks, block_axes)
end
end

# Auxiliary outer constructors
@inline _BlockArray(blocks::R, block_sizes::Vararg{AbstractVector{<:Integer}, N}) where {T, N, R<:AbstractArray{<:AbstractArray{T,N},N}} =
_BlockArray(blocks, map(blockedrange, block_sizes))
@inline _BlockArray(blocks::R, block_axes::Vararg{AbstractVector{<:Integer}, N}) where {T, N, R<:AbstractArray{<:AbstractArray{T,N},N}} =
_BlockArray(blocks, map(blockedrange, block_axes))

# support non-concrete eltypes in blocks
_BlockArray(blocks::R, block_axes::BS) where {N, R<:AbstractArray{<:AbstractArray{V,N} where V,N}, BS<:NTuple{N,AbstractUnitRange{Int}}} =
Expand Down Expand Up @@ -428,18 +431,18 @@ end
###########################


@inline Base.similar(block_array::AbstractArray, ::Type{T}, axes::Tuple{BlockedUnitRange,Vararg{Union{AbstractUnitRange{Int},Integer}}}) where T =
@inline Base.similar(block_array::AbstractArray, ::Type{T}, axes::Tuple{AbstractBlockedUnitRange,Vararg{Union{AbstractUnitRange{Int},Integer}}}) where T =
BlockArray{T}(undef, map(to_axes,axes))
@inline Base.similar(block_array::AbstractArray, ::Type{T}, axes::Tuple{BlockedUnitRange,BlockedUnitRange,Vararg{Union{AbstractUnitRange{Int},Integer}}}) where T =
@inline Base.similar(block_array::AbstractArray, ::Type{T}, axes::Tuple{AbstractBlockedUnitRange,AbstractBlockedUnitRange,Vararg{Union{AbstractUnitRange{Int},Integer}}}) where T =
BlockArray{T}(undef, map(to_axes,axes))
@inline Base.similar(block_array::AbstractArray, ::Type{T}, axes::Tuple{Union{AbstractUnitRange{Int},Integer},BlockedUnitRange,Vararg{Union{AbstractUnitRange{Int},Integer}}}) where T =
@inline Base.similar(block_array::AbstractArray, ::Type{T}, axes::Tuple{Union{AbstractUnitRange{Int},Integer},AbstractBlockedUnitRange,Vararg{Union{AbstractUnitRange{Int},Integer}}}) where T =
BlockArray{T}(undef, map(to_axes,axes))

@inline Base.similar(block_array::Type{<:AbstractArray{T}}, axes::Tuple{BlockedUnitRange,Vararg{Union{AbstractUnitRange{Int},Integer}}}) where T =
@inline Base.similar(block_array::Type{<:AbstractArray{T}}, axes::Tuple{AbstractBlockedUnitRange,Vararg{Union{AbstractUnitRange{Int},Integer}}}) where T =
BlockArray{T}(undef, map(to_axes,axes))
@inline Base.similar(block_array::Type{<:AbstractArray{T}}, axes::Tuple{BlockedUnitRange,BlockedUnitRange,Vararg{Union{AbstractUnitRange{Int},Integer}}}) where T =
@inline Base.similar(block_array::Type{<:AbstractArray{T}}, axes::Tuple{AbstractBlockedUnitRange,AbstractBlockedUnitRange,Vararg{Union{AbstractUnitRange{Int},Integer}}}) where T =
BlockArray{T}(undef, map(to_axes,axes))
@inline Base.similar(block_array::Type{<:AbstractArray{T}}, axes::Tuple{Union{AbstractUnitRange{Int},Integer},BlockedUnitRange,Vararg{Union{AbstractUnitRange{Int},Integer}}}) where T =
@inline Base.similar(block_array::Type{<:AbstractArray{T}}, axes::Tuple{Union{AbstractUnitRange{Int},Integer},AbstractBlockedUnitRange,Vararg{Union{AbstractUnitRange{Int},Integer}}}) where T =
BlockArray{T}(undef, map(to_axes,axes))

@inline Base.similar(B::BlockArray, ::Type{T}) where {T} = mortar(similar.(blocks(B), T))
Expand Down
Loading
Loading