// Find the max value of a mat.Vector
763546
func vectorMax(v mat.Vector) float64 {
	n_obs, _ := v.Dims()
	max := v.At(0, 0)
	for i := 0; i < n_obs; i++ {
		if v.At(i, 0) > max {
			max = v.At(i, 0)
		}
	}
	return max
}
1166613
func (r Rect) Norm() Rect {
	return Rect{
		Min: Vec{
			math.Min(r.Min.X, r.Max.X),
			math.Min(r.Min.Y, r.Max.Y),
		},
		Max: Vec{
			math.Max(r.Min.X, r.Max.X),
			math.Max(r.Min.Y, r.Max.Y),
		},
	}
}
600851
func (s Seq) Max() float64 {
	if s.Len() == 0 {
		return 0
	}
	max := s.GetValue(0)
	var value float64
	for i := 1; i < s.Len(); i++ {
		value = s.GetValue(i)
		if value > max {
			max = value
		}
	}
	return max
}
1240423
func (mat *MatMxN) Zero(m, n int) {
	if mat == nil {
		return
	}

	mat.Reshape(m, n)
	for i := range mat.dat {
		mat.dat[i] = 0
	}
}
587786
func (t *LLRB) Max() Item {
	h := t.root
	if h == nil {
		return nil
	}
	for h.Right != nil {
		h = h.Right
	}
	return h.Item
}
233724
func Max(v1, v2 Vect) (out Vect) {
	if v1.X > v2.X {
		out.X = v1.X
	} else {
		out.X = v2.X
	}

	if v1.Y > v2.Y {
		out.Y = v1.Y
	} else {
		out.Y = v2.Y
	}
	return
}
1097264
func (t proofTerm) max(u proofTerm) proofTerm {
	if t.lessThanOrEqual(u) {
		return u
	}
	return t
}
798304
func (h *Histogram) Max() int64 {
	var max int64
	i := h.iterator()
	for i.next() {
		if i.countAtIdx != 0 {
			max = i.highestEquivalentValue
		}
	}
	return h.highestEquivalentValue(max)
}
891309
func (m *Matrix) DiagonalVector() Vector {
	rows, cols := m.Size()
	rank := minInt(rows, cols)
	values := make([]float64, rank)

	for index := 0; index < rank; index++ {
		values[index] = m.Get(index, index)
	}
	return Vector(values)
}
480892
func MinMax(min, max time.Time) (time.Time, time.Time) {
	if IsGreaterThan(min, max, false) {
		return max, min
	}
	return min, max
}
223424
func (t *Tree) Max() Interface {
	if t.Root == nil {
		return nil
	}
	return t.Root.max().Elem
}
479140
func ExtractMaxValuesPerFacet(opts ...interface{}) *opt.MaxValuesPerFacetOption {
	for _, o := range opts {
		if v, ok := o.(*opt.MaxValuesPerFacetOption); ok {
			return v
		}
	}
	return nil
}
378439
func (impl *Standard) Isamax(n int, x []float32, incX int) (retVal int) {
	// declared at cublasgen.h:384:17 enum CUBLAS_STATUS { ... } cublasIsamax ...
	if impl.e != nil {
		return
	}

	if n < 0 {
		panic("blas: n < 0")
	}
	if incX == 0 {
		panic("blas: zero x index increment")
	}
	if n == 0 || incX < 0 {
		return -1
	}
	if incX > 0 && (n-1)*incX >= len(x) {
		panic("blas: x index out of range")
	}
	if n == 0 {
		return
	}
	var ret C.int
	impl.e = status(C.cublasIsamax(C.cublasHandle_t(impl.h), C.int(n), (*C.float)(&x[0]), C.int(incX), &ret))
	return int(ret)
}
1274368
func getMaxMinFromDimensionRef(ref string) (minx, miny, maxx, maxy int, err error) {
	var parts []string
	parts = strings.Split(ref, cellRangeChar)
	minx, miny, err = GetCoordsFromCellIDString(parts[0])
	if err != nil {
		return -1, -1, -1, -1, err
	}
	maxx, maxy, err = GetCoordsFromCellIDString(parts[1])
	if err != nil {
		return -1, -1, -1, -1, err
	}
	return
}
882309
func Maximum(path, in string, data, max float64, exclusive bool) *errors.Validation {
	if (!exclusive && data > max) || (exclusive && data >= max) {
		return errors.ExceedsMaximum(path, in, max, exclusive)
	}
	return nil
}
638497
func (c C) Max(other Input) Input {
	if v, ok := other.(C); ok {
		return C(maxFloat32(float32(c), float32(v)))
	}
	return other.Max(c)
}
686714
func MultiplyMatrixVector(m *Matrix, v []float32) []float32 {
	if len(v) == 2 {
		v = []float32{v[0], v[1], 1}
	}
	v00 := m.Val[m00]*v[m00] + m.Val[m01]*v[m10] + m.Val[m02]*v[m20]
	v10 := m.Val[m10]*v[m00] + m.Val[m11]*v[m10] + m.Val[m12]*v[m20]
	v20 := m.Val[m20]*v[m00] + m.Val[m21]*v[m10] + m.Val[m22]*v[m20]
	return []float32{v00, v10, v20}
}