Java Matrix Transpose transpose(byte[][] d)

Here you can find the source of transpose(byte[][] d)

Description

transpose

License

Open Source License

Declaration

public static byte[][] transpose(byte[][] d) 

Method Source Code

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

public class Main {
    public static double[][] transpose(double[][] d) {
        double[][] ret = new double[d[0].length][d.length];
        for (int i = 0; i < d[0].length; i++) {
            for (int j = 0; j < d.length; j++) {
                ret[i][j] = d[j][i];//from  w w  w .j  av a2s.  c  om
            }
        }
        return ret;
    }

    public static int[][] transpose(int[][] d) {
        int[][] ret = new int[d[0].length][d.length];
        for (int i = 0; i < d[0].length; i++) {
            for (int j = 0; j < d.length; j++) {
                ret[i][j] = d[j][i];
            }
        }
        return ret;
    }

    public static float[][] transpose(float[][] d) {
        float[][] ret = new float[d[0].length][d.length];
        for (int i = 0; i < d[0].length; i++) {
            for (int j = 0; j < d.length; j++) {
                ret[i][j] = d[j][i];
            }
        }
        return ret;
    }

    public static byte[][] transpose(byte[][] d) {
        byte[][] ret = new byte[d[0].length][d.length];
        for (int i = 0; i < d[0].length; i++) {
            for (int j = 0; j < d.length; j++) {
                ret[i][j] = d[j][i];
            }
        }
        return ret;
    }

    public static String[][] transpose(String[][] d) {
        String[][] ret = new String[d[0].length][d.length];
        for (int i = 0; i < d[0].length; i++) {
            for (int j = 0; j < d.length; j++) {
                ret[i][j] = d[j][i];
            }
        }
        return ret;
    }

    public static Object[][] transpose(Object[][] d) {
        Object[][] ret = new Object[d[0].length][d.length];
        for (int i = 0; i < d[0].length; i++) {
            for (int j = 0; j < d.length; j++) {
                ret[i][j] = d[j][i];
            }
        }
        return ret;
    }
}

Related

  1. matrixTransform(Object[][] datas)
  2. matrixTranspose(Object[][] matrix)
  3. transpose(boolean[][] inputMatrix)
  4. transpose(boolean[][] matrix)
  5. transpose(boolean[][] toBeTransposed)
  6. transpose(double array[], int W, int H, int D)
  7. transpose(double[] m)
  8. transpose(double[][] A)
  9. transpose(double[][] arr)