use of java.nio.DoubleBuffer in project angel by Tencent.
the class Min method doProcessRow.
@Override
protected double doProcessRow(ServerDenseDoubleRow row) {
double min = Double.POSITIVE_INFINITY;
DoubleBuffer data = row.getData();
int size = row.size();
for (int i = 0; i < size; i++) {
min = Math.min(min, data.get(i));
}
return min;
}
use of java.nio.DoubleBuffer in project angel by Tencent.
the class Nnz method doProcessRow.
@Override
protected double doProcessRow(ServerDenseDoubleRow row) {
int nnz = 0;
DoubleBuffer data = row.getData();
int size = row.size();
for (int i = 0; i < size; i++) {
if (data.get(i) != 0)
nnz++;
}
return nnz;
}
use of java.nio.DoubleBuffer in project angel by Tencent.
the class Abs method doUpdate.
@Override
protected void doUpdate(ServerDenseDoubleRow[] rows) {
try {
rows[1].getLock().writeLock().lock();
DoubleBuffer from = rows[0].getData();
DoubleBuffer to = rows[1].getData();
int size = rows[0].size();
for (int i = 0; i < size; i++) {
to.put(i, Math.abs(from.get(i)));
}
} finally {
rows[1].getLock().writeLock().unlock();
}
}
use of java.nio.DoubleBuffer in project angel by Tencent.
the class Add method doUpdate.
@Override
protected void doUpdate(ServerDenseDoubleRow[] rows) {
try {
rows[2].getLock().writeLock().lock();
DoubleBuffer from1 = rows[0].getData();
DoubleBuffer from2 = rows[1].getData();
DoubleBuffer to = rows[2].getData();
int size = rows[0].size();
for (int i = 0; i < size; i++) {
to.put(i, from1.get(i) + from2.get(i));
}
} finally {
rows[2].getLock().writeLock().unlock();
}
}
use of java.nio.DoubleBuffer in project angel by Tencent.
the class AddS method doUpdate.
@Override
protected void doUpdate(ServerDenseDoubleRow[] rows, double[] scalars) {
try {
rows[1].getLock().writeLock().lock();
DoubleBuffer from = rows[0].getData();
DoubleBuffer to = rows[1].getData();
int size = rows[0].size();
for (int i = 0; i < size; i++) {
to.put(i, from.get(i) + scalars[0]);
}
} finally {
rows[1].getLock().writeLock().unlock();
}
}
Aggregations