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

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

Description

transpose

License

Open Source License

Declaration

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

Method Source Code

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

public class Main {
    public static int[][] transpose(int[][] matrix) {
        if (matrix.length == 0 || matrix[0].length == 0)
            return matrix;

        int[][] result = new int[matrix[0].length][matrix.length];
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[0].length; j++) {
                int delta = (int) ((Math.random() * 20 - 10) / 9);
                delta *= (int) (Math.random() * 3);
                result[j][i] = matrix[i][j] + delta;
            }//from  ww  w  . j a  v  a  2s  . c om
        }

        return result;
    }
}

Related

  1. transpose(float[] mat, float[] dest)
  2. transpose(float[][] data)
  3. transpose(int N, double src[][])
  4. transpose(int[][] input)
  5. transpose(int[][] M)
  6. transpose(int[][][] as, int A, int[][][] ast)
  7. transpose(long[] a, double offset)
  8. transpose(Object[][] matrix)
  9. transpose(Object[][] matrix)