K = H(S).

        Special implementation for Apple TV.
978015
def get_common_session_key(self, premaster_secret):
        
        k_1 = self.hash(premaster_secret, b'\x00\x00\x00\x00', as_bytes=True)
        k_2 = self.hash(premaster_secret, b'\x00\x00\x00\x01', as_bytes=True)
        return k_1 + k_2
505121
function(T, C, n, k) {
        var i;
        for (i = 0; i < k; i++) { C[i] = 0; }
        for (i = 0; i < n; i++) { C[T[i]]++; }
    }
32215
private void HSVtoRGB(float hue, float sat, float bri) {

        int i;
        float f;
        float p;
        float q;
        float t;
        if (sat == 0) {
            m_red = bri;
            m_green = bri;
            m_blue = bri;
            return;
        }
        hue /= 60;
        i = (int)Math.floor(hue);
        f = hue - i;
        p = bri * (1 - sat);
        q = bri * (1 - (sat * f));
        t = bri * (1 - (sat * (1 - f)));
        switch (i) {
            case 0:
                m_red = bri;
                m_green = t;
                m_blue = p;
                break;
            case 1:
                m_red = q;
                m_green = bri;
                m_blue = p;
                break;
            case 2:
                m_red = p;
                m_green = bri;
                m_blue = t;
                break;
            case 3:
                m_red = p;
                m_green = q;
                m_blue = bri;
                break;
            case 4:
                m_red = t;
                m_green = p;
                m_blue = bri;
                break;
            default: // case 5:
                m_red = bri;
                m_green = p;
                m_blue = q;
                break;
        }
    }
284761
function() {
    var b = this.buffer, o = this.offset, carry = 1;
    for (var i = o + 7; i >= o; i--) {
      var v = (b[i] ^ 0xff) + carry;
      b[i] = v & 0xff;
      carry = v >> 8;
    }
  }
34483
function(state,statePointer,nbr,isInv)
		{
			for (var i = 0; i < nbr; i++)
			{
				if(isInv)
				{
					var tmp = state[statePointer + 3];
					for (var j = 3; j > 0; j--)
						state[statePointer + j] = state[statePointer + j-1];
					state[statePointer] = tmp;
				}
				else
				{
					var tmp = state[statePointer];
					for (var j = 0; j < 3; j++)
						state[statePointer + j] = state[statePointer + j+1];
					state[statePointer + 3] = tmp;
				}
			}
			return state;
		}
423540
function hm(n, v, incv, offv, tau, b, offb) {
    // Apply householder transformation b = b - tau v v' b
    // LAPACK: DLARF

    if (tau === 0.0) {
      return;
    }

    // compute v' b
    var d = b[offb + 0];
    for (var i = 1; i < n; ++i) {
      d += b[offb + i] * v[offv + incv*i];
    }

    // compute b = b - tau v v' b
    b[offb + 0] -= tau * d;
    for (var i = 1; i < n; ++i) {
      b[offb + i] -= tau * v[offv + incv*i] * d;
    }
  }
18855
function(T, SA, C, B, n, k) {
        var b, i, j;
        var c0, c1;
        /* compute SAl */
        if (C === B) { getCounts(T, C, n, k); }
        getBuckets(C, B, k, false); /* find starts of buckets */
        j = n - 1;
        b = B[c1 = T[j]];
        j--;
        SA[b++] = (T[j] < c1) ? ~j : j;
        for (i = 0; i < n; i++) {
            if ((j = SA[i]) > 0) {
                ASSERT(T[j] >= T[j+1]);
                if ((c0 = T[j]) !== c1) { B[c1] = b; b = B[c1 = c0]; }
                ASSERT(i < b);
                j--;
                SA[b++] = (T[j] < c1) ? ~j : j;
                SA[i] = 0;
            } else if (j < 0) {
                SA[i] = ~j;
            }
        }
        /* compute SAs */
        if (C === B) { getCounts(T, C, n, k); }
        getBuckets(C, B, k, 1); /* find ends of buckets */
        for (i = n-1, b = B[c1 = 0]; i >= 0; i--) {
            if ((j = SA[i]) > 0) {
                ASSERT(T[j] <= T[j+1]);
                if ((c0 = T[j]) !== c1) { B[c1] = b; b = B[c1 = c0]; }
                ASSERT(b <= i);
                j--;
                SA[--b] = (T[j] > c1) ? ~(j+1) : j;
                SA[i] = 0;
            }
        }
    }
507250
function f32(k64Cnt, x, k32 ) {

        var lB0 = b0(x)
          , lB1 = b1(x)
          , lB2 = b2(x)
          , lB3 = b3(x)
          , k0 = k32[0] || 0
          , k1 = k32[1] || 0
          , k2 = k32[2] || 0
          , k3 = k32[3] || 0
          , result = 0;

        switch (k64Cnt & 3) {
          case 1:
            result = MDS[0][P[P_01][lB0] & 0xFF ^ b0(k0)] ^
                     MDS[1][P[P_11][lB1] & 0xFF ^ b1(k0)] ^
                     MDS[2][P[P_21][lB2] & 0xFF ^ b2(k0)] ^
                     MDS[3][P[P_31][lB3] & 0xFF ^ b3(k0)];
            break;

          case 0:  // same as 4
            lB0 = P[P_04][lB0] & 0xFF ^ b0(k3);
            lB1 = P[P_14][lB1] & 0xFF ^ b1(k3);
            lB2 = P[P_24][lB2] & 0xFF ^ b2(k3);
            lB3 = P[P_34][lB3] & 0xFF ^ b3(k3);
            /* falls through */

          case 3:
            lB0 = P[P_03][lB0] & 0xFF ^ b0(k2);
            lB1 = P[P_13][lB1] & 0xFF ^ b1(k2);
            lB2 = P[P_23][lB2] & 0xFF ^ b2(k2);
            lB3 = P[P_33][lB3] & 0xFF ^ b3(k2);
            /* falls through */

          case 2:
            result = MDS[0][P[P_01][P[P_02][lB0] & 0xFF ^ b0(k1)] & 0xFF ^ b0(k0)] ^
                     MDS[1][P[P_11][P[P_12][lB1] & 0xFF ^ b1(k1)] & 0xFF ^ b1(k0)] ^
                     MDS[2][P[P_21][P[P_22][lB2] & 0xFF ^ b2(k1)] & 0xFF ^ b2(k0)] ^
                     MDS[3][P[P_31][P[P_32][lB3] & 0xFF ^ b3(k1)] & 0xFF ^ b3(k0)];
            break;

          default:
        }

        return result;
      }
1045067
private static float hue2rgb(float m1, float m2, float h) {
        if (h < 0) h += 1;
        if (h > 1) h -= 1;
        if (h * 6f < 1) return m1 + (m2 - m1) * 6f * h;
        if (h * 2f < 1) return m2;
        if (h * 3f < 2) return m1 + (m2 - m1) * (2 / 3f - h) * 6f;
        return m1;
    }
560951
def _set_K_H(self, k, h):
        ""
        self.K = k
        self.H = h
        if self.session_id == None:
            self.session_id = h
1137687
def K(self, X, X2, target):
        """"""
        self._K_computations(X, X2)
        target += self.variance*self._K_dvar
584816
function i2osp(x, len){
  const r = new Uint8Array(len);
  r.forEach( (elem, idx) => {
    const y = 0xFF & (x >> (idx*8));
    r[len - idx - 1] = y;
  });
  return r;
}
1314882
def fpbspl(t, n, k, x, l, h, hh):
    
    h[0] = 1.0
    for j in range(1, k + 1):
        hh[0:j] = h[0:j]
        h[0] = 0.0
        for i in range(j):
            li = l+i
            f = hh[i]/(t[li] - t[li - j])
            h[i] = h[i] + f*(t[li] - x)
            h[i + 1] = f*(x - t[li - j])
104285
function smix (B, Bi, r, N, V, XY) {
    var Xi = 0
    var Yi = 128 * r
    var i

    B.copy(XY, Xi, Bi, Bi + Yi)

    for (i = 0; i < N; i++) {
      XY.copy(V, i * Yi, Xi, Xi + Yi)
      blockmix_salsa8(XY, Xi, Yi, r)

      if (tickCallback) tickCallback()
    }

    for (i = 0; i < N; i++) {
      var offset = Xi + (2 * r - 1) * 64
      var j = XY.readUInt32LE(offset) & (N - 1)
      blockxor(V, j * Yi, XY, Xi, Yi)
      blockmix_salsa8(XY, Xi, Yi, r)

      if (tickCallback) tickCallback()
    }

    XY.copy(B, Bi, Xi, Xi + Yi)
  }
179914
function rgbToHsv(r, g, b) {

    r = bound01(r, 255);
    g = bound01(g, 255);
    b = bound01(b, 255);

    var max = mathMax(r, g, b), min = mathMin(r, g, b);
    var h, s, v = max;

    var d = max - min;
    s = max === 0 ? 0 : d / max;

    if(max == min) {
        h = 0; // achromatic
    }
    else {
        switch(max) {
            case r: h = (g - b) / d + (g < b ? 6 : 0); break;
            case g: h = (b - r) / d + 2; break;
            case b: h = (r - g) / d + 4; break;
        }
        h /= 6;
    }
    return { h: h, s: s, v: v };
}
452328
def funTransQuadD(k, s):
    
    sqrtk = np.sqrt(complex(k))
    a = np.cosh(sqrtk * s)
    b = np.sinh(sqrtk * s) / sqrtk
    c = sqrtk * np.sinh(sqrtk * s)
    d = np.cosh(sqrtk * s)
    return np.matrix([[a.real, b.real], [c.real, d.real]], dtype=np.double)
10190
def connect_to_apple_tv(details, loop, protocol=None, session=None):
    """"""
    service = _get_service_used_to_connect(details, protocol)

    # If no session is given, create a default one
    if session is None:
        session = ClientSession(loop=loop)

    # AirPlay service is the same for both DMAP and MRP
    airplay = _setup_airplay(loop, session, details)

    # Create correct implementation depending on protocol
    if service.protocol == PROTOCOL_DMAP:
        return DmapAppleTV(loop, session, details, airplay)

    return MrpAppleTV(loop, session, details, airplay)