code: public static double[][] transpose(double[][] A) {
          int m = A.length;
          int n = A[0].length;
  
          double[][] matrix = new double[n][m];
          for (int i = 0; i < m; i++) {
              for (int j = 0; j < n; j++) {
                  matrix[j][i] = A[i][j];
              }
          }
  
          return matrix;
      }
docs: Returns the matrix transpose.