integrateRegion method
Integrates a submatrix of matrix
. The submatrix boundaries are given by
startRow
, endRow
, startCol
, endCol
. The indices are inclusive.
Returns a list with 3 elements:
0
= sum of All matrix values in the region
1
= sum of the POSITIVE matrix values in the region
2
= sum of the NEGATIVE matrix values in the region
Implementation
Float64List integrateRegion(List<Float64List> matrix, int startRow,
int endRow, int startCol, int endCol) {
Float64List submatrixAs1D =
getSubmatrixAs1D(matrix, startRow, endRow, startCol, endCol);
double sumAll = 0.0, sumPos = 0.0, sumNeg = 0.0;
submatrixAs1D.forEach((double matrixValue) {
sumAll += matrixValue;
if (matrixValue > 0) sumPos += matrixValue;
if (matrixValue < 0) sumNeg += matrixValue;
});
return new Float64List.fromList([sumAll, sumPos, sumNeg]);
}