本文整理匯總了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);
}
});
});