@@ -73,7 +73,7 @@ mul!(ones(3,3), A, reshape(collect(1:9), 3, 3), 2, 2)
73
73
using BenchmarkTools
74
74
75
75
@benchmark mul! ($ (zeros (3 )), $ A, $ x)
76
-
76
+
77
77
# -
78
78
79
79
@benchmark mul! ($ (zeros (3 )), $ A, $ x, $ (rand ()), $ (rand ()))
@@ -241,6 +241,9 @@ mul!(similar(x)', x', A)
241
241
F = MyFillMap (5 , (100 ,100 ))
242
242
M = Matrix {eltype(F)} (undef, size (F))
243
243
@benchmark Matrix ($ F)
244
+
245
+ # -
246
+
244
247
@benchmark LinearMaps. _unsafe_mul! ($ (Matrix {Int} (undef, (100 ,100 ))), $ (MyFillMap (5 , (100 ,100 ))), true )
245
248
246
249
# If a more performant implementation exists, it is recommended to overwrite this method,
@@ -249,6 +252,9 @@ M = Matrix{eltype(F)}(undef, size(F))
249
252
250
253
LinearMaps. _unsafe_mul! (M:: AbstractMatrix , A:: MyFillMap , s:: Number ) = fill! (M, A. λ* s)
251
254
@benchmark Matrix ($ F)
255
+
256
+ # -
257
+
252
258
@benchmark LinearMaps. _unsafe_mul! ($ (Matrix {Int} (undef, (100 ,100 ))), $ (MyFillMap (5 , (100 ,100 ))), true )
253
259
254
260
# As one can see, the above runtimes are dominated by the allocation of the output matrix,
@@ -259,16 +265,18 @@ LinearMaps._unsafe_mul!(M::AbstractMatrix, A::MyFillMap, s::Number) = fill!(M, A
259
265
260
266
# As usual, generic fallbacks for `LinearMap` slicing exist and are handled by the following
261
267
# method hierarchy, where at least one of `I` and `J` has to be a `Colon`:
262
- #
268
+ #
263
269
# Base.getindex(::LinearMap, I, J)
264
270
# -> LinearMaps._getindex(::LinearMap, I, J)
265
- #
271
+ #
266
272
# The method `Base.getindex` checks the validity of the the requested indices and calls
267
273
# `LinearMaps._getindex`, which should be overloaded for custom `LinearMap`s subtypes.
268
274
# For instance:
269
275
270
276
@benchmark F[1 ,:]
271
277
278
+ # -
279
+
272
280
LinearMaps. _getindex (A:: MyFillMap , :: Integer , J:: Base.Slice ) = fill (A. λ, axes (J))
273
281
@benchmark F[1 ,:]
274
282
0 commit comments