@@ -67,13 +67,13 @@ struct BlockArray{T, N, R <: AbstractArray{<:AbstractArray{T,N},N}, BS<:NTuple{N
67
67
end
68
68
69
69
# Auxilary outer constructors
70
- @inline _BlockArray (blocks:: R , block_sizes:: Vararg{AbstractVector{Int }, N} ) where {T, N, R<: AbstractArray{<:AbstractArray{T,N},N} } =
70
+ @inline _BlockArray (blocks:: R , block_sizes:: Vararg{AbstractVector{<:Integer }, N} ) where {T, N, R<: AbstractArray{<:AbstractArray{T,N},N} } =
71
71
_BlockArray (blocks, map (blockedrange, block_sizes))
72
72
73
73
# support non-concrete eltypes in blocks
74
74
_BlockArray (blocks:: R , block_axes:: BS ) where {T, N, R<: AbstractArray{<:AbstractArray{V,N} where V,N} , BS<: NTuple{N,AbstractUnitRange{Int}} } =
75
75
_BlockArray (convert (AbstractArray{AbstractArray{mapreduce (eltype,promote_type,blocks),N},N}, blocks), block_axes)
76
- _BlockArray (blocks:: R , block_sizes:: Vararg{AbstractVector{Int }, N} ) where {T, N, R<: AbstractArray{<:AbstractArray{V,N} where V,N} } =
76
+ _BlockArray (blocks:: R , block_sizes:: Vararg{AbstractVector{<:Integer }, N} ) where {T, N, R<: AbstractArray{<:AbstractArray{V,N} where V,N} } =
77
77
_BlockArray (convert (AbstractArray{AbstractArray{mapreduce (eltype,promote_type,blocks),N},N}, blocks), block_sizes... )
78
78
79
79
const BlockMatrix{T, R <: AbstractMatrix{<:AbstractMatrix{T}} } = BlockArray{T, 2 , R}
@@ -84,7 +84,7 @@ const BlockVecOrMat{T, R} = Union{BlockMatrix{T, R}, BlockVector{T, R}}
84
84
# Constructors #
85
85
# ###############
86
86
87
- @inline _BlockArray (:: Type{R} , block_sizes:: Vararg{AbstractVector{Int }, N} ) where {T, N, R<: AbstractArray{<:AbstractArray{T,N},N} } =
87
+ @inline _BlockArray (:: Type{R} , block_sizes:: Vararg{AbstractVector{<:Integer }, N} ) where {T, N, R<: AbstractArray{<:AbstractArray{T,N},N} } =
88
88
_BlockArray (R, map (blockedrange,block_sizes))
89
89
90
90
function _BlockArray (:: Type{R} , baxes:: NTuple{N,AbstractUnitRange{Int}} ) where {T, N, R<: AbstractArray{<:AbstractArray{T,N},N} }
@@ -93,7 +93,7 @@ function _BlockArray(::Type{R}, baxes::NTuple{N,AbstractUnitRange{Int}}) where {
93
93
_BlockArray (blocks, baxes)
94
94
end
95
95
96
- @inline undef_blocks_BlockArray (:: Type{R} , block_sizes:: Vararg{AbstractVector{Int }, N} ) where {T, N, R<: AbstractArray{<:AbstractArray{T,N},N} } =
96
+ @inline undef_blocks_BlockArray (:: Type{R} , block_sizes:: Vararg{AbstractVector{<:Integer }, N} ) where {T, N, R<: AbstractArray{<:AbstractArray{T,N},N} } =
97
97
_BlockArray (R, block_sizes... )
98
98
99
99
"""
@@ -109,16 +109,16 @@ julia> BlockArray(undef_blocks, Matrix{Float64}, [1,3], [2,2])
109
109
#undef #undef │ #undef #undef
110
110
```
111
111
"""
112
- @inline BlockArray (:: UndefBlocksInitializer , :: Type{R} , block_sizes:: Vararg{AbstractVector{Int }, N} ) where {T, N, R<: AbstractArray{T,N} } =
112
+ @inline BlockArray (:: UndefBlocksInitializer , :: Type{R} , block_sizes:: Vararg{AbstractVector{<:Integer }, N} ) where {T, N, R<: AbstractArray{T,N} } =
113
113
undef_blocks_BlockArray (Array{R,N}, block_sizes... )
114
114
115
- @inline BlockArray {T} (:: UndefBlocksInitializer , block_sizes:: Vararg{AbstractVector{Int }, N} ) where {T, N} =
115
+ @inline BlockArray {T} (:: UndefBlocksInitializer , block_sizes:: Vararg{AbstractVector{<:Integer }, N} ) where {T, N} =
116
116
BlockArray (undef_blocks, Array{T,N}, block_sizes... )
117
117
118
- @inline BlockArray {T,N} (:: UndefBlocksInitializer , block_sizes:: Vararg{AbstractVector{Int }, N} ) where {T, N} =
118
+ @inline BlockArray {T,N} (:: UndefBlocksInitializer , block_sizes:: Vararg{AbstractVector{<:Integer }, N} ) where {T, N} =
119
119
BlockArray (undef_blocks, Array{T,N}, block_sizes... )
120
120
121
- @inline BlockArray {T,N,R} (:: UndefBlocksInitializer , block_sizes:: Vararg{AbstractVector{Int }, N} ) where {T, N, R<: AbstractArray{<:AbstractArray{T,N},N} } =
121
+ @inline BlockArray {T,N,R} (:: UndefBlocksInitializer , block_sizes:: Vararg{AbstractVector{<:Integer }, N} ) where {T, N, R<: AbstractArray{<:AbstractArray{T,N},N} } =
122
122
undef_blocks_BlockArray (R, block_sizes... )
123
123
124
124
@generated function initialized_blocks_BlockArray (:: Type{R} , baxes:: NTuple{N,AbstractUnitRange{Int}} ) where R<: AbstractArray{V,N} where {T,N,V<: AbstractArray{T,N} }
@@ -134,7 +134,7 @@ julia> BlockArray(undef_blocks, Matrix{Float64}, [1,3], [2,2])
134
134
end
135
135
136
136
137
- initialized_blocks_BlockArray (:: Type{R} , block_sizes:: Vararg{AbstractVector{Int }, N} ) where {T, N, R<: AbstractArray{<:AbstractArray{T,N},N} } =
137
+ initialized_blocks_BlockArray (:: Type{R} , block_sizes:: Vararg{AbstractVector{<:Integer }, N} ) where {T, N, R<: AbstractArray{<:AbstractArray{T,N},N} } =
138
138
initialized_blocks_BlockArray (R, map (blockedrange,block_sizes))
139
139
140
140
@inline BlockArray {T} (:: UndefInitializer , baxes:: NTuple{N,AbstractUnitRange{Int}} ) where {T, N} =
@@ -149,20 +149,20 @@ initialized_blocks_BlockArray(::Type{R}, block_sizes::Vararg{AbstractVector{Int}
149
149
@inline BlockArray {T,N,R,BS} (:: UndefInitializer , baxes:: BS ) where {T, N, R<: AbstractArray{<:AbstractArray{T,N},N} , BS<: NTuple{N,AbstractUnitRange{Int}} } =
150
150
initialized_blocks_BlockArray (R, baxes)
151
151
152
- @inline BlockArray {T} (:: UndefInitializer , block_sizes:: Vararg{AbstractVector{Int }, N} ) where {T, N} =
152
+ @inline BlockArray {T} (:: UndefInitializer , block_sizes:: Vararg{AbstractVector{<:Integer }, N} ) where {T, N} =
153
153
initialized_blocks_BlockArray (Array{Array{T,N},N}, block_sizes... )
154
154
155
- @inline BlockArray {T, N} (:: UndefInitializer , block_sizes:: Vararg{AbstractVector{Int }, N} ) where {T, N} =
155
+ @inline BlockArray {T, N} (:: UndefInitializer , block_sizes:: Vararg{AbstractVector{<:Integer }, N} ) where {T, N} =
156
156
initialized_blocks_BlockArray (Array{Array{T,N},N}, block_sizes... )
157
157
158
- @inline BlockArray {T, N, R} (:: UndefInitializer , block_sizes:: Vararg{AbstractVector{Int }, N} ) where {T, N, R<: AbstractArray{<:AbstractArray{T,N},N} } =
158
+ @inline BlockArray {T, N, R} (:: UndefInitializer , block_sizes:: Vararg{AbstractVector{<:Integer }, N} ) where {T, N, R<: AbstractArray{<:AbstractArray{T,N},N} } =
159
159
initialized_blocks_BlockArray (R, block_sizes... )
160
160
161
161
162
162
@inline BlockArray {T,N,R,BS} (:: UndefInitializer , sizes:: NTuple{N,Int} ) where {T, N, R<: AbstractArray{<:AbstractArray{T,N},N} , BS<: NTuple{N,AbstractUnitRange{Int}} } =
163
163
BlockArray {T,N,R,BS} (undef, convert (BS, map (Base. OneTo, sizes)))
164
164
165
- function BlockArray {T} (arr:: AbstractArray{V, N} , block_sizes:: Vararg{AbstractVector{Int }, N} ) where {T,V,N}
165
+ function BlockArray {T} (arr:: AbstractArray{V, N} , block_sizes:: Vararg{AbstractVector{<:Integer }, N} ) where {T,V,N}
166
166
for i in 1 : N
167
167
if sum (block_sizes[i]) != size (arr, i)
168
168
throw (DimensionMismatch (" block size for dimension $i : $(block_sizes[i]) does not sum to the array size: $(size (arr, i)) " ))
@@ -171,7 +171,7 @@ function BlockArray{T}(arr::AbstractArray{V, N}, block_sizes::Vararg{AbstractVec
171
171
BlockArray {T} (arr, map (blockedrange,block_sizes))
172
172
end
173
173
174
- BlockArray (arr:: AbstractArray{T, N} , block_sizes:: Vararg{AbstractVector{Int }, N} ) where {T,N} =
174
+ BlockArray (arr:: AbstractArray{T, N} , block_sizes:: Vararg{AbstractVector{<:Integer }, N} ) where {T,N} =
175
175
BlockArray {T} (arr, block_sizes... )
176
176
177
177
@generated function BlockArray {T} (arr:: AbstractArray{T, N} , baxes:: NTuple{N,AbstractUnitRange{Int}} ) where {T,N}
@@ -194,18 +194,18 @@ BlockArray(arr::AbstractArray{T, N}, baxes::NTuple{N,AbstractUnitRange{Int}}) wh
194
194
BlockArray {T} (arr, baxes)
195
195
196
196
BlockVector (blocks:: AbstractVector , baxes:: Tuple{AbstractUnitRange{Int}} ) = BlockArray (blocks, baxes)
197
- BlockVector (blocks:: AbstractVector , block_sizes:: AbstractVector{Int } ) = BlockArray (blocks, block_sizes)
197
+ BlockVector (blocks:: AbstractVector , block_sizes:: AbstractVector{<:Integer } ) = BlockArray (blocks, block_sizes)
198
198
BlockMatrix (blocks:: AbstractMatrix , baxes:: NTuple{2,AbstractUnitRange{Int}} ) = BlockArray (blocks, baxes)
199
- BlockMatrix (blocks:: AbstractMatrix , block_sizes:: Vararg{AbstractVector{Int },2} ) = BlockArray (blocks, block_sizes... )
199
+ BlockMatrix (blocks:: AbstractMatrix , block_sizes:: Vararg{AbstractVector{<:Integer },2} ) = BlockArray (blocks, block_sizes... )
200
200
201
201
BlockArray {T} (λ:: UniformScaling , baxes:: NTuple{2,AbstractUnitRange{Int}} ) where T = BlockArray {T} (Matrix (λ, map (length,baxes)... ), baxes)
202
- BlockArray {T} (λ:: UniformScaling , block_sizes:: Vararg{AbstractVector{Int }, 2} ) where T = BlockArray {T} (λ, map (blockedrange,block_sizes))
203
- BlockArray (λ:: UniformScaling{T} , block_sizes:: Vararg{AbstractVector{Int }, 2} ) where T = BlockArray {T} (λ, block_sizes... )
202
+ BlockArray {T} (λ:: UniformScaling , block_sizes:: Vararg{AbstractVector{<:Integer }, 2} ) where T = BlockArray {T} (λ, map (blockedrange,block_sizes))
203
+ BlockArray (λ:: UniformScaling{T} , block_sizes:: Vararg{AbstractVector{<:Integer }, 2} ) where T = BlockArray {T} (λ, block_sizes... )
204
204
BlockArray (λ:: UniformScaling{T} , baxes:: NTuple{2,AbstractUnitRange{Int}} ) where T = BlockArray {T} (λ, baxes)
205
205
BlockMatrix (λ:: UniformScaling , baxes:: NTuple{2,AbstractUnitRange{Int}} ) = BlockArray (λ, baxes)
206
- BlockMatrix (λ:: UniformScaling , block_sizes:: Vararg{AbstractVector{Int },2} ) = BlockArray (λ, block_sizes... )
206
+ BlockMatrix (λ:: UniformScaling , block_sizes:: Vararg{AbstractVector{<:Integer },2} ) = BlockArray (λ, block_sizes... )
207
207
BlockMatrix {T} (λ:: UniformScaling , baxes:: NTuple{2,AbstractUnitRange{Int}} ) where T = BlockArray {T} (λ, baxes)
208
- BlockMatrix {T} (λ:: UniformScaling , block_sizes:: Vararg{AbstractVector{Int },2} ) where T = BlockArray {T} (λ, block_sizes... )
208
+ BlockMatrix {T} (λ:: UniformScaling , block_sizes:: Vararg{AbstractVector{<:Integer },2} ) where T = BlockArray {T} (λ, block_sizes... )
209
209
210
210
"""
211
211
mortar(blocks::AbstractArray)
244
244
mortar (blocks:: AbstractArray{R, N} , baxes:: NTuple{N,AbstractUnitRange{Int}} ) where {R, N} =
245
245
_BlockArray (blocks, baxes)
246
246
247
- mortar (blocks:: AbstractArray{R, N} , block_sizes:: Vararg{AbstractVector{Int }, N} ) where {R, N} =
247
+ mortar (blocks:: AbstractArray{R, N} , block_sizes:: Vararg{AbstractVector{<:Integer }, N} ) where {R, N} =
248
248
_BlockArray (blocks, block_sizes... )
249
249
250
250
mortar (blocks:: AbstractArray ) = mortar (blocks, sizes_from_blocks (blocks)... )
0 commit comments