Beispiel #1
0
// Although b0 is not a used coefficient, space for it is still expected
func cascadeFilterStages(stageAs1, stageBs1, stageAs2, stageBs2 []float64) (stageAs3, stageBs3 []float64) {
	// Transfer function uses the negatives of the b coefficients
	stageBs1 = functional.Map(functional.Negate, stageBs1)
	stageBs2 = functional.Map(functional.Negate, stageBs2)

	// Transfer function has a 1 in the denominator
	stageBs1[0], stageBs2[0] = 1, 1

	// Polynomial multiplication of the numerator and denominator of the transfer functions is done by convolution
	stageAs3 = convolve(stageAs1, stageAs2)
	stageBs3 = convolve(stageBs1, stageBs2)

	functional.MapInPlace(functional.Negate, stageBs3)
	// just for good measure
	stageBs3[0] = 0

	return
}
Beispiel #2
0
// Although b0 is not a used coefficient, space for it is still expected
func CascadeFilterStages(stage1, stage2 FilterCoefficients) (stage3 FilterCoefficients) {
	// Transfer function uses the negatives of the b coefficients
	stage1Bs := functional.Map(functional.Negate, stage1.Bs)
	stage2Bs := functional.Map(functional.Negate, stage2.Bs)

	// Transfer function has a 1 in the denominator
	stage1Bs[0], stage2Bs[0] = 1, 1

	// Polynomial multiplication of the numerator and denominator of the transfer functions is done by convolution
	stage3.As = convolve(stage1.As, stage2.As)
	stage3.Bs = convolve(stage1Bs, stage2Bs)

	functional.MapInPlace(functional.Negate, stage3.Bs)
	// just for good measure
	stage3.Bs[0] = 0

	return
}
Beispiel #3
0
// Although b0 is not a used coefficient, space for it is still expected
func parallelizeFilterStages(stageAs1, stageBs1, stageAs2, stageBs2 []float64) (stageAs3, stageBs3 []float64) {
	// Transfer function uses the negatives of the b coefficients
	stageBs1 = functional.Map(functional.Negate, stageBs1)
	stageBs2 = functional.Map(functional.Negate, stageBs2)

	// Transfer function has a 1 in the denominator
	stageBs1[0], stageBs2[0] = 1, 1

	// For addition of transfer functions, numerator is stagesA1 * stagesB2 + stagesA2 * stagesB1. Denominator is the same as for cascading.
	// Polynomial multiplication of the numerator and denominator of the tranfer functions is done by convolution
	stageAs3 = functional.ZipWith(functional.Add, convolve(stageAs1, stageBs2), convolve(stageAs2, stageBs1))
	stageBs3 = convolve(stageBs1, stageBs2)

	functional.MapInPlace(functional.Negate, stageBs3)
	// just for good measure
	stageBs3[0] = 0

	return
}
Beispiel #4
0
// Although b0 is not a used coefficient, space for it is still expected
func ParallelizeFilterStages(stage1, stage2 FilterCoefficients) (stage3 FilterCoefficients) {
	// Transfer function uses the negatives of the b coefficients
	stage1Bs := functional.Map(functional.Negate, stage1.Bs)
	stage2Bs := functional.Map(functional.Negate, stage2.Bs)

	// Transfer function has a 1 in the denominator
	stage1Bs[0], stage2Bs[0] = 1, 1

	// For addition of transfer functions, numerator is stagesA1 * stagesB2 + stagesA2 * stagesB1. Denominator is the same as for cascading.
	// Polynomial multiplication of the numerator and denominator of the tranfer functions is done by convolution
	stage3.As = functional.ZipWith(functional.Add, convolve(stage1.As, stage2Bs), convolve(stage2.As, stage1Bs))
	stage3.Bs = convolve(stage1Bs, stage2Bs)

	functional.MapInPlace(functional.Negate, stage3.Bs)
	// just for good measure
	stage3.Bs[0] = 0

	return
}