Here you can find the source of transpose2DArray(Double[][] data)
Parameter | Description |
---|---|
data | a parameter |
public static Double[][] transpose2DArray(Double[][] data)
//package com.java2s; //License from project: Apache License public class Main { /**/*w w w .j a v a 2s. c o m*/ * Transpose a 2D array of Double * * @param data * @return the same 2D array but transposed */ public static Double[][] transpose2DArray(Double[][] data) { Double[][] transposed = new Double[data[0].length][data.length]; for (int rowIndex = 0; rowIndex < data.length; rowIndex++) { for (int columnIndex = 0; columnIndex < data[0].length; columnIndex++) { if (data[rowIndex][columnIndex] != null) { transposed[columnIndex][rowIndex] = data[rowIndex][columnIndex]; } } } return transposed; } /** * Transpose a 2D array of double * * @param data * @return the same 2D array but transposed */ public static double[][] transpose2DArray(double[][] data) { double[][] transposed = new double[data[0].length][data.length]; for (int rowIndex = 0; rowIndex < data.length; rowIndex++) { for (int columnIndex = 0; columnIndex < data[0].length; columnIndex++) { transposed[columnIndex][rowIndex] = data[rowIndex][columnIndex]; } } return transposed; } }