Logo Search packages:      
Sourcecode: jblas version File versions  Download package

String org::jblas::la::DoubleMatrix::toString ( String  fmt  )  [inline]

Generate string representation of the matrix, with specified format for the entries. For example, x.toString("%.1f") generates a string representations having only one position after the decimal point.

Definition at line 1182 of file DoubleMatrix.java.

References columns, and rows.

                                       {
        StringWriter s = new StringWriter();
        PrintWriter p = new PrintWriter(s);

        p.print("[");

        for (int r = 0; r < rows; r++) {
            for (int c = 0; c < columns; c++) {
                p.printf(fmt, get(r, c));
                if (c < columns - 1) {
                    p.print(", ");
                }
            }
            if (r < rows - 1) {
                p.print("; ");
            }
        }

        p.print("]");

        return s.toString();
    }


Generated by  Doxygen 1.6.0   Back to index