Esempio 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

}
Esempio 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
}
Esempio n. 3
0
func Complex2ComplexAFn(InObj []SComplex128Obj) (Outobjs SComplex128AObj) {

	veclen := len(InObj)
	samples := vlib.NewVectorC(veclen)

	for i := 0; i < veclen; i++ {
		samples[i] = InObj[i].Ch
	}
	maxexp := int(float64(InObj[0].MaxExpected) / float64(veclen))
	Outobjs.Ch = samples
	Outobjs.Message = InObj[0].Message
	Outobjs.MaxExpected = maxexp
	Outobjs.Ts = InObj[0].Ts * float64(veclen)
	Outobjs.TimeStamp = InObj[0].TimeStamp

	return Outobjs
}
Esempio n. 4
0
func (m *MPChannel) updateCoeff(timestamp float64) {
	/// first time
	generated := false
	if m.TimeStamp == -1 {
		m.Coeff.Resize(m.pdp.Size())
		for i := 0; i < m.pdp.Size(); i++ {
			m.Coeff[i] = sources.RandNC(m.pdp[i])
		}
		generated = true
		m.TimeStamp = 0 /// Unusuall if inbetween the MPchannel timestamp has got RESET !!

	} else {

		/// Existing channel-coeff is valid till m.Timestamp+m.TS,
		valid := timestamp < (m.TimeStamp + m.Ts)

		if !valid {
			/// TRIGGER NEW COEFF
			m.Coeff = vlib.NewVectorC(m.pdp.Size())
			for i := 0; i < m.pdp.Size(); i++ {
				m.Coeff[i] = sources.RandNC(m.pdp[i])
			}

			m.TimeStamp = timestamp
			generated = true
		}

	}

	/// Write new coeff to feedback channel if new was generated
	if m.FeedbackCH != nil && generated {
		var chdata gocomm.SComplex128AObj
		chdata.Ch = m.Coeff
		chdata.TimeStamp = m.TimeStamp
		chdata.Ts = m.Ts
		// fmt.Printf("\n CH:GENERATED @ %v with Coeff : %v, Gain : %v ", timestamp, m.Coeff[0], cmplx.Abs(m.Coeff[0])*cmplx.Abs(m.Coeff[0]))
		m.FeedbackCH <- chdata
	}

}
Esempio n. 5
0
func Conv(in1, in2 vlib.VectorC) (result vlib.VectorC) {
	L1 := in1.Size()
	L2 := in2.Size()
	N := L1 + L2 - 1
	result = vlib.NewVectorC(N)
	fmt.Printf("\n in1=%v", in1)
	fmt.Printf("\n in2=%v", in2)
	for n := 0; n < N; n++ {

		for l := 0; l < L1; l++ {
			indx := n - l
			if indx < L2 && indx >= 0 {
				result[n] += in1[l] * in2[n-l]
			}

		}
		// result[n] = sum

	}
	fmt.Printf("\n result=%v", result)
	return result
}
Esempio n. 6
0
func GoFFTPerK(outputSymbol gocomm.Complex128Channel, inputsamples vlib.VectorC, k, N int, inverse bool) {

	kbyN := float64(k) / float64(N)
	normalize := complex(1.0/math.Sqrt(float64(N)), 0)
	if !inverse {
		kbyN = kbyN * -1.0
	}

	fbins := vlib.NewVectorC(N)

	for n := 0; n < N; n++ {
		scale := kbyN * float64(n)
		binf := complex(0, 2.0*math.Pi*scale)
		fbins[n] = cmplx.Exp(binf)
	}
	result := vlib.GoDotC(inputsamples, fbins, 4) * normalize
	// result := vlib.DotC(inputsamples, fbins) * normalize

	var data gocomm.SComplex128Obj
	data.Ch = result
	outputSymbol <- data
}
Esempio n. 7
0
/// Default is a BPSK modulator
func (m *cdmaMeta) setDefaults() {
	m.spreadSeq = vlib.NewVectorC(1)
	m.sf = 1
}