Here you can find the source of transpose(double[][] A)
public static double[][] transpose(double[][] A)
//package com.java2s; //License from project: BSD License public class Main { public static double[][] transpose(double[][] A) { int m = A.length; if (m == 0) return new double[0][0]; int n = A[0].length; double[][] out = new double[n][m]; for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) out[j][i] = A[i][j];/*from w w w .j av a2 s . com*/ return out; } }