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