// Degree returns the number of outward directed edges from v.
14074
func (g *Immutable) Degree(v int) int {
	return len(g.edges[v])
}
1307582
func (col Color) Luv() (l, u, v float64) {
	return XyzToLuv(col.Xyz())
}
500415
func (c Cell) Vertex(k int) Point {
	return Point{faceUVToXYZ(int(c.face), c.uv.Vertices()[k].X, c.uv.Vertices()[k].Y).Normalize()}
}
751209
func (t *Title) Drive() {
	degree = (degree - 1) % 360
	for i := range t.sprites {
		r := float32(degree) * math.Pi / 180
		t.sprites[i].SetRotate(r)
	}
	t.mu.Lock()
	t.fps++
	t.mu.Unlock()
	//runtime.GC()
}
1271314
func (l *Loop) Edge(i int) Edge {
	return Edge{l.Vertex(i), l.Vertex(i + 1)}
}
38368
func (p *PolyKernel) Distance(vectorX *mat.Dense, vectorY *mat.Dense) float64 {
	subVector := new(mat.Dense)
	subVector.Sub(vectorX, vectorY)
	result := p.InnerProduct(subVector, subVector)

	return math.Sqrt(result)
}
260300
func (n *internal) direction(key []byte) int {
	if n.offset < len(key) && (key[n.offset]&n.bit != 0 || n.cont) {
		return 1
	}
	return 0
}
120095
func (g *SimpleGraph) Degree(v interface{}) (int, error) {
	g.mutex.RLock()
	defer g.mutex.RUnlock()

	val, ok := g.adjacencyList[v]
	if !ok {
		return 0, ErrVertexNotFound
	}
	return len(val), nil
}
284698
func (c Cell) Edge(k int) Point {
	switch k {
	case 0:
		return Point{vNorm(int(c.face), c.uv.Y.Lo).Normalize()} // Bottom
	case 1:
		return Point{uNorm(int(c.face), c.uv.X.Hi).Normalize()} // Right
	case 2:
		return Point{vNorm(int(c.face), c.uv.Y.Hi).Mul(-1.0).Normalize()} // Top
	default:
		return Point{uNorm(int(c.face), c.uv.X.Lo).Mul(-1.0).Normalize()} // Left
	}
}
855803
func Perspective(fovy, aspect, near, far float32) Mat4 {
	// fovy = (fovy * math.Pi) / 180.0 // convert from degrees to radians
	nmf, f := near-far, float32(1./math.Tan(float64(fovy)/2.0))

	return Mat4{float32(f / aspect), 0, 0, 0, 0, float32(f), 0, 0, 0, 0, float32((near + far) / nmf), -1, 0, 0, float32((2. * far * near) / nmf), 0}
}
322214
func (u Vec) Dot(v Vec) float64 {
	return u.X*v.X + u.Y*v.Y
}
947459
func (r Rect) Vertex(i int) LatLng {
	var lat, lng float64

	switch i {
	case 0:
		lat = r.Lat.Lo
		lng = r.Lng.Lo
	case 1:
		lat = r.Lat.Lo
		lng = r.Lng.Hi
	case 2:
		lat = r.Lat.Hi
		lng = r.Lng.Hi
	case 3:
		lat = r.Lat.Hi
		lng = r.Lng.Lo
	}
	return LatLng{s1.Angle(lat) * s1.Radian, s1.Angle(lng) * s1.Radian}
}
1283655
func Poly(xvalues, yvalues []float64, degree int) ([]float64, error) {
	if len(xvalues) != len(yvalues) {
		return nil, ErrPolyRegArraysSameLength
	}

	m := len(yvalues)
	n := degree + 1
	y := New(m, 1, yvalues...)
	x := Zero(m, n)

	for i := 0; i < m; i++ {
		ip := float64(1)
		for j := 0; j < n; j++ {
			x.Set(i, j, ip)
			ip *= xvalues[i]
		}
	}

	q, r := x.QR()
	qty, err := q.Transpose().Times(y)
	if err != nil {
		return nil, err
	}

	c := make([]float64, n)
	for i := n - 1; i >= 0; i-- {
		c[i] = qty.Get(i, 0)
		for j := i + 1; j < n; j++ {
			c[i] -= c[j] * r.Get(i, j)
		}
		c[i] /= r.Get(i, i)
	}

	return c, nil
}
577599
func Cycle(n int) *Virtual {
	switch {
	case n < 0:
		return nil
	case n == 0:
		return null
	case n == 1:
		return singleton()
	case n == 2:
		return edge()
	}

	g := generic0(n, func(v, w int) (edge bool) {
		switch v - w {
		case 1 - n, -1, 1, n - 1:
			edge = true
		}
		return
	})

	// Precondition : n ≥ 3.
	g.degree = func(v int) int { return 2 }

	// Precondition : n ≥ 3.
	g.visit = func(v int, a int, do func(w int, c int64) bool) (aborted bool) {
		var w [2]int
		switch v {
		case 0:
			w = [2]int{1, n - 1}
		case n - 1:
			w = [2]int{0, n - 2}
		default:
			w = [2]int{v - 1, v + 1}
		}
		for _, w := range w {
			if w >= a && do(w, 0) {
				return true
			}
		}
		return
	}
	return g
}
1034244
func (g *Virtual) Degree(v int) int {
	if v < 0 || v >= g.order {
		panic("vertex out of range")
	}
	return g.degree(v)
}
1105534
func Medial(c rune) rune {
	switch {
	case MEDIAL_A <= c && c <= MEDIAL_I:
		return c
	case A <= c && c <= I:
		return c - A + MEDIAL_BASE
	}

	return 0
}
1001529
func (l *Loop) Vertex(i int) Point {
	return l.vertices[i%len(l.vertices)]
}