Ejemplo n.º 1
0
func GoIFFT_C(samples vlib.VectorC, N int) vlib.VectorC {
	n := runtime.GOMAXPROCS(8)
	if N != samples.Size() {
		samples.Resize(N)
	}
	// fbins := vlib.NewVectorC(N)
	result := vlib.NewVectorC(N)
	NChannels := make([]gocomm.Complex128Channel, N)

	//bigChannel := make(gocomm.Complex128Channel, N)

	for i := 0; i < N; i++ {
		NChannels[i] = gocomm.NewComplex128Channel()
		go GoFFTPerK(NChannels[i], samples, i, N, true)
		//go GoFFTPerK(bigChannel, samples, i, N, false)
	}

	//for i := 0; i < N; i++ {
	//	result[i] = (<-bigChannel).Ch
	//}
	for i := 0; i < N; i++ {
		result[i] = (<-NChannels[i]).Ch
	}

	runtime.GOMAXPROCS(n)
	return result

}
Ejemplo n.º 2
0
func IFFT_C(samples vlib.VectorC, N int) vlib.VectorC {

	samples.Resize(N)
	fbins := vlib.NewVectorC(N)
	normalize := complex(math.Sqrt(1.0/float64(N)), 0)
	result := vlib.NewVectorC(N)
	for i := 0; i < N; i++ {
		for n := 0; n < N; n++ {
			scale := float64(i) * float64(n) / float64(N)
			binf := complex(0, 2.0*math.Pi*scale)
			fbins[n] = cmplx.Exp(binf)
		}
		// fbins = fbins.ScaleC(i)
		// fmt.Print("\ni=", i, fbins)
		result[i] = vlib.DotC(samples, fbins) * normalize
	}

	return result
}