Closed GoogleCodeExporter closed 9 years ago
An easy way (but perhaps naive, performance wise) is:
public static SimpleMatrix rowTotals(SimpleMatrix A) {
SimpleMatrix l = new SimpleMatrix(1, A.numCols());
l.set(1.0);
return l.mult(A.transpose()).transpose();
}
public static SimpleMatrix columnTotals(SimpleMatrix A) {
SimpleMatrix l = new SimpleMatrix(1, A.numRows());
l.set(1.0);
return l.mult(A).transpose();
}
Which is a simple trick to get the totals. The final transpose is
there just to get vertical vectors in stead of horizontal ones. I'm
not sure if this is the most efficient way in ejml or if iteration is
faster. Feel free to reuse.
Original comment by b.broeks...@gmail.com
on 30 May 2011 at 12:15
I remember you mentioned this before. I'll add something similar to CommonOps.
Original comment by peter.ab...@gmail.com
on 1 Jun 2011 at 11:23
Similar functions have been added to CommonOps. Take a look at sumRows() and
sumCols() in common ops. A more direct method was used to compute the output
which should be faster.
Original comment by peter.ab...@gmail.com
on 11 Jun 2011 at 5:52
Assuming that the functions added are sufficient. Will reopen if this is not
the case.
Original comment by peter.ab...@gmail.com
on 22 Jun 2011 at 6:50
Original issue reported on code.google.com by
b.broeks...@gmail.com
on 30 May 2011 at 12:14