Esempio n. 1
0
  public Vector columnSums() throws MatricksException {
    Vector sums = new DenseDoubleVector(numCols());

    MatrixCursor cursor = cursor();
    while (cursor.next()) {
      sums.set(cursor.col(), cursor.val() + sums.get(cursor.col()));
    }

    return sums;
  }
Esempio n. 2
0
  public Vector rowSums() throws MatricksException {
    // TODO: can change this to a lower level interface,
    // taking in an array of doubles and not allocating ... ?
    Vector sums = new DenseDoubleVector(numRows());

    // TODO: optimize out row() with local var? microopt, measure speed
    MatrixCursor cursor = cursor();
    while (cursor.next()) {
      sums.set(cursor.row(), cursor.val() + sums.get(cursor.row()));
    }

    return sums;
  }
Esempio n. 3
0
 /*
  * A = A ./ (x*x')
  */
 public void dotDivOuterProd(Vector x) {
   MatrixCursor mCursor = cursor();
   while (mCursor.next()) {
     mCursor.set(mCursor.val() / (x.get(mCursor.row()) * x.get(mCursor.col())));
   }
 }