use of java.nio.DoubleBuffer in project angel by Tencent.
the class RandomNormal method doUpdate.
@Override
protected void doUpdate(ServerDenseDoubleRow[] rows, double[] scalars) {
Random rand = new Random(System.currentTimeMillis());
try {
rows[0].getLock().writeLock().lock();
double mean = scalars[0];
double stdDev = scalars[1];
DoubleBuffer data = rows[0].getData();
int size = rows[0].size();
for (int i = 0; i < size; i++) {
data.put(i, stdDev * rand.nextGaussian() + mean);
}
} finally {
rows[0].getLock().writeLock().unlock();
}
}
use of java.nio.DoubleBuffer in project angel by Tencent.
the class Round 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.round(from.get(i)));
}
} finally {
rows[1].getLock().writeLock().unlock();
}
}
use of java.nio.DoubleBuffer in project angel by Tencent.
the class Sqrt 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.sqrt(from.get(i)));
}
} finally {
rows[1].getLock().writeLock().unlock();
}
}
use of java.nio.DoubleBuffer in project angel by Tencent.
the class SubS 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 Map method doUpdate.
@Override
protected void doUpdate(ServerDenseDoubleRow[] rows, Serialize func) {
MapFunc mapper = (MapFunc) func;
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, mapper.call(from.get(i)));
}
}
Aggregations