protected static void validateSameType(String opName, boolean numericalOnly, SDVariable... vars) {
        if (vars.length == 0)
            return;
        if (vars.length == 1) {
            if (numericalOnly) {
                validateNumerical(opName, vars[0]);
            }
        } else {
            DataType first = vars[0].dataType();
            if (numericalOnly)
                validateNumerical(opName, vars[0]);
            for (int i = 1; i < vars.length; i++) {
                if (first != vars[i].dataType()) {
                    String[] names = new String[vars.length];
                    DataType[] dtypes = new DataType[vars.length];
                    for (int j = 0; j < vars.length; j++) {
                        names[j] = vars[j].getVarName();
                        dtypes[j] = vars[j].dataType();
                    }
                    throw new IllegalStateException("Cannot perform operation \"" + opName + "\" to variables with different datatypes:" +
                            " Variable names " + Arrays.toString(names) + ", datatypes " + Arrays.toString(dtypes));
                }
            }
        }
    }
protected static void validateSameType ( String opName , boolean numericalOnly , SDVariable ... vars ) { if ( vars . length == 0 ) return ; if ( vars . length == 1 ) { if ( numericalOnly ) { validateNumerical ( opName , vars [ 0 ] ) ; } } else { DataType first = vars [ 0 ] . dataType ( ) ; if ( numericalOnly ) validateNumerical ( opName , vars [ 0 ] ) ; for ( int i = 1 ; i < vars . length ; i ++ ) { if ( first != vars [ i ] . dataType ( ) ) { String [ ] names = new String [ vars . length ] ; DataType [ ] dtypes = new DataType [ vars . length ] ; for ( int j = 0 ; j < vars . length ; j ++ ) { names [ j ] = vars [ j ] . getVarName ( ) ; dtypes [ j ] = vars [ j ] . dataType ( ) ; } throw new IllegalStateException ( "Cannot perform operation \"" + opName + "\" to variables with different datatypes:" + " Variable names " + Arrays . toString ( names ) + ", datatypes " + Arrays . toString ( dtypes ) ) ; } } } }
Validate that the operation is being applied on array with the exact same datatypes (which may optionally be
restricted to numerical SDVariables only (not boolean or utf8))

@param opName        Operation name to print in the exception
@param numericalOnly If true, the variables must all be the same type, and must be numerical (not boolean/utf8)
@param vars          Variable to perform operation on