Commit 073bc0e
committed
Allow
This change has two benefits:
* The new implementation applies to more combinations of types. For
example, it now applies to `&Array2<f32>` and `Complex<f32>`.
* The new implementation avoids cloning the elements twice, and it
avoids iterating over the elements twice. (The old implementation
called `.to_owned()` followed by the arithmetic operation, while the
new implementation clones the elements and performs the arithmetic
operation in the same iteration.)
On my machine, this change improves the performance for both
contiguous and discontiguous arrays. (`scalar_add_1/2` go from ~530
ns/iter to ~380 ns/iter, and `scalar_add_strided_1/2` go from ~1540
ns/iter to ~1420 ns/iter.)&arr (op) scalar output to be any elem type1 parent 73ae59b commit 073bc0e
1 file changed
+5
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
156 | | - | |
| 155 | + | |
| 156 | + | |
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
162 | | - | |
163 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
0 commit comments