Java Matrix Transpose transpose(double[][] in)

Here you can find the source of transpose(double[][] in)

Description

transpose

License

Apache License

Declaration

public static final double[][] transpose(double[][] in) 

Method Source Code

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

public class Main {
    public static final double[][] transpose(double[][] in) {
        int nr = in.length;
        int nc = in[0].length;
        double[][] out = new double[nc][nr];
        for (int i = 0; i < nr; i++)
            for (int j = 0; j < nc; j++) {
                out[j][i] = in[i][j];//www  .ja v  a 2s  . c  o m
            }
        return out;
    }

    public static final float[][] transpose(float[][] in) {
        int nr = in.length;
        int nc = in[0].length;
        float[][] out = new float[nc][nr];
        for (int i = 0; i < nr; i++)
            for (int j = 0; j < nc; j++) {
                out[j][i] = in[i][j];
            }
        return out;
    }
}

Related

  1. transpose(double array[], int W, int H, int D)
  2. transpose(double[] m)
  3. transpose(double[][] A)
  4. transpose(double[][] arr)
  5. transpose(double[][] ary)
  6. transpose(double[][] matrix)
  7. transpose(double[][] matrix)
  8. transpose(final double[][] A)
  9. transpose(final double[][] m)