// Creates a n_comps array of n_feats x n_feats mat.Symmetrics
431538
func initCovariance(n_comps, n_feats int) []mat.Symmetric {
	var result []mat.Symmetric
	floats := identity(n_feats)
	for k := 0; k < n_comps; k++ {
		matrix := mat.NewSymDense(n_feats, floats)
		result = append(result, matrix)
	}
	return result
}
645943
func createMergeArray(keys, revs []string) ([]map[string]interface{}, error) {
	if keys == nil && revs == nil {
		return nil, nil
	}
	if revs == nil {
		mergeArray := make([]map[string]interface{}, len(keys))
		for i, k := range keys {
			mergeArray[i] = map[string]interface{}{
				"_key": k,
			}
		}
		return mergeArray, nil
	}
	if keys == nil {
		mergeArray := make([]map[string]interface{}, len(revs))
		for i, r := range revs {
			mergeArray[i] = map[string]interface{}{
				"_rev": r,
			}
		}
		return mergeArray, nil
	}
	if len(keys) != len(revs) {
		return nil, WithStack(InvalidArgumentError{Message: fmt.Sprintf("#keys must be equal to #revs, got %d, %d", len(keys), len(revs))})
	}
	mergeArray := make([]map[string]interface{}, len(keys))
	for i, k := range keys {
		mergeArray[i] = map[string]interface{}{
			"_key": k,
			"_rev": revs[i],
		}
	}
	return mergeArray, nil

}
652881
func NewMultiLayerNet(layers []int) *MultiLayerNet {
	return &MultiLayerNet{
		nil,
		make(map[base.Attribute]int),
		layers,
		0,
		0,
		0.001,
		500,
		0.90,
	}
}
613644
func (m Mat2x3) Cols() (col0, col1, col2 Vec2) {
	return m.Col(0), m.Col(1), m.Col(2)
}
255682
func Mat3FromRows(row0, row1, row2 Vec3) Mat3 {
	return Mat3{row0[0], row1[0], row2[0], row0[1], row1[1], row2[1], row0[2], row1[2], row2[2]}
}
860079
func buildRespForMulticast(to []string, mrs multicastResultsState, mid int) *HttpResponse {
	resp := &HttpResponse{}
	resp.MulticastId = mid
	resp.Results = make([]Result, len(to))
	for i, regId := range to {
		result, ok := mrs[regId]
		if !ok {
			continue
		}
		resp.Results[i] = *result
		if result.MessageId != "" {
			resp.Success++
		} else if result.Error != "" {
			resp.Failure++
		}
		if result.RegistrationId != "" {
			resp.CanonicalIds++
		}
	}
	return resp
}
1311703
func InstancesFromMat64(rows, cols int, data *mat.Dense) *Mat64Instances {

	var ret Mat64Instances
	for i := 0; i < cols; i++ {
		ret.attributes = append(ret.attributes, NewFloatAttribute(fmt.Sprintf("%d", i)))
	}

	ret.classAttrs = make(map[int]bool)
	ret.Data = data
	ret.rows = rows

	return &ret
}
983819
func BuildDimensions(mTags map[string]string) []*cloudwatch.Dimension {
	const MaxDimensions = 10
	dimensions := make([]*cloudwatch.Dimension, 0, MaxDimensions)

	// This is pretty ugly but we always want to include the "host" tag if it exists.
	if host, ok := mTags["host"]; ok {
		dimensions = append(dimensions, &cloudwatch.Dimension{
			Name:  aws.String("host"),
			Value: aws.String(host),
		})
	}

	var keys []string
	for k := range mTags {
		if k != "host" {
			keys = append(keys, k)
		}
	}
	sort.Strings(keys)

	for _, k := range keys {
		if len(dimensions) >= MaxDimensions {
			break
		}

		value := mTags[k]
		if value == "" {
			continue
		}

		dimensions = append(dimensions, &cloudwatch.Dimension{
			Name:  aws.String(k),
			Value: aws.String(mTags[k]),
		})
	}

	return dimensions
}
178186
func genEncMatrix(d, p int) matrix {
	r := d + p
	m := make([]byte, r*d)
	// create identity matrix upper
	for i := 0; i < d; i++ {
		m[i*d+i] = byte(1)
	}
	// create cauchy matrix below
	off := d * d // offset of encMatrix
	for i := d; i < r; i++ {
		for j := 0; j < d; j++ {
			d := i ^ j
			a := inverseTbl[d]
			m[off] = byte(a)
			off++
		}
	}
	return m
}
1024175
func (d *DefaultMetricCollector) ShortCircuits() *rolling.Number {
	d.mutex.RLock()
	defer d.mutex.RUnlock()
	return d.shortCircuits
}
163240
func SwilkCoeffs(n int) []float64 {

	a := make([]float64, n+1)

	an := float64(n)

	n2 := n / 2

	if n == 3 {
		a[1] = sqrth
	} else {
		an25 := an + 0.25
		summ2 := 0.0
		for i := 1; i <= n2; i++ {
			a[i] = ppnd((float64(i) - th) / an25)
			summ2 += a[i] * a[i]
		}
		summ2 *= 2.0
		ssumm2 := math.Sqrt(summ2)
		rsn := 1.0 / math.Sqrt(an)
		a1 := poly(c1, 6, rsn) - a[1]/ssumm2

		// Normalize coefficients

		var i1 int
		var fac float64
		if n > 5 {
			i1 = 3
			a2 := -a[2]/ssumm2 + poly(c2, 6, rsn)
			fac = math.Sqrt((summ2 - 2.0*a[1]*a[1] - 2.0*a[2]*a[2]) / (1.0 - 2.0*a1*a1 - 2.0*a2*a2))
			a[1] = a1
			a[2] = a2
		} else {
			i1 = 2
			fac = math.Sqrt((summ2 - 2.0*a[1]*a[1]) / (1.0 - 2.0*a1*a1))
			a[1] = a1
		}
		for i := i1; i <= n2; i++ {
			a[i] = -a[i] / fac
		}
	}

	return a
}
928585
func MakeMatrix2(x [][]complex128) *Matrix {
	dims := []int{len(x), len(x[0])}
	r := make([]complex128, dims[0]*dims[1])
	for n, v := range x {
		if len(v) != dims[1] {
			panic("ragged array")
		}

		copy(r[n*dims[1]:(n+1)*dims[1]], v)
	}

	return MakeMatrix(r, dims)
}
707712
func (a *AllocRegistration) NumChecks() int {
	if a == nil {
		return 0
	}

	total := 0
	for _, treg := range a.Tasks {
		for _, sreg := range treg.Services {
			total += len(sreg.Checks)
		}
	}

	return total
}
1142635
func (m Mat2x4) Cols() (col0, col1, col2, col3 Vec2) {
	return m.Col(0), m.Col(1), m.Col(2), m.Col(3)
}
439033
func dedupMergeClasses(rules []Rule, classes []string) []Rule {
	classIdx := func(class string) int {
		if class == "" {
			return math.MaxInt32
		}
		for i := range classes {
			if classes[i] == class {
				return i
			}
		}
		return math.MaxInt32
	}

	result := []Rule{}
	for i := range rules {
		found := false
		for j := range result {
			if rules[i].sameExceptClass(result[j]) {
				classIdxI := classIdx(rules[i].Class)
				classIdxJ := classIdx(result[j].Class)

				if classIdxI < classIdxJ {
					rules[i].Properties.updateMissing(result[j].Properties)
					result[j] = rules[i]
				} else if classIdxJ < classIdxI {
					result[j].Properties.updateMissing(rules[i].Properties)
				}
				found = true
				break
			}
		}
		if !found {
			result = append(result, rules[i])
		}
	}
	return result
}
871079
func (mat *MatMxN) NumRowCols() (rows, cols int) {
	return mat.m, mat.n
}
584865
func (mat *T) AssignCoordinateSystem(x, y, z *vec3.T) *T {
	mat[0][0] = x[0]
	mat[1][0] = x[1]
	mat[2][0] = x[2]

	mat[0][1] = y[0]
	mat[1][1] = y[1]
	mat[2][1] = y[2]

	mat[0][2] = z[0]
	mat[1][2] = z[1]
	mat[2][2] = z[2]

	return mat
}