// Cross returns the standard cross product of v and ov.
760743
func (v PreciseVector) Cross(ov PreciseVector) PreciseVector {
	return PreciseVector{
		X: precSub(precMul(v.Y, ov.Z), precMul(v.Z, ov.Y)),
		Y: precSub(precMul(v.Z, ov.X), precMul(v.X, ov.Z)),
		Z: precSub(precMul(v.X, ov.Y), precMul(v.Y, ov.X)),
	}
}
1068870
func Obv(real, volume []float64) []float64 {
	var outBegIdx C.int
	var outNBElement C.int
	outReal := make([]float64, len(real))
	C.TA_OBV(0, C.int(len(real)-1), (*C.double)(unsafe.Pointer(&real[0])), (*C.double)(unsafe.Pointer(&volume[0])), &outBegIdx, &outNBElement, (*C.double)(unsafe.Pointer(&outReal[0])))
	return outReal[:outNBElement]
}
1280793
func Cross(a, b Vect) Float {
	return (a.X * b.Y) - (a.Y * b.X)
}
575100
func (h *Client) ProductVariant(productVariant string) *Client {
	h.productVariant = productVariant
	h.productVariantSet = true
	return h
}
454991
func (v Vector) Normalise() {
	w := blas.Snrm2(len(v), v, 1)
	blas.Sscal(len(v), 1/w, v, 1)
}
39497
func (l Line) Intersect(k Line) (Vec, bool) {
	// Check if the lines are parallel
	lDir := l.A.To(l.B)
	kDir := k.A.To(k.B)
	if lDir.X == kDir.X && lDir.Y == kDir.Y {
		return ZV, false
	}

	// The lines intersect - but potentially not within the line segments.
	// Get the intersection point for the lines if they were infinitely long, check if the point exists on both of the
	// segments
	lm, lb := l.Formula()
	km, kb := k.Formula()

	// Account for vertical lines
	if math.IsInf(math.Abs(lm), 1) && math.IsInf(math.Abs(km), 1) {
		// Both vertical, therefore parallel
		return ZV, false
	}

	var x, y float64

	if math.IsInf(math.Abs(lm), 1) || math.IsInf(math.Abs(km), 1) {
		// One line is vertical
		intersectM := lm
		intersectB := lb
		verticalLine := k

		if math.IsInf(math.Abs(lm), 1) {
			intersectM = km
			intersectB = kb
			verticalLine = l
		}

		y = intersectM*verticalLine.A.X + intersectB
		x = verticalLine.A.X
	} else {
		// Coordinates of intersect
		x = (kb - lb) / (lm - km)
		y = lm*x + lb
	}

	if l.Contains(V(x, y)) && k.Contains(V(x, y)) {
		// The intersect point is on both line segments, they intersect.
		return V(x, y), true
	}

	return ZV, false
}
963627
func (g1 *Virtual) Connect(v1 int, g2 *Virtual) *Virtual {
	if g1.order == 0 || g2.order == 0 || v1 < 0 || v1 >= g1.order {
		return nil
	}

	n := g1.order + g2.order - 1
	t := g1.order - 1 // transpose
	if n == 1 {
		return singleton()
	}

	newCost := func(v, w int) int64 {
		switch {
		case v <= t && w <= t:
			return g1.cost(v, w)
		case v > t && w > t:
			return g2.cost(v-t, w-t)
		case v == v1:
			return g2.cost(0, w-t)
		case w == v1:
			return g2.cost(v-t, 0)
		default:
			return 0
		}
	}

	res := generic(n, newCost, func(v, w int) bool {
		switch {
		case v <= t && w <= t:
			return g1.edge(v, w)
		case v > t && w > t:
			return g2.edge(v-t, w-t)
		case v == v1:
			return g2.edge(0, w-t)
		case w == v1:
			return g2.edge(v-t, 0)
		default:
			return false
		}
	})

	res.degree = func(v int) (deg int) {
		switch {
		case v == v1:
			return g1.degree(v) + g2.degree(0)
		case v <= t:
			return g1.degree(v)
		default:
			return g2.degree(v - t)
		}
	}

	res.visit = func(v int, a int, do func(w int, c int64) bool) (aborted bool) {
		switch {
		case v > t:
			return g2.visit(v-t, max(0, a-t), func(w int, c int64) (skip bool) {
				if w == 0 {
					return v1 >= a && do(v1, c)
				}
				return do(w+t, c)
			})
		case g1.visit(v, a, do):
			return true
		case v == v1:
			return g2.visit(0, max(0, a-t), func(w int, c int64) (skip bool) {
				return do(w+t, c)
			})
		default:
			return
		}
	}
	return res
}
1028923
func Concat(xs interface{}) interface{} {
	chk := ty.Check(
		new(func([][]ty.A) []ty.A),
		xs)
	vxs, tflat := chk.Args[0], chk.Returns[0]

	xsLen := vxs.Len()
	vflat := reflect.MakeSlice(tflat, 0, xsLen*3)
	for i := 0; i < xsLen; i++ {
		vflat = reflect.AppendSlice(vflat, vxs.Index(i))
	}
	return vflat.Interface()
}
874569
func (r *Regression) applyCrosses() {
	unusedVariableIndexCursor := len(r.data[0].Variables)
	for _, point := range r.data {
		for _, cross := range r.crosses {
			point.Variables = append(point.Variables, cross.Calculate(point.Variables)...)
		}
	}

	if len(r.names.vars) == 0 {
		r.names.vars = make(map[int]string, 5)
	}
	for _, cross := range r.crosses {
		unusedVariableIndexCursor += cross.ExtendNames(r.names.vars, unusedVariableIndexCursor)
	}
}
453387
func (l Line) ScaledXY(around Vec, scale float64) Line {
	toA := around.To(l.A).Scaled(scale)
	toB := around.To(l.B).Scaled(scale)

	return Line{
		A: around.Add(toA),
		B: around.Add(toB),
	}
}
1080479
func (s stringSet) cross(t stringSet, isSuffix bool) stringSet {
	p := stringSet{}
	for _, ss := range s {
		for _, tt := range t {
			p.add(ss + tt)
		}
	}
	p.clean(isSuffix)
	return p
}
323832
func (l *loopCrosser) edgeCrossesCell(bClipped *clippedShape) bool {
	// Test the current edge of A against all edges of bClipped
	bNumEdges := bClipped.numEdges()
	for j := 0; j < bNumEdges; j++ {
		bj := bClipped.edges[j]
		if bj != l.bjPrev+1 {
			l.crosser.RestartAt(l.b.Vertex(bj))
		}
		l.bjPrev = bj
		if crossing := l.crosser.ChainCrossingSign(l.b.Vertex(bj + 1)); crossing == DoNotCross {
			continue
		} else if crossing == Cross {
			return true
		}

		// We only need to check each shared vertex once, so we only
		// consider the case where l.aVertex(l.aj+1) == l.b.Vertex(bj+1).
		if l.a.Vertex(l.aj+1) == l.b.Vertex(bj+1) {
			if l.swapped {
				if l.relation.wedgesCross(l.b.Vertex(bj), l.b.Vertex(bj+1), l.b.Vertex(bj+2), l.a.Vertex(l.aj), l.a.Vertex(l.aj+2)) {
					return true
				}
			} else {
				if l.relation.wedgesCross(l.a.Vertex(l.aj), l.a.Vertex(l.aj+1), l.a.Vertex(l.aj+2), l.b.Vertex(bj), l.b.Vertex(bj+2)) {
					return true
				}
			}
		}
	}

	return false
}
643076
func Vis(src string, flag VisFlag) (string, error) {
	if flag&visMask != flag {
		return "", fmt.Errorf("vis: flag %q contains unknown or unsupported flags", flag)
	}

	output := ""
	for _, ch := range []byte(src) {
		encodedCh, err := vis(ch, flag)
		if err != nil {
			return "", err
		}
		output += encodedCh
	}

	return output, nil
}
726982
func Product(x, y Vector) (Vector, error) {
	if len(x) != len(y) {
		return nil, fmt.Errorf("x and y have unequal lengths: %d / %d", len(x), len(y))
	}

	p := make(Vector, len(x))
	for i, _ := range x {
		p[i] = x[i] * y[i]
	}
	return p, nil
}
281979
func (r Rect) Union(other Rect) Rect {
	return Rect{r.X.Union(other.X), r.Y.Union(other.Y)}
}
465448
func NewEdgeCrosser(a, b Point) *EdgeCrosser {
	norm := a.PointCross(b)
	return &EdgeCrosser{
		a:        a,
		b:        b,
		aXb:      Point{a.Cross(b.Vector)},
		aTangent: Point{a.Cross(norm.Vector)},
		bTangent: Point{norm.Cross(b.Vector)},
	}
}
770583
func (u Vec) Sub(v Vec) Vec {
	return Vec{
		u.X - v.X,
		u.Y - v.Y,
	}
}