本文整理汇总了TypeScript中neuroglancer/util/random.getRandomValues函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getRandomValues函数的具体用法?TypeScript getRandomValues怎么用?TypeScript getRandomValues使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getRandomValues函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: fragmentShaderTest
fragmentShaderTest(1, tester => {
let {gl, builder} = tester;
builder.addFragmentCode(glsl_addUint32);
builder.addUniform('highp vec4', 'uValue1');
builder.addUniform('highp vec4', 'uValue2');
builder.addOutputBuffer('vec4', 'v4f_fragData0', 0);
builder.setFragmentMain(`
uint32_t a, b; a.value = uValue1; b.value = uValue2;
v4f_fragData0 = add(a, b).value;
`);
tester.build();
let {shader} = tester;
shader.bind();
function testPair(a: number, b: number) {
let result = (a + b) >>> 0;
gl.uniform4fv(shader.uniform('uValue1'), setVec4FromUint32(vec4.create(), a));
gl.uniform4fv(shader.uniform('uValue2'), setVec4FromUint32(vec4.create(), b));
tester.execute();
let value = tester.readUint32();
expect(value).toEqual(result, `${a} + ${b}`);
}
function testPairs(values: Uint32Array) {
for (let i = 0; i < values.length; i += 2) {
testPair(values[i], values[i + 1]);
}
}
testPairs(Uint32Array.of(0, 1, 3, 2, 3, 17));
const count = 50;
testPairs(getRandomValues(new Uint32Array(count * 2)));
});
示例2: describe
describe('random values', () => {
for (let volumeSize of [vec4.fromValues(64, 64, 64, 1), vec4.fromValues(36, 36, 36, 1), ]) {
const numElements = prod4(volumeSize);
let rawData = new Uint32Array(numElements * 2);
getRandomValues(rawData);
runTest(DataType.UINT64, volumeSize, rawData, vec888);
}
for (let volumeSize of [vec4.fromValues(13, 17, 23, 1), vec4.fromValues(13, 17, 23, 2), ]) {
const numElements = prod4(volumeSize);
{
let rawData = new Uint32Array(numElements * 2);
getRandomValues(rawData);
runTest(DataType.UINT64, volumeSize, rawData, vec888);
}
{
let rawData = new Uint32Array(numElements);
getRandomValues(rawData);
runTest(DataType.UINT32, volumeSize, rawData, vec888);
}
}
});
示例3: suite
suite('gpu_hash/hash_table', () => {
let ht = new HashSetUint64();
const numValues = 100;
let values = new Uint32Array(numValues * 2);
let temp = new Uint64();
getRandomValues(values);
benchmark('insert', () => {
ht.clear();
for (let i = 0, length = values.length; i < length; i += 2) {
temp.low = values[i];
temp.high = values[i + 1];
ht.add(temp);
}
});
});