public static void print( PrintStream out , FMatrixSparseCSC m , String format ) { if( format.toLowerCase().equals("matlab")) { printMatlab(out,m); } else { printTypeSize(out, m); int length = String.format(format, -1.1123).length(); char[] zero = new char[length]; Arrays.fill(zero, ' '); zero[length / 2] = '*'; for (int row = 0; row < m.numRows; row++) { for (int col = 0; col < m.numCols; col++) { int index = m.nz_index(row, col); if (index >= 0) out.printf(format, m.nz_values[index]); else out.print(zero); if (col != m.numCols - 1) out.print(" "); } out.println(); } } }
printMatlab(out,m); } else { printTypeSize(out, m);
public static void print(PrintStream out , FMatrix mat , String format ) { if( format.toLowerCase().equals("matlab")) { printMatlab(out, mat); } else if( format.toLowerCase().equals("java")) { printJava(out,mat,format); } else { printTypeSize(out, mat); format += " "; for (int row = 0; row < mat.getNumRows(); row++) { for (int col = 0; col < mat.getNumCols(); col++) { out.printf(format, mat.get(row, col)); } out.println(); } } }
/** * Prints the matrix out in a text format. The format is specified using notation from * {@link String#format(String, Object...)}. Unless the format is set to 'matlab' then it will print it out * in a format that's understood by Matlab. 'java' will print a java 2D array. * * @param out Output stream * @param mat Matrix to be printed * @param format printf style or 'matlab' */ public static void print(PrintStream out , DMatrix mat , String format ) { if( format.toLowerCase().equals("matlab")) { printMatlab(out, mat); } else if( format.toLowerCase().equals("java")) { printJava(out,mat,format); } else { printTypeSize(out, mat); format += " "; for (int row = 0; row < mat.getNumRows(); row++) { for (int col = 0; col < mat.getNumCols(); col++) { out.printf(format, mat.get(row, col)); } out.println(); } } }