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

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

Description

Prints the provided incidence matrix

License

Open Source License

Parameter

Parameter Description
matrix int[][]

Declaration

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

Method Source Code

//package com.java2s;
/*/*from   ww  w  .j  ava 2 s.com*/
 * Open Source Physics software is free software; you can redistribute
 * it and/or modify it under the terms of the GNU General Public License (GPL) as
 * published by the Free Software Foundation; either version 2 of the License,
 * or(at your option) any later version.

 * Code that uses any portion of the code in the org.opensourcephysics package
 * or any subpackage (subdirectory) of this package must must also be be released
 * under the GNU GPL license.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston MA 02111-1307 USA
 * or view the license online at http://www.gnu.org/copyleft/gpl.html
 *
 * Copyright (c) 2007  The Open Source Physics project
 *                     http://www.opensourcephysics.org
 */

public class Main {
    /**
     * Prints the provided incidence matrix
     * @param matrix int[][]
     */
    public static void printMatrix(int matrix[][]) {
        System.out.println("{"); //$NON-NLS-1$
        for (int i = 0; i < matrix.length; i++) { // for each state
            int[] row = matrix[i];
            System.out.print("  { "); //$NON-NLS-1$
            for (int j = 0; j < row.length; j++) { // for each rate in the direct matrix
                if (j == 0)
                    System.out.print(row[j]);
                else
                    System.out.print(", " + row[j]); //$NON-NLS-1$
            }
            System.out.println(" }"); //$NON-NLS-1$
        }
        System.out.println("}"); //$NON-NLS-1$
    }
}

Related

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