use of org.apache.sysml.runtime.matrix.data.IJV in project incubator-systemml by apache.
the class SpoofCellwise method executeCompressedRowAggSum.
private long executeCompressedRowAggSum(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);
long lnnz = 0;
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.getI()], 0);
kplus.execute2(kbuff, val);
c[cell.getI()] = kbuff._sum;
}
for (int i = rl; i < ru; i++) lnnz += (c[i] != 0) ? 1 : 0;
return lnnz;
}
use of org.apache.sysml.runtime.matrix.data.IJV in project incubator-systemml by apache.
the class SpoofCellwise method executeCompressedAggMxx.
private double executeCompressedAggMxx(CompressedMatrixBlock a, SideInput[] b, double[] scalars, int m, int n, boolean sparseSafe, int rl, int ru) {
// safe aggregation for min/max w/ handling of zero entries
// note: sparse safe with zero value as min/max handled outside
double ret = (_aggOp == AggOp.MIN) ? Double.POSITIVE_INFINITY : Double.NEGATIVE_INFINITY;
ValueFunction vfun = getAggFunction();
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());
ret = vfun.execute(ret, val);
}
return ret;
}
use of org.apache.sysml.runtime.matrix.data.IJV in project incubator-systemml by apache.
the class SpoofMultiAggregate method executeCompressed.
private void executeCompressed(CompressedMatrixBlock a, SideInput[] b, double[] scalars, double[] c, int m, int n, int rl, int ru) {
// core compressed aggregation operation
Iterator<IJV> iter = a.getIterator(rl, ru, true);
while (iter.hasNext()) {
IJV cell = iter.next();
genexec(cell.getV(), b, scalars, c, m, n, cell.getI(), cell.getJ());
}
}
use of org.apache.sysml.runtime.matrix.data.IJV in project incubator-systemml by apache.
the class SpoofOuterProduct method executeCellwiseCompressed.
private void executeCellwiseCompressed(CompressedMatrixBlock a, DenseBlock u, DenseBlock v, SideInput[] b, double[] scalars, MatrixBlock out, int m, int n, int k, OutProdType type, int rl, int ru, int cl, int cu) {
// NOTE: we don't create sparse side inputs w/ row-major cursors because
// compressed data is access in a column-major order
double[] c = (out.getDenseBlock() != null) ? out.getDenseBlockValues() : null;
SparseBlock csblock = out.getSparseBlock();
Iterator<IJV> iter = a.getIterator(rl, ru, false);
while (iter.hasNext()) {
IJV cell = iter.next();
double[] uvals = u.values(cell.getI());
double[] vvals = v.values(cell.getJ());
int uix = u.pos(cell.getI());
int vix = v.pos(cell.getJ());
if (type == OutProdType.CELLWISE_OUTER_PRODUCT) {
if (out.isInSparseFormat()) {
csblock.allocate(cell.getI());
csblock.append(cell.getI(), cell.getJ(), genexecCellwise(cell.getV(), uvals, uix, vvals, vix, b, scalars, m, n, k, cell.getI(), cell.getJ()));
} else {
c[cell.getI() * n + cell.getJ()] = genexecCellwise(cell.getV(), uvals, uix, vvals, vix, b, scalars, m, n, k, cell.getI(), cell.getJ());
}
} else {
c[0] += genexecCellwise(cell.getV(), uvals, uix, vvals, vix, b, scalars, m, n, k, cell.getI(), cell.getJ());
}
}
}
use of org.apache.sysml.runtime.matrix.data.IJV in project incubator-systemml by apache.
the class SpoofOuterProduct method executeCompressed.
private void executeCompressed(CompressedMatrixBlock a, DenseBlock u, DenseBlock v, SideInput[] b, double[] scalars, DenseBlock c, int m, int n, int k, OutProdType type, int rl, int ru, int cl, int cu) {
// NOTE: we don't create sparse side inputs w/ row-major cursors because
// compressed data is access in a column-major order
boolean left = (_outerProductType == OutProdType.LEFT_OUTER_PRODUCT);
Iterator<IJV> iter = !left ? a.getIterator(rl, ru, false) : // cl/cu -> colgroups
a.getIterator(rl, ru, cl, cu, false);
while (iter.hasNext()) {
IJV cell = iter.next();
double[] uvals = u.values(cell.getI());
double[] vvals = v.values(cell.getJ());
double[] cvals = c.values(left ? cell.getJ() : cell.getI());
int uix = u.pos(cell.getI());
int vix = v.pos(cell.getJ());
genexecDense(cell.getV(), uvals, uix, vvals, vix, b, scalars, cvals, left ? vix : uix, m, n, k, cell.getI(), cell.getJ());
}
}
Aggregations