// Atan2 returns the arctangent of y/x.
974328
func (u *Ugen) Atan2(val Input) Input {
	return binOpAtan2(u.Rate, u, val, u.NumOutputs)
}
88885
func Haversin(lon1, lat1, lon2, lat2 float64) float64 {
	x1 := lat1 * degreesToRadian
	x2 := lat2 * degreesToRadian
	h1 := 1 - cos(x1-x2)
	h2 := 1 - cos((lon1-lon2)*degreesToRadian)
	h := (h1 + cos(x1)*cos(x2)*h2) / 2
	avgLat := (x1 + x2) / 2
	diameter := earthDiameter(avgLat)

	return diameter * asin(math.Min(1, math.Sqrt(h)))
}
1002055
func (s *Rule) SetArn(v string) *Rule {
	s.Arn = &v
	return s
}
252420
func (l *Line) Angle() float32 {
	return math.Atan2(l.P1.X-l.P2.X, l.P1.Y-l.P2.Y)
}
1175914
func Atan(inReal []float64) []float64 {
	outReal := make([]float64, len(inReal))
	for i := 0; i < len(inReal); i++ {
		outReal[i] = math.Atan(inReal[i])
	}
	return outReal
}
748178
func (u *Ugen) Ring2(val Input) Input {
	return binOpRing2(u.Rate, u, val, u.NumOutputs)
}
1218617
func (s *DefinitionInformation) SetArn(v string) *DefinitionInformation {
	s.Arn = &v
	return s
}
459748
func (v *PVector) AssocN(i int, val interface{}) iseq.PVector {
	if i >= 0 && i < v.cnt {
		if i >= v.tailoff() {
			newTail := make([]interface{}, len(v.tail))
			copy(newTail, v.tail)
			newTail[i&indexMask] = val
			return &PVector{AMeta: AMeta{v.meta}, cnt: v.cnt, shift: v.shift, root: v.root, tail: newTail}
		}
		return &PVector{AMeta: AMeta{v.meta}, cnt: v.cnt, shift: v.shift, root: doAssoc(v.shift, v.root, i, val), tail: v.tail}

	} else if i == v.cnt {
		return v.ConsV(val)
	}

	panic("Argument out of range")

}
596563
func (p Point) IsNaN() bool {
	return math.IsNaN(p.x) || math.IsNaN(p.y)
}
205118
func (c C) Fold2(val Input) Input {
	if v, ok := val.(C); ok {
		return C(fold2(float32(c), float32(v)))
	}
	return c // TODO: fix this
}
584512
func At2d(x, y float64) float64 {
	// Noise contributions from the three corners
	var n0, n1, n2 float64

	// Skew the input space to determine which simplex cell we're in
	var s float64 = (x + y) * f2 // Hairy factor for 2D
	var i int = fastfloor(x + s)
	var j int = fastfloor(y + s)

	var t = float64(i+j) * g2

	// Unskew the cell origin back to (x,y) space
	var ox0 = float64(i) - t
	var oy0 = float64(j) - t

	// The x,y distances from the cell origin
	var x0 float64 = x - ox0
	var y0 float64 = y - oy0

	// For the 2D case, the simplex shape is an equilateral triangle.
	// Determine which simplex we are in.
	var i1, j1 int // Offsets for second (middle) corner of simplex in (i,j) coords
	if x0 > y0 {
		// lower triangle, XY order: (0,0)->(1,0)->(1,1)
		i1, j1 = 1, 0
	} else {
		// upper triangle, YX order: (0,0)->(0,1)->(1,1)
		i1, j1 = 0, 1
	}

	// A step of (1,0) in (i,j) means a step of (1-c,-c) in (x,y), and
	// a step of (0,1) in (i,j) means a step of (-c,1-c) in (x,y), where
	// c = (3-sqrt(3))/6

	// Offsets for middle corner in (x,y) unskewed coords
	var x1 float64 = x0 - float64(i1) + g2
	var y1 float64 = y0 - float64(j1) + g2

	// Offsets for last corner in (x,y) unskewed coords
	var x2 float64 = x0 - 1.0 + 2.0*g2
	var y2 float64 = y0 - 1.0 + 2.0*g2

	// Work out the hashed gradient indices of the three simplex corners
	var ii = i & 0xff
	var jj = j & 0xff
	var gi0 int = permMod12[ii+perm[jj]]
	var gi1 int = permMod12[ii+i1+perm[jj+j1]]
	var gi2 int = permMod12[ii+1+perm[jj+1]]

	// Calculate the contribution from the three corners
	var t0 float64 = 0.5 - x0*x0 - y0*y0
	if t0 < 0 {
		n0 = 0.0
	} else {
		t0 *= t0
		n0 = t0 * t0 * dot2(grad3[gi0], x0, y0) // (x,y) of grad3 used for 2D gradient
	}

	var t1 float64 = 0.5 - x1*x1 - y1*y1
	if t1 < 0 {
		n1 = 0.0
	} else {
		t1 *= t1
		n1 = t1 * t1 * dot2(grad3[gi1], x1, y1)
	}

	var t2 float64 = 0.5 - x2*x2 - y2*y2
	if t2 < 0 {
		n2 = 0.0
	} else {
		t2 *= t2
		n2 = t2 * t2 * dot2(grad3[gi2], x2, y2)
	}

	// Sum and scale to [-1,1]
	return 70.0 * (n0 + n1 + n2)
}
295038
func AngleBetween(tip1, tail, tip2 geom.Coord) float64 {
	a1 := Angle(tail, tip1)
	a2 := Angle(tail, tip2)

	return Diff(a1, a2)
}
815146
func (s *BGPPeer) SetAsn(v int64) *BGPPeer {
	s.Asn = &v
	return s
}
463033
func ToComplex2(x [][]float64) [][]complex128 {
	y := make([][]complex128, len(x))
	for n, v := range x {
		y[n] = ToComplex(v)
	}
	return y
}
382211
func (s *Preset) SetArn(v string) *Preset {
	s.Arn = &v
	return s
}
338345
func (c C) Atan() Input {
	return C(float32(math.Atan(float64(c))))
}
103815
func power2(x uint) uint {
	x--
	x |= x >> 1
	x |= x >> 2
	x |= x >> 4
	x |= x >> 8
	x |= x >> 16
	x |= x >> 32
	x++
	return x
}