// Create normalized array from bools
16072
func createFromBool(data [][]bool) []*TabulateRow {
	rows := make([]*TabulateRow, len(data))
	for index_1, arr := range data {
		row := make([]string, len(arr))
		for index, el := range arr {
			row[index] = strconv.FormatBool(el)
		}
		rows[index_1] = &TabulateRow{Elements: row}
	}
	return rows
}
823243
func (d *Drain) BoolArray(ps ProxySet) []bool {
	v, err := ps.BoolArray()
	d.put(err)
	return v
}
646521
func ensureArray(a []interface{}, l int) []interface{} {
	if len(a) >= l {
		return a
	}
	b := make([]interface{}, l)
	copy(b, a)
	return b
}
1293711
func (k *Kernel) Normalized() Matrix {
	sum := k.Absum()
	w := k.Width
	h := k.Height
	nk := NewKernel(w, h)

	// avoid division by 0
	if sum == 0 {
		sum = 1
	}

	for i := 0; i < w*h; i++ {
		nk.Matrix[i] = k.Matrix[i] / sum
	}

	return nk
}
740296
func (s *SparseRange) Normalize() error {
	if len(s.Items) == 0 {
		s.Items = []*RangeItem{{RangeItem: &RangeItem_Single{1}}}
		return nil
	}
	current := uint32(0)
	for _, itm := range s.Items {
		switch i := itm.RangeItem.(type) {
		case *RangeItem_Single:
			if i.Single <= current {
				return fmt.Errorf("malformed SparseRange")
			}
			current = i.Single
		case *RangeItem_Range:
			if err := i.Range.Normalize(); err != nil {
				return err
			}
			if i.Range.Low <= current {
				return fmt.Errorf("malformed SparseRange")
			}
			current = i.Range.High
		default:
			return fmt.Errorf("unknown SparseRange entry")
		}
	}
	return nil
}
773846
func (m mathUtil) Normalize(values ...float64) []float64 {
	var total float64
	for _, v := range values {
		total += v
	}
	output := make([]float64, len(values))
	for x, v := range values {
		output[x] = m.RoundDown(v/total, 0.0001)
	}
	return output
}
51601
func BoolSlice(val, sep string) ([]bool, error) {
	s := strings.Split(val, sep)
	values := make([]bool, len(s))
	for i, v := range s {
		value, err := Bool(v)
		if err != nil {
			return values, err
		}
		values[i] = value
	}
	return values, nil
}
405533
func flattenValues(values map[string][]string) map[string]interface{} {
	result := make(map[string]interface{})

	for k, v := range values {
		if len(v) == 1 {
			result[k] = v[0]
		} else {
			result[k] = v
		}
	}

	return result
}
793738
func BooleanArrayEncodeAll(src []bool, b []byte) ([]byte, error) {
	sz := 1 + 8 + ((len(src) + 7) / 8) // Header + Num bools + bool data.
	if len(b) < sz && cap(b) > sz {
		b = b[:sz]
	} else if len(b) < sz {
		b = append(b, make([]byte, sz)...)
	}

	// Store the encoding type in the 4 high bits of the first byte
	b[0] = byte(booleanCompressedBitPacked) << 4
	n := uint64(8) // Current bit in current byte.

	// Encode the number of booleans written.
	i := binary.PutUvarint(b[n>>3:], uint64(len(src)))
	n += uint64(i * 8)

	for _, v := range src {
		if v {
			b[n>>3] |= 128 >> (n & 7) // Set current bit on current byte.
		} else {
			b[n>>3] &^= 128 >> (n & 7) // Clear current bit on current byte.
		}
		n++
	}

	length := n >> 3
	if n&7 > 0 {
		length++ // Add an extra byte to capture overflowing bits.
	}
	return b[:length], nil
}
1283389
func NewDoubleArray(seqs [][]string) *DoubleArray {
	da := &DoubleArray{Encoding: make(map[string]int)}
	if len(seqs) == 0 {
		return da
	}

	encoded := registerTokens(da, seqs)
	sort.Sort(byLex(encoded))

	root := node{row: -1, col: -1, left: 0, right: len(encoded)}
	addSeqs(da, encoded, 0, root)

	for i := len(da.Base); i > 0; i-- {
		if da.Check[i-1] != 0 {
			da.Base = da.Base[:i]
			da.Check = da.Check[:i]
			break
		}
	}
	return da
}
779451
func (vec *T) Normalize() *T {
	v3 := vec.Vec3DividedByW()
	v3.Normalize()
	vec[0] = v3[0]
	vec[1] = v3[1]
	vec[2] = v3[2]
	vec[3] = 1
	return vec
}
681485
func (n *normalizer) Normalize(un *unstructured.Unstructured) error {
	matched := make([]normalizerPatch, 0)
	for _, patch := range n.patches {
		groupKind := un.GroupVersionKind().GroupKind()
		if groupKind == patch.groupKind &&
			(patch.name == "" || patch.name == un.GetName()) &&
			(patch.namespace == "" || patch.namespace == un.GetNamespace()) {

			matched = append(matched, patch)
		}
	}
	if len(matched) == 0 {
		return nil
	}

	docData, err := json.Marshal(un)
	if err != nil {
		return err
	}

	for _, patch := range matched {
		patchedData, err := patch.patch.Apply(docData)
		if err != nil {
			// bug?
			if strings.HasPrefix(err.Error(), "Unable to remove nonexistent key") {
				continue
			}
			return err
		}
		docData = patchedData
	}

	err = json.Unmarshal(docData, un)
	if err != nil {
		return err
	}
	return nil
}
450867
func (ba *BoolArray) BoolArrayOr(or []bool) []bool {
	switch {
	case ba == nil:
		return or
	case !ba.Valid:
		return or
	default:
		return ba.BoolArray
	}
}
1271326
func (v *Value) Normalize() error {
	norm, needsNormalization := v.Value.(interface {
		Normalize() error
	})
	if !needsNormalization {
		return nil
	}
	return norm.Normalize()
}
454991
func (v Vector) Normalise() {
	w := blas.Snrm2(len(v), v, 1)
	blas.Sscal(len(v), 1/w, v, 1)
}
781399
func normalize(v reflect.Value) interface{} {
	k := v.Kind()

	switch {
	case isNumber(k):
		f, err := numberToFloat(v)
		if err == nil {
			return f
		}
	}

	return v.Interface()
}
870276
func NewArrayValue(unindexed ...bool) Value {
	return Value{Array, nil, optionalBool(unindexed, false)}
}