@@ -18,27 +18,27 @@ allow anyone to make use of mutability when desired.
1818
1919The package allows a given type to declare itself mutable through the
2020` MA.mutability ` trait.
21- Then the user can use the ` MA.operate! ` function to write generic code
21+ Then the user can use the ` MA.operate!! ` function to write generic code
2222that works for arbitrary type while exploiting mutability of the type
2323if possible. More precisely:
2424
25- * The ` MA.operate!(op::Function, x, args...) ` redirects to ` op(x, args...) `
25+ * The ` MA.operate!! (op::Function, x, args...) ` redirects to ` op(x, args...) `
2626 if ` x ` is not mutable or if the result of the operation cannot be stored in ` x ` .
27- Otherwise, it redirects to ` MA.mutable_operate !(op, x, args...) ` .
28- * ` MA.mutable_operate !(op::Function, x, args...) ` stores the result of the
27+ Otherwise, it redirects to ` MA.operate !(op, x, args...) ` .
28+ * ` MA.operate !(op::Function, x, args...) ` stores the result of the
2929 operation in ` x ` . It is a ` MethodError ` if ` x ` is not mutable or if the
3030 result of the operation cannot be stored in ` x ` .
3131
32- So from a generic code, ` MA.operate! ` can be used when the value of ` x ` is not
32+ So from a generic code, ` MA.operate!! ` can be used when the value of ` x ` is not
3333used anywhere else to recycle it if possible. This allows the code to both
3434work for mutable and for non-mutable type.
3535
36- When the type is known to be mutable, ` MA.mutable_operate ! ` can be used to make
36+ When the type is known to be mutable, ` MA.operate ! ` can be used to make
3737sure the operation is done in-place. If it is not possible, the ` MethodError `
38- allows to easily fix the issue while ` MA.operate! ` would have silently fallen
38+ allows to easily fix the issue while ` MA.operate!! ` would have silently fallen
3939back to the non-mutating function.
4040
41- In conclusion, the distinction between ` MA.operate! ` and ` MA.mutable_operate ! `
41+ In conclusion, the distinction between ` MA.operate!! ` and ` MA.operate ! `
4242allows to cover all use case while having an universal convention accross all
4343operations.
4444
@@ -136,11 +136,11 @@ BenchmarkTools.Trial: 407 samples with 1 evaluation.
136136 Memory estimate: 3.66 MiB, allocs estimate: 197732.
137137```
138138
139- In ` MA.mutable_operate !(::typeof(MA.add_mul), ::Vector, ::Matrix, ::Vector) ` , we
139+ In ` MA.operate !(::typeof(MA.add_mul), ::Vector, ::Matrix, ::Vector) ` , we
140140exploit the mutability of ` BigInt ` through the MutableArithmetics API.
141141This provides a significant speedup and a drastic reduction of memory usage:
142142``` julia
143- trial2 = @benchmark MA. add_mul! ($ c2, $ A2, $ b2)
143+ trial2 = @benchmark MA. add_mul!! ($ c2, $ A2, $ b2)
144144display (trial2)
145145
146146# output
@@ -158,15 +158,15 @@ BenchmarkTools.Trial: 4878 samples with 1 evaluation.
158158```
159159
160160There is still 48 bytes that are allocated, where does this come from ?
161- ` MA.mutable_operate !(::typeof(MA.add_mul), ::BigInt, ::BigInt, ::BigInt) `
161+ ` MA.operate !(::typeof(MA.add_mul), ::BigInt, ::BigInt, ::BigInt) `
162162allocates a temporary ` BigInt ` to hold the result of the multiplication.
163163This buffer is allocated only once for the whole matrix-vector multiplication
164164through the system of buffers of MutableArithmetics.
165165If may Matrix-Vector products need to be computed, the buffer can even be allocated
166166outside of the matrix-vector product as follows:
167167``` julia
168168buffer = MA. buffer_for (MA. add_mul, typeof (c2), typeof (A2), typeof (b2))
169- trial3 = @benchmark MA. buffered_operate! ($ buffer, MA. add_mul, $ c2, $ A2, $ b2)
169+ trial3 = @benchmark MA. buffered_operate!! ($ buffer, MA. add_mul, $ c2, $ A2, $ b2)
170170display (trial3)
171171
172172# output
0 commit comments