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


Java LongBuffer.allocate方法代碼示例

本文整理匯總了Java中java.nio.LongBuffer.allocate方法的典型用法代碼示例。如果您正苦於以下問題:Java LongBuffer.allocate方法的具體用法?Java LongBuffer.allocate怎麽用?Java LongBuffer.allocate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.nio.LongBuffer的用法示例。


在下文中一共展示了LongBuffer.allocate方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toLongArray

import java.nio.LongBuffer; //導入方法依賴的package包/類
static
public long[] toLongArray(Tensor tensor){
	LongBuffer longBuffer = LongBuffer.allocate(tensor.numElements());

	tensor.writeTo(longBuffer);

	return longBuffer.array();
}
 
開發者ID:jpmml,項目名稱:jpmml-tensorflow,代碼行數:9,代碼來源:TensorUtil.java

示例2: getCompressedCounts

import java.nio.LongBuffer; //導入方法依賴的package包/類
@Override
public long[] getCompressedCounts() {
    LongBuffer buf = LongBuffer.allocate(200);
    Simple64.compress(buf, counts, 0, counts.length);
    long[] r = new long[buf.position()];
    buf.flip();
    buf.get(r);
    return r;
}
 
開發者ID:tdunning,項目名稱:latency-histograms,代碼行數:10,代碼來源:ExpHistogram.java

示例3: getCompressedCounts

import java.nio.LongBuffer; //導入方法依賴的package包/類
@Override
public long[] getCompressedCounts() {
    LongBuffer buf = LongBuffer.allocate(counts.length);
    Simple64.compress(buf, counts, 0, counts.length);
    long[] r = new long[buf.position()];
    buf.flip();
    buf.get(r);
    return r;
}
 
開發者ID:tdunning,項目名稱:latency-histograms,代碼行數:10,代碼來源:FloatHistogram.java

示例4: generateLongBuffer

import java.nio.LongBuffer; //導入方法依賴的package包/類
@Generates private LongBuffer generateLongBuffer() {
  return LongBuffer.allocate(generateInt());
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:4,代碼來源:FreshValueGenerator.java

示例5: testTensorToImgReverse

import java.nio.LongBuffer; //導入方法依賴的package包/類
/** Tests the img<Type>(Tensor) functions */
@Test
public void testTensorToImgReverse() {
	final long[] shape = new long[] { 20, 10, 3 };
	final int[] mapping = new int[] { 2, 1, 0 };
	final long[] dims = new long[] { 3, 10, 20 };
	final int n = shape.length;
	final int size = 600;

	// Get some points to mark
	List<Point> points = createTestPoints(n);

	// Create Tensors of different type and convert them to images
	ByteBuffer dataByte = ByteBuffer.allocateDirect(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataByte.put(i, (byte) (int) v));
	Tensor tensorByte = Tensor.create(DataType.UINT8, shape, dataByte);
	Img<ByteType> imgByte = Tensors.imgByte(tensorByte);

	DoubleBuffer dataDouble = DoubleBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataDouble.put(i, v));
	Tensor tensorDouble = Tensor.create(shape, dataDouble);
	Img<DoubleType> imgDouble = Tensors.imgDouble(tensorDouble);

	FloatBuffer dataFloat = FloatBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataFloat.put(i, v));
	Tensor tensorFloat = Tensor.create(shape, dataFloat);
	Img<FloatType> imgFloat = Tensors.imgFloat(tensorFloat);

	IntBuffer dataInt = IntBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataInt.put(i, v));
	Tensor tensorInt = Tensor.create(shape, dataInt);
	Img<IntType> imgInt = Tensors.imgInt(tensorInt);

	LongBuffer dataLong = LongBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataLong.put(i, v));
	Tensor tensorLong = Tensor.create(shape, dataLong);
	Img<LongType> imgLong = Tensors.imgLong(tensorLong);

	// Check all created images
	checkImage(imgByte, n, dims, points);
	checkImage(imgDouble, n, dims, points);
	checkImage(imgFloat, n, dims, points);
	checkImage(imgInt, n, dims, points);
	checkImage(imgLong, n, dims, points);
}
 
開發者ID:imagej,項目名稱:imagej-tensorflow,代碼行數:46,代碼來源:TensorsTest.java

示例6: testTensorToImgDirect

import java.nio.LongBuffer; //導入方法依賴的package包/類
/** Tests the img<Type>Direct(Tensor) functions */
@Test
public void testTensorToImgDirect() {
	final long[] shape = new long[] { 20, 10, 3 };
	final int[] mapping = new int[] { 0, 1, 2 };
	final int n = shape.length;
	final int size = 600;

	// Get some points to mark
	List<Point> points = createTestPoints(n);

	// Create Tensors of different type and convert them to images
	ByteBuffer dataByte = ByteBuffer.allocateDirect(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataByte.put(i, (byte) (int) v));
	Tensor tensorByte = Tensor.create(DataType.UINT8, shape, dataByte);
	Img<ByteType> imgByte = Tensors.imgByteDirect(tensorByte);

	DoubleBuffer dataDouble = DoubleBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataDouble.put(i, v));
	Tensor tensorDouble = Tensor.create(shape, dataDouble);
	Img<DoubleType> imgDouble = Tensors.imgDoubleDirect(tensorDouble);

	FloatBuffer dataFloat = FloatBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataFloat.put(i, v));
	Tensor tensorFloat = Tensor.create(shape, dataFloat);
	Img<FloatType> imgFloat = Tensors.imgFloatDirect(tensorFloat);

	IntBuffer dataInt = IntBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataInt.put(i, v));
	Tensor tensorInt = Tensor.create(shape, dataInt);
	Img<IntType> imgInt = Tensors.imgIntDirect(tensorInt);

	LongBuffer dataLong = LongBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataLong.put(i, v));
	Tensor tensorLong = Tensor.create(shape, dataLong);
	Img<LongType> imgLong = Tensors.imgLongDirect(tensorLong);

	// Check all created images
	checkImage(imgByte, n, shape, points);
	checkImage(imgDouble, n, shape, points);
	checkImage(imgFloat, n, shape, points);
	checkImage(imgInt, n, shape, points);
	checkImage(imgLong, n, shape, points);
}
 
開發者ID:imagej,項目名稱:imagej-tensorflow,代碼行數:45,代碼來源:TensorsTest.java

示例7: testTensorToImgMapping

import java.nio.LongBuffer; //導入方法依賴的package包/類
/** Tests the img<Type>(Tensor, int[]) functions */
@Test
public void testTensorToImgMapping() {
	final long[] shape = new long[] { 3, 5, 2, 4 };
	final int[] mapping = new int[] { 1, 3, 0, 2 }; // A strange mapping
	final long[] dims = new long[] { 5, 4, 3, 2 };
	final int n = shape.length;
	final int size = 120;

	// Get some points to mark
	List<Point> points = createTestPoints(n);

	// Create Tensors of different type and convert them to images
	ByteBuffer dataByte = ByteBuffer.allocateDirect(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataByte.put(i, (byte) (int) v));
	Tensor tensorByte = Tensor.create(DataType.UINT8, shape, dataByte);
	Img<ByteType> imgByte = Tensors.imgByte(tensorByte, mapping);

	DoubleBuffer dataDouble = DoubleBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataDouble.put(i, v));
	Tensor tensorDouble = Tensor.create(shape, dataDouble);
	Img<DoubleType> imgDouble = Tensors.imgDouble(tensorDouble, mapping);

	FloatBuffer dataFloat = FloatBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataFloat.put(i, v));
	Tensor tensorFloat = Tensor.create(shape, dataFloat);
	Img<FloatType> imgFloat = Tensors.imgFloat(tensorFloat, mapping);

	IntBuffer dataInt = IntBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataInt.put(i, v));
	Tensor tensorInt = Tensor.create(shape, dataInt);
	Img<IntType> imgInt = Tensors.imgInt(tensorInt, mapping);

	LongBuffer dataLong = LongBuffer.allocate(size);
	execForPointsWithBufferIndex(shape, mapping, points, (i, v) -> dataLong.put(i, v));
	Tensor tensorLong = Tensor.create(shape, dataLong);
	Img<LongType> imgLong = Tensors.imgLong(tensorLong, mapping);

	// Check all created images
	checkImage(imgByte, n, dims, points);
	checkImage(imgDouble, n, dims, points);
	checkImage(imgFloat, n, dims, points);
	checkImage(imgInt, n, dims, points);
	checkImage(imgLong, n, dims, points);
}
 
開發者ID:imagej,項目名稱:imagej-tensorflow,代碼行數:46,代碼來源:TensorsTest.java


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