Skip to content

Commit 6bddde0

Browse files
authored
Fix docstrings, and make docs runnable (#155)
* fix docstrings, and make docs runnable * don't track docs/build
1 parent d1d552a commit 6bddde0

File tree

7 files changed

+119
-16
lines changed

7 files changed

+119
-16
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11

22
.DS_Store
33
Manifest.toml
4+
docs/build

docs/Project.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
[deps]
2+
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
3+
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
24
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
5+
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
6+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
37

48
[compat]
5-
Documenter = "= 0.27"
9+
BlockArrays = "0.16"
10+
Documenter = "0.27"
11+
FillArrays = "1"

docs/make.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Documenter, BlockBandedMatrices
22

3+
DocMeta.setdocmeta!(BlockBandedMatrices, :DocTestSetup, :(using BlockBandedMatrices))
4+
35
makedocs(
46
modules = [BlockBandedMatrices],
57
sitename = "BlockBandedMatrices.jl",

docs/src/index.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55

66
```@docs
77
BlockBandedMatrix
8-
```
9-
10-
```@docs
8+
BlockBandedMatrix(::AbstractMatrix, ::AbstractVector{Int}, ::AbstractVector{Int}, ::NTuple{2,Int})
9+
BlockBandedMatrix(::AbstractMatrix, ::NTuple{2,Int})
10+
BlockBandedMatrix{T}(::UndefInitializer, ::AbstractVector{Int}, ::AbstractVector{Int}, ::NTuple{2,Int})
1111
BandedBlockBandedMatrix
12+
BandedBlockBandedMatrix{T}(::UndefInitializer, ::AbstractVector{Int}, ::AbstractVector{Int}, ::NTuple{2,Int}, ::NTuple{2,Int})
1213
```
1314

1415

@@ -41,7 +42,7 @@ of row and column blocks, then `A` has zero structure
4142
a_21 a_22 │
4243
──────────┼──────────
4344
a_31 a_32 │ a_33 a_34
44-
a_41 a_42 │ a_43 a_44
45+
a_41 a_42 │ a_43 a_44
4546
──────────┼──────────
4647
│ a_53 a_54
4748
│ a_63 a_64 ]
@@ -69,7 +70,7 @@ of row and column blocks, then `A` has zero structure
6970
a_21 a_22 │
7071
──────────┼──────────
7172
a_31 │ a_33
72-
a_41 a_42 │ a_43 a_44
73+
a_41 a_42 │ a_43 a_44
7374
──────────┼──────────
7475
│ a_53
7576
│ a_63 a_64 ]
@@ -78,7 +79,7 @@ and is stored in memory via `A.data` as a `PseudoBlockMatrix`, which has block s
7879
2 x 2, containing entries:
7980
```julia
8081
[a_11 a_22 │ a_33 a_44
81-
a_21 × │ a_43 ×
82+
a_21 × │ a_43 ×
8283
──────────┼──────────
8384
a_31 a_42 │ a_53 a_64
8485
a_41 × │ a_63 × ]

src/AbstractBlockBandedMatrix.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Returns the lower blockbandwidth (`i==1`) or the upper blockbandwidth (`i==2`).
7878
blockbandwidth(A, k::Integer) = blockbandwidths(A)[k]
7979

8080
"""
81-
bandrange(A)
81+
blockbandrange(A)
8282
8383
Returns the range `-blockbandwidth(A,1):blockbandwidth(A,2)`.
8484
"""

src/BandedBlockBandedMatrix.jl

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,33 @@ BandedBlockBandedMatrix{T,B}(::UndefInitializer, rblocksizes::AbstractVector{Int
6262

6363
BandedBlockBandedMatrix{T}(::UndefInitializer, axes::NTuple{2,AbstractUnitRange{Int}}, lu::NTuple{2,Int}, λμ::NTuple{2,Int}) where T =
6464
_BandedBlockBandedMatrix(PseudoBlockMatrix{T}(undef, _bbb_data_axes(axes[2],lu,λμ)), axes[1], lu, λμ)
65+
"""
66+
BandedBlockBandedMatrix{T}(undef, rows, cols, (l, u), (λ, μ))
67+
68+
Return an unitialized `BandedBlockBandedMatrix` having `eltype` `T`,
69+
with block-bandwidths `(l,u)` and where `A[Block(K,J)]` is a
70+
`BandedMatrix{T}` of size `rows[K]×cols[J]` with bandwidths `(λ,μ)`.
71+
"""
6572
BandedBlockBandedMatrix{T}(::UndefInitializer, rblocksizes::AbstractVector{Int}, cblocksizes::AbstractVector{Int}, lu::NTuple{2,Int}, λμ::NTuple{2,Int}) where T =
6673
BandedBlockBandedMatrix{T}(undef, (blockedrange(rblocksizes),blockedrange(cblocksizes)), lu, λμ)
6774

6875

6976
"""
70-
BandedBlockBandedMatrix{T}(M::Union{UndefInitializer,UniformScaling,AbstractMatrix},
77+
BandedBlockBandedMatrix(M::Union{UniformScaling,AbstractMatrix},
7178
rows, cols, (l, u), (λ, μ))
7279
73-
returns a `sum(rows)`×`sum(cols)` banded-block-banded matrix `A` having elements of
74-
type `T`, with block-bandwidths `(l,u)` and where `A[Block(K,J)]` is a
75-
`BandedMatrix{T}` of size `rows[K]`×`cols[J]` with bandwidths `(λ,μ)`.
80+
Return a `sum(rows) × sum(cols)` banded-block-banded matrix `A`,
81+
with block-bandwidths `(l,u)` and where `A[Block(K,J)]` is a
82+
`BandedMatrix` of size `rows[K]`×`cols[J]` with bandwidths `(λ,μ)`.
83+
The structural non-zero elements of the returned matrix corresponds to those of `M`.
7684
7785
# Examples
7886
7987
```jldoctest
88+
julia> using LinearAlgebra, FillArrays
89+
8090
julia> BandedBlockBandedMatrix(I, [3,4,3], [3,4,3], (1,1), (1,1))
81-
3×3-blocked 10×10 BandedBlockBandedMatrix{Bool,BlockArrays.PseudoBlockArray{Bool,2,Array{Bool,2},Tuple{BlockArrays.BlockedUnitRange{Array{Int64,1}},BlockArrays.BlockedUnitRange{Array{Int64,1}}}},BlockArrays.BlockedUnitRange{Array{Int64,1}}}:
91+
3×3-blocked 10×10 BandedBlockBandedMatrix{Bool, BlockArrays.PseudoBlockMatrix{Bool, Matrix{Bool}, Tuple{BlockArrays.BlockedUnitRange{Vector{Int64}}, BlockArrays.BlockedUnitRange{Vector{Int64}}}}, BlockArrays.BlockedUnitRange{Vector{Int64}}}:
8292
1 0 ⋅ │ 0 0 ⋅ ⋅ │ ⋅ ⋅ ⋅
8393
0 1 0 │ 0 0 0 ⋅ │ ⋅ ⋅ ⋅
8494
⋅ 0 1 │ ⋅ 0 0 0 │ ⋅ ⋅ ⋅
@@ -93,7 +103,7 @@ julia> BandedBlockBandedMatrix(I, [3,4,3], [3,4,3], (1,1), (1,1))
93103
⋅ ⋅ ⋅ │ ⋅ 0 0 0 │ ⋅ 0 1
94104
95105
julia> BandedBlockBandedMatrix(Ones{Int}(10,13), [3,4,3], [4,5,4], (1,1), (1,1))
96-
3×3-blocked 10×13 BandedBlockBandedMatrix{Int64,BlockArrays.PseudoBlockArray{Int64,2,Array{Int64,2},Tuple{BlockArrays.BlockedUnitRange{Array{Int64,1}},BlockArrays.BlockedUnitRange{Array{Int64,1}}}},BlockArrays.BlockedUnitRange{Array{Int64,1}}}:
106+
3×3-blocked 10×13 BandedBlockBandedMatrix{Int64, BlockArrays.PseudoBlockMatrix{Int64, Matrix{Int64}, Tuple{BlockArrays.BlockedUnitRange{Vector{Int64}}, BlockArrays.BlockedUnitRange{Vector{Int64}}}}, BlockArrays.BlockedUnitRange{Vector{Int64}}}:
97107
1 1 ⋅ ⋅ │ 1 1 ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅
98108
1 1 1 ⋅ │ 1 1 1 ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅
99109
⋅ 1 1 1 │ ⋅ 1 1 1 ⋅ │ ⋅ ⋅ ⋅ ⋅

src/BlockSkylineMatrix.jl

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ struct BlockSkylineMatrix{T, DATA<:AbstractVector{T}, BS<:BlockSkylineSizes} <:
120120
end
121121
end
122122

123+
"""
124+
BlockBandedMatrix
125+
126+
A `BlockBandedMatrix` is a subtype of `BlockMatrix` of `BlockArrays.jl` whose
127+
layout of non-zero blocks is banded.
128+
"""
123129
const BlockBandedMatrix{T} = BlockSkylineMatrix{T, Vector{T}, BlockBandedSizes}
124130

125131
# Auxiliary outer constructors
@@ -149,8 +155,10 @@ lengths `rows` and `cols`, respectively, for ragged bands.
149155
# Examples
150156
151157
```jldoctest
158+
julia> using LinearAlgebra, FillArrays
159+
152160
julia> BlockSkylineMatrix(I, [2,3,4], [1,2,3], ([2,0,1],[1,1,1]))
153-
3×3-blocked 9×6 BlockSkylineMatrix{Bool,Array{Bool,1},BlockBandedMatrices.BlockSkylineSizes{Tuple{BlockArrays.BlockedUnitRange{Array{Int64,1}},BlockArrays.BlockedUnitRange{Array{Int64,1}}},Array{Int64,1},Array{Int64,1},BandedMatrices.BandedMatrix{Int64,Array{Int64,2},Base.OneTo{Int64}},Array{Int64,1}}}:
161+
3×3-blocked 9×6 BlockSkylineMatrix{Bool, Vector{Bool}, BlockBandedMatrices.BlockSkylineSizes{Tuple{BlockArrays.BlockedUnitRange{Vector{Int64}}, BlockArrays.BlockedUnitRange{Vector{Int64}}}, Vector{Int64}, Vector{Int64}, BandedMatrices.BandedMatrix{Int64, Matrix{Int64}, Base.OneTo{Int64}}, Vector{Int64}}}:
154162
1 │ 0 0 │ ⋅ ⋅ ⋅
155163
0 │ 1 0 │ ⋅ ⋅ ⋅
156164
───┼────────┼─────────
@@ -164,7 +172,7 @@ julia> BlockSkylineMatrix(I, [2,3,4], [1,2,3], ([2,0,1],[1,1,1]))
164172
0 │ ⋅ ⋅ │ 0 0 0
165173
166174
julia> BlockSkylineMatrix(Ones(9,6), [2,3,4], [1,2,3], ([2,0,1],[1,1,1]))
167-
3×3-blocked 9×6 BlockSkylineMatrix{Float64,Array{Float64,1},BlockBandedMatrices.BlockSkylineSizes{Tuple{BlockArrays.BlockedUnitRange{Array{Int64,1}},BlockArrays.BlockedUnitRange{Array{Int64,1}}},Array{Int64,1},Array{Int64,1},BandedMatrices.BandedMatrix{Int64,Array{Int64,2},Base.OneTo{Int64}},Array{Int64,1}}}:
175+
3×3-blocked 9×6 BlockSkylineMatrix{Float64, Vector{Float64}, BlockBandedMatrices.BlockSkylineSizes{Tuple{BlockArrays.BlockedUnitRange{Vector{Int64}}, BlockArrays.BlockedUnitRange{Vector{Int64}}}, Vector{Int64}, Vector{Int64}, BandedMatrices.BandedMatrix{Int64, Matrix{Int64}, Base.OneTo{Int64}}, Vector{Int64}}}:
168176
1.0 │ 1.0 1.0 │ ⋅ ⋅ ⋅
169177
1.0 │ 1.0 1.0 │ ⋅ ⋅ ⋅
170178
─────┼────────────┼───────────────
@@ -186,6 +194,13 @@ BlockSkylineMatrix
186194
@inline BlockSkylineMatrix{T}(::UndefInitializer, axes::NTuple{2,AbstractUnitRange{Int}}, lu::NTuple{2, AbstractVector{Int}}) where T =
187195
BlockSkylineMatrix{T}(undef, BlockSkylineSizes(axes, lu...))
188196

197+
"""
198+
BlockBandedMatrix{T}(undef, rows::AbstractVector{Int}, cols::AbstractVector{Int},
199+
(l,u)::NTuple{2,Int})
200+
201+
Return an unitialized `sum(rows) × sum(cols)` `BlockBandedMatrix` having `eltype` `T`,
202+
with `rows` by `cols` blocks and `(l,u)` as the block-bandwidth.
203+
"""
189204
@inline BlockBandedMatrix{T}(::UndefInitializer, rdims::AbstractVector{Int}, cdims::AbstractVector{Int}, lu::NTuple{2, Int}) where T =
190205
BlockSkylineMatrix{T}(undef, BlockBandedSizes(rdims, cdims, lu...))
191206

@@ -257,10 +272,78 @@ BlockBandedMatrix{T}(A::Union{AbstractMatrix,UniformScaling},
257272
BlockSkylineMatrix(A::Union{AbstractMatrix,UniformScaling},
258273
rdims::AbstractVector{Int}, cdims::AbstractVector{Int},
259274
lu::NTuple{2,AbstractVector{Int}}) = BlockSkylineMatrix{eltype(A)}(A, rdims, cdims, lu)
275+
276+
277+
"""
278+
BlockBandedMatrix(A::Union{AbstractMatrix,UniformScaling},
279+
rows::AbstractVector{Int}, cols::AbstractVector{Int},
280+
(l,u)::NTuple{2,Int})
281+
282+
Return a `sum(rows) × sum(cols)` `BlockBandedMatrix`, with `rows` by `cols` blocks,
283+
with `(l,u)` as the block-bandwidth.
284+
The structural non-zero entries are equal to the corresponding indices of `A`.
285+
286+
# Examples
287+
```jldoctest
288+
julia> using LinearAlgebra, FillArrays
289+
290+
julia> l,u = 0,1; # block bandwidths
291+
292+
julia> nrowblk, ncolblk = 3, 3; # number of row/column blocks
293+
294+
julia> rows = 1:nrowblk; cols = 1:ncolblk; # block sizes
295+
296+
julia> BlockBandedMatrix(I, rows, cols, (l,u))
297+
3×3-blocked 6×6 BlockBandedMatrix{Bool}:
298+
1 │ 0 0 │ ⋅ ⋅ ⋅
299+
───┼────────┼─────────
300+
⋅ │ 1 0 │ 0 0 0
301+
⋅ │ 0 1 │ 0 0 0
302+
───┼────────┼─────────
303+
⋅ │ ⋅ ⋅ │ 1 0 0
304+
⋅ │ ⋅ ⋅ │ 0 1 0
305+
⋅ │ ⋅ ⋅ │ 0 0 1
306+
307+
julia> BlockBandedMatrix(Ones(sum(rows),sum(cols)), rows, cols, (l,u))
308+
3×3-blocked 6×6 BlockBandedMatrix{Float64}:
309+
1.0 │ 1.0 1.0 │ ⋅ ⋅ ⋅
310+
─────┼────────────┼───────────────
311+
⋅ │ 1.0 1.0 │ 1.0 1.0 1.0
312+
⋅ │ 1.0 1.0 │ 1.0 1.0 1.0
313+
─────┼────────────┼───────────────
314+
⋅ │ ⋅ ⋅ │ 1.0 1.0 1.0
315+
⋅ │ ⋅ ⋅ │ 1.0 1.0 1.0
316+
⋅ │ ⋅ ⋅ │ 1.0 1.0 1.0
317+
```
318+
"""
260319
BlockBandedMatrix(A::Union{AbstractMatrix,UniformScaling},
261320
rdims::AbstractVector{Int}, cdims::AbstractVector{Int},
262321
lu::NTuple{2,Int}) = BlockBandedMatrix{eltype(A)}(A, rdims, cdims, lu)
263322

323+
"""
324+
BlockBandedMatrix(A::AbstractMatrix, (l,u)::NTuple{2,Int})
325+
326+
Return a `BlockBandedMatrix` with block-bandwidths `(l,u)`, where the
327+
structural non-zero blocks correspond to those of `A`.
328+
329+
Examples
330+
```jldoctest
331+
julia> using BlockArrays
332+
333+
julia> B = BlockArray(ones(6,6), 1:3, 1:3);
334+
335+
julia> BlockBandedMatrix(B, (1,1))
336+
3×3-blocked 6×6 BlockBandedMatrix{Float64}:
337+
1.0 │ 1.0 1.0 │ ⋅ ⋅ ⋅
338+
─────┼────────────┼───────────────
339+
1.0 │ 1.0 1.0 │ 1.0 1.0 1.0
340+
1.0 │ 1.0 1.0 │ 1.0 1.0 1.0
341+
─────┼────────────┼───────────────
342+
⋅ │ 1.0 1.0 │ 1.0 1.0 1.0
343+
⋅ │ 1.0 1.0 │ 1.0 1.0 1.0
344+
⋅ │ 1.0 1.0 │ 1.0 1.0 1.0
345+
```
346+
"""
264347
BlockBandedMatrix(A::AbstractMatrix, lu::NTuple{2,Int}) = BlockBandedMatrix(A, BlockBandedSizes(axes(A), lu...))
265348

266349
function convert(::Type{BlockSkylineMatrix}, A::AbstractMatrix)

0 commit comments

Comments
 (0)