getSumRowsCols method
Computes the sum of all rows, or the sum of all columms.
sumRows
- set true to sum rows, false to sum columns.
type
= POS: adds the positive or zero values of a1
and a2
only
type
= one of Array1D.POS, Array1D.NEG, Array1D.POSNEG to
take into account only positive, negative, or all values to build the sum.
Implementation
static Float64List getSumRowsCols(
List<Float64List> matrix, bool sumRows, int type) {
int ncols = matrix[0].length; // = rowlength!
int nrows = matrix.length; // = collength
Float64List cursum; // has 0.0 elements initially!
if (sumRows) {
cursum = new Float64List(ncols);
for (int i = 0; i < nrows; i++) // all rows
{
cursum = Array1D.addArrays(matrix[i], cursum, type);
}
} else {
Float64List curcol;
cursum = new Float64List(nrows);
for (int i = 0; i < ncols; i++) // all cols
{
curcol = getColumn(matrix, i);
cursum = Array1D.addArrays(curcol, cursum, type);
}
}
return cursum;
}