code: public Matrix transpose()
      {
          double tv[][] = new double[nCols][nRows];  // transposed values
  
          // Set the values of the transpose.
          for (int r = 0; r < nRows; ++r) {
              for (int c = 0; c < nCols; ++c) {
                  tv[c][r] = values[r][c];
              }
          }
  
          return new Matrix(tv);
      }
docs: Return the transpose of this matrix.
  @return the transposed matrix