public static void print( PrintStream out , DMatrixSparseTriplet m , String format ) { printTypeSize(out,m); 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_value.data[index]); else out.print(" * "); if( col != m.numCols-1 ) out.print(" "); } out.println(); } }
public static void print( PrintStream out , FMatrixSparseTriplet m , String format ) { printTypeSize(out,m); 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_value.data[index]); else out.print(" * "); if( col != m.numCols-1 ) out.print(" "); } out.println(); } }
public static void printFancy(PrintStream out , DMatrixSparseCSC m , int length ) { DecimalFormat format = new DecimalFormat("#"); printTypeSize(out, m); 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.print(fancyStringF(m.nz_values[index],format,length, 4)); else out.print(zero); if (col != m.numCols - 1) out.print(" "); } out.println(); } }
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(); } } }
public static void printFancy(PrintStream out , FMatrix mat , int length ) { printTypeSize(out, mat); DecimalFormat format = new DecimalFormat("#"); final int cols = mat.getNumCols(); for (int row = 0; row < mat.getNumRows(); row++) { for (int col = 0; col < cols; col++) { out.print(fancyStringF(mat.get(row,col),format,length, 4)); if( col != cols-1 ) out.print(" "); } out.println(); } }
printMatlab(out,m); } else { printTypeSize(out, m);
public static void printFancy(PrintStream out , DMatrix mat , int length ) { printTypeSize(out, mat); DecimalFormat format = new DecimalFormat("#"); final int cols = mat.getNumCols(); for (int row = 0; row < mat.getNumRows(); row++) { for (int col = 0; col < cols; col++) { out.print(fancyStringF(mat.get(row,col),format,length, 4)); if( col != cols-1 ) out.print(" "); } out.println(); } }
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(); } } }
public static void print(PrintStream out , ZMatrix mat , String format ) { printTypeSize(out, mat); format = format+" + "+format+"i"; Complex_F64 c = new Complex_F64(); for( int y = 0; y < mat.getNumRows(); y++ ) { for( int x = 0; x < mat.getNumCols(); x++ ) { mat.get(y,x,c); out.printf(format,c.real,c.imaginary); if( x < mat.getNumCols()-1 ) { out.print(" , "); } } out.println(); } }
public static void print(PrintStream out , CMatrix mat , String format ) { printTypeSize(out, mat); format += " "; Complex_F32 c = new Complex_F32(); for( int y = 0; y < mat.getNumRows(); y++ ) { for( int x = 0; x < mat.getNumCols(); x++ ) { mat.get(y,x,c); out.printf(format,c.real,c.imaginary); if( x < mat.getNumCols()-1 ) { out.print(" , "); } } 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(); } } }
public static void printFancy(PrintStream out , ZMatrix mat , int length ) { printTypeSize(out, mat); DecimalFormat format = new DecimalFormat("#"); StringBuilder builder = new StringBuilder(length); final int cols = mat.getNumCols(); Complex_F64 c = new Complex_F64(); for( int y = 0; y < mat.getNumRows(); y++ ) { for( int x = 0; x < cols; x++ ) { mat.get(y,x,c); String real = fancyString(c.real,format,length,4); String img = fancyString(c.imaginary,format,length,4); real = real+padSpace(builder,length-real.length()); img = img+"i"+padSpace(builder,length-img.length()); out.print(real+" + "+ img); if( x < mat.getNumCols()-1 ) { out.print(" , "); } } out.println(); } }
public static void printFancy(PrintStream out , CMatrix mat , int length ) { printTypeSize(out, mat); DecimalFormat format = new DecimalFormat("#"); StringBuilder builder = new StringBuilder(length); final int cols = mat.getNumCols(); Complex_F32 c = new Complex_F32(); for( int y = 0; y < mat.getNumRows(); y++ ) { for( int x = 0; x < cols; x++ ) { mat.get(y,x,c); String real = fancyString(c.real,format,length,4); String img = fancyString(c.imaginary,format,length,4); real = real+padSpace(builder,length-real.length()); img = img+padSpace(builder,length-img.length()); out.print(real+" + "+ img+"i "); if( x < mat.getNumCols()-1 ) { out.print(" , "); } } out.println(); } }