• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript uint32array_builder.Uint32ArrayBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中neuroglancer/util/uint32array_builder.Uint32ArrayBuilder的典型用法代码示例。如果您正苦于以下问题:TypeScript Uint32ArrayBuilder类的具体用法?TypeScript Uint32ArrayBuilder怎么用?TypeScript Uint32ArrayBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Uint32ArrayBuilder类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: suite

suite('compressed_segmentation', () => {
  const blockSize = [8, 8, 8];
  const output = new Uint32ArrayBuilder(1000000);
  for (let volumeSize of [   //
           [16, 16, 16, 1],  //
                             // [64, 64, 64, 1],  //
  ]) {
    const numPossibleValues = 15;
    const input = makeRandomUint64Array(prod4(volumeSize), numPossibleValues);
    benchmark(`encode_uint64 ${vec3Key(volumeSize)}`, () => {
      output.clear();
      encodeChannelsUint64(output, blockSize, input, volumeSize);
    });
  }
});
开发者ID:google,项目名称:neuroglancer,代码行数:15,代码来源:encode.benchmark.ts


示例2: writeBlock

export function writeBlock(
    output: Uint32ArrayBuilder, baseOffset: number, cache: ValueTableCache,
    numBlockElements: number, numUniqueValues: number, valuesBuffer2: Uint32Array,
    encodingBuffer: Uint32Array, indexBuffer2: Uint32Array,
    uint32sPerElement: number): [number, number] {
  let encodedBits: number;
  if (numUniqueValues === 1) {
    encodedBits = 0;
  } else {
    encodedBits = 1;
    while ((1 << encodedBits) < numUniqueValues) {
      encodedBits *= 2;
    }
  }

  let encodedSize32bits = Math.ceil(encodedBits * numBlockElements / 32);

  let encodedValueBaseOffset = output.length;
  let elementsToWrite = encodedSize32bits;

  let writeTable = false;
  let key = Array.prototype.join.call(
      valuesBuffer2.subarray(0, numUniqueValues * uint32sPerElement), ',');
  let tableOffset = cache.get(key);

  if (tableOffset === undefined) {
    writeTable = true;
    elementsToWrite += numUniqueValues * uint32sPerElement;
    tableOffset = encodedValueBaseOffset + encodedSize32bits - baseOffset;
    cache.set(key, tableOffset);
  }

  output.resize(encodedValueBaseOffset + elementsToWrite);
  let outputData = output.data;

  writeEncodedRepresentation(
      outputData, encodedValueBaseOffset, encodingBuffer, indexBuffer2, encodedBits,
      encodedSize32bits);

  // Write table
  if (writeTable) {
    let curOutputOff = encodedValueBaseOffset + encodedSize32bits;
    for (let i = 0, length = numUniqueValues * uint32sPerElement; i < length; ++i) {
      outputData[curOutputOff++] = valuesBuffer2[i];
    }
  }
  return [encodedBits, tableOffset];
}
开发者ID:google,项目名称:neuroglancer,代码行数:48,代码来源:encode_common.ts


示例3: encodeChannel

export function encodeChannel(
    output: Uint32ArrayBuilder, blockSize: ArrayLike<number>, rawData: Uint32Array,
    volumeSize: ArrayLike<number>, baseInputOffset: number, inputStrides: ArrayLike<number>,
    encodeBlock: EncodeBlockFunction) {
  // Maps a sorted list of table entries in the form <low>,<high>,<low>,<high>,... to the table
  // offset relative to baseOffset.
  let cache = newCache();
  let gridSize = new Array<number>(3);
  let blockIndexSize = BLOCK_HEADER_SIZE;
  for (let i = 0; i < 3; ++i) {
    let curGridSize = gridSize[i] = Math.ceil(volumeSize[i] / blockSize[i]);
    blockIndexSize *= curGridSize;
  }
  const gx = gridSize[0], gy = gridSize[1], gz = gridSize[2];
  const xSize = volumeSize[0], ySize = volumeSize[1], zSize = volumeSize[2];
  const xBlockSize = blockSize[0], yBlockSize = blockSize[1], zBlockSize = blockSize[2];
  const baseOffset = output.length;
  let headerOffset = baseOffset;
  const actualSize = [0, 0, 0];
  output.resize(baseOffset + blockIndexSize);
  let sx = inputStrides[0], sy = inputStrides[1], sz = inputStrides[2];
  for (let bz = 0; bz < gz; ++bz) {
    actualSize[2] = Math.min(zBlockSize, zSize - bz * zBlockSize);
    for (let by = 0; by < gy; ++by) {
      actualSize[1] = Math.min(yBlockSize, ySize - by * yBlockSize);
      for (let bx = 0; bx < gx; ++bx) {
        actualSize[0] = Math.min(xBlockSize, xSize - bx * xBlockSize);
        let inputOffset = bz * zBlockSize * sz + by * yBlockSize * sy + bx * xBlockSize * sx;
        let encodedValueBaseOffset = output.length - baseOffset;
        let [encodedBits, tableOffset] = encodeBlock(
            rawData, baseInputOffset + inputOffset, inputStrides, blockSize, actualSize, baseOffset,
            cache, output);
        let outputData = output.data;
        outputData[headerOffset++] = tableOffset | (encodedBits << 24);
        outputData[headerOffset++] = encodedValueBaseOffset;
      }
    }
  }
}
开发者ID:google,项目名称:neuroglancer,代码行数:39,代码来源:encode_common.ts


示例4: benchmark

 benchmark(`encode_uint64 ${vec3Key(volumeSize)}`, () => {
   output.clear();
   encodeChannelsUint64(output, blockSize, input, volumeSize);
 });
开发者ID:google,项目名称:neuroglancer,代码行数:4,代码来源:encode.benchmark.ts



注:本文中的neuroglancer/util/uint32array_builder.Uint32ArrayBuilder类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript uint32array_builder.ts.Uint32ArrayBuilder类代码示例发布时间:2022-05-25
下一篇:
TypeScript signal.Signal类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap