@Test public void testTransposed2() { int[][] arr = new int[][] { { 0 } }; Assert.assertArrayEquals(new int[][] { { 0 } }, ArrayUtils.transposed(arr)); }
public static int[][] transposed(int[][] arr) { Preconditions.checkArgument(arr.length > 0); int n = arr.length; int m = arr[0].length; assert m > 0; int[][] tran = new int[m][n]; for (int i = 0; i < n; ++i) { assert arr[i].length == m; for (int j = 0; j < m; ++j) { tran[j][i] = arr[i][j]; } } return tran; }
ArrayUtils { public static int[][] transposed(int[][] arr) { Preconditions.checkArgument(arr.length > 0); int n = arr.length; int m = arr[0].length; assert m > 0; int[][] tran = new int[m][n]; for (int i = 0; i < n; ++i) { assert arr[i].length == m; for (int j = 0; j < m; ++j) { tran[j][i] = arr[i][j]; } } return tran; } }
ArrayUtils { public static int[][] transposed(int[][] arr) { Preconditions.checkArgument(arr.length > 0); int n = arr.length; int m = arr[0].length; assert m > 0; int[][] tran = new int[m][n]; for (int i = 0; i < n; ++i) { assert arr[i].length == m; for (int j = 0; j < m; ++j) { tran[j][i] = arr[i][j]; } } return tran; }  }
ArrayUtils { public static int[][] transposed(int[][] arr) { Preconditions.checkArgument(arr.length > 0); int n = arr.length; int m = arr[0].length; assert m > 0; int[][] tran = new int[m][n]; for (int i = 0; i < n; ++i) { assert arr[i].length == m; for (int j = 0; j < m; ++j) { tran[j][i] = arr[i][j]; } } return tran; }  static String toJavaArray(int[][] arr); static String toJavaArray(int[] arr); static String toJavaArray(double[] arr); static double[] flatten(double[][] arr); static int[] flatten(int[][] arr); static int[][] transposed(int[][] arr); static int[] sorted(int[] arr); static int[] sorted(int[] arr, int numElements); static double sum(double[] arr); static double mean(double[] arr); static double absmax(double[] arr); static double[] normalized(double[] arr); static double[] fromPythonString(String string); static String toPythonString(double[] arr); static double[] add(double[] a, double[] b); static double[] subtract(double[] a, double[] b); static double[] multiplied(double[] a, double multiplier); static double[] toDoubleArray(float[] arr); static float[] toFloatArray(double[] arr); }
ArrayUtils { public static int[][] transposed(int[][] arr) { Preconditions.checkArgument(arr.length > 0); int n = arr.length; int m = arr[0].length; assert m > 0; int[][] tran = new int[m][n]; for (int i = 0; i < n; ++i) { assert arr[i].length == m; for (int j = 0; j < m; ++j) { tran[j][i] = arr[i][j]; } } return tran; }  static String toJavaArray(int[][] arr); static String toJavaArray(int[] arr); static String toJavaArray(double[] arr); static double[] flatten(double[][] arr); static int[] flatten(int[][] arr); static int[][] transposed(int[][] arr); static int[] sorted(int[] arr); static int[] sorted(int[] arr, int numElements); static double sum(double[] arr); static double mean(double[] arr); static double absmax(double[] arr); static double[] normalized(double[] arr); static double[] fromPythonString(String string); static String toPythonString(double[] arr); static double[] add(double[] a, double[] b); static double[] subtract(double[] a, double[] b); static double[] multiplied(double[] a, double multiplier); static double[] toDoubleArray(float[] arr); static float[] toFloatArray(double[] arr);  }