@@ -11,11 +11,13 @@ using Dictionaries: Dictionary
1111using SparseArraysBase: SparseArrayDOK
1212
1313"""
14- SparseArrayDOK{T}(::UndefBlocksInitializer , axes)
15- SparseArrayDOK{T,N}(::UndefBlocksInitializer , axes)
14+ SparseArrayDOK{T}(undef_blocks , axes)
15+ SparseArrayDOK{T,N}(undef_blocks , axes)
1616
1717Construct the block structure of an undefined BlockSparseArray that will have
1818blocked axes `axes`.
19+
20+ See also: [`undef_blocks`](@ref BlockArrays.undef_blocks)`
1921"""
2022function SparseArraysBase. SparseArrayDOK {T,N} (
2123 :: UndefBlocksInitializer , ax:: Tuple{Vararg{AbstractUnitRange{<:Integer},N}}
@@ -28,14 +30,17 @@ function SparseArraysBase.SparseArrayDOK{T,N}(
2830 return SparseArrayDOK {T,N} (undef_blocks, ax)
2931end
3032function SparseArraysBase. SparseArrayDOK {T,N} (
31- :: UndefBlocksInitializer , dims:: Tuple{Vararg{AbstractVector{<:Integer},N}}
33+ :: UndefBlocksInitializer ,
34+ dims:: Tuple{AbstractVector{<:Integer},Vararg{AbstractVector{<:Integer}}} ,
3235) where {T,N}
3336 return SparseArrayDOK {T,N} (undef_blocks, blockedrange .(dims))
3437end
3538function SparseArraysBase. SparseArrayDOK {T,N} (
36- :: UndefBlocksInitializer , dims:: Vararg{AbstractVector{<:Integer},N}
39+ :: UndefBlocksInitializer ,
40+ dim1:: AbstractVector{<:Integer} ,
41+ dim_rest:: AbstractVector{<:Integer} ...,
3742) where {T,N}
38- return SparseArrayDOK {T,N} (undef_blocks, blockedrange .(dims ))
43+ return SparseArrayDOK {T,N} (undef_blocks, (dim1, dim_rest ... ))
3944end
4045
4146function SparseArraysBase. SparseArrayDOK {T} (
@@ -49,14 +54,17 @@ function SparseArraysBase.SparseArrayDOK{T}(
4954 return SparseArrayDOK {T,N} (undef_blocks, ax)
5055end
5156function SparseArraysBase. SparseArrayDOK {T} (
52- :: UndefBlocksInitializer , dims:: Tuple{Vararg{AbstractVector{<:Integer},N}}
53- ) where {T,N}
54- return SparseArrayDOK {T,N} (undef_blocks, blockedrange .(dims))
57+ :: UndefBlocksInitializer ,
58+ dims:: Tuple{AbstractVector{<:Integer},Vararg{AbstractVector{<:Integer}}} ,
59+ ) where {T}
60+ return SparseArrayDOK {T} (undef_blocks, blockedrange .(dims))
5561end
5662function SparseArraysBase. SparseArrayDOK {T} (
57- :: UndefBlocksInitializer , dims:: Vararg{AbstractVector{<:Integer},N}
58- ) where {T,N}
59- return SparseArrayDOK {T,N} (undef_blocks, blockedrange .(dims))
63+ :: UndefBlocksInitializer ,
64+ dim1:: AbstractVector{<:Integer} ,
65+ dim_rest:: AbstractVector{<:Integer} ...,
66+ ) where {T}
67+ return SparseArrayDOK {T} (undef_blocks, (dim1, dim_rest... ))
6068end
6169
6270function _BlockSparseArray end
@@ -110,14 +118,16 @@ function sparsemortar(
110118end
111119function sparsemortar (
112120 blocks:: AbstractArray{<:AbstractArray{T,N},N} ,
113- dims:: Tuple{Vararg{AbstractVector{<:Integer},N }} ,
121+ dims:: Tuple{AbstractVector{<:Integer}, Vararg{AbstractVector{<:Integer}}} ,
114122) where {T,N}
115123 return sparsemortar (blocks, blockedrange .(dims))
116124end
117125function sparsemortar (
118- blocks:: AbstractArray{<:AbstractArray{T,N},N} , dims:: Vararg{AbstractVector{<:Integer},N}
126+ blocks:: AbstractArray{<:AbstractArray{T,N},N} ,
127+ dim1:: AbstractVector{<:Integer} ,
128+ dim_rest:: AbstractVector{<:Integer} ...,
119129) where {T,N}
120- return sparsemortar (blocks, dims )
130+ return sparsemortar (blocks, (dim1, dim_rest ... ) )
121131end
122132
123133@doc """
@@ -142,22 +152,18 @@ function BlockSparseArray{T,N,A}(
142152end
143153
144154function BlockSparseArray {T,N,A} (
145- :: UndefInitializer , dims:: Tuple{Vararg{AbstractVector{<:Integer},N}}
155+ :: UndefInitializer ,
156+ dims:: Tuple{AbstractVector{<:Integer},Vararg{AbstractVector{<:Integer}}} ,
146157) where {T,N,A<: AbstractArray{T,N} }
147158 return BlockSparseArray {T,N,A} (undef, blockedrange .(dims))
148159end
149160
150- # Fix ambiguity error.
151- function BlockSparseArray {T,0,A} (
152- :: UndefInitializer , axes:: Tuple{}
153- ) where {T,A<: AbstractArray{T,0} }
154- return _BlockSparseArray (SparseArrayDOK {A} (undef_blocks, axes), axes)
155- end
156-
157161function BlockSparseArray {T,N,A} (
158- :: UndefInitializer , dims:: Vararg{AbstractVector{<:Integer},N}
162+ :: UndefInitializer ,
163+ dim1:: AbstractVector{<:Integer} ,
164+ dim_rest:: AbstractVector{<:Integer} ...,
159165) where {T,N,A<: AbstractArray{T,N} }
160- return BlockSparseArray {T,N,A} (undef, dims )
166+ return BlockSparseArray {T,N,A} (undef, (dim1, dim_rest ... ) )
161167end
162168
163169function BlockSparseArray {T,N} (
@@ -172,24 +178,24 @@ function BlockSparseArray{T,N}(
172178 return BlockSparseArray {T,N} (undef, axes)
173179end
174180
175- function BlockSparseArray {T,0} (:: UndefInitializer , axes:: Tuple{} ) where {T}
176- return BlockSparseArray {T,0,Array{T,0}} (undef, axes)
177- end
178-
179181function BlockSparseArray {T,N} (
180- :: UndefInitializer , dims:: Tuple{Vararg{AbstractVector{<:Integer},N}}
182+ :: UndefInitializer ,
183+ dims:: Tuple{AbstractVector{<:Integer},Vararg{AbstractVector{<:Integer}}} ,
181184) where {T,N}
182185 return BlockSparseArray {T,N} (undef, blockedrange .(dims))
183186end
184187
185188function BlockSparseArray {T,N} (
186- :: UndefInitializer , dims:: Vararg{AbstractVector{<:Integer},N}
189+ :: UndefInitializer ,
190+ dim1:: AbstractVector{<:Integer} ,
191+ dim_rest:: AbstractVector{<:Integer} ...,
187192) where {T,N}
188- return BlockSparseArray {T,N} (undef, dims )
193+ return BlockSparseArray {T,N} (undef, (dim1, dim_rest ... ) )
189194end
190195
191196function BlockSparseArray {T} (
192- :: UndefInitializer , dims:: Tuple{Vararg{AbstractVector{<:Integer}}}
197+ :: UndefInitializer ,
198+ dims:: Tuple{AbstractVector{<:Integer},Vararg{AbstractVector{<:Integer}}} ,
193199) where {T}
194200 return BlockSparseArray {T,length(dims)} (undef, dims)
195201end
@@ -200,14 +206,12 @@ function BlockSparseArray{T}(
200206 return BlockSparseArray {T,length(axes)} (undef, axes)
201207end
202208
203- function BlockSparseArray {T} (:: UndefInitializer , axes:: Tuple{} ) where {T}
204- return BlockSparseArray {T,length(axes)} (undef, axes)
205- end
206-
207209function BlockSparseArray {T} (
208- :: UndefInitializer , dims:: Vararg{AbstractVector{<:Integer}}
210+ :: UndefInitializer ,
211+ dim1:: AbstractVector{<:Integer} ,
212+ dim_rest:: AbstractVector{<:Integer} ...,
209213) where {T}
210- return BlockSparseArray {T} (undef, dims )
214+ return BlockSparseArray {T} (undef, (dim1, dim_rest ... ) )
211215end
212216
213217function BlockSparseArray {T} (
@@ -216,10 +220,6 @@ function BlockSparseArray{T}(
216220 return BlockSparseArray {T} (undef, axes)
217221end
218222
219- function BlockSparseArray {T} (:: UndefInitializer ) where {T}
220- return BlockSparseArray {T} (undef, ())
221- end
222-
223223# Base `AbstractArray` interface
224224Base. axes (a:: BlockSparseArray ) = a. axes
225225
0 commit comments