// Dot computes the dot product with u.
424670
func (v Vector) Dot(u Vector) float32 {
	return blas.Sdot(len(v), u, 1, v, 1)
}
905600
func (v PreciseVector) Dot(ov PreciseVector) *big.Float {
	return precAdd(precMul(v.X, ov.X), precAdd(precMul(v.Y, ov.Y), precMul(v.Z, ov.Z)))
}
248419
func (m Mat2x4) Abs() Mat2x4 {
	return Mat2x4{Abs(m[0]), Abs(m[1]), Abs(m[2]), Abs(m[3]), Abs(m[4]), Abs(m[5]), Abs(m[6]), Abs(m[7])}
}
725844
func (p *Point) Dot(v *Point) float64 {
	return p[0]*v[0] + p[1]*v[1]
}
911066
func (m Mat2x4) Row(row int) Vec4 {
	return Vec4{m[row+0], m[row+2], m[row+4], m[row+6]}
}
955425
func (m Mat2) Abs() Mat2 {
	return Mat2{Abs(m[0]), Abs(m[1]), Abs(m[2]), Abs(m[3])}
}
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,
	})
}
1366856
func (s Style) GetDotWidth(defaults ...float64) float64 {
	if s.DotWidth == 0 {
		if len(defaults) > 0 {
			return defaults[0]
		}
		return DefaultDotWidth
	}
	return s.DotWidth
}
1034774
func (m Mat4) Abs() Mat4 {
	return Mat4{Abs(m[0]), Abs(m[1]), Abs(m[2]), Abs(m[3]), Abs(m[4]), Abs(m[5]), Abs(m[6]), Abs(m[7]), Abs(m[8]), Abs(m[9]), Abs(m[10]), Abs(m[11]), Abs(m[12]), Abs(m[13]), Abs(m[14]), Abs(m[15])}
}
433146
func WriteDot(w io.Writer, nodes []Node) error {
	w.Write([]byte("digraph {\n"))
	defer w.Write([]byte("}\n"))

	for _, n := range nodes {
		nodeLine := fmt.Sprintf("\t\"%s\";\n", n)

		w.Write([]byte(nodeLine))

		for _, edge := range n.Edges() {
			target := edge.Tail()
			line := fmt.Sprintf("\t\"%s\" -> \"%s\" [label=\"%s\"];\n",
				n, target, edge)
			w.Write([]byte(line))
		}
	}

	return nil
}
711722
func (me identifier) Col(col interface{}) IdentifierExpression {
	ret := me.clone()
	if s, ok := me.col.(string); ok && s != "" && me.table == "" {
		ret.table = s
	}
	if col == "*" {
		ret.col = Star()
	} else {
		ret.col = col
	}

	return ret
}
1053432
func (m Mat2x4) Col(col int) Vec2 {
	return Vec2{m[col*2+0], m[col*2+1]}
}
185584
func (m Mat4) Row(row int) Vec4 {
	return Vec4{m[row+0], m[row+4], m[row+8], m[row+12]}
}
375838
func DotProduct(x, y Vector) (float64, error) {
	p, err := Product(x, y)
	if err != nil {
		return NA, err
	}
	return p.Sum(), nil
}
449982
func (mat *MatMxN) Trace() float64 {
	if mat == nil || mat.m != mat.n {
		return float64(math.NaN())
	}

	var out float64
	for i := 0; i < mat.m; i++ {
		out += mat.At(i, i)
	}

	return out
}
567884
func (c *Cosine) Dot(vectorX *mat.Dense, vectorY *mat.Dense) float64 {
	subVector := new(mat.Dense)
	subVector.MulElem(vectorX, vectorY)
	result := mat.Sum(subVector)

	return result
}
3504
func (c *Cosine) Distance(vectorX *mat.Dense, vectorY *mat.Dense) float64 {
	dotXY := c.Dot(vectorX, vectorY)
	lengthX := math.Sqrt(c.Dot(vectorX, vectorX))
	lengthY := math.Sqrt(c.Dot(vectorY, vectorY))

	cos := dotXY / (lengthX * lengthY)

	return 1 - cos
}