public static String format(double[][] m,int w,int d,String pre,String pos,String csep){
  DecimalFormat format=new DecimalFormat();
  format.setDecimalFormatSymbols(new DecimalFormatSymbols(Locale.US));
  format.setMinimumIntegerDigits(1);
  format.setMaximumFractionDigits(d);
  format.setMinimumFractionDigits(d);
  format.setGroupingUsed(false);
  StringBuilder msg=new StringBuilder();
  for (int i=0; i < m.length; i++) {
    double[] row=m[i];
    msg.append(pre);
    for (int j=0; j < row.length; j++) {
      if (j > 0) {
        msg.append(csep);
      }
      String s=format.format(row[j]);
      whitespace(msg,w - s.length());
      msg.append(s);
    }
    msg.append(pos);
  }
  return msg.toString();
}

public static String format ( double [ ] [ ] m , int w , int d , String pre , String pos , String csep ) { DecimalFormat format = new DecimalFormat ( ) ; format . setDecimalFormatSymbols ( new DecimalFormatSymbols ( Locale . US ) ) ; format . setMinimumIntegerDigits ( 1 ) ; format . setMaximumFractionDigits ( d ) ; format . setMinimumFractionDigits ( d ) ; format . setGroupingUsed ( false ) ; StringBuilder msg = new StringBuilder ( ) ; for ( int i = 0 ; i < m . length ; i ++ ) { double [ ] row = m [ i ] ; msg . append ( pre ) ; for ( int j = 0 ; j < row . length ; j ++ ) { if ( j > 0 ) { msg . append ( csep ) ; } String s = format . format ( row [ j ] ) ; whitespace ( msg , w - s . length ( ) ) ; msg . append ( s ) ; } msg . append ( pos ) ; } return msg . toString ( ) ; }
returns a string representation of this matrix .
