Java Utililty Methods Matrix to String

List of utility methods to do Matrix to String

Description

The list of methods to do Matrix to String are organized into topic(s).

Method

StringtoString(double[][] A)
to String
StringBuilder sb = new StringBuilder("(");
for (double[] rawA : A)
    sb.append(Arrays.toString(rawA)).append(',');
sb.delete(sb.length() - 1, sb.length()).append(')');
return sb.toString();
StringtoString(double[][] array)
to String
final StringBuffer buffer = new StringBuffer(ARRAY_OPEN_TAG);
for (int i = 0; i < array.length; i++) {
    final StringBuffer tempBuffer = new StringBuffer(Arrays.toString(array[i]));
    buffer.append(tempBuffer.substring(1, tempBuffer.length() - 1));
    buffer.append(ARRAY_SEPARATOR);
buffer.append(ARRAY_CLOSE_TAG);
return buffer.toString();
...
StringtoString(double[][] data)
Convert a 2D array to string
StringBuffer buf = new StringBuffer();
buf.append("row num = word num=" + data.length + "\n");
if (data.length > 0)
    buf.append("col num = doc num = " + data[0].length + "\n");
for (int c0 = 0; c0 < data.length; c0++) {
    double[] row = data[c0];
    buf.append(Arrays.toString(row)).append("\n");
return buf.toString();
StringtoString(int partition[][])
ToString - A string representation for the super-class partition 'partition'.
StringBuilder sb = new StringBuilder();
sb.append("{");
for (int i = 0; i < partition.length; i++) {
    sb.append(" " + Arrays.toString(partition[i]));
sb.append(" }");
return sb.toString();
StringtoString(int[][] a)
to String
StringBuilder result = new StringBuilder("[");
for (int i = 0; i < a.length; i++) {
    result.append(Arrays.toString(a[i]));
    if (i < a.length - 1)
        result.append(',');
result.append(']');
return result.toString();
...
StringtoString(int[][] matrix)
Format matrix as String, by joining Arrays.toString of each row
StringBuilder builder = new StringBuilder();
builder.append("[");
if (matrix.length > 0) {
    builder.append(Arrays.toString(matrix[0]));
    for (int i = 1; i < matrix.length; ++i) {
        builder.append(", ").append(Arrays.toString(matrix[i]));
builder.append("]");
return builder.toString();
StringtoString(Object[][] arr)
to String
String s = "{";
for (int i = 0; i < arr.length; i++) {
    if (i == arr.length - 1)
        s += Arrays.toString(arr[i]);
    else
        s += Arrays.toString(arr[i]) + ", ";
s += "}";
...