Java Matrix Swap swapColumns(int i, int j, boolean[][] matrix)

Here you can find the source of swapColumns(int i, int j, boolean[][] matrix)

Description

swap Columns

License

Apache License

Declaration

private static void swapColumns(int i, int j, boolean[][] matrix) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    private static void swapColumns(int i, int j, boolean[][] matrix) {
        int m = matrix.length;
        if (m == 0) {
            // do nothing
            return;
        }//from   w  ww.  j  a va  2 s  . c o m
        int n = matrix[0].length;
        if (i >= n || j >= n || i == j) {
            // do nothing
            return;
        }

        boolean temp;
        for (int k = 0; k < m; k++) {
            temp = matrix[k][i];
            matrix[k][i] = matrix[k][j];
            matrix[k][j] = temp;
        }
    }
}

Related

  1. swap(double[][] noteOrder, final int i, final int j)
  2. swap2d(Object[][] array, int c1, int r1, int c2, int r2)
  3. swapColumns(byte[][] matrix, int a, int b)
  4. swapColumns(double[][] front, int colA, int colB)
  5. swapRows(double[][] a, int i, int j)
  6. swapRows(double[][] Ab, int k, int i)
  7. swapRows(double[][] matrix, int i1, int i2)
  8. swapShorts(byte bs[][])