// MakeEmptyMatrix creates an empty Matrix with given dimensions.
504599
func MakeEmptyMatrix(dims []int) *Matrix {
	x := 1
	for _, v := range dims {
		x *= v
	}

	return MakeMatrix(make([]complex128, x), dims)
}
605262
func mean(matrix *mat.Dense) *mat.Dense {
	rows, cols := matrix.Dims()
	meanVector := make([]float64, cols)
	for i := 0; i < cols; i++ {
		sum := mat.Sum(matrix.ColView(i))
		meanVector[i] = sum / float64(rows)
	}
	return mat.NewDense(1, cols, meanVector)
}
475158
func NewAdjacencyMatrixAggregation() *AdjacencyMatrixAggregation {
	return &AdjacencyMatrixAggregation{
		filters:         make(map[string]Query),
		subAggregations: make(map[string]Aggregation),
	}
}
1055997
func CreateMultipartMetadata(metadata map[string]string) map[string]string {
	if metadata == nil {
		metadata = map[string]string{}
	}
	metadata[SSEMultipart] = ""
	return metadata
}
834156
func longestCommonSubsequenceMatrix(seq1, seq2 []string) [][]int {
	matrix := intMatrix(len(seq1)+1, len(seq2)+1)
	for i := 1; i < len(matrix); i++ {
		for j := 1; j < len(matrix[i]); j++ {
			if seq1[len(seq1)-i] == seq2[len(seq2)-j] {
				matrix[i][j] = matrix[i-1][j-1] + 1
			} else {
				matrix[i][j] = int(math.Max(float64(matrix[i-1][j]),
					float64(matrix[i][j-1])))
			}
		}
	}
	return matrix
}
1076678
func generateEmptyInitPy(dir string) error {
	return commons.GenerateFile(nil, "./templates/python/init_py.tmpl", "init_py", filepath.Join(dir, "__init__.py"), false)
}
590085
func deleteEmptyMapValues(i interface{}) bool {
	switch i := i.(type) {
	case map[interface{}]interface{}:
		if len(i) == 0 {
			return true
		} else {
			for k, v := range i {
				if deleteEmptyMapValues(v) {
					delete(i, k)
				}
			}
		}
	case []interface{}:
		if len(i) == 0 {
			return true
		} else {
			for _, e := range i {
				deleteEmptyMapValues(e)
			}
		}
	case nil:
		return true
	}
	return false
}
514821
func namePartFromDimensions(m stringmapflag.Value) string {
	a := mapToArray(m)
	pairs := make([]string, 0, len(a))
	for i := 0; i < len(a); i++ {
		pairs = append(pairs, fmt.Sprintf("%s=%s", a[i].Key, a[i].Value))
	}
	return strings.Join(pairs, "_")
}
900658
func (b *LEDDriver) ReadMatrix() (data []byte, err error) {
	data, err = b.adaptor().ReadCharacteristic(ledMatrixStateCharacteristic)
	return
}
216521
func NewEmptyConfig() *Config {
	ret := &Config{}
	ret.Root = ret
	ret.Children = make(map[string]*Config)
	ret.Module = &Module{}
	return ret
}
341146
func FixEmptyDesc(rs *spec.Response) {
	if rs == nil || rs.Description != "" || rs.Ref.Ref.GetURL() != nil {
		return
	}
	rs.Description = "(empty)"
}
687532
func newMatrix(rows, cols int) (matrix, error) {
	if rows <= 0 {
		return nil, errInvalidRowSize
	}
	if cols <= 0 {
		return nil, errInvalidColSize
	}

	m := matrix(make([][]byte, rows))
	for i := range m {
		m[i] = make([]byte, cols)
	}
	return m, nil
}
1323025
func (cr *Context) GetFontMatrix(matrix *Matrix) {
	C.cairo_get_font_matrix(cr.Ptr, (*C.cairo_matrix_t)(unsafe.Pointer(matrix)))
	if err := cr.status(); err != nil {
		panic(err)
	}
}
207185
func newAllocMatrix(job *structs.Job, allocs []*structs.Allocation) allocMatrix {
	m := allocMatrix(make(map[string]allocSet))
	for _, a := range allocs {
		s, ok := m[a.TaskGroup]
		if !ok {
			s = make(map[string]*structs.Allocation)
			m[a.TaskGroup] = s
		}
		s[a.ID] = a
	}

	if job != nil {
		for _, tg := range job.TaskGroups {
			if _, ok := m[tg.Name]; !ok {
				m[tg.Name] = make(map[string]*structs.Allocation)
			}
		}
	}
	return m
}
405454
func (m matrix) SubMatrix(rmin, cmin, rmax, cmax int) (matrix, error) {
	result, err := newMatrix(rmax-rmin, cmax-cmin)
	if err != nil {
		return nil, err
	}
	// OPTME: If used heavily, use copy function to copy slice
	for r := rmin; r < rmax; r++ {
		for c := cmin; c < cmax; c++ {
			result[r-rmin][c-cmin] = m[r][c]
		}
	}
	return result, nil
}
1308349
func (m *Matrix) Transpose() *Matrix {
	rows, cols := m.Size()
	m2 := Zero(cols, rows)
	for i := 0; i < rows; i++ {
		for j := 0; j < cols; j++ {
			m2.Set(j, i, m.Get(i, j))
		}
	}
	return m2
}
1216090
func (m *Matrix) To2D() [][]complex128 {
	if len(m.dims) != 2 {
		panic("can only convert 2-D Matrixes")
	}

	r := make([][]complex128, m.dims[0])
	for i := 0; i < m.dims[0]; i++ {
		r[i] = make([]complex128, m.dims[1])
		copy(r[i], m.list[i*m.dims[1]:(i+1)*m.dims[1]])
	}

	return r
}