@@ -18,6 +18,13 @@ ismutable(x) = ismutable(typeof(x))
18
18
ismutable (:: Type{<:Array} ) = true
19
19
ismutable (:: Type{<:Number} ) = false
20
20
21
+ # Piracy
22
+ function Base. setindex (x:: Array ,v,i:: Int )
23
+ _x = copy (x)
24
+ _x[i] = v
25
+ _x
26
+ end
27
+
21
28
"""
22
29
can_setindex(x::DataType)
23
30
@@ -34,6 +41,20 @@ Query whether an array type has fast scalar indexing
34
41
fast_scalar_indexing (x) = true
35
42
fast_scalar_indexing (x:: AbstractArray ) = fast_scalar_indexing (typeof (x))
36
43
44
+ """
45
+ allowed_getindex(x,i...)
46
+
47
+ A scalar getindex which is always allowed
48
+ """
49
+ allowed_getindex (x,i... ) = x[i... ]
50
+
51
+ """
52
+ allowed_setindex!(x,v,i...)
53
+
54
+ A scalar setindex! which is always allowed
55
+ """
56
+ allowed_setindex! (x,v,i... ) = setindex! (x,v,i... )
57
+
37
58
"""
38
59
isstructured(x::DataType)
39
60
@@ -193,12 +214,20 @@ function __init__()
193
214
194
215
@require CuArrays= " 3a865a2d-5b23-5a0f-bc46-62713ec82fae" begin
195
216
fast_scalar_indexing (:: Type{<:CuArrays.CuArray} ) = false
217
+ @inline allowed_getindex (x:: CuArrays.CuArray ,i... ) = CuArrays. _getindex (x,i... )
218
+ @inline allowed_setindex! (x:: CuArrays.CuArray ,v,i... ) = CuArrays. _setindex! (x,v,i... )
219
+
220
+ function Base. setindex (x:: CuArrays.CuArray ,v,i:: Int )
221
+ _x = copy (x)
222
+ allowed_setindex! (_x,v,i)
223
+ _x
224
+ end
196
225
end
197
226
198
227
@require BandedMatrices= " aae01518-5342-5314-be14-df237901396f" begin
199
228
is_structured (:: Type{<:BandedMatrices.BandedMatrix} ) = true
200
229
fast_matrix_colors (:: Type{<:BandedMatrices.BandedMatrix} ) = true
201
-
230
+
202
231
function matrix_colors (A:: BandedMatrices.BandedMatrix )
203
232
u,l= bandwidths (A)
204
233
width= u+ l+ 1
0 commit comments