当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript uint64.Uint64类代码示例

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


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

示例1: mapMetricsToColors

export function mapMetricsToColors(
    IdMetricMap: any, metricKeyData: MetricKeyData): Map<string, Uint64> {
  let colors = ['Yellow', 'aquamarine', 'deepskyblue', 'mediumorchid'];
  let metricIteratee = function(el: ArrayLike<number>) {
    return el[1];  // metric value
  };
  let min = metricKeyData.min = minBy(IdMetricMap, metricIteratee)![1];
  let max = metricKeyData.max = maxBy(IdMetricMap, metricIteratee)![1];
  let scale = metricKeyData.chromaScale = chroma!.scale(colors).domain([min, max]);

  for (let i = 0, len = IdMetricMap.length; i < len; i++) {
    let metricArr = IdMetricMap[i];
    let metricVal = metricArr[1];
    let rgb = (scale(metricVal)).rgba();
    // convert color to 32bit little-endian value
    metricArr[1] = (rgb[3] << 24) + (rgb[2] << 16) + (rgb[1] << 8) + rgb[0];
    // make data key
    let idUint64 = new Uint64();
    idUint64.parseString(metricArr[0].toString());
    metricArr[0] = idUint64.low + ',' + idUint64.high;
    // convert val to Uint64 with rand high values
    let randHigh = Math.floor(Math.random() * Math.pow(2, 32));
    metricArr[1] = new Uint64(metricArr[1], randHigh);
  }
  metricKeyData.IDColorMap = new Map<string, Uint64>(IdMetricMap);
  return metricKeyData.IDColorMap;
}
开发者ID:janelia-flyem,项目名称:neuroglancer,代码行数:27,代码来源:metric_color_util.ts

示例2: it

 it('less', () => {
   expect(Uint64.less(new Uint64(0, 0), new Uint64(0, 1))).toBe(true);
   expect(Uint64.less(new Uint64(1, 1), new Uint64(1, 0))).toBe(false);
   expect(Uint64.less(new Uint64(1, 1), new Uint64(1, 1))).toBe(false);
   expect(Uint64.less(new Uint64(0, 1), new Uint64(1, 0))).toBe(false);
   expect(Uint64.less(new Uint64(1, 0), new Uint64(0, 1))).toBe(true);
 });
开发者ID:janelia-flyem,项目名称:neuroglancer,代码行数:7,代码来源:uint64.spec.ts

示例3: it

  it('HashSetUint64', () => {
    let ht = new HashSetUint64();
    let set = new Set<string>();

    function compareViaIterate() {
      let htValues = new Set<string>();
      for (let v of ht) {
        let s = v.toString();
        expect(htValues.has(s)).toBe(false, `Duplicate key in hash table: ${s}`);
        expect(set.has(s)).toBe(true, `Unexpected key ${s} in hash table`);
        htValues.add(s);
      }
      for (let s of set) {
        expect(htValues.has(s)).toBe(true, `Hash table is missing key ${s}`);
      }
    }

    function compareViaHas() {
      for (let s of set) {
        let k = Uint64.parseString(s);
        expect(ht.has(k)).toBe(true, `Hash table is missing key ${s}`);
      }
    }

    function compare() {
      compareViaIterate();
      compareViaHas();
    }
    let numInsertions = 100;

    function testInsert(k: Uint64) {
      let s = '' + k;
      set.add(s);
      expect(ht.has(k)).toBe(false, `Unexpected positive has result for ${[k.low, k.high]}`);
      ht.add(k);
      compare();
    }

    let empty0 = new Uint64(ht.emptyLow, ht.emptyHigh);
    testInsert(empty0);

    for (let i = 0; i < numInsertions; ++i) {
      let k: Uint64;
      let s: string;
      while (true) {
        k = Uint64.random();
        s = k.toString();
        if (!set.has(s)) {
          break;
        }
      }
      testInsert(k);
    }

    let empty1 = new Uint64(ht.emptyLow, ht.emptyHigh);
    testInsert(empty1);

  });
开发者ID:google,项目名称:neuroglancer,代码行数:58,代码来源:hash_table.spec.ts

示例4: fragmentShaderTest

    fragmentShaderTest({isPresent: 'uint', outLow: 'uint', outHigh: 'uint'}, tester => {
      let {gl, builder} = tester;
      let shaderManager = new HashMapShaderManager('h');
      shaderManager.defineShader(builder);
      builder.addUniform('highp uvec2', 'inputValue');
      builder.setFragmentMain(`
uint64_t key = unpackUint64leFromUint32(inputValue);
uint64_t value;
isPresent = uint(h_get(key, value));
outLow = value.value[0];
outHigh = value.value[1];
`);
      tester.build();
      let {shader} = tester;
      shader.bind();
      let hashTable = new HashMapUint64();
      let gpuHashTable = tester.registerDisposer(GPUHashTable.get(gl, hashTable));
      let testValues = new Array<Uint64>();
      while (testValues.length < COUNT) {
        let x = Uint64.random();
        if (hashTable.has(x)) {
          continue;
        }
        testValues.push(x);
        hashTable.set(x, Uint64.random());
      }
      let notPresentValues = new Array<Uint64>();
      notPresentValues.push(new Uint64(hashTable.emptyLow, hashTable.emptyHigh));
      while (notPresentValues.length < COUNT) {
        let x = Uint64.random();
        if (hashTable.has(x)) {
          continue;
        }
        notPresentValues.push(x);
      }
      function checkPresent(x: Uint64) {
        gl.uniform2ui(shader.uniform('inputValue'), x.low, x.high);
        shaderManager.enable(gl, shader, gpuHashTable);
        tester.execute();
        const {values} = tester;
        let expectedValue = new Uint64();
        let expectedHas = hashTable.get(x, expectedValue);
        const has = values.isPresent === 1;
        expect(has).toBe(expectedHas, `x=${x}`);
        if (has) {
          expect(values.outLow).toBe(expectedValue.low, `x=${x}, low`);
          expect(values.outHigh).toBe(expectedValue.high, `x=${x}, high`);
        }
      }
      testValues.forEach((x, i) => {
        expect(hashTable.has(x)).toBe(true, `cpu: i = ${i}, x = ${x}`);
        checkPresent(x);
      });
      notPresentValues.forEach(x => {
        checkPresent(x);
      });
    });
开发者ID:google,项目名称:neuroglancer,代码行数:57,代码来源:shader.spec.ts

示例5: compareViaGet

 function compareViaGet() {
   let value = new Uint64();
   for (let [s, expectedValue] of map) {
     let key = Uint64.parseString(s);
     let has = ht.get(key, value);
     expect(has && Uint64.equal(value, expectedValue))
         .toBe(
             true,
             `Hash table maps ${key} -> ${has ? value : undefined} rather than -> ${expectedValue}`);
   }
 }
开发者ID:janelia-flyem,项目名称:neuroglancer,代码行数:11,代码来源:hash_table.spec.ts

示例6: fragmentShaderTest

    fragmentShaderTest(3, tester => {
      const shaderManager = new SegmentColorShaderManager('getColor');
      let {gl, builder} = tester;
      shaderManager.defineShader(builder);
      builder.addUniform('highp vec4', 'inputValue', 2);
      const colorHash = SegmentColorHash.getDefault();
      builder.addOutputBuffer('vec4', 'v4f_fragData0', 0);
      builder.addOutputBuffer('vec4', 'v4f_fragData1', 1);
      builder.addOutputBuffer('vec4', 'v4f_fragData2', 2);
      builder.setFragmentMain(`
uint64_t x;
x.low = inputValue[0];
x.high = inputValue[1];

highp vec3 color = getColor(x);
v4f_fragData0 = packFloatIntoVec4(color.x);
v4f_fragData1 = packFloatIntoVec4(color.y);
v4f_fragData2 = packFloatIntoVec4(color.z);
`);
      tester.build();
      let {shader} = tester;
      shader.bind();
      shaderManager.enable(gl, shader, colorHash);

      function testValue(x: Uint64) {
        let temp = new Uint32Array(2);
        temp[0] = x.low;
        temp[1] = x.high;
        let inputValue = encodeBytesToFloat32(temp);
        gl.uniform4fv(shader.uniform('inputValue'), inputValue);
        tester.execute();

        let actual = new Float32Array(3);
        for (let i = 0; i < 3; ++i) {
          actual[i] = tester.readFloat(i);
        }

        let expected = new Float32Array(3);
        colorHash.compute(expected, x);

        expect(actual).toEqual(expected, `x = ${x}`);
      }

      testValue(Uint64.parseString('0'));
      testValue(Uint64.parseString('8'));
      const COUNT = 100;
      for (let iter = 0; iter < COUNT; ++iter) {
        let x = Uint64.random();
        testValue(x);
      }
    });
开发者ID:stephenplaza,项目名称:neuroglancer,代码行数:51,代码来源:segment_color.spec.ts


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