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 }
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) }
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) }
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 }