コード例 #1
0
ファイル: fft.go プロジェクト: postfix/gocomm
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

}
コード例 #2
0
ファイル: cdmachip.go プロジェクト: postfix/gocomm
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)

}
コード例 #3
0
ファイル: fft.go プロジェクト: postfix/gocomm
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
}
コード例 #4
0
ファイル: cdma.go プロジェクト: postfix/gocomm
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)
}
コード例 #5
0
ファイル: conv.go プロジェクト: postfix/gocomm
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
}
コード例 #6
0
ファイル: webmatlab.go プロジェクト: wiless/webplot
func (m *MatlabSession) ScatterC(c vlib.VectorC, params ...string) int {

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

}
コード例 #7
0
ファイル: fft.go プロジェクト: postfix/gocomm
func IFFT_F(samples vlib.VectorF, N int) vlib.VectorC {
	var csamples vlib.VectorC
	csamples.SetVectorF(samples)
	return IFFT_C(csamples, N)
}