Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
&arr (op) scalar
output to be any elem type
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.)
- Loading branch information