Here you can find the source of transpose(double[][] in)
public static final double[][] transpose(double[][] in)
//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; } }