// Dot returns the dot product of vectors u and v.
322214
func (u Vec) Dot(v Vec) float64 {
	return u.X*v.X + u.Y*v.Y
}
1287392
func (x Vector) Sum() float64 {
	s := 0.0
	for _, v := range x {
		s += v
	}
	return s
}
413623
func (n *NodeApplyableOutput) DotNode(name string, opts *dag.DotOpts) *dag.DotNode {
	return &dag.DotNode{
		Name: name,
		Attrs: map[string]string{
			"label": n.Name(),
			"shape": "note",
		},
	}
}
204177
func (m *Matrix) Row(row int) Vector {
	_, cols := m.Size()
	values := make([]float64, cols)
	for col := 0; col < cols; col++ {
		values[col] = m.Get(row, col)
	}
	return Vector(values)
}
697527
func (vn *VecN) Dot(other *VecN) float32 {
	if vn == nil || other == nil || len(vn.vec) != len(other.vec) {
		return float32(math.NaN())
	}

	var result float32 = 0.0
	for i, el := range vn.vec {
		result += el * other.vec[i]
	}

	return result
}
323682
func (v Vector) Copy() Vector {
	nv := make([]Counter, len(v.Counters))
	copy(nv, v.Counters)
	return Vector{Counters: nv}
}
988441
func (q1 Quat) Dot(q2 Quat) float64 {
	return q1.W*q2.W + q1.V[0]*q2.V[0] + q1.V[1]*q2.V[1] + q1.V[2]*q2.V[2]
}
208012
func (m Mat4x3) Col(col int) Vec4 {
	return Vec4{m[col*4+0], m[col*4+1], m[col*4+2], m[col*4+3]}
}
1025747
func Dot(v1, v2 []float32) (float32, error) {
	if len(v1) != len(v2) {
		return 0.0, fmt.Errorf("Length mismatched %d, %d\n", len(v1), len(v2))
	}
	sum := float32(0.0)
	for i := 0; i < len(v1); i++ {
		sum += v1[i] * v2[i]
	}
	return sum, nil
}
606626
func (s *Statement) Dot(name string) *Statement {
	d := token{
		typ:     delimiterToken,
		content: ".",
	}
	t := token{
		typ:     identifierToken,
		content: name,
	}
	*s = append(*s, d, t)
	return s
}
117198
func Dotted(d Duration, dots int) Duration {
	return Duration{d.Value, dots, false}
}
467221
func (v Vector) String() string {
	return fmt.Sprintf("<%f, %f>", v.x, v.y)
}
736010
func (v PreciseVector) Abs() PreciseVector {
	return PreciseVector{
		X: new(big.Float).Abs(v.X),
		Y: new(big.Float).Abs(v.Y),
		Z: new(big.Float).Abs(v.Z),
	}
}
810180
func Dot(s *fsm.State) string {
	trs := dot(s, mkStateNames(), map[*fsm.State]struct{}{})
	return fmt.Sprintf("digraph G {\n\trankdir=LR\n%s\n}\n", strings.Join(trs, "\n"))
}
189041
func Join(vectors ...Vector) Vector {
	// figure out how big to make the resulting vector so we can
	// allocate efficiently
	n := 0
	for _, vector := range vectors {
		n += vector.Len()
	}

	i := 0
	v := make(Vector, n)
	for _, vector := range vectors {
		for _, value := range vector {
			v[i] = value
			i++
		}
	}

	return v
}
817974
func (p Point) VectorTo(op *Point) *Vector {
	return NewVector(op.X()-p.x, op.Y()-p.y)
}
460386
func (ui *webInterface) dot(w http.ResponseWriter, req *http.Request) {
	rpt, errList := ui.makeReport(w, req, []string{"svg"})
	if rpt == nil {
		return // error already reported
	}

	// Generate dot graph.
	g, config := report.GetDOT(rpt)
	legend := config.Labels
	config.Labels = nil
	dot := &bytes.Buffer{}
	graph.ComposeDot(dot, g, &graph.DotAttributes{}, config)

	// Convert to svg.
	svg, err := dotToSvg(dot.Bytes())
	if err != nil {
		http.Error(w, "Could not execute dot; may need to install graphviz.",
			http.StatusNotImplemented)
		ui.options.UI.PrintErr("Failed to execute dot. Is Graphviz installed?\n", err)
		return
	}

	// Get all node names into an array.
	nodes := []string{""} // dot starts with node numbered 1
	for _, n := range g.Nodes {
		nodes = append(nodes, n.Info.Name)
	}

	ui.render(w, "graph", rpt, errList, legend, webArgs{
		HTMLBody: template.HTML(string(svg)),
		Nodes:    nodes,
	})
}