Files
ndarray-math/src/ndarray_15_extra.rs
2025-06-23 15:38:28 +05:30

16 lines
344 B
Rust

pub trait Pow {
type Output;
fn powi(&self, rhs: i32) -> Self::Output;
}
impl<T, S, D> Pow for ndarray::ArrayBase<S, D>
where
S: ndarray::Data<Elem = T>,
T: num::Float,
D: ndarray::Dimension,
{
type Output = ndarray::Array<T, D>;
fn powi(&self, rhs: i32) -> Self::Output {
self.mapv(|x| x.powi(rhs))
}
}