SMix; a specific case of ROMix based on Salsa20/8
493060
def smix(B, Bi, r, N, V, X):
    """"""

    X[0:(0)+(32 * r)] = B[Bi:(Bi)+(32 * r)]

    for i in xrange(N):                                # ROMix - 2
        V[i * (32 * r):(i * (32 * r))+(32 * r)] = X[0:(0)+(32 * r)]
        blockmix_salsa8(X, 32 * r, r)                  # ROMix - 4

    for i in xrange(N):                                # ROMix - 6
        j = integerify(X, r) & (N - 1)                 # ROMix - 7
        blockxor(V, j * (32 * r), X, 0, 32 * r)        # ROMix - 8(inner)
        blockmix_salsa8(X, 32 * r, r)                  # ROMix - 9(outer)

    B[Bi:(Bi)+(32 * r)] = X[0:(0)+(32 * r)]
156481
public final void pinsrq(XMMRegister dst, Register src, Immediate imm8)
  {
    emitX86(INST_PINSRQ, dst, src, imm8);
  }
277171
def salsa20_8(B, x, src, s_start, dest, d_start):
    """"""

    # Merged blockxor for speed
    for i in xrange(16):
        x[i] = B[i] = B[i] ^ src[s_start + i]

    # This is the actual Salsa 20/8: four identical double rounds
    for i in xrange(4):
        a = (x[0]+x[12]) & 0xffffffff
        b = (x[5]+x[1]) & 0xffffffff
        x[4] ^= (a << 7) | (a >> 25)
        x[9] ^= (b << 7) | (b >> 25)
        a = (x[10]+x[6]) & 0xffffffff
        b = (x[15]+x[11]) & 0xffffffff
        x[14] ^= (a << 7) | (a >> 25)
        x[3] ^= (b << 7) | (b >> 25)
        a = (x[4]+x[0]) & 0xffffffff
        b = (x[9]+x[5]) & 0xffffffff
        x[8] ^= (a << 9) | (a >> 23)
        x[13] ^= (b << 9) | (b >> 23)
        a = (x[14]+x[10]) & 0xffffffff
        b = (x[3]+x[15]) & 0xffffffff
        x[2] ^= (a << 9) | (a >> 23)
        x[7] ^= (b << 9) | (b >> 23)
        a = (x[8]+x[4]) & 0xffffffff
        b = (x[13]+x[9]) & 0xffffffff
        x[12] ^= (a << 13) | (a >> 19)
        x[1] ^= (b << 13) | (b >> 19)
        a = (x[2]+x[14]) & 0xffffffff
        b = (x[7]+x[3]) & 0xffffffff
        x[6] ^= (a << 13) | (a >> 19)
        x[11] ^= (b << 13) | (b >> 19)
        a = (x[12]+x[8]) & 0xffffffff
        b = (x[1]+x[13]) & 0xffffffff
        x[0] ^= (a << 18) | (a >> 14)
        x[5] ^= (b << 18) | (b >> 14)
        a = (x[6]+x[2]) & 0xffffffff
        b = (x[11]+x[7]) & 0xffffffff
        x[10] ^= (a << 18) | (a >> 14)
        x[15] ^= (b << 18) | (b >> 14)
        a = (x[0]+x[3]) & 0xffffffff
        b = (x[5]+x[4]) & 0xffffffff
        x[1] ^= (a << 7) | (a >> 25)
        x[6] ^= (b << 7) | (b >> 25)
        a = (x[10]+x[9]) & 0xffffffff
        b = (x[15]+x[14]) & 0xffffffff
        x[11] ^= (a << 7) | (a >> 25)
        x[12] ^= (b << 7) | (b >> 25)
        a = (x[1]+x[0]) & 0xffffffff
        b = (x[6]+x[5]) & 0xffffffff
        x[2] ^= (a << 9) | (a >> 23)
        x[7] ^= (b << 9) | (b >> 23)
        a = (x[11]+x[10]) & 0xffffffff
        b = (x[12]+x[15]) & 0xffffffff
        x[8] ^= (a << 9) | (a >> 23)
        x[13] ^= (b << 9) | (b >> 23)
        a = (x[2]+x[1]) & 0xffffffff
        b = (x[7]+x[6]) & 0xffffffff
        x[3] ^= (a << 13) | (a >> 19)
        x[4] ^= (b << 13) | (b >> 19)
        a = (x[8]+x[11]) & 0xffffffff
        b = (x[13]+x[12]) & 0xffffffff
        x[9] ^= (a << 13) | (a >> 19)
        x[14] ^= (b << 13) | (b >> 19)
        a = (x[3]+x[2]) & 0xffffffff
        b = (x[4]+x[7]) & 0xffffffff
        x[0] ^= (a << 18) | (a >> 14)
        x[5] ^= (b << 18) | (b >> 14)
        a = (x[9]+x[8]) & 0xffffffff
        b = (x[14]+x[13]) & 0xffffffff
        x[10] ^= (a << 18) | (a >> 14)
        x[15] ^= (b << 18) | (b >> 14)

    # While we are handling the data, write it to the correct dest.
    # The latter half is still part of salsa20
    for i in xrange(16):
        dest[d_start + i] = B[i] = (x[i] + B[i]) & 0xffffffff
966088
def d2Sbus_dV2(Ybus, V, lam):
    
    n = len(V)
    Ibus = Ybus * V
    diaglam = spdiag(lam)
    diagV = spdiag(V)

    A = spmatrix(mul(lam, V), range(n), range(n))
    B = Ybus * diagV
    C = A * conj(B)
    D = Ybus.H * diagV
    E = conj(diagV) * (D * diaglam - spmatrix(D*lam, range(n), range(n)))
    F = C - A * spmatrix(conj(Ibus), range(n), range(n))
    G = spmatrix(div(matrix(1.0, (n, 1)), abs(V)), range(n), range(n))

    Gaa = E + F
    Gva = 1j * G * (E - F)
    Gav = Gva.T
    Gvv = G * (C + C.T) * G

    return Gaa, Gav, Gva, Gvv
428434
def run(align_bams, items, ref_file, assoc_files, region=None, out_file=None):
    
    paired = vcfutils.get_paired_bams(align_bams, items)
    assert paired and not paired.normal_bam, ("smCounter2 supports tumor-only variant calling: %s" %
                                              (",".join([dd.get_sample_name(d) for d in items])))
    vrs = bedutils.population_variant_regions(items)
    target = shared.subset_variant_regions(vrs, region,
                                            out_file, items=items, do_merge=True)
    out_file = out_file.replace(".vcf.gz", ".vcf")
    out_prefix = utils.splitext_plus(os.path.basename(out_file))[0]
    if not utils.file_exists(out_file) and not utils.file_exists(out_file + ".gz"):
        with file_transaction(paired.tumor_data, out_file) as tx_out_file:
            cmd = ["smCounter2", "--runPath", os.path.dirname(tx_out_file),
                   "--outPrefix", out_prefix,
                   "--bedTarget", target, "--refGenome", ref_file,
                   "--bamFile", paired.tumor_bam, "--bamType", "consensus",
                   "--nCPU", dd.get_num_cores(paired.tumor_data)]
            do.run(cmd, "smcounter2 variant calling")
            for fname in glob.glob(os.path.join(os.path.dirname(tx_out_file), "*.smCounter*")):
                shutil.move(fname, os.path.join(os.path.dirname(out_file), os.path.basename(fname)))
            utils.symlink_plus(os.path.join(os.path.dirname(out_file),
                                            "%s.smCounter.cut.vcf" % out_prefix),
                               out_file)
    return vcfutils.bgzip_and_index(out_file, paired.tumor_data["config"], remove_orig=False,
                                    prep_cmd="sed 's#FORMAT\t%s#FORMAT\t%s#' | %s" %
                                    (out_prefix, dd.get_sample_name(paired.tumor_data),
                                     vcfutils.add_contig_to_header_cl(dd.get_ref_file(paired.tumor_data), out_file)))
1177780
function( accuIndex ) {

		var stride = this.valueSize,
			buffer = this.buffer,
			offset = accuIndex * stride + stride,

			weight = this.cumulativeWeight,

			binding = this.binding;

		this.cumulativeWeight = 0;

		if ( weight < 1 ) {

			// accuN := accuN + original * ( 1 - cumulativeWeight )

			var originalValueOffset = stride * 3;

			this._mixBufferRegion(
					buffer, offset, originalValueOffset, 1 - weight, stride );

		}

		for ( var i = stride, e = stride + stride; i !== e; ++ i ) {

			if ( buffer[ i ] !== buffer[ i + stride ] ) {

				// value has changed -> update scene graph

				binding.setValue( buffer, offset );
				break;

			}

		}

	}
999180
public function main(): void
    {
        $args = getopt('t::');

        if (isset($args['t']) === false) {
            $this->showBasicExample();
            $this->showIncludedObjectsExample();
            $this->showSparseAndFieldSetsExample();
            $this->showTopLevelMetaAndLinksExample();
            $this->dynamicSchemaExample();
        } else {
            $num = $args['t'];
            $inv = empty($num) === true || is_numeric($num) === false || ctype_digit($num) == false || (int)$num <= 0;
            $num = $inv === true ? 1000 : (int)$num;

            $this->runPerformanceTestForSmallNestedResources($num);
            $this->runPerformanceTestForBigCollection($num);
        }
    }
984982
public final void pshufhw(XMMRegister dst, Mem src, Immediate imm8)
  {
    emitX86(INST_PSHUFHW, dst, src, imm8);
  }
719287
public final void pshuflw(XMMRegister dst, XMMRegister src, Immediate imm8)
  {
    emitX86(INST_PSHUFLW, dst, src, imm8);
  }
288432
private BinaryFast thinBinaryRep( BinaryFast b, int[] kernel ) {
        Point p;
        HashSet<Point> inputHashSet = new HashSet<Point>();
        int[][] pixels = b.getPixels();
        if (kernelNo0s(kernel)) {
            for( int j = 0; j < b.getHeight(); ++j ) {
                for( int i = 0; i < b.getWidth(); ++i ) {
                    if (pixels[i][j] == BinaryFast.FOREGROUND) {
                        inputHashSet.add(new Point(i, j));
                    }
                }
            }
        } else {
            Iterator<Point> it = b.getForegroundEdgePixels().iterator();
            while( it.hasNext() ) {
                inputHashSet.add(it.next());
            }
        }
        HashSet<Point> result = hitMissHashSet(b, inputHashSet, kernel);
        Iterator<Point> it = result.iterator();
        while( it.hasNext() ) {
            p = new Point(it.next());
            // make p a background pixel and update the edge sets
            b.removePixel(p);
            b.getForegroundEdgePixels().remove(p);
            b.getBackgroundEdgePixels().add(p);
            // check if new foreground pixels are exposed as edges
            for( int j = -1; j < 2; ++j ) {
                for( int k = -1; k < 2; ++k ) {
                    if (p.x + j >= 0 && p.y + k > 0 && p.x + j < b.getWidth() && p.y + k < b.getHeight()
                            && pixels[p.x + j][p.y + k] == BinaryFast.FOREGROUND) {
                        Point p2 = new Point(p.x + j, p.y + k);
                        b.getForegroundEdgePixels().add(p2);
                    }
                }
            }
        }
        return b;
    }
629072
function flushPins (callback) {
    let dLink, rLink, root
    series([
      // create a DAGLink to the node with direct pins
      cb => waterfall([
        cb => pinset.storeSet(directKeys(), cb),
        ({ node, cid }, cb) => DAGLink.create(types.direct, node.size, cid, cb),
        (link, cb) => { dLink = link; cb(null) }
      ], cb),

      // create a DAGLink to the node with recursive pins
      cb => waterfall([
        cb => pinset.storeSet(recursiveKeys(), cb),
        ({ node, cid }, cb) => DAGLink.create(types.recursive, node.size, cid, cb),
        (link, cb) => { rLink = link; cb(null) }
      ], cb),

      // the pin-set nodes link to a special 'empty' node, so make sure it exists
      cb => DAGNode.create(Buffer.alloc(0), (err, empty) => {
        if (err) { return cb(err) }
        dag.put(empty, {
          version: 0,
          hashAlg: 'sha2-256',
          format: 'dag-pb',
          preload: false
        }, cb)
      }),

      // create a root node with DAGLinks to the direct and recursive DAGs
      cb => DAGNode.create(Buffer.alloc(0), [dLink, rLink], (err, node) => {
        if (err) { return cb(err) }
        root = node
        dag.put(root, {
          version: 0,
          hashAlg: 'sha2-256',
          format: 'dag-pb',
          preload: false
        }, (err, cid) => {
          if (!err) {
            root.multihash = cid.buffer
          }
          cb(err)
        })
      }),

      // hack for CLI tests
      cb => repo.closed ? repo.open(cb) : cb(null, null),

      // save root to datastore under a consistent key
      cb => repo.datastore.put(pinDataStoreKey, root.multihash, cb)
    ], (err, res) => {
      if (err) { return callback(err) }
      self.log(`Flushed pins with root: ${root}`)
      return callback(null, root)
    })
  }
186091
def run_cortex(align_bams, items, ref_file, assoc_files, region=None,
               out_file=None):
    
    raise NotImplementedError("Cortex currently out of date and needs reworking.")
    if len(align_bams) == 1:
        align_bam = align_bams[0]
        config = items[0]["config"]
    else:
        raise NotImplementedError("Need to add multisample calling for cortex_var")
    if out_file is None:
        out_file = "%s-cortex.vcf" % os.path.splitext(align_bam)[0]
    if region is not None:
        work_dir = safe_makedir(os.path.join(os.path.dirname(out_file),
                                             region.replace(".", "_")))
    else:
        work_dir = os.path.dirname(out_file)
    if not file_exists(out_file):
        bam.index(align_bam, config)
        variant_regions = config["algorithm"].get("variant_regions", None)
        if not variant_regions:
            raise ValueError("Only support regional variant calling with cortex_var: set variant_regions")
        target_regions = subset_variant_regions(variant_regions, region, out_file)
        if os.path.isfile(target_regions):
            with open(target_regions) as in_handle:
                regional_vcfs = [_run_cortex_on_region(x.strip().split("\t")[:3], align_bam,
                                                       ref_file, work_dir, out_file, config)
                                 for x in in_handle]

            combine_file = "{0}-raw{1}".format(*os.path.splitext(out_file))
            _combine_variants(regional_vcfs, combine_file, ref_file, config)
            _select_final_variants(combine_file, out_file, config)
        else:
            vcfutils.write_empty_vcf(out_file)
    return out_file
844416
public static function run()
    {
        \Swoole\Runtime::enableCoroutine();
        self::$debug = new \swoole_atomic(0);
        self::$xdebug = false;
        self::$coverage = false;
        self::$leader = new \swoole_atomic(0);
        self::$xdebug_table = new \swoole_table(1);
        self::$xdebug_table->column('wid', \swoole_table::TYPE_INT, 8);
        self::$xdebug_table->column('cid', \swoole_table::TYPE_INT, 8);
        self::$xdebug_table->create();
        self::$startTime = date('Y-m-d H:i:s');
        self::$startMillisecond = getMillisecond();
        self::setProcessTitle(getServerName());
        $application = new Application();
        $input = new ArgvInput();
        $output = new ConsoleOutput();
        self::$io = new SymfonyStyle($input, $output);
        self::addDirCommand(SERVER_DIR, "Server", $application);
        self::addDirCommand(APP_DIR, "app", $application);
        $application->run($input, $output);
    }
979742
function crypto_stream_salsa20_xor(c,cpos,m,mpos,b,n,k) {
  var z = new Uint8Array(16), x = new Uint8Array(64);
  var u, i;
  for (i = 0; i < 16; i++) z[i] = 0;
  for (i = 0; i < 8; i++) z[i] = n[i];
  while (b >= 64) {
    crypto_core_salsa20(x,z,k,sigma);
    for (i = 0; i < 64; i++) c[cpos+i] = m[mpos+i] ^ x[i];
    u = 1;
    for (i = 8; i < 16; i++) {
      u = u + (z[i] & 0xff) | 0;
      z[i] = u & 0xff;
      u >>>= 8;
    }
    b -= 64;
    cpos += 64;
    mpos += 64;
  }
  if (b > 0) {
    crypto_core_salsa20(x,z,k,sigma);
    for (i = 0; i < b; i++) c[cpos+i] = m[mpos+i] ^ x[i];
  }
  return 0;
}
862453
public final void cmpss(XMMRegister dst, Mem src, Immediate imm8)
  {
    emitX86(INST_CMPSS, dst, src, imm8);
  }
364247
public function readByteOrder() : void
    {
        $byteOrder = $this->readUnsignedChar();

        if ($byteOrder !== WKBTools::BIG_ENDIAN && $byteOrder !== WKBTools::LITTLE_ENDIAN) {
            throw GeometryIOException::invalidWKB('unknown byte order: ' . $byteOrder);
        }

        $this->invert = ($byteOrder !== $this->machineByteOrder);
    }
1053295
def cublasZtpsv(handle, uplo, trans, diag, n, AP, x, incx):
    
    
    status = _libcublas.cublasZtpsv_v2(handle, 
                                       _CUBLAS_FILL_MODE[uplo], 
                                       _CUBLAS_OP[trans], 
                                       _CUBLAS_DIAG[diag], 
                                       n, int(AP), int(x), incx)
    cublasCheckStatus(status)