convert linear, quadratic and offset from binary to spin.
        Does no checking of vartype. Copies all of the values into new objects.
324787
def binary_to_spin(linear, quadratic, offset):
        
        h = {}
        J = {}
        linear_offset = 0.0
        quadratic_offset = 0.0

        for u, bias in iteritems(linear):
            h[u] = .5 * bias
            linear_offset += bias

        for (u, v), bias in iteritems(quadratic):

            J[(u, v)] = .25 * bias

            h[u] += .25 * bias
            h[v] += .25 * bias

            quadratic_offset += bias

        offset += .5 * linear_offset + .25 * quadratic_offset

        return h, J, offset
549464
@Pure
	@Inline(value = "Float.intBitsToFloat(EndianNumbers.toBEInt($1, $2, $3, $4))",
			imported = {EndianNumbers.class})
	public static float toBEFloat(int b1, int b2, int b3, int b4) {
		return Float.intBitsToFloat(toBEInt(b1, b2, b3, b4));
	}
755042
def spin1x_from_xi1_phi_a_phi_s(xi1, phi_a, phi_s):
    
    phi1 = phi1_from_phi_a_phi_s(phi_a, phi_s)
    return xi1 * numpy.cos(phi1)
310353
def cast(cls, c):
        """"""
        if isinstance(c, Complete):
            return c
        elif isinstance(c, Translation):
            return Complete(np.identity(3, float), c.t)
        elif isinstance(c, Rotation):
            return Complete(c.r, np.zeros(3, float))
1304977
def spin1y_from_xi1_phi_a_phi_s(xi1, phi_a, phi_s):
    
    phi1 = phi1_from_phi_a_phi_s(phi_s, phi_a)
    return xi1 * numpy.sin(phi1)
479752
def to_affine(self):
        
        X, Y, Z = self.x, self.y, self.inverse(self.z)
        return ((X * Z ** 2) % P, (Y * Z ** 3) % P)
690771
int flipTriangles(long[] flippedA, long[] flippedB) {
    int numflips = 0;
    BitsUtil.zeroI(flippedB);
    for(int i = BitsUtil.nextSetBit(flippedA, 0); i > -1; i = BitsUtil.nextSetBit(flippedA, i + 1)) {
      if(!BitsUtil.get(flippedB, i) && flipTriangle(i, flippedB) >= 0) {
        numflips += 2;
      }
    }
    if(LOG.isDebuggingFinest()) {
      LOG.debugFinest("Flips: " + numflips);
    }
    return numflips;
  }
448049
def fp(x):
    

    def bin32(f):
        """ Returns ASCII representation for a 32 bit integer value
        """
        result = ''
        a = int(f) & 0xFFFFFFFF  # ensures int 32

        for i in range(32):
            result = str(a % 2) + result
            a = a >> 1

        return result

    def bindec32(f):
        """ Returns binary representation of a mantissa x (x is float)
        """
        result = '0'
        a = f

        if f >= 1:
            result = bin32(f)

        result += '.'
        c = int(a)

        for i in range(32):
            a -= c
            a *= 2
            c = int(a)
            result += str(c)

        return result

    e = 0  # exponent
    s = 1 if x < 0 else 0  # sign
    m = abs(x)  # mantissa

    while m >= 1:
        m /= 2.0
        e += 1

    while 0 < m < 0.5:
        m *= 2.0
        e -= 1

    M = bindec32(m)[3:]
    M = str(s) + M
    E = bin32(e + 128)[-8:] if x != 0 else bin32(0)[-8:]

    return M, E
1210953
def process_slice(self, b_rot90=None):
        '''
        
        '''
        if b_rot90:
            self._Mnp_2Dslice = np.rot90(self._Mnp_2Dslice)
        if self.func == 'invertIntensities':
            self.invert_slice_intensities()
1264376
def rot_from_vectors(start_vec, end_vec):
        """"""

        dot = start_vec.dot(end_vec)
        # TODO: check if dot is a valid number
        angle = math.acos(dot)
        # TODO: check if angle is a valid number
        cross = start_vec.cross(end_vec)
        cross.normalize
        rot_matrix = Matrix44.from_axis_angle(cross, angle)

        # TODO: catch exception and return identity for invalid numbers
        return rot_matrix
342984
private static float bytesToFloat(byte b0, byte b1) {
        int mantissa = unsignedToSigned(unsignedByteToInt(b0)
                + ((unsignedByteToInt(b1) & 0x0F) << 8), 12);
        int exponent = unsignedToSigned(unsignedByteToInt(b1) >> 4, 4);
        return (float) (mantissa * Math.pow(10, exponent));
    }
133148
def _bits_to_float(bits, lower=-90.0, middle=0.0, upper=90.0):
  """"""
  for i in bits:
    if i:
      lower = middle
    else:
      upper = middle
    middle = (upper + lower) / 2
  return middle
1302128
function convert(data, output, frombits, tobits, pad, off) {
  const maxv = (1 << tobits) - 1;
  let acc = 0;
  let bits = 0;
  let j = 0;

  if (pad !== -1)
    output[j++] = pad;

  for (let i = off; i < data.length; i++) {
    const value = data[i];

    if ((value >> frombits) !== 0)
      throw new Error('Invalid bech32 bits.');

    acc = (acc << frombits) | value;
    bits += frombits;

    while (bits >= tobits) {
      bits -= tobits;
      output[j++] = (acc >>> bits) & maxv;
    }
  }

  if (pad !== -1) {
    if (bits > 0)
      output[j++] = (acc << (tobits - bits)) & maxv;
  } else {
    if (bits >= frombits || ((acc << (tobits - bits)) & maxv))
      throw new Error('Invalid bech32 bits.');
  }

  return output.slice(0, j);
}
68797
public Quaternion fromAnglesXY (float x, float y) {
        float hx = x * 0.5f, hy = y * 0.5f;
        float sx = FloatMath.sin(hx), cx = FloatMath.cos(hx);
        float sy = FloatMath.sin(hy), cy = FloatMath.cos(hy);
        return set(cy*sx, sy*cx, -sy*sx, cy*cx);
    }
1328740
private void voltConvertBinaryLiteralOperandsToBigint() {
        // Strange that CONCAT is an arithmetic operator.
        // You could imagine using it for VARBINARY, so
        // definitely don't convert its operands to BIGINT!
        assert(opType != OpTypes.CONCAT);

        for (int i = 0; i < nodes.length; ++i) {
            Expression e = nodes[i];
            ExpressionValue.voltMutateToBigintType(e, this, i);
        }
    }
1314055
def invert_affine_mat44(mat):
    

    inverted = Matrix44()

    # Transpose the 3x3 rotation component
    for i in range(3):
        for j in range(3):
            inverted.data[i][j] = mat.data[j][i]

    # Set translation: inverted_trans_vec3 = -inv(rot_mat33) * trans_vec3
    for row in range(3):
        inverted.data[3][row] = (
            -inverted.data[0][row] * mat.data[3][0] +
            -inverted.data[1][row] * mat.data[3][1] +
            -inverted.data[2][row] * mat.data[3][2])

    return inverted
847691
def convert_registers_to_float(registers):
      
    b = bytearray(4)
    b [0] = registers[0] & 0xff
    b [1] = (registers[0] & 0xff00)>>8 
    b [2] = (registers[1] & 0xff)
    b [3] = (registers[1] & 0xff00)>>8
    returnValue = struct.unpack('<f', b)            #little Endian
    return returnValue