本文整理汇总了Java中java.nio.DoubleBuffer.put方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleBuffer.put方法的具体用法?Java DoubleBuffer.put怎么用?Java DoubleBuffer.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.nio.DoubleBuffer
的用法示例。
在下文中一共展示了DoubleBuffer.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doUpdate
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
@Override
protected void doUpdate(ServerDenseDoubleRow[] rows, double[] scalars) {
Random rand = new Random(System.currentTimeMillis());
try {
rows[0].getLock().writeLock().lock();
double min = scalars[0];
double max = scalars[1];
double factor = max - min;
DoubleBuffer data = rows[0].getData();
int size = rows[0].size();
for (int i = 0; i < size; i++) {
data.put(i, factor * rand.nextDouble() + min);
}
} finally {
rows[0].getLock().writeLock().unlock();
}
}
示例2: doUpdate
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
@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();
}
}
示例3: doUpdate
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
@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.ceil(from.get(i)));
}
} finally {
rows[1].getLock().writeLock().unlock();
}
}
示例4: doubleToByteArray
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
public static byte[] doubleToByteArray(Double inDouble) {
byte[] bArray = new byte[8];
ByteBuffer bBuffer = ByteBuffer.wrap(bArray);
DoubleBuffer lBuffer = bBuffer.asDoubleBuffer();
lBuffer.put(inDouble);
return bArray;
}
示例5: doUpdate
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
@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, Math.pow(from.get(i), value));
}
} finally {
rows[1].getLock().writeLock().unlock();
}
}
示例6: doUpdate
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
@Override
protected void doUpdate(ServerDenseDoubleRow row, double[] delta) {
try {
row.getLock().writeLock().lock();
DoubleBuffer data = row.getData();
int size = row.size();
for (int i = 0; i < size; i++) {
data.put(i, data.get(i) + delta[i]);
}
} finally {
row.getLock().writeLock().unlock();
}
}
示例7: fillBuffer
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
@Override
public void fillBuffer(DoubleBuffer buffer, int timeSeriesOffset) {
Objects.requireNonNull(buffer);
int k = 0;
for (int i = 0; i < stepValues.length; i++) {
double value = stepValues[i];
for (int j = 0; j < stepLengths[i]; j++) {
buffer.put(timeSeriesOffset + offset + k++, value);
}
}
}
示例8: createDoubleBuffer
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
private static DoubleBuffer createDoubleBuffer(int size, double initialValue) {
DoubleBuffer doubleBuffer = createDoubleBuffer(size);
for (int i = 0; i < size; i++) {
doubleBuffer.put(initialValue);
}
return doubleBuffer;
}
示例9: createFlippedBuffer
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
public static DoubleBuffer createFlippedBuffer(double... values)
{
DoubleBuffer buffer = createDoubleBuffer(values.length);
buffer.put(values);
buffer.flip();
return buffer;
}
示例10: setTransformationMatrix
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
private void setTransformationMatrix(GeometryInfo geometryInfo, double[] transformationMatrix) {
ByteBuffer byteBuffer = ByteBuffer.allocate(16 * 8);
byteBuffer.order(ByteOrder.nativeOrder());
DoubleBuffer asDoubleBuffer = byteBuffer.asDoubleBuffer();
for (double f : transformationMatrix) {
asDoubleBuffer.put(f);
}
geometryInfo.setTransformation(byteBuffer.array());
}
示例11: doUpdate
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
@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();
}
}
}
示例12: doUpdate
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
@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();
}
}
示例13: doUpdate
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
@Override
protected void doUpdate(ServerDenseDoubleRow[] rows, double[] values) {
for (ServerDenseDoubleRow row : rows) {
int rowId = row.getRowId();
if (rowId >= row.getStartCol() && rowId < row.getEndCol()) {
try {
row.getLock().writeLock().lock();
DoubleBuffer rowData = row.getData();
rowData.put(rowId - (int)row.getStartCol(), 1);
} finally {
row.getLock().writeLock().unlock();
}
}
}
}
示例14: testGetDoubleInt
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
@Test
public void testGetDoubleInt() {
ByteBuffer bb = ByteBuffer.allocate(40);
DoubleBuffer db = bb.asDoubleBuffer();
db.put(1.1d);
db.put(2.2d);
db.put(3.3d);
db.put(4.4d);
db.put(5.5d);
byte[] bytes = bb.array();
ByteSource bs = createByteSource(bytes);
bs.position(3);
double d = bs.getDouble(0);
assertEquals(1.1d, d, 0.0001);
assertEquals(3, bs.position());
d = bs.getDouble(8);
assertEquals(2.2d, d, 0.0001);
assertEquals(3, bs.position());
d = bs.getDouble(4 * 8);
assertEquals(5.5d, d, 0.0001);
assertEquals(3, bs.position());
try {
bs.getDouble((4 * 8) + 1);
fail("expected IndexOutOfBoundsException");
} catch (IndexOutOfBoundsException expected) {
}
}
示例15: doUpdate
import java.nio.DoubleBuffer; //导入方法依赖的package包/类
@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.max(data.get(i), other[i]));
}
} finally {
row.getLock().writeLock().unlock();
}
}