Skip to content

Commit e0c0b18

Browse files
authored
Fix docstring of PseudoBlockArray (#303)
1 parent 03999b8 commit e0c0b18

File tree

1 file changed

+63
-15
lines changed

1 file changed

+63
-15
lines changed

src/pseudo_blockarray.jl

Lines changed: 63 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,34 @@
1010
1111
A `PseudoBlockArray` is similar to a [`BlockArray`](@ref) except the full array is stored
1212
contiguously instead of block by block. This means that is not possible to insert and retrieve
13-
blocks without copying data. On the other hand `Array` on a `PseudoBlockArray` is instead instant since
13+
blocks without copying data. On the other hand `parent` on a `PseudoBlockArray` is instead instant since
1414
it just returns the wrapped array.
1515
1616
When iteratively solving a set of equations with a gradient method the Jacobian typically has a block structure. It can be convenient
1717
to use a `PseudoBlockArray` to build up the Jacobian block by block and then pass the resulting matrix to
18-
a direct solver using `Array`.
18+
a direct solver using `parent`.
1919
2020
# Examples
2121
```jldoctest
22-
julia> PseudoBlockArray(reshape([1:6;], 2, 3), [1,1], [2,1])
22+
julia> A = zeros(Int, 2, 3);
23+
24+
julia> B = PseudoBlockArray(A, [1,1], [2,1])
2325
2×2-blocked 2×3 PseudoBlockMatrix{Int64}:
24-
1 35
26+
0 00
2527
──────┼───
26-
2 46
28+
0 00
2729
28-
julia> PseudoBlockArray([1:6;], [3,2,1])
29-
3-blocked 6-element PseudoBlockVector{Int64}:
30-
1
31-
2
32-
3
33-
34-
4
35-
5
36-
37-
6
30+
julia> parent(B) === A
31+
true
32+
33+
julia> B[Block(1,1)] .= 4
34+
1×2 view(::Matrix{Int64}, 1:1, 1:2) with eltype Int64:
35+
4 4
36+
37+
julia> A
38+
2×3 Matrix{Int64}:
39+
4 4 0
40+
0 0 0
3841
```
3942
"""
4043
struct PseudoBlockArray{T, N, R<:AbstractArray{T,N}, BS<:NTuple{N,AbstractUnitRange{Int}}} <: AbstractBlockArray{T, N}
@@ -46,7 +49,52 @@ struct PseudoBlockArray{T, N, R<:AbstractArray{T,N}, BS<:NTuple{N,AbstractUnitRa
4649
end
4750
end
4851

52+
"""
53+
PseudoBlockMatrix{T}
54+
55+
Alias for `PseudoBlockArray{T, 2}`
56+
57+
```jldoctest
58+
julia> A = reshape([1:6;], 2, 3)
59+
2×3 Matrix{Int64}:
60+
1 3 5
61+
2 4 6
62+
63+
julia> PseudoBlockMatrix(A, [1,1], [1,2])
64+
2×2-blocked 2×3 PseudoBlockMatrix{Int64}:
65+
1 │ 3 5
66+
───┼──────
67+
2 │ 4 6
68+
```
69+
"""
4970
const PseudoBlockMatrix{T} = PseudoBlockArray{T, 2}
71+
"""
72+
PseudoBlockVector{T}
73+
74+
Alias for `PseudoBlockArray{T, 1}`
75+
76+
```jldoctest
77+
julia> A = [1:6;]
78+
6-element Vector{Int64}:
79+
1
80+
2
81+
3
82+
4
83+
5
84+
6
85+
86+
julia> PseudoBlockVector(A, [3,2,1])
87+
3-blocked 6-element PseudoBlockVector{Int64}:
88+
1
89+
2
90+
3
91+
92+
4
93+
5
94+
95+
6
96+
```
97+
"""
5098
const PseudoBlockVector{T} = PseudoBlockArray{T, 1}
5199
const PseudoBlockVecOrMat{T} = Union{PseudoBlockMatrix{T}, PseudoBlockVector{T}}
52100

0 commit comments

Comments
 (0)