// Sum adds all the elements of a series together.
192030
func (s Seq) Sum() (accum float64) {
	if s.Len() == 0 {
		return 0
	}

	for i := 0; i < s.Len(); i++ {
		accum += s.GetValue(i)
	}
	return
}
635158
func (c *ChecksumWriter) Sum() ChecksumInfo {
	c.sum.MD5 = fmt.Sprintf("%x", c.hashes[0].Sum(nil))
	c.sum.SHA1 = fmt.Sprintf("%x", c.hashes[1].Sum(nil))
	c.sum.SHA256 = fmt.Sprintf("%x", c.hashes[2].Sum(nil))

	return c.sum
}
625110
func (l *List) Sum(i int) int64 {
	var sum int64
	for i > 0 {
		sum += l.tree[i-1]
		i -= i & -i
	}
	return sum
}
1303350
func Sum(data []byte) [Size]byte {
	imo := New()
	return imo.Sum(data)
}
1158179
func (m mathUtil) Sum(values ...float64) float64 {
	var total float64
	for _, v := range values {
		total += v
	}
	return total
}
541555
func MergeSum(vals []uint64) uint64 {
	rv := vals[0]
	for _, v := range vals[1:] {
		rv += v
	}
	return rv
}
258277
func (session *Session) Sums(bean interface{}, columnNames ...string) ([]float64, error) {
	var res = make([]float64, len(columnNames), len(columnNames))
	return res, session.sum(&res, bean, columnNames...)
}
806098
func (p Prefix) Sum(data []byte) (Cid, error) {
	length := p.MhLength
	if p.MhType == mh.ID {
		length = -1
	}

	hash, err := mh.Sum(data, p.MhType, length)
	if err != nil {
		return Undef, err
	}

	switch p.Version {
	case 0:
		return NewCidV0(hash), nil
	case 1:
		return NewCidV1(p.Codec, hash), nil
	default:
		return Undef, fmt.Errorf("invalid cid version")
	}
}
1201302
func sumSeries(series []models.Series, cache map[Req][]models.Series) models.Series {
	if len(series) == 1 {
		return series[0]
	}
	out := pointSlicePool.Get().([]schema.Point)
	crossSeriesSum(series, &out)
	var queryPatts []string

Loop:
	for _, v := range series {
		// avoid duplicates
		for _, qp := range queryPatts {
			if qp == v.QueryPatt {
				continue Loop
			}
		}
		queryPatts = append(queryPatts, v.QueryPatt)
	}
	name := fmt.Sprintf("sumSeries(%s)", strings.Join(queryPatts, ","))
	cons, queryCons := summarizeCons(series)
	sum := models.Series{
		Target:       name,
		QueryPatt:    name,
		Datapoints:   out,
		Interval:     series[0].Interval,
		Consolidator: cons,
		QueryCons:    queryCons,
		Tags:         map[string]string{"name": name},
	}
	cache[Req{}] = append(cache[Req{}], sum)
	return sum
}
413575
func (a512srv *Avx512Server) Sum(uid uint64, p []byte) [32]byte {
	sumCh := make(chan [32]byte)
	a512srv.blocksCh <- blockInput{uid: uid, msg: p, final: true, sumCh: sumCh}
	return <-sumCh
}
61730
func (engine *Engine) Sums(bean interface{}, colNames ...string) ([]float64, error) {
	session := engine.NewSession()
	defer session.Close()
	return session.Sums(bean, colNames...)
}
1366517
func (s Sample) Sum() float64 {
	if s.Weights == nil {
		return vec.Sum(s.Xs)
	}
	sum := 0.0
	for i, x := range s.Xs {
		sum += x * s.Weights[i]
	}
	return sum
}
1133693
func (v *view) sum(filter *Row, bitDepth uint) (sum, count uint64, err error) {
	for _, f := range v.allFragments() {
		fsum, fcount, err := f.sum(filter, bitDepth)
		if err != nil {
			return sum, count, err
		}
		sum += fsum
		count += fcount
	}
	return sum, count, nil
}
315042
func (s *State232) Sum(b []byte) []byte {
	s.hash = Hash232(s.tail, s.seed)
	h := s.hash
	return append(b, byte(h>>24), byte(h>>16), byte(h>>8), byte(h))
}
695233
func Sum(algo string, data []byte) ([]byte, error) {
	h, err := New(algo)
	if err != nil {
		return nil, err
	}

	_, err = h.Write(data)
	if err != nil {
		return nil, err
	}

	return h.Sum(nil), nil
}
908998
func Sum(inReal []float64, inTimePeriod int) []float64 {

	outReal := make([]float64, len(inReal))

	lookbackTotal := inTimePeriod - 1
	startIdx := lookbackTotal
	periodTotal := 0.0
	trailingIdx := startIdx - lookbackTotal
	i := trailingIdx
	if inTimePeriod > 1 {
		for i < startIdx {
			periodTotal += inReal[i]
			i++
		}
	}
	outIdx := startIdx
	for i < len(inReal) {
		periodTotal += inReal[i]
		tempReal := periodTotal
		periodTotal -= inReal[trailingIdx]
		outReal[outIdx] = tempReal
		i++
		trailingIdx++
		outIdx++
	}

	return outReal
}
55406
func Sum(out *[TagSize]byte, msg []byte, key *[32]byte) {
	poly.Sum(out, msg, key)
}