本文整理汇总了Golang中github.com/wiless/gocomm.SComplex128Obj类的典型用法代码示例。如果您正苦于以下问题:Golang SComplex128Obj类的具体用法?Golang SComplex128Obj怎么用?Golang SComplex128Obj使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SComplex128Obj类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Modulate
func (m *Modem) Modulate(bitchan gocomm.BitChannel, symbolChannel gocomm.Complex128Channel) {
// fmt.Printf("\n Reading bits from %v", bitchan.Ch)
var chdataIn gocomm.SBitObj
var chdataOut gocomm.SComplex128Obj
// fmt.Printf("\n MaxSymbols expected is %d , message = %v", bitchan.MaxExpected, bitchan.Message)
var bits []uint8
bits = make([]uint8, m.bitsPerSymbol)
length := m.bitsPerSymbol
N := m.bitsPerSymbol
for i := 0; i < length; i++ {
chdataIn = <-bitchan
chdataOut.MaxExpected = chdataIn.MaxExpected / 2
bits[i] = chdataIn.Ch
}
key := toStr(bits[0:N])
chdataOut.Ch = m.constellationTable[key]
symbolChannel <- chdataOut
// fmt.Printf("\n Writing symbols to %v", symbolChannel.Ch)
}
开发者ID:postfix,项目名称:gocomm,代码行数:25,代码来源:modem.go
示例2: main
func main() {
var channel core.MPChannel
channel.InitializeChip()
N := 100
param := core.NewIIDChannel()
param.Ts = 4
pdp := vlib.VectorF{1, .1}
param.SetPDP(pdp)
param.Mode = ""
channel.InitParam(param)
// samples := vlib.VectorC(sources.RandNCVec(N, 1))
samples := vlib.NewOnesC(N)
var data gocomm.SComplex128Obj
data.Ts = 2
for i := 0; i < N; i++ {
data.Ch = samples[i]
// fmt.Printf("\n Input %d = %v", i, data)
chout := channel.ChannelFn(data)
fmt.Printf("\n %d I/O : %v ==> %v", i, data.Ch, chout.Ch)
data.UpdateTimeStamp()
}
}
开发者ID:postfix,项目名称:gocomm,代码行数:25,代码来源:testchannel.go
示例3: FadingChannel
/// Fading/AWGN Channel that operates on each sample
func (m *ChannelEmulator) FadingChannel(InCH gocomm.Complex128Channel) {
outCH := m.Pins["symbolOut"].Channel.(gocomm.Complex128Channel)
NextSize := 1
N0 := .01 /// 10dB SNR
var chdataOut gocomm.SComplex128Obj
var chdataIn gocomm.SComplex128Obj
for i := 0; i < NextSize; i++ {
chdataIn = <-InCH
sample := chdataIn.Ch
chdataOut.Message = chdataIn.Message
chdataOut.MaxExpected = chdataIn.MaxExpected
NextSize = chdataIn.MaxExpected
var hn complex128
if chdataIn.Message == "BYPASS" {
hn = 1
chdataOut.Ch = sample
} else {
hn = sources.RandNC(N0)
psample := sample * hn
chdataOut.Ch = psample
}
outCH <- chdataOut
}
}
开发者ID:postfix,项目名称:gocomm,代码行数:29,代码来源:awgn.go
示例4: ModulateBlock
func (m *Modem) ModulateBlock(OutBlockSize int, bitchan gocomm.BitChannel, symbolChannel gocomm.Complex128Channel) {
for i := 0; i < OutBlockSize; i++ {
var chdataIn gocomm.SBitObj
var chdataOut gocomm.SComplex128Obj
// fmt.Printf("\n MaxSymbols expected is %d , message = %v", bitchan.MaxExpected, bitchan.Message)
var bits []uint8
bits = make([]uint8, m.bitsPerSymbol)
length := m.bitsPerSymbol
N := m.bitsPerSymbol
for i := 0; i < length; i++ {
chdataIn = <-bitchan
chdataOut.MaxExpected = chdataIn.MaxExpected / 2
chdataOut.Message = chdataIn.Message
bits[i] = chdataIn.Ch
OutBlockSize = chdataIn.MaxExpected
}
key := toStr(bits[0:N])
chdataOut.Ch = m.constellationTable[key]
symbolChannel <- chdataOut
}
// close(bitchan.Ch)
}
开发者ID:postfix,项目名称:gocomm,代码行数:29,代码来源:modem.go
示例5: DeSpread
func (cdma *CDMA) DeSpread(InCH gocomm.Complex128Channel, OutCH gocomm.Complex128Channel) {
despcode := vlib.Conj(cdma.SpreadSequence)
var result complex128
for i := 0; i < len(despcode); i++ {
rxchips := (<-InCH).Ch
result += rxchips * cmplx.Conj(despcode[i])
}
var chdataOut gocomm.SComplex128Obj
chdataOut.Ch = result
OutCH <- chdataOut
}
开发者ID:postfix,项目名称:gocomm,代码行数:12,代码来源:cdma.go
示例6: ChannelDuplexer
func ChannelDuplexer(InCH gocomm.Complex128Channel, OutCHA []gocomm.Complex128Channel) {
Nchanels := len(OutCHA)
var chdataIn gocomm.SComplex128Obj
var chdataOut gocomm.SComplex128Obj
NextSize := 1
for cnt := 0; cnt < NextSize; cnt++ {
chdataIn = <-InCH
data := chdataIn.Ch
NextSize = chdataIn.MaxExpected
// fmt.Printf("%d InputDuplexer : %v ", cnt, data)
for i := 0; i < Nchanels; i++ {
chdataOut.Ch = data
chdataOut.MaxExpected = NextSize
chdataOut.Message = chdataIn.Message
OutCHA[i] <- chdataOut
}
}
close(InCH)
}
开发者ID:postfix,项目名称:gocomm,代码行数:20,代码来源:wire.go
示例7: DeModulateBlock
func (m *Modem) DeModulateBlock(OutBlockSize int, InCH gocomm.Complex128Channel, outCH gocomm.Complex128Channel) {
var chdataIn gocomm.SComplex128Obj
var chdataOut gocomm.SComplex128Obj
for i := 0; i < OutBlockSize; i++ {
chdataIn = <-InCH
symbol := chdataIn.Ch
OutBlockSize = chdataIn.MaxExpected
bits := m.DeModulateBits(symbol)
result := complex(float64(bits[0]), float64(bits[1]))
chdataOut.Ch = result
chdataOut.MaxExpected = OutBlockSize
chdataOut.Message = chdataIn.Message
// fmt.Printf("\n Writing demod bits to %v ", outCH.Ch)
outCH <- chdataOut
}
// close(InCH.Ch)
}
开发者ID:postfix,项目名称:gocomm,代码行数:20,代码来源:modem.go
示例8: DeSpreadBlock
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)
}
开发者ID:postfix,项目名称:gocomm,代码行数:41,代码来源:cdma.go
示例9: GoFFTPerK
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
}
开发者ID:postfix,项目名称:gocomm,代码行数:22,代码来源:fft.go
示例10: main
func main() {
N := 20 /// 20 samples
L := 4 /// 5tap channel
begin := time.Now()
var cdma core.CDMA
cdma.InitializeChip()
cdma.SetSpreadCode(vlib.NewOnesC(L), true)
samples := vlib.VectorC(sources.RandNCVec(N, 1))
var data gocomm.SComplex128Obj
/// METHOD A
data.Ts = 1
data.TimeStamp = 0
data.MaxExpected = N
data.Message = ""
for i := 0; i < N; i++ {
data.Next(samples[i])
chips := cdma.SpreadFn(data)
output := cdma.DeSpreadFn(chips)
fmt.Printf("\nTxSymbol %v ", data)
// fmt.Printf("\nTx %v ", chips)
fmt.Printf("\nRxSymbol %v ", output)
}
/// METHOD B
// dataArray.MaxExpected = samples.Size()
// inCHA := gocomm.NewComplex128Channel()
// outputPin := filter.PinByID(1)
// go filter.Filter(inCHA)
// go chipset.Sink(outputPin)
// /// Actual data pushing
// for i := 0; i < N; i++ {
// dataArray.MaxExpected = N
// dataArray.Ch = samples[i]
// inCHA <- dataArray
// }
//fmt.Printf("\nFilter Residues %v", filter.FilterMemory)
// Of code
fmt.Printf("\nTime Elapsed : %v\n", time.Since(begin))
}
开发者ID:postfix,项目名称:gocomm,代码行数:45,代码来源:cdma.go
示例11: AWGNChannel
func (m *ChannelEmulator) AWGNChannel(dummy gocomm.Complex128Channel) {
// fmt.Printf("\n Noise ready to Input %v", dummy)
outCH := m.Pins["symbolOut"].Channel.(gocomm.Complex128Channel)
// fmt.Printf("\n Output ready to Output %v", outCH)
var chdataOut gocomm.SComplex128Obj
var chdataIn gocomm.SComplex128Obj
samples := 1
// result := make([]complex64, samples)
var StdDev float64 = math.Sqrt(m.noise * .5)
var Mean float64 = m.Mean
var noise complex128
// var noisevector vlib.VectorC
for i := 0; i < samples; i++ {
chdataIn = <-dummy
chdataOut.MaxExpected = chdataIn.MaxExpected
samples = chdataIn.MaxExpected
// fmt.Printf("\nAWGN expects %d samples @ %v", samples, dummy)
chdataOut.Message = chdataIn.Message
chdataOut.Ts = chdataIn.Ts
chdataOut.TimeStamp = chdataIn.TimeStamp
if !strings.Contains(chdataIn.Message, "BYPASS") {
if Mean == 0 && StdDev == 1 {
noise = complex128(complex(rand.NormFloat64(), rand.NormFloat64()))
} else {
noise = complex128(complex(rand.NormFloat64()*StdDev+Mean, rand.NormFloat64()*StdDev+Mean))
}
// noisevector = append(noisevector, noise)
chdataOut.Ch = chdataIn.Ch + noise
} else {
chdataOut.Ch = chdataIn.Ch
}
//fmt.Printf("\nNoise%f=%f", StdDev, noisevector)
outCH <- chdataOut
}
}
开发者ID:postfix,项目名称:gocomm,代码行数:42,代码来源:awgn.go
注:本文中的github.com/wiless/gocomm.SComplex128Obj类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论