@Override
 public DoubleMatrix transpose() {
   SparseDoubleRowMatrix m = new SparseDoubleRowMatrix(this.numColumns, this.numRows);
   for (int row : this.matrix.keys()) {
     Iterator<DoubleVectorElement> iterateNonZero = matrix.get(row).iterateNonZero();
     while (iterateNonZero.hasNext()) {
       DoubleVectorElement e = iterateNonZero.next();
       m.set(e.getIndex(), row, e.getValue());
     }
   }
   return m;
 }
  @Override
  public DoubleMatrix add(DoubleMatrix other) {
    SparseDoubleRowMatrix result =
        new SparseDoubleRowMatrix(other.getRowCount(), other.getColumnCount());

    for (int row : this.matrix.keys()) {
      Iterator<DoubleVectorElement> iterate = matrix.get(row).iterate();
      while (iterate.hasNext()) {
        DoubleVectorElement e = iterate.next();
        result.set(row, e.getIndex(), e.getValue() + other.get(row, e.getIndex()));
      }
    }

    return result;
  }
  @Override
  public DoubleMatrix divide(DoubleMatrix other) {
    SparseDoubleRowMatrix m = new SparseDoubleRowMatrix(other);

    for (int row : this.matrix.keys()) {
      Iterator<DoubleVectorElement> iterateNonZero = matrix.get(row).iterateNonZero();
      while (iterateNonZero.hasNext()) {
        DoubleVectorElement e = iterateNonZero.next();
        m.set(row, e.getIndex(), get(row, e.getIndex()) / other.get(row, e.getIndex()));
      }
    }

    for (int col : other.columnIndices()) {
      Iterator<DoubleVectorElement> iterateNonZero = other.getColumnVector(col).iterateNonZero();
      while (iterateNonZero.hasNext()) {
        DoubleVectorElement e = iterateNonZero.next();
        m.set(e.getIndex(), col, get(e.getIndex(), col) / other.get(e.getIndex(), col));
      }
    }

    return m;
  }