pub fn multi_broadcast<T>(shapes: &[impl AsRef<[T]>]) -> Option<TVec<T>>
where
    T: One + PartialEq + Copy,
{
    let len = shapes.iter().map(|shape| shape.as_ref().len()).max()?;
    let mut shape = tvec!();
    for i in 0..len {
        let mut wanted_size = T::one();
        for shape in shapes {
            let len = shape.as_ref().len();
            let dim = if i < len { shape.as_ref()[len - i - 1] } else { T::one() };
            if dim != T::one() {
                if wanted_size != T::one() && dim != wanted_size {
                    return None;
                }
                wanted_size = dim;
            }
        }
        shape.push(wanted_size)
    }
    shape.reverse();
    Some(shape)
}
/// Computes a shape, if any, to which all shapes can be broadcasted.
Computes a shape, if any, to which all shapes can be broadcasted.
Computes a shape if any to which all shapes can be broadcasted .
pub fn multi_broadcast<T>(shapes: &[impl AsRef<[T]>]) -> Option<TVec<T>>
where
    T: One + PartialEq + Copy,
{
    let len = shapes.iter().map(|shape| shape.as_ref().len()).max()?;
    let mut shape = tvec!();
    for i in 0..len {
        let mut wanted_size = T::one();
        for shape in shapes {
            let len = shape.as_ref().len();
            let dim = if i < len { shape.as_ref()[len - i - 1] } else { T::one() };
            if dim != T::one() {
                if wanted_size != T::one() && dim != wanted_size {
                    return None;
                }
                wanted_size = dim;
            }
        }
        shape.push(wanted_size)
    }
    shape.reverse();
    Some(shape)
}
pub fn multi_broadcast < T > ( shapes : & [ impl AsRef < [ T ] > ] ) -> Option < TVec < T > > where T : One + PartialEq + Copy , { let len = shapes . iter ( ) . map ( | shape | shape . as_ref ( ) . len ( ) ) . max ( ) ? ; let mut shape = tvec ! ( ) ; for i in 0 .. len { let mut wanted_size = T :: one ( ) ; for shape in shapes { let len = shape . as_ref ( ) . len ( ) ; let dim = if i < len { shape . as_ref ( ) [ len - i - 1 ] } else { T :: one ( ) } ; if dim != T :: one ( ) { if wanted_size != T :: one ( ) && dim != wanted_size { return None ; } wanted_size = dim ; } } shape . push ( wanted_size ) } shape . reverse ( ) ; Some ( shape ) }
Computes a shape, if any, to which all shapes can be broadcasted.
Computes a shape if any to which all shapes can be broadcasted .
shapes
&[impl AsRef<[T]>]
shapes
&[impl AsRef<[T]>]