Java Matrix Print printMatrix(double[][] matrix)

Here you can find the source of printMatrix(double[][] matrix)

Description

Debug function for displaying a matrix

License

Open Source License

Parameter

Parameter Description
matrix The matrix to display

Declaration

public static void printMatrix(double[][] matrix) 

Method Source Code

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

public class Main {
    /**//from   w ww .  java 2 s.  c o m
     * Debug function for displaying a matrix
     * 
     * @param matrix The matrix to display
     */
    public static void printMatrix(double[][] matrix) {
        int dim = matrix.length;
        for (int i = 0; i < dim; i++) {
            for (int j = 0; j < dim; j++) {
                System.out.printf("%5f", matrix[i][j]);
                if (i == j && matrix[i][j] != 0) {
                    //   System.err.println("Error at i = " + i + " j = " + j +" Value = " + matrix[i][j]);
                }
            }
            System.out.println();
        }

        System.out.println();
    }
}

Related

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