public static boolean conformable(int[] shapeA, int[] shapeB) {
    if (reducedRank(shapeA) != reducedRank(shapeB))
      return false;

    int rankB = shapeB.length;

    int dimB = 0;
    for (int aShapeA : shapeA) {
      //System.out.println(dimA + " "+ dimB);

      //skip length 1 dimensions
      if (aShapeA == 1)
        continue;
      while (dimB < rankB)
        if (shapeB[dimB] == 1) dimB++;
        else break;

      // test same shape (NB dimB cant be > rankB due to first test)
      if (aShapeA != shapeB[dimB])
        return false;
      dimB++;
    }

    return true;
  }
public static boolean conformable(int[] shapeA, int[] shapeB) {
    if (reducedRank(shapeA) != reducedRank(shapeB))
      return false;

    int rankB = shapeB.length;

    int dimB = 0;
    for (int aShapeA : shapeA) {
      

      
      if (aShapeA == 1)
        continue;
      while (dimB < rankB)
        if (shapeB[dimB] == 1) dimB++;
        else break;

      
      if (aShapeA != shapeB[dimB])
        return false;
      dimB++;
    }

    return true;
  }
public static boolean conformable ( int [ ] shapeA , int [ ] shapeB ) { if ( reducedRank ( shapeA ) != reducedRank ( shapeB ) ) return false ; int rankB = shapeB . length ; int dimB = 0 ; for ( int aShapeA : shapeA ) { //System.out.println(dimA + " "+ dimB);
 //skip length 1 dimensions
 if ( aShapeA == 1 ) continue ; while ( dimB < rankB ) if ( shapeB [ dimB ] == 1 ) dimB ++ ; else break ; // test same shape (NB dimB cant be > rankB due to first test)
 if ( aShapeA != shapeB [ dimB ] ) return false ; dimB ++ ; } return true ; }
Check that two array shapes are conformable.
The shapes must match exactly, except that dimensions of length 1 are ignored.

@param shapeA shape of array 1
@param shapeB shape of array 2
@return true if conformable
Check that two array shapes are conformable . The shapes must match exactly except that dimensions of length 1 are ignored .