// ApproxEqualThreshold returns whether the two vectors are approximately equal
// to within the given threshold given by "epsilon" (See ApproxEqualThreshold).
766092
func (vn *VecN) ApproxEqualThreshold(vn2 *VecN, epsilon float64) bool {
	if vn == nil || vn2 == nil || len(vn.vec) != len(vn2.vec) {
		return false
	}

	for i, el := range vn.vec {
		if !FloatEqualThreshold(el, vn2.vec[i], epsilon) {
			return false
		}
	}

	return true
}
1304434
func (b *AnnealingEpsilonGreedy) Epsilon() float64 {
	// Compute epsilon based on the total number of trials
	t := uint64(1)
	for _, i := range b.counts {
		t += i
	}

	// The more trials the smaller that epsilon is
	return 1 / math.Log(float64(t)+0.0000001)
}
304004
func (m1 Mat2) ApproxFuncEqual(m2 Mat2, eq func(float64, float64) bool) bool {
	for i := range m1 {
		if !eq(m1[i], m2[i]) {
			return false
		}
	}
	return true
}
674322
func ExplainEqual(o1, o2 *ExplainOption) bool {
	if o1 != nil {
		return o1.Equal(o2)
	}
	if o2 != nil {
		return o2.Equal(o1)
	}
	return true
}
596161
func filterEqual(a, b []Filter) bool {
	if len(a) != len(b) {
		return false
	}
	for i := range a {
		if a[i].Field != b[i].Field {
			return false
		}
		if a[i].CompOp != b[i].CompOp {
			return false
		}
		if a[i].Value != b[i].Value {
			return false
		}
	}
	return true
}
1040647
func Equal(x, y Value) (bool, error) {
	if x, ok := x.(String); ok {
		return x == y, nil // fast path for an important special case
	}
	return EqualDepth(x, y, maxdepth)
}
1009976
func formatThreshold(threshold evictionapi.Threshold) string {
	return fmt.Sprintf("threshold(signal=%v, operator=%v, value=%v, gracePeriod=%v)", threshold.Signal, threshold.Operator, evictionapi.ThresholdValue(threshold.Value), threshold.GracePeriod)
}
1118495
func exactCompareDistance(x, y r3.PreciseVector, r2 *big.Float) int {
	// This code produces the same result as though all points were reprojected
	// to lie exactly on the surface of the unit sphere.  It is based on
	// comparing the cosine of the angle XY (when both points are projected to
	// lie exactly on the sphere) to the given threshold.
	cosXY := x.Dot(y)
	cosR := newBigFloat().Sub(bigOne, newBigFloat().Mul(bigHalf, r2))

	// If the two values have different signs, we need to handle that case now
	// before squaring them below.
	xySign := cosXY.Sign()
	rSign := cosR.Sign()
	if xySign != rSign {
		if xySign > rSign {
			return -1
		}
		return 1 // If cos(XY) > cos(r), then XY < r.
	}
	cmp := newBigFloat().Sub(
		newBigFloat().Mul(
			newBigFloat().Mul(cosR, cosR), newBigFloat().Mul(x.Norm2(), y.Norm2())),
		newBigFloat().Mul(cosXY, cosXY))
	return xySign * cmp.Sign()
}
1120416
func (s *HistoricalMetric) SetThreshold(v *Threshold) *HistoricalMetric {
	s.Threshold = v
	return s
}
1210911
func Float64Equal(a, b float64) bool {
	return math.Abs(a-b) <= closeFactor || math.Abs(1-a/b) <= closeFactor
}
432157
func parseThreshold(threshold string) (min float64, max float64, err error) {
	thresh := strings.Split(threshold, ":")
	switch len(thresh) {
	case 1:
		max, err = strconv.ParseFloat(string(thresh[0]), 64)
		if err != nil {
			return 0, 0, ErrBadThresholdFormat
		}

		return 0, max, nil
	case 2:
		if thresh[0] == "~" {
			min = MinFloat64
		} else {
			min, err = strconv.ParseFloat(string(thresh[0]), 64)
			if err != nil {
				min = 0
			}
		}

		if thresh[1] == "" {
			max = MaxFloat64
		} else {
			max, err = strconv.ParseFloat(string(thresh[1]), 64)
			if err != nil {
				return 0, 0, ErrBadThresholdFormat
			}
		}
	default:
		return 0, 0, ErrBadThresholdFormat
	}

	return
}
317700
func (vn *VecN) ApproxEqual(vn2 *VecN) bool {
	if vn == nil || vn2 == nil || len(vn.vec) != len(vn2.vec) {
		return false
	}

	for i, el := range vn.vec {
		if !FloatEqual(el, vn2.vec[i]) {
			return false
		}
	}

	return true
}
839783
func (c *config) updateThreshold() {
	max := OFF
	for _, e := range c.registry {
		if e.threshold > max && !e.degraded {
			max = e.threshold
		}
	}
	c.threshold = max
}
600016
func (s *PutScalingPolicyInput) SetThreshold(v float64) *PutScalingPolicyInput {
	s.Threshold = &v
	return s
}
353414
func (t proofTerm) lessThanOrEqual(u proofTerm) bool {
	return t.seqno() <= u.seqno()
}
380943
func (v *Validator) LessOrEqual(field string, value float64) *ValidationResult {
	return v.inequality(field, value, lessOrEqual, "less than or equal to")
}
265034
func (q1 Quat) ApproxEqual(q2 Quat) bool {
	return FloatEqual(q1.W, q2.W) && q1.V.ApproxEqual(q2.V)
}