Here you can find the source of transpose(double[][] ary)
public static double[][] transpose(double[][] ary)
//package com.java2s; //License from project: Apache License public class Main { public static double[][] transpose(double[][] ary) { if (ary == null) return null; double[][] res = new double[ary[0].length][ary.length]; for (int i = 0; i < res.length; i++) { for (int j = 0; j < res[0].length; j++) res[i][j] = ary[j][i];/*from w ww . j av a 2 s . c om*/ } return res; } }