Java Matrix Transpose transposeBooleanMatrix(boolean[][] matrix)

Here you can find the source of transposeBooleanMatrix(boolean[][] matrix)

Description

Transpose a 2D array of boolean

License

Apache License

Parameter

Parameter Description
matrix a parameter

Declaration

public static boolean[][] transposeBooleanMatrix(boolean[][] matrix) 

Method Source Code

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

public class Main {
    /**//from   w w  w  . ja v  a2 s. c  o  m
     * Transpose a 2D array of boolean
     *
     * @param matrix
     * @return
     */
    public static boolean[][] transposeBooleanMatrix(boolean[][] matrix) {
        boolean[][] transposed = new boolean[matrix.length][matrix[0].length];
        for (int rowIndex = 0; rowIndex < matrix.length; rowIndex++) {
            for (int columnIndex = 0; columnIndex < matrix[0].length; columnIndex++) {
                if (matrix[rowIndex][columnIndex]) {
                    transposed[columnIndex][rowIndex] = true;
                }
            }
        }
        return transposed;
    }
}

Related

  1. transpose2d(Object[][] array)
  2. transpose2DArray(Double[][] data)
  3. transpose3x3Matrix(float[][] m)
  4. transpose4x4(float m[], float t[])
  5. transpose_image(Object source, int width, int height)
  6. transposeInPlace(float[] src)
  7. transposeMatrix(double[][] m)
  8. transposeMatrix(double[][] m)
  9. transposeMatrix(final float[] msrc, final int msrc_offset, final float[] mres, final int mres_offset)