pub fn veclen_squared<'a, T>(inp: &'a ndarray::NdArray<T>, out: &mut ndarray::NdArray<T>)
where
    T: Copy + Default + std::ops::AddAssign,
    &'a T: std::ops::Mul<Output = T>,
{
    if matches!(inp.shape(), Shape::Scalar(_)) {
        *out = inp.clone();
    }
    let shape_len = inp.shape().as_slice().len();
    let out_shape = &inp.shape().as_slice()[..shape_len - 1];
    out.reshape(out_shape);
    for (i, vector) in inp.iter_rows().enumerate() {
        let mut vec_len = T::default();
        for x in vector {
            vec_len += x * x;
        }
        out.as_mut_slice()[i] = vec_len;
    }
}
/// Calculate the square of the eucledian length of the vector(s). Matrices and Tensors are treated as a list of vectors.
Calculate the square of the eucledian length of the vector(s). Matrices and Tensors are treated as a list of vectors.
Calculate the square of the eucledian length of the vector ( s ) . Matrices and Tensors are treated as a list of vectors .
pub fn veclen_squared<'a, T>(inp: &'a ndarray::NdArray<T>, out: &mut ndarray::NdArray<T>)
where
    T: Copy + Default + std::ops::AddAssign,
    &'a T: std::ops::Mul<Output = T>,
{
    if matches!(inp.shape(), Shape::Scalar(_)) {
        *out = inp.clone();
    }
    let shape_len = inp.shape().as_slice().len();
    let out_shape = &inp.shape().as_slice()[..shape_len - 1];
    out.reshape(out_shape);
    for (i, vector) in inp.iter_rows().enumerate() {
        let mut vec_len = T::default();
        for x in vector {
            vec_len += x * x;
        }
        out.as_mut_slice()[i] = vec_len;
    }
}
pub fn veclen_squared < ' a , T > ( inp : & ' a ndarray :: NdArray < T > , out : & mut ndarray :: NdArray < T > ) where T : Copy + Default + std :: ops :: AddAssign , & ' a T : std :: ops :: Mul < Output = T > , { if matches ! ( inp shape ( ) Shape Scalar ( ) ) { * out = inp . clone ( ) ; } let shape_len = inp . shape ( ) . as_slice ( ) . len ( ) ; let out_shape = & inp . shape ( ) . as_slice ( ) [ .. shape_len - 1 ] ; out . reshape ( out_shape ) ; for ( i , vector ) in inp . iter_rows ( ) . enumerate ( ) { let mut vec_len = T :: default ( ) ; for x in vector { vec_len += x * x ; } out . as_mut_slice ( ) [ i ] = vec_len ; } }
Calculate the square of the eucledian length of the vector(s).
Calculate the square of the eucledian length of the vector ( s ) .
inp
&'a ndarray::NdArray<T>
out
&mut ndarray::NdArray<T>