Compare Scalar SP-FP Values (SSE2).
967454
public final void cmpsd(XMMRegister dst, XMMRegister src, Immediate imm8)
  {
    emitX86(INST_CMPSD, dst, src, imm8);
  }
78548
def _compare(cur_cmp, cur_struct):
    '''
    
    '''
    if isinstance(cur_cmp, dict) and isinstance(cur_struct, dict):
        log.debug('Comparing dict to dict')
        for cmp_key, cmp_value in six.iteritems(cur_cmp):
            if cmp_key == '*':
                # matches any key from the source dictionary
                if isinstance(cmp_value, dict):
                    found = False
                    for _, cur_struct_val in six.iteritems(cur_struct):
                        found |= _compare(cmp_value, cur_struct_val)
                    return found
                else:
                    found = False
                    if isinstance(cur_struct, (list, tuple)):
                        for cur_ele in cur_struct:
                            found |= _compare(cmp_value, cur_ele)
                    elif isinstance(cur_struct, dict):
                        for _, cur_ele in six.iteritems(cur_struct):
                            found |= _compare(cmp_value, cur_ele)
                    return found
            else:
                if isinstance(cmp_value, dict):
                    if cmp_key not in cur_struct:
                        return False
                    return _compare(cmp_value, cur_struct[cmp_key])
                if isinstance(cmp_value, list):
                    found = False
                    for _, cur_struct_val in six.iteritems(cur_struct):
                        found |= _compare(cmp_value, cur_struct_val)
                    return found
                else:
                    return _compare(cmp_value, cur_struct[cmp_key])
    elif isinstance(cur_cmp, (list, tuple)) and isinstance(cur_struct, (list, tuple)):
        log.debug('Comparing list to list')
        found = False
        for cur_cmp_ele in cur_cmp:
            for cur_struct_ele in cur_struct:
                found |= _compare(cur_cmp_ele, cur_struct_ele)
        return found
    elif isinstance(cur_cmp, dict) and isinstance(cur_struct, (list, tuple)):
        log.debug('Comparing dict to list (of dicts?)')
        found = False
        for cur_struct_ele in cur_struct:
            found |= _compare(cur_cmp, cur_struct_ele)
        return found
    elif isinstance(cur_cmp, bool) and isinstance(cur_struct, bool):
        log.debug('Comparing booleans: %s ? %s', cur_cmp, cur_struct)
        return cur_cmp == cur_struct
    elif isinstance(cur_cmp, (six.string_types, six.text_type)) and \
         isinstance(cur_struct, (six.string_types, six.text_type)):
        log.debug('Comparing strings (and regex?): %s ? %s', cur_cmp, cur_struct)
        # Trying literal match
        matched = re.match(cur_cmp, cur_struct, re.I)
        if matched:
            return True
        return False
    elif isinstance(cur_cmp, (six.integer_types, float)) and \
         isinstance(cur_struct, (six.integer_types, float)):
        log.debug('Comparing numeric values: %d ? %d', cur_cmp, cur_struct)
        # numeric compare
        return cur_cmp == cur_struct
    elif isinstance(cur_struct, (six.integer_types, float)) and \
         isinstance(cur_cmp, (six.string_types, six.text_type)):
        # Comapring the numerical value agains a presumably mathematical value
        log.debug('Comparing a numeric value (%d) with a string (%s)', cur_struct, cur_cmp)
        numeric_compare = _numeric_regex.match(cur_cmp)
        # determine if the value to compare agains is a mathematical operand
        if numeric_compare:
            compare_value = numeric_compare.group(2)
            return getattr(float(cur_struct), _numeric_operand[numeric_compare.group(1)])(float(compare_value))
        return False
    return False
23878
private int ssPivot(int Td, int PA, int first, int last) {
        int middle;// SA pointer
        int t = last - first;
        middle = first + t / 2;

        if (t <= 512) {
            if (t <= 32) {
                return ssMedian3(Td, PA, first, middle, last - 1);
            } else {
                t >>= 2;
                return ssMedian5(Td, PA, first, first + t, middle, last - 1 - t, last - 1);
            }
        }
        t >>= 3;
        first = ssMedian3(Td, PA, first, first + t, first + (t << 1));
        middle = ssMedian3(Td, PA, middle - t, middle, middle + t);
        last = ssMedian3(Td, PA, last - 1 - (t << 1), last - 1 - t, last - 1);
        return ssMedian3(Td, PA, first, middle, last);
    }
402826
def ssim(x, y, data_range=None, scaled = False, verbose = False):
    
    if not x.shape == y.shape:
        raise ValueError('Input images must have the same dimensions.')

    K1 = 0.01
    K2 = 0.03
    sigma = 1.5
    win_size = 7


    if scaled:
        x = x.astype(np.float32)
        y = y.astype(np.float32)

        # center it first for numerical stability...
        my = np.mean(y)
        mx = np.mean(x)
        y = y - my
        sxy = np.mean(x * y)  # mean(y)=0
        sy = np.std(y)
        a, b = sxy / (sy ** 2 + 1.e-30), mx
        if verbose:
            print("scaling in ssim: y2 = %.2g*y+%.2g" % (a, b-my))
        y = a * y + b

        # my = np.mean(y)
        # y = y - my
        # sxy = np.mean(x * y)  # - np.mean(x) * np.mean(y)
        # sy = np.std(y)
        # sx = np.std(x)
        # mx = np.mean(x)
        # a, b = sx / sy, mx
        # print("scaling in ssim: y2 = %.2g*y+%.2g" % (a, b-my))
        # y = a * y + b
        #

    if np.any((np.asarray(x.shape) - win_size) < 0):
        raise ValueError("win_size exceeds image extent.")

    if data_range is None:
        dmin, dmax = np.amin(x), np.amax(x)
        data_range = dmax - dmin+1.e-10

    x_g = OCLArray.from_array(x.astype(np.float32, copy=False))
    y_g = OCLArray.from_array(y.astype(np.float32, copy=False))

    ndim = x.ndim
    NP = win_size ** ndim
    cov_norm = 1. * NP / (NP - 1)  # sample covariance

    filter_func = uniform_filter
    filter_args = {'size': win_size}

    ux = filter_func(x_g, **filter_args)
    uy = filter_func(y_g, **filter_args)

    # compute (weighted) variances and covariances
    uxx = filter_func(x_g * x_g, **filter_args)
    uyy = filter_func(y_g * y_g, **filter_args)
    uxy = filter_func(x_g * y_g, **filter_args)
    vx = cov_norm * (uxx - ux * ux)
    vy = cov_norm * (uyy - uy * uy)
    vxy = cov_norm * (uxy - ux * uy)


    R = 1. * data_range
    C1 = (K1 * R) ** 2
    C2 = (K2 * R) ** 2

    # save some gpu space by minimizing intermediate buffers

    # A1 = 2. * ux * uy+C1
    A1 = np.float32(2.) * ux
    A1 *= uy
    A1 += np.float32(C1)



    # A2 =  2. * vxy + C2
    # overwrite vxy to save space
    A2 = vxy
    A2 *= np.float32(2.)
    A2 += np.float32(C2)


    # B1 =  ux ** 2 + uy ** 2 + C1
    # overwrite ux to save space
    B1 = ux
    B1 *= ux
    uy *= uy
    B1 += uy
    B1 += np.float32(C1)

    # B2 =  vx + vy + C2
    # overwrite vx to save space
    B2 = vx
    B2 += vy
    B2 += np.float32(C2)

    D = B1
    D *= B2
    S = A1
    S *= A2
    S /= D


    # import time
    # time.sleep(2)
    # return 1

    # to avoid edge effects will ignore filter radius strip around edges
    pad = (win_size - 1) // 2

    ss = tuple(slice(pad, s - pad) for s in x.shape)
    # compute (weighted) mean of ssim
    mssim = S.get()[ss].mean()

    return mssim
112842
def _get_pga_bc(self, f0, f1, f2, SC, mag, rrup, vs30, scale_fac):
        
        pga_bc = np.zeros_like(vs30)
        self._compute_mean(self.COEFFS_BC[PGA()], f0, f1, f2, SC, mag,
                           rrup, vs30 < 2000.0, pga_bc, scale_fac)

        return (10 ** pga_bc) * 1e-2 / g
1046009
def run_freidman_supsmu(x, y, bass_enhancement=0.0):
    """"""
    N = len(x)
    weight = numpy.ones(N)
    results = numpy.zeros(N)
    flags = numpy.zeros((N, 7))
    mace.supsmu(x, y, weight, 1, 0.0, bass_enhancement, results, flags)
    return results
633297
private static boolean multiPointEqualsMultiPoint_(MultiPoint multipoint_a,
			MultiPoint multipoint_b, double tolerance,
			ProgressTracker progress_tracker) {
		Envelope2D env_a = new Envelope2D(), env_b = new Envelope2D();
		multipoint_a.queryEnvelope2D(env_a);
		multipoint_b.queryEnvelope2D(env_b);

		if (!envelopeEqualsEnvelope_(env_a, env_b, tolerance, progress_tracker))
			return false;

		if (multiPointExactlyEqualsMultiPoint_(multipoint_a, multipoint_b,
				tolerance, progress_tracker))
			return true;

		return multiPointCoverageMultiPoint_(multipoint_a, multipoint_b,
				tolerance, false, true, false, progress_tracker);
	}
1028465
def get_scalar_product(self, other):
        """"""
        return self.x*other.x+self.y*other.y
1197311
def _scalar_pattern_uniform_op_right(func):
        """"""
        @wraps(func)
        def verif(self, patt):
            if isinstance(patt, numbers.Number):
                return ScalarPatternUniform(func(self, self._dsphere, patt),
                                   doublesphere=True)
            else:
                raise TypeError(err_msg['no_combi_SP'])
        return verif
1113746
def p_common_scalar_magic_ns(p):
    ''
    p[0] = ast.MagicConstant(p[1].upper(), None, lineno=p.lineno(1))
1213266
def get_fptr(self):
        """"""
        cmpfunc = ctypes.CFUNCTYPE(ctypes.c_int,
                                   WPARAM,
                                   LPARAM,
                                   ctypes.POINTER(KBDLLHookStruct))
        return cmpfunc(self.handle_input)
698528
private double spfL(InfoTree it1, InfoTree it2) {

		int fPostorder = it1.getCurrentNode();
		int gPostorder = it2.getCurrentNode();

		int minKR = it2.info[POST2_MIN_KR][gPostorder];
		int[] kr = it2.info[KR];
		if (minKR > -1) {
			for (int j = minKR; kr[j] < gPostorder; j++) {
				treeEditDist(it1, it2, fPostorder, kr[j]);
			}
		}
		treeEditDist(it1, it2, fPostorder, gPostorder);

		return it1.isSwitched() ? delta[gPostorder][fPostorder]
				+ deltaBit[gPostorder][fPostorder] * costMatch
				: delta[fPostorder][gPostorder]
						+ deltaBit[fPostorder][gPostorder] * costMatch;
	}
1311310
def read_lsm_floatpairs(fh):
    """"""
    size = struct.unpack('<i', fh.read(4))[0]
    return fh.read_array('<2f8', count=size)
1219686
def _check_scalar_vertical_extents(self, ds, z_variable):
        '''
        
        '''
        vert_min = ds.geospatial_vertical_min
        vert_max = ds.geospatial_vertical_max
        msgs = []
        total = 2

        zvalue = ds.variables[z_variable][:].item()
        if not np.isclose(vert_min, vert_max):
            msgs.append("geospatial_vertical_min != geospatial_vertical_max for scalar depth values, %s != %s" % (
                vert_min,
                vert_max
            ))

        if not np.isclose(vert_max, zvalue):
            msgs.append("geospatial_vertical_max != %s values, %s != %s" % (
                z_variable,
                vert_max,
                zvalue
            ))

        return Result(BaseCheck.MEDIUM,
                      (total - len(msgs), total),
                      'geospatial_vertical_extents_match',
                      msgs)
540499
private double spfH(InfoTree it1, InfoTree it2, int[] heavyPath) {

		int fSize = it1.info[POST2_SIZE][it1.getCurrentNode()];
		int gSize = it2.info[POST2_SIZE][it2.getCurrentNode()];

		int gRevPre = it2.getSize() - 1 - it2.getCurrentNode();
		int gPre = it2.info[POST2_PRE][it2.getCurrentNode()];

		int gTreeSize = it2.getSize();

		int strategy;

		int jOfi;

		// Initialize arrays to their maximal possible size for current pairs of
		// subtrees.
		t = new double[gSize][gSize];
		tCOPY = new double[gSize][gSize];
		s = new double[fSize][gSize];
		q = new double[fSize];

		int vp = -1;
		int nextVp = -1;

		for (int it = heavyPath.length - 1; it >= 0; it--) {
			vp = heavyPath[it];
			strategy = it1.info[POST2_STRATEGY][vp];
			if (strategy != BOTH) {
				if (it1.info[POST2_SIZE][vp] == 1) {
					for (int i = gSize - 1; i >= 0; i--) {
						jOfi = jOfI(it2, i, gSize, gRevPre, gPre, strategy,
								gTreeSize);
						for (int j = jOfi; j >= 0; j--) {
							t[i][j] = (gSize - (i + j)) * costIns;
						}
					}
					previousStrategy = strategy;
				}
				computePeriod(it1, vp, nextVp, it2, strategy);
			} else {
				if (it1.info[POST2_SIZE][vp] == 1) {
					for (int i = gSize - 1; i >= 0; i--) {
						jOfi = jOfI(it2, i, gSize, gRevPre, gPre, LEFT,
								gTreeSize);
						for (int j = jOfi; j >= 0; j--) {
							t[i][j] = (gSize - (i + j)) * costIns;
						}
					}
					previousStrategy = LEFT;
				}
				computePeriod(it1, vp, nextVp, it2, LEFT);
				if (it1.info[POST2_SIZE][vp] == 1) {
					for (int i = gSize - 1; i >= 0; i--) {
						jOfi = jOfI(it2, i, gSize, gRevPre, gPre, RIGHT,
								gTreeSize);
						for (int j = jOfi; j >= 0; j--) {
							t[i][j] = (gSize - (i + j)) * costIns;
						}
					}
					previousStrategy = RIGHT;
				}
				computePeriod(it1, vp, nextVp, it2, RIGHT);
			}
			nextVp = vp;
		}
		return t[0][0];
	}
1096009
def F(self, x):
        
        if isinstance(x, np.ndarray):
            nfwvals = np.ones_like(x)
            inds1 = np.where(x < 1)
            inds2 = np.where(x > 1)
            nfwvals[inds1] = (1 - x[inds1] ** 2) ** -.5 * np.arctanh((1 - x[inds1] ** 2) ** .5)
            nfwvals[inds2] = (x[inds2] ** 2 - 1) ** -.5 * np.arctan((x[inds2] ** 2 - 1) ** .5)
            return nfwvals

        elif isinstance(x, float) or isinstance(x, int):
            if x == 1:
                return 1
            if x < 1:
                return (1 - x ** 2) ** -.5 * np.arctanh((1 - x ** 2) ** .5)
            else:
                return (x ** 2 - 1) ** -.5 * np.arctan((x ** 2 - 1) ** .5)
672211
private static int compare(long v1, long v2) {
		int pos = 0;
		if (v1 != v2) {
			long x = v1 ^ v2;
			pos += Long.numberOfLeadingZeros(x);
			return pos;
		}
		return -1;
	}