public static Object flatten(Object input){
  int[] dimens=getDimensions(input);
  if (dimens.length <= 1) {
    return input;
  }
  int size=1;
  for (  int dimen : dimens) {
    size*=dimen;
  }
  Object flat=ArrayFuncs.newInstance(getBaseClass(input),size);
  MultiArrayCopier.copyInto(input,flat);
  return flat;
}

public static Object flatten ( Object input ) { int [ ] dimens = getDimensions ( input ) ; if ( dimens . length <= 1 ) { return input ; } int size = 1 ; for ( int dimen : dimens ) { size *= dimen ; } Object flat = ArrayFuncs . newInstance ( getBaseClass ( input ) , size ) ; MultiArrayCopier . copyInto ( input , flat ) ; return flat ; }
given an array of arbitrary dimensionality .
