Java Matrix Transpose transpose(Object[][] matrix)

Here you can find the source of transpose(Object[][] matrix)

Description

Transposes the matrix

License

Apache License

Parameter

Parameter Description
matrix Matrix to be transposed

Return

a transposed copy of the matrix

Declaration

public static Object[][] transpose(Object[][] matrix) 

Method Source Code

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

public class Main {
    /**/*from  ww  w.  ja  v a  2s .  c om*/
     * Transposes the matrix
     * @param matrix Matrix to be transposed
     * @return a transposed copy of the matrix
     */
    public static Object[][] transpose(Object[][] matrix) {
        Object[][] temp = new Object[matrix[0].length][matrix.length];
        for (int i = 0; i < matrix.length; i++)
            for (int j = 0; j < matrix[0].length; j++)
                temp[j][i] = matrix[i][j];
        return temp;
    }
}

Related

  1. transpose(int[][] M)
  2. transpose(int[][] matrix)
  3. transpose(int[][][] as, int A, int[][][] ast)
  4. transpose(long[] a, double offset)
  5. transpose(Object[][] matrix)
  6. transpose2d(Object[][] array)
  7. transpose2DArray(Double[][] data)
  8. transpose3x3Matrix(float[][] m)
  9. transpose4x4(float m[], float t[])