Java Matrix Print printMatrix(float[] array, int rows, int columns)

Here you can find the source of printMatrix(float[] array, int rows, int columns)

Description

print Matrix

License

Open Source License

Declaration

public static void printMatrix(float[] array, int rows, int columns) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.text.DecimalFormat;
import java.text.NumberFormat;

import java.util.stream.IntStream;

public class Main {
    public static void printMatrix(float[] array, int rows, int columns) {
        StringBuilder sb = new StringBuilder();
        NumberFormat formatter = new DecimalFormat("#0.00");

        IntStream.range(0, columns).forEach(i -> {
            IntStream.range(0, columns)
                    .forEach(j -> sb.append(formatter.format(array[i * columns + j])).append(" "));
            sb.append(System.getProperty("line.separator"));
        });//from   ww w.ja  v a 2s  . c o m

        System.out.println(sb.toString());
    }
}

Related

  1. printMatrix(double[][] matrix)
  2. printMatrix(double[][] matrix)
  3. printMatrix(double[][] matrix)
  4. printMatrix(double[][] sims)
  5. printMatrix(final double m[][])
  6. printMatrix(int M, int N, double mat[][])
  7. printMatrix(int m, int n, double[][] a)
  8. printMatrix(int matrix[][])
  9. printMatrix(int[] array, String format, int width)