本文整理汇总了TypeScript中neuroglancer/util/uint32array_builder.ts.Uint32ArrayBuilder类的典型用法代码示例。如果您正苦于以下问题:TypeScript ts.Uint32ArrayBuilder类的具体用法?TypeScript ts.Uint32ArrayBuilder怎么用?TypeScript ts.Uint32ArrayBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ts.Uint32ArrayBuilder类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('map data with 0-bit encoded data', () => {
const input = Uint32Array.of(
4, 0, 4, 0, 4, 0, 4, 0, // block 1
3, 0, 3, 0, 3, 0, 3, 0, // block 2
3, 0, 3, 0, 3, 0, 3, 0, // block 3
4, 0, 4, 0, 4, 0, 4, 0 // block 4
);
const volumeSize = [2, 2, 4];
const blockSize = [2, 2, 1];
const output = new Uint32ArrayBuilder();
output.appendArray([1, 2, 3]);
encodeChannel(output, blockSize, input, volumeSize);
const dataMap = new Map([['4,0', new Uint64(10, 0)]]);
updateLookupTableData(output.view, dataMap, 3, blockSize, volumeSize);
expect(output.view)
.toEqual(Uint32Array.of(
1, 2, 3, // junk padding
8 | (0 << 24),
8, // header block 1(#encoding bits |(lookuptableoffset), encData offset)
10 | (0 << 24), 10, // header block 2
10 | (0 << 24), 12, // header block 3
8 | (0 << 24), 12, // header block 4
10, 0, // enc & table data for blocks 1, 4
0, 0 // enc & table data for blocks 2, 3
));
});
示例2: it
it('basic cached 2-bit', () => {
const input = Uint32Array.of(
4, 3, 5, 4, //
1, 3, 3, 3, //
3, 1, 1, 1, //
5, 5, 3, 4 //
);
const volumeSize = [2, 2, 4];
const blockSize = [2, 2, 1];
const output = new Uint32ArrayBuilder();
output.appendArray([1, 2, 3]);
encodeChannel(output, blockSize, input, volumeSize);
expect(output.view)
.toEqual(Uint32Array.of(
1, 2, 3, //
9 | (2 << 24), 8, //
13 | (1 << 24), 12, //
13 | (1 << 24), 15, //
9 | (2 << 24), 16, //
0b01100001, 3, 4, 5, //
0b1110, 1, 3, //
0b00000001, //
0b01001010 //
));
});
示例3: it
it('size mismatch 1-bit', () => {
const input = Uint32Array.of(4, 0, 3, 0, 4, 0, 3, 0);
const inputStrides = [2, 4, 8];
const blockSize = [3, 2, 1];
const actualSize = [2, 2, 1];
const output = new Uint32ArrayBuilder();
output.appendArray([1, 2, 3]);
const cache = newCache();
let [encodedBits, tableOffset] =
encodeBlock(input, 0, inputStrides, blockSize, actualSize, 3, cache, output);
expect(encodedBits).toBe(1);
expect(tableOffset).toBe(1);
expect(output.view).toEqual(Uint32Array.of(1, 2, 3, 0b001001, 3, 0, 4, 0));
expect(Array.from(cache)).toEqual([['3,0,4,0', 1]]);
});
示例4: encodeChannels
export function encodeChannels(
output: Uint32ArrayBuilder, blockSize: ArrayLike<number>, rawData: Uint32Array,
volumeSize: ArrayLike<number>, baseInputOffset: number, inputStrides: ArrayLike<number>,
encodeBlock: EncodeBlockFunction) {
let channelOffsetOutputBase = output.length;
const numChannels = volumeSize[3];
output.resize(channelOffsetOutputBase + numChannels);
for (let channel = 0; channel < numChannels; ++channel) {
output.data[channelOffsetOutputBase + channel] = output.length;
encodeChannel(output, blockSize, rawData, volumeSize, baseInputOffset + inputStrides[3] * channel, inputStrides, encodeBlock);
}
}
示例5: suite
suite('64x64x64 example', () => {
const blockSize = [8, 8, 8];
const output = new Uint32ArrayBuilder(1000000);
const volumeSize = [64, 64, 64, 1];
benchmark(`encode_uint64`, () => {
output.clear();
encodeChannelsUint64(output, blockSize, exampleChunkData64, volumeSize);
});
benchmark(`encode_uint32`, () => {
output.clear();
encodeChannelsUint32(output, blockSize, exampleChunkData32, volumeSize);
});
});