use of org.apache.sysml.runtime.functionobjects.KahanFunction in project incubator-systemml by apache.
the class SpoofCellwise method executeDenseAggSum.
private double executeDenseAggSum(double[] a, SideInput[] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) throws DMLRuntimeException {
KahanFunction kplus = (KahanFunction) getAggFunction();
KahanObject kbuff = new KahanObject(0, 0);
for (int i = rl, ix = rl * n; i < ru; i++) for (int j = 0; j < n; j++, ix++) {
double aval = (a != null) ? a[ix] : 0;
if (aval != 0 || !sparseSafe)
kplus.execute2(kbuff, genexec(aval, b, scalars, m, n, i, j));
}
return kbuff._sum;
}
use of org.apache.sysml.runtime.functionobjects.KahanFunction in project incubator-systemml by apache.
the class SpoofCellwise method executeDenseRowAggSum.
private long executeDenseRowAggSum(double[] a, SideInput[] b, double[] scalars, double[] c, int m, int n, boolean sparseSafe, int rl, int ru) throws DMLRuntimeException {
KahanFunction kplus = (KahanFunction) getAggFunction();
KahanObject kbuff = new KahanObject(0, 0);
long lnnz = 0;
for (int i = rl, ix = rl * n; i < ru; i++) {
kbuff.set(0, 0);
for (int j = 0; j < n; j++, ix++) {
double aval = (a != null) ? a[ix] : 0;
if (aval != 0 || !sparseSafe)
kplus.execute2(kbuff, genexec(aval, b, scalars, m, n, i, j));
}
lnnz += ((c[i] = kbuff._sum) != 0) ? 1 : 0;
}
return lnnz;
}
use of org.apache.sysml.runtime.functionobjects.KahanFunction in project incubator-systemml by apache.
the class SpoofCellwise method executeDenseAggSum.
private double executeDenseAggSum(DenseBlock a, SideInput[] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) {
KahanFunction kplus = (KahanFunction) getAggFunction();
KahanObject kbuff = new KahanObject(0, 0);
if (a == null && !sparseSafe) {
for (int i = rl; i < ru; i++) for (int j = 0; j < n; j++) kplus.execute2(kbuff, genexec(0, b, scalars, m, n, i, j));
} else if (a != null) {
for (int i = rl; i < ru; i++) {
double[] avals = a.values(i);
int aix = a.pos(i);
for (int j = 0; j < n; j++) {
double aval = avals[aix + j];
if (aval != 0 || !sparseSafe)
kplus.execute2(kbuff, genexec(aval, b, scalars, m, n, i, j));
}
}
}
return kbuff._sum;
}
use of org.apache.sysml.runtime.functionobjects.KahanFunction in project incubator-systemml by apache.
the class SpoofCellwise method executeCompressedColAggSum.
private long executeCompressedColAggSum(CompressedMatrixBlock a, SideInput[] b, double[] scalars, double[] c, int m, int n, boolean sparseSafe, int rl, int ru) {
KahanFunction kplus = (KahanFunction) getAggFunction();
KahanObject kbuff = new KahanObject(0, 0);
double[] corr = new double[n];
Iterator<IJV> iter = a.getIterator(rl, ru, !sparseSafe);
while (iter.hasNext()) {
IJV cell = iter.next();
double val = genexec(cell.getV(), b, scalars, m, n, cell.getI(), cell.getJ());
kbuff.set(c[cell.getJ()], corr[cell.getJ()]);
kplus.execute2(kbuff, val);
c[cell.getJ()] = kbuff._sum;
corr[cell.getJ()] = kbuff._correction;
}
return -1;
}
use of org.apache.sysml.runtime.functionobjects.KahanFunction in project incubator-systemml by apache.
the class SpoofCellwise method executeDenseRowAggSum.
private long executeDenseRowAggSum(DenseBlock a, SideInput[] b, double[] scalars, DenseBlock c, int m, int n, boolean sparseSafe, int rl, int ru) {
// note: output always single block
double[] lc = c.valuesAt(0);
KahanFunction kplus = (KahanFunction) getAggFunction();
KahanObject kbuff = new KahanObject(0, 0);
long lnnz = 0;
if (a == null && !sparseSafe) {
for (int i = rl; i < ru; i++) {
kbuff.set(0, 0);
for (int j = 0; j < n; j++) kplus.execute2(kbuff, genexec(0, b, scalars, m, n, i, j));
lnnz += ((lc[i] = kbuff._sum) != 0) ? 1 : 0;
}
} else if (a != null) {
for (int i = rl; i < ru; i++) {
kbuff.set(0, 0);
double[] avals = a.values(i);
int aix = a.pos(i);
for (int j = 0; j < n; j++) {
double aval = avals[aix + j];
if (aval != 0 || !sparseSafe)
kplus.execute2(kbuff, genexec(aval, b, scalars, m, n, i, j));
}
lnnz += ((lc[i] = kbuff._sum) != 0) ? 1 : 0;
}
}
return lnnz;
}
Aggregations