Skip to content

Commit 2de68d9

Browse files
authored
permutedims for Number block arrays (#164)
* permutedims for Number block arrays * more layout_getindex overloads * Add mortar example to README * test on 1.6
1 parent 3f44dea commit 2de68d9

File tree

5 files changed

+539
-490
lines changed

5 files changed

+539
-490
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
matrix:
1212
version:
1313
- '1.5'
14+
- '^1.6.0-0'
1415
- 'nightly'
1516
os:
1617
- ubuntu-latest

Project.toml

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

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
@@ -9,7 +9,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
99

1010
[compat]
1111
ArrayLayouts = "0.5, 0.6"
12-
FillArrays = "0.11"
12+
FillArrays = "0.11.6"
1313
julia = "1.5"
1414

1515
[extras]

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,27 @@ A block array is a partition of an array into blocks or subarrays, see [wikipedi
88

99
Secondly, it also implements two different type of block arrays that follow the `AbstractBlockArray` interface. The type `BlockArray` stores each block contiguously while the type `PseudoBlockArray` stores the full matrix contiguously. This means that `BlockArray` supports fast non copying extraction and insertion of blocks while `PseudoBlockArray` supports fast access to the full matrix to use in in for example a linear solver.
1010

11+
A simple way to produce `BlockArray`s is via `mortar`, which combines an array of arrays into a `BlockArray`:
12+
```julia
13+
julia> mortar([randn(3), randn(4)])
14+
2-blocked 7-element BlockArray{Float64,1}:
15+
-0.19808699390960527
16+
0.04711385377738941
17+
-0.6308529482215658
18+
─────────────────────
19+
-0.021279626465135287
20+
-1.0991149020591062
21+
1.0817971931026398
22+
-0.012442892450142308
23+
24+
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}:
26+
-1.17797 0.3597380.87676 -2.06495 1.74256
27+
1.54787 1.64133-0.0416484 -2.00241 -0.522441
28+
───────────────────────┼──────────────────────────────────
29+
0.430093 -0.0263753-1.31275 0.278447 -0.139579
30+
```
31+
1132
## Documentation
1233

1334
- [**STABLE**][docs-stable-url] — **most recently tagged version of the documentation.**

src/abstractblockarray.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,16 @@ end
178178
@inline Base.getindex(A::AbstractArray{T,N}, kr::Block{1}, jrs...) where {T,N} = ArrayLayouts.layout_getindex(A, kr, jrs...)
179179
@inline Base.getindex(A::AbstractArray{T,N}, block::Block{N}) where {T,N} = ArrayLayouts.layout_getindex(A, block)
180180
@inline Base.getindex(A::AbstractMatrix, kr::AbstractVector, jr::Block) = ArrayLayouts.layout_getindex(A, kr, jr)
181+
@inline Base.getindex(A::AbstractMatrix, kr::BlockRange{1}, jr::BlockRange{1}) = ArrayLayouts.layout_getindex(A, kr, jr)
182+
@inline Base.getindex(A::LayoutMatrix, kr::BlockRange{1}, jr::BlockRange{1}) = ArrayLayouts.layout_getindex(A, kr, jr)
183+
184+
###
185+
# permutedims
186+
#
187+
# just use transpose for now
188+
###
189+
190+
Base.permutedims(A::AbstractBlockVector{<:Number}) = transpose(A)
191+
Base.permutedims(A::AbstractBlockMatrix{<:Number}) = transpose(A)
192+
193+

0 commit comments

Comments
 (0)