@@ -11,11 +11,13 @@ using Dictionaries: Dictionary
11
11
using SparseArraysBase: SparseArrayDOK
12
12
13
13
"""
14
- SparseArrayDOK{T}(::UndefBlocksInitializer , axes)
15
- SparseArrayDOK{T,N}(::UndefBlocksInitializer , axes)
14
+ SparseArrayDOK{T}(undef_blocks , axes)
15
+ SparseArrayDOK{T,N}(undef_blocks , axes)
16
16
17
17
Construct the block structure of an undefined BlockSparseArray that will have
18
18
blocked axes `axes`.
19
+
20
+ See also: [`undef_blocks`](@ref BlockArrays.undef_blocks)`
19
21
"""
20
22
function SparseArraysBase. SparseArrayDOK {T,N} (
21
23
:: UndefBlocksInitializer , ax:: Tuple{Vararg{AbstractUnitRange{<:Integer},N}}
@@ -28,14 +30,17 @@ function SparseArraysBase.SparseArrayDOK{T,N}(
28
30
return SparseArrayDOK {T,N} (undef_blocks, ax)
29
31
end
30
32
function SparseArraysBase. SparseArrayDOK {T,N} (
31
- :: UndefBlocksInitializer , dims:: Tuple{Vararg{AbstractVector{<:Integer},N}}
33
+ :: UndefBlocksInitializer ,
34
+ dims:: Tuple{AbstractVector{<:Integer},Vararg{AbstractVector{<:Integer}}} ,
32
35
) where {T,N}
33
36
return SparseArrayDOK {T,N} (undef_blocks, blockedrange .(dims))
34
37
end
35
38
function SparseArraysBase. SparseArrayDOK {T,N} (
36
- :: UndefBlocksInitializer , dims:: Vararg{AbstractVector{<:Integer},N}
39
+ :: UndefBlocksInitializer ,
40
+ dim1:: AbstractVector{<:Integer} ,
41
+ dim_rest:: AbstractVector{<:Integer} ...,
37
42
) where {T,N}
38
- return SparseArrayDOK {T,N} (undef_blocks, blockedrange .(dims ))
43
+ return SparseArrayDOK {T,N} (undef_blocks, (dim1, dim_rest ... ))
39
44
end
40
45
41
46
function SparseArraysBase. SparseArrayDOK {T} (
@@ -49,14 +54,17 @@ function SparseArraysBase.SparseArrayDOK{T}(
49
54
return SparseArrayDOK {T,N} (undef_blocks, ax)
50
55
end
51
56
function 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))
55
61
end
56
62
function 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... ))
60
68
end
61
69
62
70
function _BlockSparseArray end
@@ -110,14 +118,16 @@ function sparsemortar(
110
118
end
111
119
function sparsemortar (
112
120
blocks:: AbstractArray{<:AbstractArray{T,N},N} ,
113
- dims:: Tuple{Vararg{AbstractVector{<:Integer},N }} ,
121
+ dims:: Tuple{AbstractVector{<:Integer}, Vararg{AbstractVector{<:Integer}}} ,
114
122
) where {T,N}
115
123
return sparsemortar (blocks, blockedrange .(dims))
116
124
end
117
125
function 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} ...,
119
129
) where {T,N}
120
- return sparsemortar (blocks, dims )
130
+ return sparsemortar (blocks, (dim1, dim_rest ... ) )
121
131
end
122
132
123
133
@doc """
@@ -142,22 +152,18 @@ function BlockSparseArray{T,N,A}(
142
152
end
143
153
144
154
function BlockSparseArray {T,N,A} (
145
- :: UndefInitializer , dims:: Tuple{Vararg{AbstractVector{<:Integer},N}}
155
+ :: UndefInitializer ,
156
+ dims:: Tuple{AbstractVector{<:Integer},Vararg{AbstractVector{<:Integer}}} ,
146
157
) where {T,N,A<: AbstractArray{T,N} }
147
158
return BlockSparseArray {T,N,A} (undef, blockedrange .(dims))
148
159
end
149
160
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
-
157
161
function BlockSparseArray {T,N,A} (
158
- :: UndefInitializer , dims:: Vararg{AbstractVector{<:Integer},N}
162
+ :: UndefInitializer ,
163
+ dim1:: AbstractVector{<:Integer} ,
164
+ dim_rest:: AbstractVector{<:Integer} ...,
159
165
) 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 ... ) )
161
167
end
162
168
163
169
function BlockSparseArray {T,N} (
@@ -172,24 +178,24 @@ function BlockSparseArray{T,N}(
172
178
return BlockSparseArray {T,N} (undef, axes)
173
179
end
174
180
175
- function BlockSparseArray {T,0} (:: UndefInitializer , axes:: Tuple{} ) where {T}
176
- return BlockSparseArray {T,0,Array{T,0}} (undef, axes)
177
- end
178
-
179
181
function BlockSparseArray {T,N} (
180
- :: UndefInitializer , dims:: Tuple{Vararg{AbstractVector{<:Integer},N}}
182
+ :: UndefInitializer ,
183
+ dims:: Tuple{AbstractVector{<:Integer},Vararg{AbstractVector{<:Integer}}} ,
181
184
) where {T,N}
182
185
return BlockSparseArray {T,N} (undef, blockedrange .(dims))
183
186
end
184
187
185
188
function BlockSparseArray {T,N} (
186
- :: UndefInitializer , dims:: Vararg{AbstractVector{<:Integer},N}
189
+ :: UndefInitializer ,
190
+ dim1:: AbstractVector{<:Integer} ,
191
+ dim_rest:: AbstractVector{<:Integer} ...,
187
192
) where {T,N}
188
- return BlockSparseArray {T,N} (undef, dims )
193
+ return BlockSparseArray {T,N} (undef, (dim1, dim_rest ... ) )
189
194
end
190
195
191
196
function BlockSparseArray {T} (
192
- :: UndefInitializer , dims:: Tuple{Vararg{AbstractVector{<:Integer}}}
197
+ :: UndefInitializer ,
198
+ dims:: Tuple{AbstractVector{<:Integer},Vararg{AbstractVector{<:Integer}}} ,
193
199
) where {T}
194
200
return BlockSparseArray {T,length(dims)} (undef, dims)
195
201
end
@@ -200,14 +206,12 @@ function BlockSparseArray{T}(
200
206
return BlockSparseArray {T,length(axes)} (undef, axes)
201
207
end
202
208
203
- function BlockSparseArray {T} (:: UndefInitializer , axes:: Tuple{} ) where {T}
204
- return BlockSparseArray {T,length(axes)} (undef, axes)
205
- end
206
-
207
209
function BlockSparseArray {T} (
208
- :: UndefInitializer , dims:: Vararg{AbstractVector{<:Integer}}
210
+ :: UndefInitializer ,
211
+ dim1:: AbstractVector{<:Integer} ,
212
+ dim_rest:: AbstractVector{<:Integer} ...,
209
213
) where {T}
210
- return BlockSparseArray {T} (undef, dims )
214
+ return BlockSparseArray {T} (undef, (dim1, dim_rest ... ) )
211
215
end
212
216
213
217
function BlockSparseArray {T} (
@@ -216,10 +220,6 @@ function BlockSparseArray{T}(
216
220
return BlockSparseArray {T} (undef, axes)
217
221
end
218
222
219
- function BlockSparseArray {T} (:: UndefInitializer ) where {T}
220
- return BlockSparseArray {T} (undef, ())
221
- end
222
-
223
223
# Base `AbstractArray` interface
224
224
Base. axes (a:: BlockSparseArray ) = a. axes
225
225
0 commit comments