当前位置: 首页>>代码示例>>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;未经允许,请勿转载。