pub fn last_span(&self, i: u32) -> usize {
        if i == 0 {
            return 0;
        }
        match self {
            Shape::Scalar(_) => 1,
            Shape::Vector([i]) => *i as usize,
            Shape::Matrix([n, m]) => {
                if i <= 1 {
                    *m as usize
                } else {
                    *n as usize * *m as usize
                }
            }
            Shape::Tensor(shp) => shp[shp.len() - (i as usize).min(shp.len())..]
                .iter()
                .map(|x| *x as usize)
                .product(),
        }
    }
/// Number of elements the last `i` dimensions of this shape spans
///
/// If the total number of dimensions is less than `i` then all are counted
Number of elements the last `i` dimensions of this shape spans
If the total number of dimensions is less than `i` then all are counted
Number of elements the last ` i ` dimensions of this shape spans If the total number of dimensions is less than ` i ` then all are counted
pub fn last_span(&self, i: u32) -> usize {
        if i == 0 {
            return 0;
        }
        match self {
            Shape::Scalar(_) => 1,
            Shape::Vector([i]) => *i as usize,
            Shape::Matrix([n, m]) => {
                if i <= 1 {
                    *m as usize
                } else {
                    *n as usize * *m as usize
                }
            }
            Shape::Tensor(shp) => shp[shp.len() - (i as usize).min(shp.len())..]
                .iter()
                .map(|x| *x as usize)
                .product(),
        }
    }
pub fn last_span ( & self , i : u32 ) -> usize { if i == 0 { return 0 ; } match self { Shape :: Scalar ( _ ) => 1 , Shape :: Vector ( [ i ] ) => * i as usize , Shape :: Matrix ( [ n , m ] ) => { if i <= 1 { * m as usize } else { * n as usize * * m as usize } } Shape :: Tensor ( shp ) => shp [ shp . len ( ) - ( i as usize ) . min ( shp . len ( ) ) .. ] . iter ( ) . map ( | x | * x as usize ) . product ( ) , } }
Number of elements the last `i` dimensions of this shape spans
If the total number of dimensions is less than `i` then all are counted
Number of elements the last ` i ` dimensions of this shape spans If the total number of dimensions is less than ` i ` then all are counted
&self
i
u32