當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。