You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Similarly to `setblock!` this does not copy the returned array.
134
-
135
137
For setting and getting a single scalar element, the usual `setindex!` and `getindex` are available.
136
138
137
139
```jl
@@ -141,19 +143,25 @@ julia> block_array[1, 2]
141
143
142
144
## Views of blocks
143
145
144
-
We can also view and modify views of blocks of `BlockArray`using the `view` syntax:
146
+
To view and modify blocks of `BlockArray`use the `view` syntax.
145
147
```jldoctest
146
148
julia> A = BlockArray(ones(6), 1:3);
147
149
148
150
julia> view(A, Block(2))
149
-
2-element view(::BlockArray{Float64,1,Array{Array{Float64,1},1},Tuple{BlockedUnitRange{Array{Int64,1}}}}, BlockSlice(Block(2),2:3)) with eltype Float64:
151
+
2-element Array{Float64,1}:
150
152
1.0
151
153
1.0
152
154
153
155
julia> view(A, Block(2)) .= [3,4]; A[Block(2)]
154
156
2-element Array{Float64,1}:
155
157
3.0
156
158
4.0
159
+
160
+
julia> view(A, Block.(1:2))
161
+
3-element view(::BlockArray{Float64,1,Array{Array{Float64,1},1},Tuple{BlockedUnitRange{ArrayLayouts.RangeCumsum{Int64,UnitRange{Int64}}}}}, BlockSlice(Block{1,Int64}[Block(1), Block(2)],1:1:3)) with eltype Float64 with indices 1:1:3:
Copy file name to clipboardExpand all lines: docs/src/man/pseudoblockarrays.md
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ it can just return the wrapped array.
15
15
16
16
When iteratively solving a set of equations with a gradient method the Jacobian typically has a block structure. It can be convenient
17
17
to use a `PseudoBlockArray` to build up the Jacobian block by block and then pass the resulting matrix to
18
-
a direct solver using `full`.
18
+
a direct solver using `Matrix`.
19
19
20
20
## Creating PseudoBlockArrays
21
21
@@ -50,15 +50,16 @@ We can also any other user defined array type that supports `similar`.
50
50
## Setting and getting blocks and values
51
51
52
52
Setting and getting blocks uses the same API as `BlockArrays`. The difference here is that setting a block will update the block in place and getting a block
53
-
will extract a copy of the block and return it. For `PseudoBlockArrays` there is a mutating block getter called `getblock!` which updates a passed in array to avoid a copy:
53
+
will extract a copy of the block and return it. Note to update a passed in array without allocating
54
+
one can use views:
54
55
55
56
```jldoctest A
56
57
julia> A = zeros(2,2)
57
58
2×2 Array{Float64,2}:
58
59
0.0 0.0
59
60
0.0 0.0
60
61
61
-
julia> getblock!(A, pseudo, 2, 1);
62
+
julia> copyto!(A, view(pseudo, Block(2, 1)));
62
63
63
64
julia> A
64
65
2×2 Array{Float64,2}:
@@ -83,7 +84,7 @@ We can also view and modify views of blocks of `PseudoBlockArray` using the `vie
83
84
julia> A = PseudoBlockArray(ones(6), 1:3);
84
85
85
86
julia> view(A, Block(2))
86
-
2-element view(::PseudoBlockArray{Float64,1,Array{Float64,1},Tuple{BlockedUnitRange{Array{Int64,1}}}}, BlockSlice(Block(2),2:3)) with eltype Float64:
87
+
2-element view(::Array{Float64,1}, 2:3) with eltype Float64:
0 commit comments