@@ -3,9 +3,6 @@ using DerivableInterfaces: @interface
3
3
using Dictionaries: Dictionary
4
4
using SparseArraysBase: SparseArrayDOK
5
5
6
- # TODO : Delete this.
7
- # # using BlockArrays: blocks
8
-
9
6
struct BlockSparseArray{
10
7
T,
11
8
N,
@@ -27,40 +24,48 @@ const BlockSparseVector{T,A<:AbstractVector{T},Blocks<:AbstractVector{A},Axes<:T
27
24
T,1 ,A,Blocks,Axes
28
25
}
29
26
27
+ # TODO : Rename to `sparsemortar`.
30
28
function BlockSparseArray (
31
29
block_data:: Dictionary{<:Block{N},<:AbstractArray{<:Any,N}} ,
32
30
axes:: Tuple{Vararg{AbstractUnitRange,N}} ,
33
31
) where {N}
34
32
blocks = default_blocks (block_data, axes)
33
+ # TODO : Rename to `sparsemortar`.
35
34
return BlockSparseArray (blocks, axes)
36
35
end
37
36
37
+ # TODO : Rename to `sparsemortar`.
38
38
function BlockSparseArray (
39
39
block_indices:: Vector{<:Block{N}} ,
40
40
block_data:: Vector{<:AbstractArray{<:Any,N}} ,
41
41
axes:: Tuple{Vararg{AbstractUnitRange,N}} ,
42
42
) where {N}
43
+ # TODO : Rename to `sparsemortar`.
43
44
return BlockSparseArray (Dictionary (block_indices, block_data), axes)
44
45
end
45
46
47
+ # TODO : Rename to `sparsemortar`.
46
48
function BlockSparseArray {T,N,A,Blocks} (
47
49
blocks:: AbstractArray{<:AbstractArray{T,N},N} , axes:: Tuple{Vararg{AbstractUnitRange,N}}
48
50
) where {T,N,A<: AbstractArray{T,N} ,Blocks<: AbstractArray{A,N} }
49
51
return BlockSparseArray {T,N,A,Blocks,typeof(axes)} (blocks, axes)
50
52
end
51
53
54
+ # TODO : Rename to `sparsemortar`.
52
55
function BlockSparseArray {T,N,A} (
53
56
blocks:: AbstractArray{<:AbstractArray{T,N},N} , axes:: Tuple{Vararg{AbstractUnitRange,N}}
54
57
) where {T,N,A<: AbstractArray{T,N} }
55
58
return BlockSparseArray {T,N,A,typeof(blocks)} (blocks, axes)
56
59
end
57
60
61
+ # TODO : Rename to `sparsemortar`.
58
62
function BlockSparseArray {T,N} (
59
63
blocks:: AbstractArray{<:AbstractArray{T,N},N} , axes:: Tuple{Vararg{AbstractUnitRange,N}}
60
64
) where {T,N}
61
65
return BlockSparseArray {T,N,eltype(blocks),typeof(blocks),typeof(axes)} (blocks, axes)
62
66
end
63
67
68
+ # TODO : Rename to `sparsemortar`.
64
69
function BlockSparseArray {T,N} (
65
70
block_data:: Dictionary{Block{N,Int},<:AbstractArray{T,N}} ,
66
71
axes:: Tuple{Vararg{AbstractUnitRange,N}} ,
@@ -70,99 +75,88 @@ function BlockSparseArray{T,N}(
70
75
end
71
76
72
77
function BlockSparseArray {T,N,A} (
73
- axes:: Tuple{Vararg{AbstractUnitRange,N}}
78
+ :: UndefInitializer , axes:: Tuple{Vararg{AbstractUnitRange,N}}
74
79
) where {T,N,A<: AbstractArray{T,N} }
75
80
blocks = default_blocks (A, axes)
76
81
return BlockSparseArray {T,N,A} (blocks, axes)
77
82
end
78
83
79
84
function BlockSparseArray {T,N,A} (
80
- axes:: Vararg{AbstractUnitRange,N}
85
+ :: UndefInitializer , axes:: Vararg{AbstractUnitRange,N}
81
86
) where {T,N,A<: AbstractArray{T,N} }
82
- return BlockSparseArray {T,N,A} (axes)
87
+ return BlockSparseArray {T,N,A} (undef, axes)
83
88
end
84
89
85
90
function BlockSparseArray {T,N,A} (
86
- dims:: Tuple{Vararg{Vector{Int},N}}
91
+ :: UndefInitializer , dims:: Tuple{Vararg{Vector{Int},N}}
87
92
) where {T,N,A<: AbstractArray{T,N} }
88
- return BlockSparseArray {T,N,A} (blockedrange .(dims))
93
+ return BlockSparseArray {T,N,A} (undef, blockedrange .(dims))
89
94
end
90
95
91
96
# Fix ambiguity error.
92
- function BlockSparseArray {T,0,A} (axes:: Tuple{} ) where {T,A<: AbstractArray{T,0} }
97
+ function BlockSparseArray {T,0,A} (
98
+ :: UndefInitializer , axes:: Tuple{}
99
+ ) where {T,A<: AbstractArray{T,0} }
93
100
blocks = default_blocks (A, axes)
94
101
return BlockSparseArray {T,0,A} (blocks, axes)
95
102
end
96
103
97
104
function BlockSparseArray {T,N,A} (
98
- dims:: Vararg{Vector{Int},N}
105
+ :: UndefInitializer , dims:: Vararg{Vector{Int},N}
99
106
) where {T,N,A<: AbstractArray{T,N} }
100
- return BlockSparseArray {T,N,A} (dims)
101
- end
102
-
103
- function BlockSparseArray {T,N} (axes:: Tuple{Vararg{AbstractUnitRange,N}} ) where {T,N}
104
- return BlockSparseArray {T,N,default_arraytype(T, axes)} (axes)
105
- end
106
-
107
- function BlockSparseArray {T,N} (axes:: Vararg{AbstractUnitRange,N} ) where {T,N}
108
- return BlockSparseArray {T,N} (axes)
107
+ return BlockSparseArray {T,N,A} (undef, dims)
109
108
end
110
109
111
- function BlockSparseArray {T,0} (axes:: Tuple{} ) where {T}
112
- return BlockSparseArray {T,0,default_arraytype(T, axes)} (axes)
113
- end
114
-
115
- function BlockSparseArray {T,N} (dims:: Tuple{Vararg{Vector{Int},N}} ) where {T,N}
116
- return BlockSparseArray {T,N} (blockedrange .(dims))
117
- end
118
-
119
- function BlockSparseArray {T,N} (dims:: Vararg{Vector{Int},N} ) where {T,N}
120
- return BlockSparseArray {T,N} (dims)
110
+ function BlockSparseArray {T,N} (
111
+ :: UndefInitializer , axes:: Tuple{Vararg{AbstractUnitRange,N}}
112
+ ) where {T,N}
113
+ return BlockSparseArray {T,N,default_arraytype(T, axes)} (undef, axes)
121
114
end
122
115
123
- function BlockSparseArray {T} (dims:: Tuple{Vararg{Vector{Int}}} ) where {T}
124
- return BlockSparseArray {T,length(dims)} (dims)
116
+ function BlockSparseArray {T,N} (
117
+ :: UndefInitializer , axes:: Vararg{AbstractUnitRange,N}
118
+ ) where {T,N}
119
+ return BlockSparseArray {T,N} (undef, axes)
125
120
end
126
121
127
- function BlockSparseArray {T} ( axes:: Tuple{Vararg{AbstractUnitRange} } ) where {T}
128
- return BlockSparseArray {T,length( axes)} (axes)
122
+ function BlockSparseArray {T,0} ( :: UndefInitializer , axes:: Tuple{} ) where {T}
123
+ return BlockSparseArray {T,0,default_arraytype(T, axes)} (undef, axes)
129
124
end
130
125
131
- function BlockSparseArray {T} (axes:: Tuple{} ) where {T}
132
- return BlockSparseArray {T,length(axes)} (axes)
126
+ function BlockSparseArray {T,N} (
127
+ :: UndefInitializer , dims:: Tuple{Vararg{Vector{Int},N}}
128
+ ) where {T,N}
129
+ return BlockSparseArray {T,N} (undef, blockedrange .(dims))
133
130
end
134
131
135
- function BlockSparseArray {T} ( dims:: Vararg{Vector{Int}} ) where {T}
136
- return BlockSparseArray {T} ( dims)
132
+ function BlockSparseArray {T,N} ( :: UndefInitializer , dims:: Vararg{Vector{Int},N } ) where {T,N }
133
+ return BlockSparseArray {T,N} (undef, dims)
137
134
end
138
135
139
- function BlockSparseArray {T} (axes :: Vararg{AbstractUnitRange } ) where {T}
140
- return BlockSparseArray {T} (axes )
136
+ function BlockSparseArray {T} (:: UndefInitializer , dims :: Tuple{ Vararg{Vector{Int}} } ) where {T}
137
+ return BlockSparseArray {T,length(dims)} (undef, dims )
141
138
end
142
139
143
- function BlockSparseArray {T} () where {T}
144
- return BlockSparseArray {T} (())
140
+ function BlockSparseArray {T} (
141
+ :: UndefInitializer , axes:: Tuple{Vararg{AbstractUnitRange}}
142
+ ) where {T}
143
+ return BlockSparseArray {T,length(axes)} (undef, axes)
145
144
end
146
145
147
- # undef
148
- function BlockSparseArray {T,N,A,Blocks} (
149
- :: UndefInitializer , args...
150
- ) where {T,N,A<: AbstractArray{T,N} ,Blocks<: AbstractArray{A,N} }
151
- return BlockSparseArray {T,N,A,Blocks} (args... )
146
+ function BlockSparseArray {T} (:: UndefInitializer , axes:: Tuple{} ) where {T}
147
+ return BlockSparseArray {T,length(axes)} (undef, axes)
152
148
end
153
149
154
- function BlockSparseArray {T,N,A} (
155
- :: UndefInitializer , args...
156
- ) where {T,N,A<: AbstractArray{T,N} }
157
- return BlockSparseArray {T,N,A} (args... )
150
+ function BlockSparseArray {T} (:: UndefInitializer , dims:: Vararg{Vector{Int}} ) where {T}
151
+ return BlockSparseArray {T} (undef, dims)
158
152
end
159
153
160
- function BlockSparseArray {T,N } (:: UndefInitializer , args ... ) where {T,N }
161
- return BlockSparseArray {T,N} (args ... )
154
+ function BlockSparseArray {T} (:: UndefInitializer , axes :: Vararg{AbstractUnitRange} ) where {T}
155
+ return BlockSparseArray {T} (undef, axes )
162
156
end
163
157
164
- function BlockSparseArray {T} (:: UndefInitializer , args ... ) where {T}
165
- return BlockSparseArray {T} (args ... )
158
+ function BlockSparseArray {T} (:: UndefInitializer ) where {T}
159
+ return BlockSparseArray {T} (undef, () )
166
160
end
167
161
168
162
# Base `AbstractArray` interface
0 commit comments