當前位置: 首頁>>代碼示例>>Java>>正文


Java DoubleBuffer.put方法代碼示例

本文整理匯總了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();
  }
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:20,代碼來源:RandomUniform.java

示例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();
  }
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:14,代碼來源:MinA.java

示例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();
  }
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:15,代碼來源:Ceil.java

示例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;
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:8,代碼來源:BinUtils.java

示例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();
  }
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:16,代碼來源:Pow.java

示例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();
  }
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:14,代碼來源:Increment.java

示例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);
        }
    }
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:12,代碼來源:CompressedDoubleArrayChunk.java

示例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;
}
 
開發者ID:powsybl,項目名稱:powsybl-core,代碼行數:8,代碼來源:TimeSeriesTable.java

示例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;
}
 
開發者ID:oreonengine,項目名稱:Lwjgl3-Game-Engine-Programming-Series,代碼行數:9,代碼來源:BufferUtil.java

示例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());
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:10,代碼來源:GeometryGenerator.java

示例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();
    }
  }
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:16,代碼來源:Random.java

示例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();
  }
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:16,代碼來源:Mul.java

示例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();
      }
    }
  }
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:16,代碼來源:Eye.java

示例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) {
  }
}
 
開發者ID:ampool,項目名稱:monarch,代碼行數:28,代碼來源:ByteSourceJUnitTest.java

示例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();
  }
}
 
開發者ID:Tencent,項目名稱:angel,代碼行數:14,代碼來源:MaxA.java


注:本文中的java.nio.DoubleBuffer.put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。