1010
1111A `PseudoBlockArray` is similar to a [`BlockArray`](@ref) except the full array is stored
1212contiguously 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
1414it just returns the wrapped array.
1515
1616When iteratively solving a set of equations with a gradient method the Jacobian typically has a block structure. It can be convenient
1717to 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])
23252×2-blocked 2×3 PseudoBlockMatrix{Int64}:
24- 1 3 │ 5
26+ 0 0 │ 0
2527 ──────┼───
26- 2 4 │ 6
28+ 0 0 │ 0
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"""
4043struct 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
4750end
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+ """
4970const 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+ """
5098const PseudoBlockVector{T} = PseudoBlockArray{T, 1 }
5199const PseudoBlockVecOrMat{T} = Union{PseudoBlockMatrix{T}, PseudoBlockVector{T}}
52100
0 commit comments