Exemplo 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

}
Exemplo n.º 2
0
func (m *CDMA) SetSpreadCode(spcode vlib.VectorC, doscale bool) {
	m.sf = spcode.Size()
	// normalize := 1.0 / float64(m.sf)
	if doscale {
		m.spreadSeq, _ = spcode.ToUnitEnergy() //spcode.Scale(normalize)
	} else {
		m.spreadSeq = spcode //;.ToUnitEnergy() //spcode.Scale(normalize)
	}

	// fmt.Print("\ndata", m.spreadSeq, temp, a)

}
Exemplo n.º 3
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
}
Exemplo n.º 4
0
func (cdma *CDMA) DeSpreadBlock(expectedInputSize int, chInway gocomm.Complex128AChannel, OutCH gocomm.Complex128Channel) {

	despcode := vlib.Conj(cdma.SpreadSequence)

	SF := len(despcode)

	despcode = despcode.Scale(1. / (float64(SF)))

	if SF == 0 {
		panic("Spreading Code not Set")
	}
	// maxSymbols := expectedInputSize / SF
	// rxsymbols := vlib.NewVectorC(maxSymbols)
	var recentBuffer vlib.VectorC
	for cnt := 0; cnt < expectedInputSize; {

		data := <-chInway
		rxlen := len(data.Ch)
		// log.Printf("\n Received %d samples out of %d/%d ", rxlen, cnt, expectedInputSize)
		cnt += rxlen
		recentBuffer = append(recentBuffer, data.Ch...)
		for {
			if recentBuffer.Size() < SF {

				break

			} else {
				// log.Printf("\n Symbol %d Ready to Despread with %d", sym, cnt)
				rxchips := recentBuffer[0:SF]
				recentBuffer = recentBuffer[SF:]
				rxsymbols := vlib.DotC(despcode, rxchips)
				var chdataOut gocomm.SComplex128Obj
				chdataOut.Ch = rxsymbols
				OutCH <- chdataOut

			}
		}
	}

	close(chInway)
}
Exemplo 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
}
Exemplo n.º 6
0
func (m *MatlabSession) ScatterC(c vlib.VectorC, params ...string) int {

	return m.PlotXY(c.Real(), c.Imag(), params...)

}
Exemplo n.º 7
0
func IFFT_F(samples vlib.VectorF, N int) vlib.VectorC {
	var csamples vlib.VectorC
	csamples.SetVectorF(samples)
	return IFFT_C(csamples, N)
}