Skip to content

Commit 4a7f782

Browse files
authored
make mul! fast if first arg is Adjoint, fix block size (#172) (#173)
* make mul! fast if first arg is Adjoint, fix block size (#172) * v0.15.4 * Update ci.yml * update docs for Julia v1.6 * Drop Julia v1.5 * Update blockaxis.jl * increase cov
1 parent b16f01f commit 4a7f782

22 files changed

+143
-138
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
version:
13-
- '1.5'
14-
- '^1.6.0-0'
15-
- 'nightly'
13+
- '1.6'
1614
os:
1715
- ubuntu-latest
1816
- macOS-latest
@@ -48,7 +46,7 @@ jobs:
4846
- uses: actions/checkout@v2
4947
- uses: julia-actions/setup-julia@v1
5048
with:
51-
version: '1.5'
49+
version: '1'
5250
- run: |
5351
julia --project=docs -e '
5452
using Pkg

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
name = "BlockArrays"
22
uuid = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
3-
version = "0.15.3"
3+
version = "0.16"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
77
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
88
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
99

1010
[compat]
11-
ArrayLayouts = "0.5, 0.6, 0.7"
11+
ArrayLayouts = "0.7.1"
1212
FillArrays = "0.11.6"
13-
julia = "1.5"
13+
julia = "1.6"
1414

1515
[extras]
1616
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Secondly, it also implements two different type of block arrays that follow the
1111
A simple way to produce `BlockArray`s is via `mortar`, which combines an array of arrays into a `BlockArray`:
1212
```julia
1313
julia> mortar([randn(3), randn(4)])
14-
2-blocked 7-element BlockArray{Float64,1}:
14+
2-blocked 7-element BlockVector{Float64}:
1515
-0.19808699390960527
1616
0.04711385377738941
1717
-0.6308529482215658
@@ -22,7 +22,7 @@ julia> mortar([randn(3), randn(4)])
2222
-0.012442892450142308
2323

2424
julia> mortar(reshape([randn(2,2), randn(1,2), randn(2,3), randn(1,3)],2,2))
25-
2×2-blocked 3×5 BlockArray{Float64,2}:
25+
2×2-blocked 3×5 BlockMatrix{Float64}:
2626
-1.17797 0.3597380.87676 -2.06495 1.74256
2727
1.54787 1.64133-0.0416484 -2.00241 -0.522441
2828
───────────────────────┼──────────────────────────────────

docs/src/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Secondly, it also implements two concrete types of block arrays that follow the
1414
We talk about an “a×b-blocked m×n block array”, if we have ``m \times n`` values arranged in ``a \times b`` blocks, like in the following example:
1515

1616
```julia
17-
2×3-blocked 4×4 BlockArray{Float64,2}:
17+
2×3-blocked 4×4 BlockMatrix{Float64}:
1818
0.566090.954290.0688403 0.980771
1919
0.2038290.1386670.0200418 0.0515364
2020
──────────┼────────────┼──────────────────────
@@ -25,7 +25,7 @@ We talk about an “a×b-blocked m×n block array”, if we have ``m \times n``
2525
The dimension of arrays works the same as with standard Julia arrays; for example the following is a ``2 \times 2`` block vector:
2626

2727
```julia
28-
2-blocked 4-element BlockArray{Float64,1}:
28+
2-blocked 4-element BlockVector{Float64}:
2929
0.35609231970760424
3030
0.7732179994849591
3131
───────────────────

docs/src/man/abstractblockarrayinterface.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ An arrays block structure is inferred from an axes, and therefore every array
2020
is in some sense already a block array:
2121
```julia
2222
julia> A = randn(5,5)
23-
5×5 Array{Float64,2}:
23+
5×5 Matrix{Float64}:
2424
0.452801 -0.416508 1.17406 1.52575 3.1574
2525
0.413142 -1.34722 -1.28597 0.637721 0.30655
2626
0.34907 -0.887615 0.284972 -0.0212884 -0.225832
2727
0.466102 -1.10425 1.49226 0.968436 -2.13637
2828
-0.0971956 -1.7664 -0.592629 -1.48947 1.53418
2929

3030
julia> A[Block(1,1)]
31-
5×5 Array{Float64,2}:
31+
5×5 Matrix{Float64}:
3232
0.452801 -0.416508 1.17406 1.52575 3.1574
3333
0.413142 -1.34722 -1.28597 0.637721 0.30655
3434
0.34907 -0.887615 0.284972 -0.0212884 -0.225832
@@ -50,7 +50,7 @@ that are subtypes of `AbstractBlockArray`:
5050
* A pretty printing `show` function that uses unicode lines to split up the blocks:
5151
```
5252
julia> A = BlockArray(rand(4, 5), [1,3], [2,3])
53-
2×2-blocked 4×5 BlockArray{Float64,2}:
53+
2×2-blocked 4×5 BlockMatrix{Float64}:
5454
0.61179 0.965631 │ 0.696476 0.392796 0.712462
5555
--------------------┼-------------------------------
5656
0.620099 0.364706 │ 0.0311643 0.27895 0.73477
@@ -62,7 +62,7 @@ julia> A = BlockArray(rand(4, 5), [1,3], [2,3])
6262

6363
```
6464
julia> blockcheckbounds(A, 5, 3)
65-
ERROR: BlockBoundsError: attempt to access 2×2-blocked 4×5 BlockArrays.BlockArray{Float64,2,Array{Float64,2}} at block index [5,3]
65+
ERROR: BlockBoundsError: attempt to access 2×2-blocked 4×5 BlockMatrix{Float64, Matrix{Float64}} at block index [5,3]
6666
```
6767

6868
* Happy users who know how to use your new block array :)

docs/src/man/blockarrays.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ An `AbstractArray` can be repacked into a `BlockArray` with `BlockArray(array, b
1414

1515
```julia
1616
julia> BlockArray(rand(4, 4), [2,2], [1,1,2])
17-
2×3-blocked 4×4 BlockArray{Float64,2}:
17+
2×3-blocked 4×4 BlockMatrix{Float64}:
1818
0.703930.5687030.0137366 0.953038
1919
0.249570.1459240.884324 0.134155
2020
──────────┼────────────┼─────────────────────
2121
0.4081330.7077230.467458 0.326718
2222
0.8443140.7942790.0421491 0.683791
2323

2424
julia> block_array_sparse = BlockArray(sprand(4, 5, 0.7), [1,3], [2,3])
25-
2×2-blocked 4×5 BlockArray{Float64,2,Array{SparseMatrixCSC{Float64,Int64},2},Tuple{BlockedUnitRange{Array{Int64,1}},BlockedUnitRange{Array{Int64,1}}}}:
25+
2×2-blocked 4×5 BlockMatrix{Float64, Matrix{SparseMatrixCSC{Float64, Int64}}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}}:
2626
0.0341601 0.3741870.0118196 0.299058 0.0
2727
----------------------------------------------------
2828
0.0945445 0.9311150.0460428 0.0 0.0
@@ -38,7 +38,7 @@ A block array can be created with uninitialized values (but initialized blocks)
3838

3939
```julia
4040
julia> BlockArray{Float32}(undef, [1,2,1], [1,1,1])
41-
3×3-blocked 4×3 BlockArray{Float32,2}:
41+
3×3-blocked 4×3 BlockMatrix{Float32}:
4242
-2.15145e-351.4013e-45-1.77199e-35
4343
──────────────┼────────────────┼──────────────
4444
1.4013e-45-1.77199e-35-1.72473e-34
@@ -56,7 +56,7 @@ A `BlockArray` can be created with the blocks left uninitialized using the `Bloc
5656

5757
```jldoctest
5858
julia> BlockArray{Float32}(undef_blocks, [1,2], [3,2])
59-
2×2-blocked 3×5 BlockArray{Float32,2}:
59+
2×2-blocked 3×5 BlockMatrix{Float32}:
6060
#undef #undef #undef │ #undef #undef
6161
────────────────────────┼────────────────
6262
#undef #undef #undef │ #undef #undef
@@ -67,7 +67,7 @@ The `block_type` should be an array type. It specifies the internal block type,
6767

6868
```julia
6969
julia> BlockArray(undef_blocks, SparseVector{Float64, Int}, [1,2])
70-
2-blocked 3-element BlockArray{Float64,1,Array{SparseVector{Float64,Int64},1},Tuple{BlockedUnitRange{Array{Int64,1}}}}:
70+
2-blocked 3-element BlockVector{Float64, Vector{SparseVector{Float64, Int64}}, Tuple{BlockedUnitRange{Vector{Int64}}}}:
7171
#undef
7272
------
7373
#undef
@@ -92,21 +92,21 @@ A block can be set by `block_array[Block(i...)] = v` or
9292

9393
```jldoctest block_array
9494
julia> block_array = BlockArray{Float64}(undef_blocks, [1,2], [2,2])
95-
2×2-blocked 3×4 BlockArray{Float64,2}:
95+
2×2-blocked 3×4 BlockMatrix{Float64}:
9696
#undef #undef │ #undef #undef
9797
────────────────┼────────────────
9898
#undef #undef │ #undef #undef
9999
#undef #undef │ #undef #undef
100100
101101
julia> block_array[Block(2,1)] = rand(2,2)
102-
2×2 Array{Float64,2}:
102+
2×2 Matrix{Float64}:
103103
0.590845 0.566237
104104
0.766797 0.460085
105105
106106
julia> block_array[Block(1),Block(1)] = [1 2];
107107
108108
julia> block_array
109-
2×2-blocked 3×4 BlockArray{Float64,2}:
109+
2×2-blocked 3×4 BlockMatrix{Float64}:
110110
1.0 2.0 │ #undef #undef
111111
────────────────────┼────────────────
112112
0.590845 0.566237 │ #undef #undef
@@ -120,15 +120,15 @@ or if a copy is desired, `block_array[Block(i...)]`:
120120

121121
```jldoctest block_array
122122
julia> view(block_array, Block(1, 1))
123-
1×2 Array{Float64,2}:
123+
1×2 Matrix{Float64}:
124124
1.0 2.0
125125
126126
julia> block_array[Block(1, 1)] # makes a copy
127-
1×2 Array{Float64,2}:
127+
1×2 Matrix{Float64}:
128128
1.0 2.0
129129
130130
julia> block_array[Block(1), Block(1)] # equivalent to above
131-
1×2 Array{Float64,2}:
131+
1×2 Matrix{Float64}:
132132
1.0 2.0
133133
```
134134

@@ -146,17 +146,17 @@ To view and modify blocks of `BlockArray` use the `view` syntax.
146146
julia> A = BlockArray(ones(6), 1:3);
147147
148148
julia> view(A, Block(2))
149-
2-element Array{Float64,1}:
149+
2-element Vector{Float64}:
150150
1.0
151151
1.0
152152
153153
julia> view(A, Block(2)) .= [3,4]; A[Block(2)]
154-
2-element Array{Float64,1}:
154+
2-element Vector{Float64}:
155155
3.0
156156
4.0
157157
158158
julia> view(A, Block.(1:2))
159-
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:
159+
3-element view(::BlockVector{Float64, Vector{Vector{Float64}}, 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:
160160
1.0
161161
3.0
162162
4.0
@@ -170,7 +170,7 @@ An array can be repacked into a `BlockArray` with `BlockArray(array, block_sizes
170170

171171
```jl
172172
julia> block_array_sparse = BlockArray(sprand(4, 5, 0.7), [1,3], [2,3])
173-
2×2-blocked 4×5 BlockArray{Float64,2,Array{SparseMatrixCSC{Float64,Int64},2},Tuple{BlockedUnitRange{Array{Int64,1}},BlockedUnitRange{Array{Int64,1}}}}:
173+
2×2-blocked 4×5 BlockArray{Float64, 2, Matrix{SparseMatrixCSC{Float64, Int64}}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}}:
174174
0.0341601 0.3741870.0118196 0.299058 0.0
175175
----------------------------------------------------
176176
0.0945445 0.9311150.0460428 0.0 0.0

docs/src/man/pseudoblockarrays.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Creating a `PseudoBlockArray` works in the same way as a `BlockArray`.
2323

2424
```jldoctest A
2525
julia> pseudo = PseudoBlockArray(rand(3,3), [1,2], [2,1])
26-
2×2-blocked 3×3 PseudoBlockArray{Float64,2}:
26+
2×2-blocked 3×3 PseudoBlockMatrix{Float64}:
2727
0.590845 0.460085 │ 0.200586
2828
────────────────────┼──────────
2929
0.766797 0.794026 │ 0.298614
@@ -39,7 +39,7 @@ A block array can be created with uninitialized entries using the `BlockArray{T}
3939
function. The block_sizes are each an `AbstractVector{Int}` which determines the size of the blocks in that dimension. We here create a `[1,2]×[3,2]` block matrix of `Float32`s:
4040
```julia
4141
julia> PseudoBlockArray{Float32}(undef, [1,2], [3,2])
42-
2×2-blocked 3×5 PseudoBlockArray{Float32,2}:
42+
2×2-blocked 3×5 PseudoBlockMatrix{Float32}:
4343
1.02295e-43 0.0 1.09301e-430.0 1.17709e-43
4444
───────────────────────────────────────┼──────────────────────────
4545
0.0 1.06499e-43 0.01.14906e-43 0.0
@@ -55,14 +55,14 @@ one can use views:
5555

5656
```jldoctest A
5757
julia> A = zeros(2,2)
58-
2×2 Array{Float64,2}:
58+
2×2 Matrix{Float64}:
5959
0.0 0.0
6060
0.0 0.0
6161
6262
julia> copyto!(A, view(pseudo, Block(2, 1)));
6363
6464
julia> A
65-
2×2 Array{Float64,2}:
65+
2×2 Matrix{Float64}:
6666
0.766797 0.794026
6767
0.566237 0.854147
6868
```
@@ -84,12 +84,12 @@ We can also view and modify views of blocks of `PseudoBlockArray` using the `vie
8484
julia> A = PseudoBlockArray(ones(6), 1:3);
8585
8686
julia> view(A, Block(2))
87-
2-element view(::Array{Float64,1}, 2:3) with eltype Float64:
87+
2-element view(::Vector{Float64}, 2:3) with eltype Float64:
8888
1.0
8989
1.0
9090
9191
julia> view(A, Block(2)) .= [3,4]; A[Block(2)]
92-
2-element Array{Float64,1}:
92+
2-element Vector{Float64}:
9393
3.0
9494
4.0
9595
```

src/abstractblockarray.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ specialize this method if they need to provide custom block bounds checking beha
8686
julia> A = BlockArray(rand(2,3), [1,1], [2,1]);
8787
8888
julia> blockcheckbounds(A, 3, 2)
89-
ERROR: BlockBoundsError: attempt to access 2×2-blocked 2×3 BlockArray{Float64,2,Array{Array{Float64,2},2},Tuple{BlockedUnitRange{Array{Int64,1}},BlockedUnitRange{Array{Int64,1}}}} at block index [3,2]
89+
ERROR: BlockBoundsError: attempt to access 2×2-blocked 2×3 BlockMatrix{Float64, Matrix{Matrix{Float64}}, Tuple{BlockedUnitRange{Vector{Int64}}, BlockedUnitRange{Vector{Int64}}}} at block index [3,2]
9090
[...]
9191
```
9292
"""
@@ -144,23 +144,23 @@ returning views.
144144
145145
```jldoctest; setup = quote using BlockArrays end
146146
julia> v = Array(reshape(1:6, (2, 3)))
147-
2×3 Array{Int64,2}:
147+
2×3 Matrix{Int64}:
148148
1 3 5
149149
2 4 6
150150
151151
julia> A = BlockArray(v, [1,1], [2,1])
152-
2×2-blocked 2×3 BlockArray{Int64,2}:
152+
2×2-blocked 2×3 BlockMatrix{Int64}:
153153
1 3 │ 5
154154
──────┼───
155155
2 4 │ 6
156156
157157
julia> Matrix.(collect(eachblock(A)))
158-
2×2 Array{Array{Int64,2},2}:
158+
2×2 Matrix{Matrix{Int64}}:
159159
[1 3] [5]
160160
[2 4] [6]
161161
162162
julia> sum.(eachblock(A))
163-
2×2 Array{Int64,2}:
163+
2×2 Matrix{Int64}:
164164
4 5
165165
6 6
166166
```

src/blockarray.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ undef_blocks (@ref), an alias for UndefBlocksInitializer().
1616
# Examples
1717
```julia
1818
julia> BlockArray(undef_blocks, Matrix{Float32}, [1,2], [3,2])
19-
2×2-blocked 3×5 BlockArray{Float32,2}:
19+
2×2-blocked 3×5 BlockMatrix{Float32}:
2020
#undef #undef #undef │ #undef #undef
2121
────────────────────────┼────────────────
2222
#undef #undef #undef │ #undef #undef
@@ -35,7 +35,7 @@ array-constructor-caller would like an uninitialized block array.
3535
# Examples
3636
```julia
3737
julia> BlockArray(undef_blocks, Matrix{Float32}, [1,2], [3,2])
38-
2×2-blocked 3×5 BlockArray{Float32,2}:
38+
2×2-blocked 3×5 BlockMatrix{Float32}:
3939
#undef #undef #undef │ #undef #undef
4040
------------------------┼----------------
4141
#undef #undef #undef │ #undef #undef
@@ -101,7 +101,7 @@ Constructs a `BlockArray` with uninitialized blocks from a block type `R` with s
101101
102102
```jldoctest; setup = quote using BlockArrays end
103103
julia> BlockArray(undef_blocks, Matrix{Float64}, [1,3], [2,2])
104-
2×2-blocked 4×4 BlockArray{Float64,2}:
104+
2×2-blocked 4×4 BlockMatrix{Float64}:
105105
#undef #undef │ #undef #undef
106106
────────────────┼────────────────
107107
#undef #undef │ #undef #undef
@@ -223,12 +223,12 @@ julia> arrays = permutedims(reshape([
223223
1ones(1, 3), 2ones(1, 2),
224224
3ones(2, 3), 4ones(2, 2),
225225
], (2, 2)))
226-
2×2 Array{Array{Float64,2},2}:
226+
2×2 Matrix{Matrix{Float64}}:
227227
[1.0 1.0 1.0] [2.0 2.0]
228228
[3.0 3.0 3.0; 3.0 3.0 3.0] [4.0 4.0; 4.0 4.0]
229229
230230
julia> mortar(arrays)
231-
2×2-blocked 3×5 BlockArray{Float64,2}:
231+
2×2-blocked 3×5 BlockMatrix{Float64}:
232232
1.0 1.0 1.0 │ 2.0 2.0
233233
───────────────┼──────────
234234
3.0 3.0 3.0 │ 4.0 4.0

0 commit comments

Comments
 (0)