use crate::Tensor;
use std::ops::Neg;
impl Neg for &Tensor {
type Output = Tensor;
fn neg(self) -> Tensor {
#[cfg(feature = "dynamic")]
if self.is_dynamic() {
panic!(
"matten unsupported error in neg: unary negation is not supported on dynamic tensors; call try_numeric() first"
);
}
Tensor {
data: self.data.iter().map(|&v| -v).collect(),
shape: self.shape.clone(),
#[cfg(feature = "dynamic")]
dynamic: None,
}
}
}