use of java.nio.DoubleBuffer in project angel by Tencent.
the class MinA method doUpdate.
@Override
protected void doUpdate(ServerDenseDoubleRow row, double[] other) {
try {
row.getLock().writeLock().lock();
DoubleBuffer data = row.getData();
int size = row.size();
for (int i = 0; i < size; i++) {
data.put(i, Math.min(data.get(i), other[i]));
}
} finally {
row.getLock().writeLock().unlock();
}
}
use of java.nio.DoubleBuffer in project angel by Tencent.
the class Mul 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 MulS method doUpdate.
@Override
protected void doUpdate(ServerDenseDoubleRow[] rows, double[] values) {
try {
rows[1].getLock().writeLock().lock();
DoubleBuffer from = rows[0].getData();
DoubleBuffer to = rows[1].getData();
double value = values[0];
int size = rows[0].size();
for (int i = 0; i < size; i++) {
to.put(i, from.get(i) * value);
}
} finally {
rows[1].getLock().writeLock().unlock();
}
}
use of java.nio.DoubleBuffer in project angel by Tencent.
the class Push method doUpdate.
@Override
protected void doUpdate(ServerDenseDoubleRow row, double[] values) {
DoubleBuffer data = row.getData();
int size = row.size();
for (int i = 0; i < size; i++) {
data.put(i, values[i]);
}
}
use of java.nio.DoubleBuffer in project angel by Tencent.
the class Random method doUpdate.
@Override
protected void doUpdate(ServerDenseDoubleRow[] rows, double[] value) {
for (ServerDenseDoubleRow row : rows) {
try {
row.getLock().writeLock().lock();
DoubleBuffer rowData = row.getData();
java.util.Random rand = new java.util.Random(row.getRowId());
for (int j = 0; j < row.size(); j++) {
rowData.put(j, rand.nextDouble());
}
} finally {
row.getLock().writeLock().unlock();
}
}
}
Aggregations