// CumulativeF creates a SignalFx cumulative counter for float values.
541166
func CumulativeF(metricName string, dimensions map[string]string, val float64) *datapoint.Datapoint {
	return datapoint.New(metricName, dimensions, datapoint.NewFloatValue(val), datapoint.Counter, time.Time{})
}
843464
func Tracef(e *logrus.Entry, format string, args ...interface{}) {
	level := logrus.Level(atomic.LoadUint32((*uint32)(&e.Logger.Level)))
	if level >= TraceLevel {
		e.Debugf(format, args...)
	}
}
923548
func (c *Chunk) AppendFloat32(colIdx int, f float32) {
	c.columns[colIdx].appendFloat32(f)
}
110820
func (r *Regression) Coeff(i int) float64 {
	if len(r.coeff) == 0 {
		return 0
	}
	return r.coeff[i]
}
1094174
func Linear(width int) ScaleFunc {
	return func(min, max, value float64) float64 {
		diff := max - min
		offset := value - min
		ratio := offset / diff
		return ratio * float64(width)
	}
}
60768
func Cumulative(metricName string, dimensions map[string]string, val int64) *datapoint.Datapoint {
	return datapoint.New(metricName, dimensions, datapoint.NewIntValue(val), datapoint.Counter, time.Time{})
}
142514
func IncrPowOf(a []float64, s float64, incr []float64) {
	incr = incr[:len(a)]
	for i, v := range a {
		incr[i] += math.Pow(v, s)
	}
}
203749
func FloatFromPtr(f *float64) Float {
	if f == nil {
		return NewFloat(0, false)
	}
	return NewFloat(*f, true)
}
1227319
func CrossVF(a Vect, s Float) Vect {
	return Vect{s * a.Y, -s * a.X}
}
546130
func ClampFunc(low, high float32) func(float32) float32 {
	return func(a float32) float32 {
		return Clamp(a, low, high)
	}
}
697258
func (s *CountService) Df(df string) *CountService {
	s.df = df
	return s
}
1030339
func (buf *FloatBuffer) AsFloat32Buffer() *Float32Buffer {
	newB := &Float32Buffer{}
	newB.Data = make([]float32, len(buf.Data))
	for i := 0; i < len(buf.Data); i++ {
		newB.Data[i] = float32(buf.Data[i])
	}
	newB.Format = &Format{
		NumChannels: buf.Format.NumChannels,
		SampleRate:  buf.Format.SampleRate,
	}
	return newB
}
500441
func normalizeFunc(edges []*lnrpc.ChannelEdge, scaleFactor float64) func(int64) float64 {
	var (
		min float64 = math.MaxInt64
		max float64
	)

	for _, edge := range edges {
		// In order to obtain saner values, we reduce the capacity of a
		// channel to its base 2 logarithm.
		z := math.Log2(float64(edge.Capacity))

		if z < min {
			min = z
		}
		if z > max {
			max = z
		}
	}

	return func(x int64) float64 {
		y := math.Log2(float64(x))

		// TODO(roasbeef): results in min being zero
		return (y - min) / (max - min) * scaleFactor
	}
}
1021107
func (s *regexFcd) calculateFC(nt nodeType, node *regexNode, CurIndex int) {
	//fmt.Printf("NodeType: %v, CurIndex: %v, Desc: %v\n", nt, CurIndex, node.description())
	ci := false
	rtl := false

	if nt <= ntRef {
		if (node.options & IgnoreCase) != 0 {
			ci = true
		}
		if (node.options & RightToLeft) != 0 {
			rtl = true
		}
	}

	switch nt {
	case ntConcatenate | beforeChild, ntAlternate | beforeChild, ntTestref | beforeChild, ntLoop | beforeChild, ntLazyloop | beforeChild:
		break

	case ntTestgroup | beforeChild:
		if CurIndex == 0 {
			s.skipChild()
		}
		break

	case ntEmpty:
		s.pushFC(regexFc{nullable: true})
		break

	case ntConcatenate | afterChild:
		if CurIndex != 0 {
			child := s.popFC()
			cumul := s.topFC()

			s.failed = !cumul.addFC(*child, true)
		}

		fc := s.topFC()
		if !fc.nullable {
			s.skipAllChildren = true
		}
		break

	case ntTestgroup | afterChild:
		if CurIndex > 1 {
			child := s.popFC()
			cumul := s.topFC()

			s.failed = !cumul.addFC(*child, false)
		}
		break

	case ntAlternate | afterChild, ntTestref | afterChild:
		if CurIndex != 0 {
			child := s.popFC()
			cumul := s.topFC()

			s.failed = !cumul.addFC(*child, false)
		}
		break

	case ntLoop | afterChild, ntLazyloop | afterChild:
		if node.m == 0 {
			fc := s.topFC()
			fc.nullable = true
		}
		break

	case ntGroup | beforeChild, ntGroup | afterChild, ntCapture | beforeChild, ntCapture | afterChild, ntGreedy | beforeChild, ntGreedy | afterChild:
		break

	case ntRequire | beforeChild, ntPrevent | beforeChild:
		s.skipChild()
		s.pushFC(regexFc{nullable: true})
		break

	case ntRequire | afterChild, ntPrevent | afterChild:
		break

	case ntOne, ntNotone:
		s.pushFC(newRegexFc(node.ch, nt == ntNotone, false, ci))
		break

	case ntOneloop, ntOnelazy:
		s.pushFC(newRegexFc(node.ch, false, node.m == 0, ci))
		break

	case ntNotoneloop, ntNotonelazy:
		s.pushFC(newRegexFc(node.ch, true, node.m == 0, ci))
		break

	case ntMulti:
		if len(node.str) == 0 {
			s.pushFC(regexFc{nullable: true})
		} else if !rtl {
			s.pushFC(newRegexFc(node.str[0], false, false, ci))
		} else {
			s.pushFC(newRegexFc(node.str[len(node.str)-1], false, false, ci))
		}
		break

	case ntSet:
		s.pushFC(regexFc{cc: node.set.Copy(), nullable: false, caseInsensitive: ci})
		break

	case ntSetloop, ntSetlazy:
		s.pushFC(regexFc{cc: node.set.Copy(), nullable: node.m == 0, caseInsensitive: ci})
		break

	case ntRef:
		s.pushFC(regexFc{cc: *AnyClass(), nullable: true, caseInsensitive: false})
		break

	case ntNothing, ntBol, ntEol, ntBoundary, ntNonboundary, ntECMABoundary, ntNonECMABoundary, ntBeginning, ntStart, ntEndZ, ntEnd:
		s.pushFC(regexFc{nullable: true})
		break

	default:
		panic(fmt.Sprintf("unexpected op code: %v", nt))
	}
}
726755
func floatToValue(f float64) *Value {
	intPart, fracPart := math.Modf(f)
	if fracPart == 0 {
		return FromInt(int64(intPart))
	}
	return FromFloat(f)
}
233563
func (c Chain) HandlerCF(xhc HandlerFuncC) HandlerC {
	return c.HandlerC(HandlerFuncC(xhc))
}
269034
func (x Vector) Cumsum() Vector {
	y := make(Vector, len(x))

	y[0] = x[0]

	i := 1
	for i < len(x) {
		y[i] = x[i] + y[i-1]
		i++
	}

	return y
}