/*LinearRegAngle - Linear Regression Angle

Input = double

Output = double

Optional Parameters

-------------------

optInTimePeriod:(From 2 to 100000)

Number of period

*/
324678
func LinearRegAngle(real []float64, timePeriod int32) []float64 {
	var outBegIdx C.int
	var outNBElement C.int
	outReal := make([]float64, len(real))
	C.TA_LINEARREG_ANGLE(0, C.int(len(real)-1), (*C.double)(unsafe.Pointer(&real[0])), C.int(timePeriod), &outBegIdx, &outNBElement, (*C.double)(unsafe.Pointer(&outReal[0])))
	return outReal[:outNBElement]
}
1135845
func linear(v0, v1, v2, v3 *uint32) {
	t0 := ((*v0 << 13) | (*v0 >> (32 - 13)))
	t2 := ((*v2 << 3) | (*v2 >> (32 - 3)))
	t1 := *v1 ^ t0 ^ t2
	t3 := *v3 ^ t2 ^ (t0 << 3)
	*v1 = (t1 << 1) | (t1 >> (32 - 1))
	*v3 = (t3 << 7) | (t3 >> (32 - 7))
	t0 ^= *v1 ^ *v3
	t2 ^= *v3 ^ (*v1 << 7)
	*v0 = (t0 << 5) | (t0 >> (32 - 5))
	*v2 = (t2 << 22) | (t2 >> (32 - 22))
}
911948
func (macd MACDSeries) GetPeriods() (w1, w2, sig int) {
	if macd.PrimaryPeriod == 0 {
		w1 = DefaultMACDPeriodPrimary
	} else {
		w1 = macd.PrimaryPeriod
	}
	if macd.SecondaryPeriod == 0 {
		w2 = DefaultMACDPeriodSecondary
	} else {
		w2 = macd.SecondaryPeriod
	}
	if macd.SignalPeriod == 0 {
		sig = DefaultMACDSignalPeriod
	} else {
		sig = macd.SignalPeriod
	}
	return
}
1088338
func (s *Channel) SetRetentionPeriod(v *RetentionPeriod) *Channel {
	s.RetentionPeriod = v
	return s
}
1287678
func LinearDelayFunction(retryDelay uint, retries uint) time.Duration {
	return time.Duration(retryDelay*retries) * time.Millisecond
}
124898
func (t *Translator) formatDateTimeComponentPeriodNarrow(hour int) string {
	if hour < 12 {
		return t.rules.DateTime.FormatNames.Periods.Narrow.AM
	}

	return t.rules.DateTime.FormatNames.Periods.Narrow.PM
}
108207
func ExponentialRegression(s Series) (regressions Series, err error) {

	if len(s) == 0 {
		return nil, EmptyInputErr
	}

	var sum [6]float64

	for i := 0; i < len(s); i++ {
		if s[i].Y < 0 {
			return nil, YCoordErr
		}
		sum[0] += s[i].X
		sum[1] += s[i].Y
		sum[2] += s[i].X * s[i].X * s[i].Y
		sum[3] += s[i].Y * math.Log(s[i].Y)
		sum[4] += s[i].X * s[i].Y * math.Log(s[i].Y)
		sum[5] += s[i].X * s[i].Y
	}

	denominator := (sum[1]*sum[2] - sum[5]*sum[5])
	a := math.Pow(math.E, (sum[2]*sum[3]-sum[5]*sum[4])/denominator)
	b := (sum[1]*sum[4] - sum[5]*sum[3]) / denominator

	for j := 0; j < len(s); j++ {
		regressions = append(regressions, Coordinate{
			X: s[j].X,
			Y: a * math.Exp(b*s[j].X),
		})
	}

	return regressions, nil
}
496966
func MinIndex(real []float64, timePeriod int32) []int32 {
	var outBegIdx C.int
	var outNBElement C.int
	outInteger := make([]int32, len(real))
	C.TA_MININDEX(0, C.int(len(real)-1), (*C.double)(unsafe.Pointer(&real[0])), C.int(timePeriod), &outBegIdx, &outNBElement, (*C.int)(unsafe.Pointer(&outInteger[0])))
	return outInteger[:outNBElement]
}
995980
func (s *GetReservationPurchaseRecommendationInput) SetLookbackPeriodInDays(v string) *GetReservationPurchaseRecommendationInput {
	s.LookbackPeriodInDays = &v
	return s
}
352387
func (t *Translator) formatDateTimeComponentPeriod(datetime time.Time, length int) (string, error) {
	hour := datetime.Hour()

	switch length {
	case datetimeFormatLength1Plus:
		return t.formatDateTimeComponentPeriodWide(hour), nil
	case datetimeFormatLengthAbbreviated:
		return t.formatDateTimeComponentPeriodAbbreviated(hour), nil
	case datetimeFormatLengthWide:
		return t.formatDateTimeComponentPeriodWide(hour), nil
	case datetimeFormatLengthNarrow:
		return t.formatDateTimeComponentPeriodNarrow(hour), nil
	}

	return "", translatorError{message: fmt.Sprintf("unsupported day-period: %d", length)}
}
1226991
func MinMax(real []float64, timePeriod int32) ([]float64, []float64) {
	var outBegIdx C.int
	var outNBElement C.int
	outMin := make([]float64, len(real))
	outMax := make([]float64, len(real))
	C.TA_MINMAX(0, C.int(len(real)-1), (*C.double)(unsafe.Pointer(&real[0])), C.int(timePeriod), &outBegIdx, &outNBElement, (*C.double)(unsafe.Pointer(&outMin[0])), (*C.double)(unsafe.Pointer(&outMax[0])))
	return outMin[:outNBElement], outMax[:outNBElement]
}
848166
func (servo *Servo) SetPeriod(milliseconds int) error {
	return servo.PWM.SetPeriod(servo.Pin, int64(milliseconds*1000000))
}
1051079
func NewDefaultLinRegAngWithSrcLen(sourceLength uint) (indicator *LinRegAng, err error) {
	ind, err := NewDefaultLinRegAng()

	// only initialise the storage if there is enough source data to require it
	if sourceLength-uint(ind.GetLookbackPeriod()) > 1 {
		ind.Data = make([]float64, 0, sourceLength-uint(ind.GetLookbackPeriod()))
	}

	return ind, err
}
104440
func (s *PutMetricAlarmInput) SetEvaluationPeriods(v int64) *PutMetricAlarmInput {
	s.EvaluationPeriods = &v
	return s
}
174014
func Correl(real0, real1 []float64, timePeriod int32) []float64 {
	var outBegIdx C.int
	var outNBElement C.int
	outReal := make([]float64, len(real0))
	C.TA_CORREL(0, C.int(len(real0)-1), (*C.double)(unsafe.Pointer(&real0[0])), (*C.double)(unsafe.Pointer(&real1[0])), C.int(timePeriod), &outBegIdx, &outNBElement, (*C.double)(unsafe.Pointer(&outReal[0])))
	return outReal[:outNBElement]
}
1255083
func (s *CreateChannelInput) SetRetentionPeriod(v *RetentionPeriod) *CreateChannelInput {
	s.RetentionPeriod = v
	return s
}
415086
func (t *Translator) formatDateTimeComponentPeriodAbbreviated(hour int) string {
	if hour < 12 {
		return t.rules.DateTime.FormatNames.Periods.Abbreviated.AM
	}

	return t.rules.DateTime.FormatNames.Periods.Abbreviated.PM
}