Open duskmoon314 opened 4 weeks ago
I think this falls under the "too many methods" problem, but other maintainers may have a different opinion.
You might already know, but what you request can be coded like this
let ans = Zip::from(&x1).and(&x2).map_collect(|&a, &b| a.powi(b)); // Or powf
I think this falls under the "too many methods" problem
Indeed. Adding more methods would be convenient when people want to port some Python code to Rust. I opened this issue while trying to port some Python code and found out I needed to use iterators.
However, this would also make implementation and maintenance more complex and may confuse users. I genuinely think more discussion should be taken.
1042 has added element-wise power methods
powi
andpowf
. But they only accept one parameter.In NumPy,
numpy.power
receives two arrays,x1
andx2
. The latter could be a number or an array and performs power with different exponents.An example from: https://numpy.org/doc/stable/reference/generated/numpy.power.html#numpy.power
Though we may archive this using an iterator, a more powerful function might fill the gap for users coming from NumPy.