class OGMatrixAlgebra extends MatrixAlgebra {

  @Override
  public DoubleMatrix2D getTranspose(final Matrix<?> m) {
    Validate.notNull(m, "m");
    if (m instanceof IdentityMatrix) {
      return (IdentityMatrix) m;
    }
    if (m instanceof DoubleMatrix2D) {
      final double[][] data = ((DoubleMatrix2D) m).getData();
      final int rows = data.length;
      final int cols = data[0].length;
      final double[][] res = new double[cols][rows];
      int i, j;
      for (i = 0; i < cols; i++) {
        for (j = 0; j < rows; j++) {
          res[i][j] = data[j][i];
        }
      }
      return new DoubleMatrix2D(res);
    }
    throw new IllegalArgumentException("Can only take transpose of DoubleMatrix2D; have " + m.getClass());
  }

}