// binOpFold2 folds input wave a to +/- b
972278
func binOpFold2(rate int8, x, y Input, numOutputs int) Input {
	CheckRate(rate)
	return NewInput(BinOpUgenName, rate, BinOpFold2, numOutputs, x, y)
}
1256264
func (s *EmptyTransformer) AcceptBinaryNegation(v BinaryNegation) {
	s.Result = BinaryNegation{s.Transform(v.Operand)}
}
1124656
func binOpRing3(rate int8, x, y Input, numOutputs int) Input {
	CheckRate(rate)
	return NewInput(BinOpUgenName, rate, BinOpRing3, numOutputs, x, y)
}
1028738
func (u *Ugen) Amclip(val Input) Input {
	return binOpAmclip(u.Rate, u, val, u.NumOutputs)
}
838390
func (u *Ugen) Pow(val Input) Input {
	return binOpPow(u.Rate, u, val, u.NumOutputs)
}
220412
func (as ArraySpec) Wrap2(val Input) Input {
	return as.proc(func(i Input) Input {
		return i.Wrap2(val)
	})
}
68641
func binOpDifsqr(rate int8, x, y Input, numOutputs int) Input {
	CheckRate(rate)
	return NewInput(BinOpUgenName, rate, BinOpDifsqr, numOutputs, x, y)
}
1035897
func (u *Ugen) Max(other Input) Input {
	return binOpMax(u.Rate, u, other, u.NumOutputs)
}
268026
func (u *Ugen) Difsqr(val Input) Input {
	return binOpDifsqr(u.Rate, u, val, u.NumOutputs)
}
685548
func GenerateCrossFoldValidationConfusionMatrices(data base.FixedDataGrid, cls base.Classifier, folds int) ([]ConfusionMatrix, error) {
	_, rows := data.Size()

	// Assign each row to a fold
	foldMap := make([]int, rows)
	inverseFoldMap := make(map[int][]int)
	for i := 0; i < rows; i++ {
		fold := rand.Intn(folds)
		foldMap[i] = fold
		if _, ok := inverseFoldMap[fold]; !ok {
			inverseFoldMap[fold] = make([]int, 0)
		}
		inverseFoldMap[fold] = append(inverseFoldMap[fold], i)
	}

	ret := make([]ConfusionMatrix, folds)

	// Create training/test views for each fold
	for i := 0; i < folds; i++ {
		// Fold i is for testing
		testData := base.NewInstancesViewFromVisible(data, inverseFoldMap[i], data.AllAttributes())
		otherRows := make([]int, 0)
		for j := 0; j < folds; j++ {
			if i == j {
				continue
			}
			otherRows = append(otherRows, inverseFoldMap[j]...)
		}
		trainData := base.NewInstancesViewFromVisible(data, otherRows, data.AllAttributes())
		// Train
		err := cls.Fit(trainData)
		if err != nil {
			return nil, err
		}
		// Predict
		pred, err := cls.Predict(testData)
		if err != nil {
			return nil, err
		}
		// Evaluate
		cf, err := GetConfusionMatrix(testData, pred)
		if err != nil {
			return nil, err
		}
		ret[i] = cf
	}
	return ret, nil
}
14184
func binOpHypotApx(rate int8, x, y Input, numOutputs int) Input {
	CheckRate(rate)
	return NewInput(BinOpUgenName, rate, BinOpHypotApx, numOutputs, x, y)
}
586173
func (pm *PickleMachine) opcode_BININT1() error {
	var v uint8
	err := pm.readBinaryInto(&v, false)
	if err != nil {
		return err
	}
	pm.push(int64(v))
	return nil
}
547396
func binOpHypot(rate int8, x, y Input, numOutputs int) Input {
	CheckRate(rate)
	return NewInput(BinOpUgenName, rate, BinOpHypot, numOutputs, x, y)
}
1112355
func (d *DFT) BinWidth() int {
	if d == nil {
		return 0
	}
	if d._binWidth > 0 {
		return d._binWidth
	}
	d._binWidth = (d.SampleRate / 2) / len(d.Coefs)
	return d._binWidth
}
1146897
func binOpMin(rate int8, x, y Input, numOutputs int) Input {
	CheckRate(rate)
	return NewInput(BinOpUgenName, rate, BinOpMin, numOutputs, x, y)
}
507419
func binOpExcess(rate int8, x, y Input, numOutputs int) Input {
	CheckRate(rate)
	return NewInput(BinOpUgenName, rate, BinOpExcess, numOutputs, x, y)
}
872552
func Slice2d(s [][]float32, rs, re, cs, ce uint) [][]float32 {
	sr := make([][]float32, re-rs)
	copy(sr, s[rs:re])
	for y := 0; y < len(sr); y++ {
		sr[y] = sr[y][cs:ce]
	}
	return sr
}