// Ring4 returns the value of ((a*a *b) - (a*b*b)).
184320
func (as ArraySpec) Ring4(val Input) Input {
	return as.proc(func(i Input) Input {
		return i.Ring4(val)
	})
}
1225370
func (t *translator) R(key interface{}, num1 float64, digits1 uint64, num2 float64, digits2 uint64, param1, param2 string) (string, error) {

	tarr, ok := t.rangeTanslations[key]
	if !ok {
		return unknownTranslation, ErrUnknowTranslation
	}

	rule := t.RangePluralRule(num1, digits1, num2, digits2)

	trans := tarr[rule]

	b := make([]byte, 0, 64)
	b = append(b, trans.text[:trans.indexes[0]]...)
	b = append(b, param1...)
	b = append(b, trans.text[trans.indexes[1]:trans.indexes[2]]...)
	b = append(b, param2...)
	b = append(b, trans.text[trans.indexes[3]:]...)

	return string(b), nil
}
364560
func (v Vec2) Vec4(z, w float32) Vec4 {
	return Vec4{v[0], v[1], z, w}
}
272309
func (r *ring) entry(key []byte) *entry {
	return r.getPartition(key).entry(key)
}
553224
func PolygonContains(p orb.Polygon, point orb.Point) bool {
	if !RingContains(p[0], point) {
		return false
	}

	for i := 1; i < len(p); i++ {
		if RingContains(p[i], point) {
			return false
		}
	}

	return true
}
1192288
func (s *Server) getRing(path string) (ring.Ring, error) {
	r, _, err := ring.RingOrBuilder(path)
	return r, err
}
617006
func (a Address) To4() Address {
	const (
		ipv4len = 4
		ipv6len = 16
	)
	if len(a) == ipv4len {
		return a
	}
	if len(a) == ipv6len &&
		isZeros(a[0:10]) &&
		a[10] == 0xff &&
		a[11] == 0xff {
		return a[12:16]
	}
	return ""
}
1036434
func (r Ring) Orientation() Orientation {
	area := 0.0

	// This is a fast planar area computation, which is okay for this use.
	// implicitly move everything to near the origin to help with roundoff
	offsetX := r[0][0]
	offsetY := r[0][1]
	for i := 1; i < len(r)-1; i++ {
		area += (r[i][0]-offsetX)*(r[i+1][1]-offsetY) -
			(r[i+1][0]-offsetX)*(r[i][1]-offsetY)
	}

	if area > 0 {
		return CCW
	}

	if area < 0 {
		return CW
	}

	// degenerate case, no area
	return 0
}
550700
func (c C) Ring1(val Input) Input {
	if v, ok := val.(C); ok {
		return C((c * v) + c)
	}
	return val.Ring1(c)
}
452846
func (s *Server) replicateRing(r ring.Ring, rb, bb *[]byte) error {
	failcount := 0
	for _, slave := range s.slaves {
		ctx, _ := context.WithTimeout(context.Background(), time.Duration(_SYN_REGISTER_TIMEOUT)*time.Second)
		i := &pb.RingMsg{
			Version:  r.Version(),
			Ring:     *rb,
			Builder:  *bb,
			Deadline: time.Now().Add(60 * time.Second).Unix(),
			Rollback: s.r.Version(),
		}
		res, err := slave.client.Store(ctx, i)
		if err != nil {
			log.Println(err)
			failcount++
			continue
		}
		if res.Version != r.Version() {
			log.Printf("Version or master on remote node %+v did not match local entries. Got %+v.", slave, res)
			failcount++
			continue
		}
		if !res.Ring || !res.Builder {
			log.Printf("res is: %#v\n", res)
			log.Printf("Slave failed to store ring or builder: %s", res.ErrMsg)
			failcount++
			continue
		}
		log.Printf("<-- Slave response: %+v", res)
		slave.version = res.Version
		slave.last = time.Now()
		slave.status = true
	}
	if failcount > (len(s.slaves) / 2) {
		return fmt.Errorf("Failed to get replication majority")
	}
	return nil
}
1280793
func Cross(a, b Vect) Float {
	return (a.X * b.Y) - (a.Y * b.X)
}
1247872
func (b Bound) ToRing() Ring {
	return Ring{
		b.Min,
		Point{b.Max[0], b.Min[1]},
		b.Max,
		Point{b.Min[0], b.Max[1]},
		b.Min,
	}
}
1323743
func (v1 Vec4) LenSqr() float32 {
	return v1[0]*v1[0] + v1[1]*v1[1] + v1[2]*v1[2] + v1[3]*v1[3]
}
1072618
func (u *Ugen) Ring3(val Input) Input {
	return binOpRing3(u.Rate, u, val, u.NumOutputs)
}
31233
func (rb *ringBuffer) Push(values ...interface{}) {
	for _, value := range values {
		if rb.end.next.used == false {
			rb.end.next.used = true
			rb.end.next.value = value
			rb.end = rb.end.next
			continue
		}
		link := &valueLink{
			used:  true,
			value: value,
			next:  rb.start,
		}
		rb.end.next = link
		rb.end = rb.end.next
	}
}
370990
func (u *Ugen) Ring1(val Input) Input {
	return binOpRing1(u.Rate, u, val, u.NumOutputs)
}
1358754
func (ins Inputs) Ring1(val Input) Input {
	converted := make([]Input, len(ins))
	for i, in := range ins {
		converted[i] = in.Ring1(val)
	}
	return Inputs(converted)
}