This function shows very complex chain of conversions in action.

    LCHab to LCHuv involves four different calculations, making this the
    conversion requiring the most steps.
559239
def example_lchab_to_lchuv():
    

    print("=== Complex Example: LCHab->LCHuv ===")
    # Instantiate an LCHab color object with the given values.
    lchab = LCHabColor(0.903, 16.447, 352.252)
    # Show a string representation.
    print(lchab)
    # Convert to LCHuv.
    lchuv = convert_color(lchab, LCHuvColor)
    print(lchuv)
    print("=== End Example ===\n")
26271
def to_haab(jd):
    ''''''
    # Number of days since the start of the long count
    lcount = trunc(jd) + 0.5 - EPOCH
    # Long Count begins 348 days after the start of the cycle
    day = (lcount + 348) % 365

    count = day % 20
    month = trunc(day / 20)

    return int(count), HAAB_MONTHS[month]
31915
def mix_columns(state):
    
    state = state.reshape(4, 4, 8)
    return fcat(
        multiply(MA, state[0]),
        multiply(MA, state[1]),
        multiply(MA, state[2]),
        multiply(MA, state[3]),
    )
233763
def dopri853core(n, func, x, t, hmax, h, rtol, atol, nmax, safe, beta, fac1, fac2, pos_neg, args):
    
    # array to store the result
    result = np.zeros((len(t), n))

    # initial preparations
    facold = 1.0e-4
    expo1 = 1.0 / 8.0 - beta * 0.2
    facc1 = 1.0 / fac1
    facc2 = 1.0 / fac2

    k1 = np.array(func(x, t[0], *args))
    hmax = np.fabs(hmax)
    iord = 8

    if h == 0.0:  # estimate initial time step
        h, k1, k2, k3 = hinit(func, x, t, pos_neg, k1, iord, hmax, rtol, atol, args)

    reject = 0
    t_current = 0.  # store current integration time internally (not the current time wanted by user!!)
    t_old = 0.
    finished_user_t_ii = 0  # times indices wanted by user

    result[0, :] = x

    # basic integration step
    while finished_user_t_ii < len(t) - 1:  # check if the current computed time indices less than total inices needed
        # keep time step not too small
        h = pos_neg * np.max([np.fabs(h), 1e3 * uround])

        # the twelve stages
        xx1 = x + h * a21 * k1
        k2 = np.array(func(xx1, t_current + c2 * h, *args))

        xx1 = x + h * (a31 * k1 + a32 * k2)
        k3 = np.array(func(xx1, t_current + c3 * h, *args))

        xx1 = x + h * (a41 * k1 + a43 * k3)
        k4 = np.array(func(xx1, t_current + c4 * h, *args))

        xx1 = x + h * (a51 * k1 + a53 * k3 + a54 * k4)
        k5 = np.array(func(xx1, t_current + c5 * h, *args))

        xx1 = x + h * (a61 * k1 + a64 * k4 + a65 * k5)
        k6 = np.array(func(xx1, t_current + c6 * h, *args))

        xx1 = x + h * (a71 * k1 + a74 * k4 + a75 * k5 + a76 * k6)
        k7 = np.array(func(xx1, t_current + c7 * h, *args))

        xx1 = x + h * (a81 * k1 + a84 * k4 + a85 * k5 + a86 * k6 + a87 * k7)
        k8 = np.array(func(xx1, t_current + c8 * h, *args))

        xx1 = x + h * (a91 * k1 + a94 * k4 + a95 * k5 + a96 * k6 + a97 * k7 + a98 * k8)
        k9 = np.array(func(xx1, t_current + c9 * h, *args))

        xx1 = x + h * (a101 * k1 + a104 * k4 + a105 * k5 + a106 * k6 + a107 * k7 + a108 * k8 + a109 * k9)
        k10 = np.array(func(xx1, t_current + c10 * h, *args))

        xx1 = x + h * (a111 * k1 + a114 * k4 + a115 * k5 + a116 * k6 + a117 * k7 + a118 * k8 + a119 * k9 + a1110 * k10)
        k2 = np.array(func(xx1, t_current + c11 * h, *args))

        xx1 = x + h * (
                a121 * k1 + a124 * k4 + a125 * k5 + a126 * k6 + a127 * k7 + a128 * k8 + a129 * k9 + a1210 * k10 + a1211 * k2)

        t_old_older = np.copy(t_old)
        t_old = np.copy(t_current)
        t_current += h

        k3 = np.array(func(xx1, t_current, *args))

        k4 = b1 * k1 + b6 * k6 + b7 * k7 + b8 * k8 + b9 * k9 + b10 * k10 + b11 * k2 + b12 * k3
        k5 = x + h * k4

        # error estimation
        sk = atol + rtol * np.max([np.fabs(x), np.fabs(k5)], axis=0)
        erri = k4 - bhh1 * k1 - bhh2 * k9 - bhh3 * k3
        err2 = np.sum(np.square(erri / sk), axis=0)
        erri = er1 * k1 + er6 * k6 + er7 * k7 + er8 * k8 + er9 * k9 + er10 * k10 + er11 * k2 + er12 * k3
        err = np.sum(np.square(erri / sk), axis=0)

        deno = err + 0.01 * err2
        deno = 1.0 if deno <= 0.0 else deno
        err = np.fabs(h) * err * np.sqrt(1.0 / (deno * n))

        # computation of hnew
        fac11 = np.power(err, expo1)

        # Lund-stabilization
        fac = fac11 / pow(facold, beta)

        # we require fac1 <= hnew / h <= fac2
        fac = np.max([facc2, np.min([facc1, fac / safe])])
        hnew = h / fac

        if err <= 1.0:
            # step accepted
            facold = np.max([err, 1.0e-4])
            k4 = np.array(func(k5, t_current, *args))

            # final preparation for dense output
            rcont1 = np.copy(x)
            xdiff = k5 - x
            rcont2 = xdiff
            bspl = h * k1 - xdiff
            rcont3 = np.copy(bspl)
            rcont4 = xdiff - h * k4 - bspl
            rcont5 = d41 * k1 + d46 * k6 + d47 * k7 + d48 * k8 + d49 * k9 + d410 * k10 + d411 * k2 + d412 * k3
            rcont6 = d51 * k1 + d56 * k6 + d57 * k7 + d58 * k8 + d59 * k9 + d510 * k10 + d511 * k2 + d512 * k3
            rcont7 = d61 * k1 + d66 * k6 + d67 * k7 + d68 * k8 + d69 * k9 + d610 * k10 + d611 * k2 + d612 * k3
            rcont8 = d71 * k1 + d76 * k6 + d77 * k7 + d78 * k8 + d79 * k9 + d710 * k10 + d711 * k2 + d712 * k3

            # the next three function evaluations
            xx1 = x + h * (
                    a141 * k1 + a147 * k7 + a148 * k8 + a149 * k9 + a1410 * k10 + a1411 * k2 + a1412 * k3 + a1413 * k4)
            k10 = np.array(func(xx1, t_old + c14 * h, *args))
            xx1 = x + h * (
                    a151 * k1 + a156 * k6 + a157 * k7 + a158 * k8 + a1511 * k2 + a1512 * k3 + a1513 * k4 + a1514 * k10)
            k2 = np.array(func(xx1, t_old + c15 * h, *args))
            xx1 = x + h * (
                    a161 * k1 + a166 * k6 + a167 * k7 + a168 * k8 + a169 * k9 + a1613 * k4 + a1614 * k10 + a1615 * k2)
            k3 = np.array(func(xx1, t_old + c16 * h, *args))

            # final preparation
            rcont5 = h * (rcont5 + d413 * k4 + d414 * k10 + d415 * k2 + d416 * k3)
            rcont6 = h * (rcont6 + d513 * k4 + d514 * k10 + d515 * k2 + d516 * k3)
            rcont7 = h * (rcont7 + d613 * k4 + d614 * k10 + d615 * k2 + d616 * k3)
            rcont8 = h * (rcont8 + d713 * k4 + d714 * k10 + d715 * k2 + d716 * k3)

            k1 = np.copy(k4)
            x = np.copy(k5)

            # loop for dense output in this time slot
            while (finished_user_t_ii < len(t) - 1) and (pos_neg * t[finished_user_t_ii + 1] < pos_neg * t_current):
                result[finished_user_t_ii + 1, :] = dense_output(t[finished_user_t_ii + 1], t_old, h,
                                                                 [rcont1, rcont2, rcont3, rcont4, rcont5, rcont6,
                                                                  rcont7,
                                                                  rcont8])
                finished_user_t_ii += 1

            if np.fabs(hnew) > hmax:
                hnew = pos_neg * hmax
            if reject:
                hnew = pos_neg * np.min([np.fabs(hnew), np.fabs(h)])

            reject = 0
        else:
            # step rejected since error too big
            hnew = h / np.min([facc1, fac11 / safe])
            reject = 1

            # reverse time increment since error rejected
            t_current = np.copy(t_old)
            t_old = np.copy(t_old_older)

        h = np.copy(hnew)  # current h

    return result
1357205
private static float hslConvert(float t1, float t2, float hue) {
		float value;
		if (hue < 0) {
			hue += 6;
		}
		if (hue >= 6) {
			hue -= 6;
		}
		if (hue < 1) {
			value = (t2 - t1) * hue + t1;
		} else if (hue < 3) {
			value = t2;
		} else if (hue < 4) {
			value = (t2 - t1) * (4 - hue) + t1;
		} else {
			value = t1;
		}
		return value;
	}
198973
def inv_mix_columns(state):
    
    state = state.reshape(4, 4, 8)
    return fcat(
        multiply(IMA, state[0]),
        multiply(IMA, state[1]),
        multiply(IMA, state[2]),
        multiply(IMA, state[3]),
    )
671689
public static void multTransAB(DMatrixSparseCSC A , DMatrixRMaj B , DMatrixRMaj C )
    {
        if( A.numRows != B.numCols )
            throw new MatrixDimensionException("Inconsistent matrix shapes. "+stringShapes(A,B));
        C.reshape(A.numCols,B.numRows);

        ImplSparseSparseMult_DSCC.multTransAB(A,B,C);
    }
958879
public static void rgbToYCbCr( int r , int g , int b , byte yuv[] ) {
		// multiply coefficients in book by 1024, which is 2^10
		yuv[0] = (byte)((( 187*r + 629*g + 63*b ) >> 10) + 16);
		yuv[1] = (byte)(((-103*r - 346*g + 450*b) >> 10) + 128);
		yuv[2] = (byte)((( 450*r - 409*g - 41*b ) >> 10) + 128);
	}
748162
private void accum_all2(Chunk chks[], Chunk wrks, int nh[], int[] rows) {
      final DHistogram hcs[][] = _hcs;
      // Local temp arrays, no atomic updates.
      int    bins[] = new int   [nbins];
      double sums[] = new double[nbins];
      double ssqs[] = new double[nbins];
      // For All Columns
      for( int c=0; c<_ncols; c++) { // for all columns
        Chunk chk = chks[c];
        // For All NIDs
        for( int n=0; n<hcs.length; n++ ) {
          final DRealHistogram rh = ((DRealHistogram)hcs[n][c]);
          if( rh==null ) continue; // Ignore untracked columns in this split
          final int lo = n==0 ? 0 : nh[n-1];
          final int hi = nh[n];
          float min = rh._min2;
          float max = rh._maxIn;
          // While most of the time we are limited to nbins, we allow more bins
          // in a few cases (top-level splits have few total bins across all
          // the (few) splits) so it's safe to bin more; also categoricals want
          // to split one bin-per-level no matter how many levels).
          if( rh._bins.length >= bins.length ) { // Grow bins if needed
            bins = new int   [rh._bins.length];
            sums = new double[rh._bins.length];
            ssqs = new double[rh._bins.length];
          }

          // Gather all the data for this set of rows, for 1 column and 1 split/NID
          // Gather min/max, sums and sum-squares.
          for( int xrow=lo; xrow<hi; xrow++ ) {
            int row = rows[xrow];
            float col_data = (float)chk.at0(row);
            if( col_data < min ) min = col_data;
            if( col_data > max ) max = col_data;
            int b = rh.bin(col_data); // Compute bin# via linear interpolation
            bins[b]++;                // Bump count in bin
            double resp = wrks.at0(row);
            sums[b] += resp;
            ssqs[b] += resp*resp;
          }

          // Add all the data into the Histogram (atomically add)
          rh.setMin(min);       // Track actual lower/upper bound per-bin
          rh.setMax(max);
          for( int b=0; b<rh._bins.length; b++ ) { // Bump counts in bins
            if( bins[b] != 0 ) { Utils.AtomicIntArray.add(rh._bins,b,bins[b]); bins[b]=0; }
            if( ssqs[b] != 0 ) { rh.incr1(b,sums[b],ssqs[b]); sums[b]=ssqs[b]=0; }
          }
        }
      }
    }
724417
def build_hmaps(hcurves_by_kind, slice_, imtls, poes, monitor):
    
    dic = {}
    for kind, hcurves in hcurves_by_kind.items():
        dic[kind] = calc.make_hmap_array(hcurves, imtls, poes, len(hcurves))
    return dic, slice_
460494
function bnpLShiftTo(n, r) {
  var bs = n % this.DB;
  var cbs = this.DB - bs;
  var bm = (1 << cbs) - 1;
  var ds = Math.floor(n / this.DB), c = this.s << bs & this.DM, i;
  for (i = this.t - 1; i >= 0; --i) {
    r[i + ds + 1] = this[i] >> cbs | c;
    c = (this[i] & bm) << bs;
  }
  for (i = ds - 1; i >= 0; --i)
    r[i] = 0;
  r[ds] = c;
  r.t = this.t + ds + 1;
  r.s = this.s;
  r.clamp();
}
641484
def _loh_to_vcf(cur):
    
    cn = int(float(cur["C"]))
    minor_cn = int(float(cur["M"]))
    if cur["type"].find("LOH"):
        svtype = "LOH"
    elif cn > 2:
        svtype = "DUP"
    elif cn < 1:
        svtype = "DEL"
    else:
        svtype = None
    if svtype:
        info = ["SVTYPE=%s" % svtype, "END=%s" % cur["end"],
                "SVLEN=%s" % (int(cur["end"]) - int(cur["start"])),
                "CN=%s" % cn, "MajorCN=%s" % (cn - minor_cn), "MinorCN=%s" % minor_cn]
        return [cur["chr"], cur["start"], ".", "N", "<%s>" % svtype, ".", ".",
                ";".join(info), "GT", "0/1"]
866810
private int mulsubLong(int[] q, int dh, int dl, int x, int offset) {
        long xLong = x & LONG_MASK;
        offset += 2;
        long product = (dl & LONG_MASK) * xLong;
        long difference = q[offset] - product;
        q[offset--] = (int)difference;
        long carry = (product >>> 32)
                 + (((difference & LONG_MASK) >
                     (((~(int)product) & LONG_MASK))) ? 1:0);
        product = (dh & LONG_MASK) * xLong + carry;
        difference = q[offset] - product;
        q[offset--] = (int)difference;
        carry = (product >>> 32)
                 + (((difference & LONG_MASK) >
                     (((~(int)product) & LONG_MASK))) ? 1:0);
        return (int)carry;
    }
958157
public static int cusolverRfBatchSolve(
        cusolverRfHandle handle, 
        Pointer P, 
        Pointer Q, 
        int nrhs, //only nrhs=1 is supported
        Pointer Temp, //of size 2*batchSize*(n*nrhs)
        int ldt, //only ldt=n is supported
        /** Input/Output (in the device memory) */
        Pointer XF_array, 
        /** Input */
        int ldxf)
    {
        return checkResult(cusolverRfBatchSolveNative(handle, P, Q, nrhs, Temp, ldt, XF_array, ldxf));
    }
796257
public static void multiplyRealComplex( GrayF32 realA ,
											InterleavedF32 complexB , InterleavedF32 complexC ) {

		checkImageArguments(realA,complexB);

		InputSanityCheck.checkSameShape( complexB,complexC);

		for( int y = 0; y < realA.height; y++ ) {

			int indexA = realA.startIndex + y*realA.stride;
			int indexB = complexB.startIndex + y*complexB.stride;
			int indexC = complexC.startIndex + y*complexC.stride;

			for( int x = 0; x < realA.width; x++, indexA++ , indexB += 2  ,indexC += 2 ) {

				float real = realA.data[indexA];
				float realB = complexB.data[indexB];
				float imgB = complexB.data[indexB+1];

				complexC.data[indexC] = real*realB;
				complexC.data[indexC+1] = real*imgB;
			}
		}
	}
576735
function(fromNumAndIns, toNumAndIns, ss) {
    // FIXME: when the chain numbers are completely ordered, perform binary 
    // search to identify range of residues to assign secondary structure to.
    var from = rnumInsCodeHash(fromNumAndIns[0], fromNumAndIns[1]);
    var to = rnumInsCodeHash(toNumAndIns[0], toNumAndIns[1]);
    for (var i = 1; i < this._residues.length-1; ++i) {
      var res = this._residues[i];
      // FIXME: we currently don't set the secondary structure of the last 
      // residue of helices and sheets. that takes care of better transitions 
      // between coils and helices. ideally, this should be done in the 
      // cartoon renderer, NOT in this function.
      var combined = rnumInsCodeHash(res.num(), res.insCode());
      if (combined <  from || combined >= to) {
        continue;
      }
      res.setSS(ss);
    }
  }
34046
public void mul(Complex c) {
        double newreal = real * c.real - imag * c.imag;
        double newimag = real * c.imag + imag * c.real;
        real = newreal;
        imag = newimag;
    }