コード例 #1
0
ファイル: MUcdma_link.go プロジェクト: postfix/gocomm
func Print(xyvec map[float64]float64, xlabel string, ylabel string) []byte {
	x := vlib.NewVectorF(len(xyvec))
	y := vlib.NewVectorF(len(xyvec))
	cnt := 0
	for vx, _ := range xyvec {
		x[cnt] = vx
		cnt++
	}

	sort.Float64s([]float64(x))

	for indx, vx := range x {
		y[indx] = xyvec[vx]
	}
	type temp struct {
		SNR vlib.VectorF
		BER vlib.VectorF
	}
	data := temp{x, y}
	//keys := []float64(x)
	fmt.Printf("\n%s=%1.2e\n %s=%1.2e", xlabel, x, ylabel, y)
	result, err := json.Marshal(data)
	if err != nil {
		return nil
	} else {
		return result
	}

	//fmt.Printf("\n%s=%f", xlabel, x)
	//fmt.Printf("\n%s=%f", ylabel, y)
}
コード例 #2
0
ファイル: stats.go プロジェクト: istdev/stats
func CDF(xInput vlib.VectorF) (xOut, yOut vlib.VectorF) {
	n := xInput.Size()
	str := fmt.Sprintf("%f:%f:1", 1/float64(n), 1/float64(n))
	yOut = vlib.ToVectorF(str)
	if yOut[yOut.Size()-1] < 1 {
		yOut = yOut.Insert(yOut.Size()-1, 1)
	}
	sort.Float64s([]float64(xInput))
	xOut = xInput
	// xx := vlib.NewVectorI(n)
	for i := 0; i < n-1; i++ {
		if xOut[i] == xOut[i+1] {
			xOut.Delete(i)
			yOut.Delete(i)
			i--
			n--
		}
	}
	yOut = yOut.Insert(0, 0)
	xOut1 := vlib.NewVectorF(2 * n)
	yOut1 := vlib.NewVectorF(2 * n)
	// fmt.Printf("\n %v \n", yOut)
	for i := 0; i < n; i++ {
		xOut1[2*i] = xOut[i]
		xOut1[2*i+1] = xOut[i]
		yOut1[2*i] = yOut[i+1]
		yOut1[2*i+1] = yOut[i+1]
	}

	return xOut1, yOut1
}
コード例 #3
0
ファイル: ltecodec.go プロジェクト: oldmonkABA/turbo
func (l *LTECodec) lambda_calc(alpha *matrix.DenseMatrix, beta *matrix.DenseMatrix, gamma *matrix.DenseMatrix, lambda *matrix.DenseMatrix) {
	La_0 := [][]int{{0, 0, 0}, {1, 4, 0}, {2, 5, 1}, {3, 1, 1}, {4, 2, 1}, {5, 6, 1}, {6, 7, 0}, {7, 3, 0}}
	La_1 := [][]int{{0, 4, 3}, {1, 0, 3}, {2, 1, 2}, {3, 5, 2}, {4, 6, 2}, {5, 2, 2}, {6, 3, 3}, {7, 7, 3}}
	temp_0, temp_1 := vlib.NewVectorF(8), vlib.NewVectorF(8)
	LEN := alpha.Rows() - 1

	for k := 1; k <= LEN; k++ {
		for i := 0; i < 8; i++ {
			temp_0[i] = alpha.Get(k-1, La_0[i][0]) + beta.Get(k, La_0[i][1]) + gamma.Get(k, La_0[i][2])
			temp_1[i] = alpha.Get(k-1, La_1[i][0]) + beta.Get(k, La_1[i][1]) + gamma.Get(k, La_1[i][2])
		}
		lambda.Set(k, 0, vlib.Min(temp_0))
		lambda.Set(k, 1, vlib.Min(temp_1))
	}
}
コード例 #4
0
ファイル: ltecodec.go プロジェクト: oldmonkABA/turbo
func (l *LTECodec) extrinsic_info(alpha *matrix.DenseMatrix, beta *matrix.DenseMatrix, parllhd []float64, le *matrix.DenseMatrix) {

	LE_0 := [][]int{{0, 0, 0}, {1, 4, 0}, {2, 5, 1}, {3, 1, 1}, {4, 2, 1}, {5, 6, 1}, {6, 7, 0}, {7, 3, 0}}
	LE_1 := [][]int{{0, 4, 1}, {1, 0, 1}, {2, 1, 0}, {3, 5, 0}, {4, 6, 0}, {5, 2, 0}, {6, 3, 1}, {7, 7, 1}}
	LEN := alpha.Rows() - 4
	temp_0, temp_1 := vlib.NewVectorF(8), vlib.NewVectorF(8)
	for k := 1; k <= LEN; k++ {
		for i := 0; i < 8; i++ {
			temp_0[i] = alpha.Get(k-1, LE_0[i][0]) + beta.Get(k, LE_0[i][1]) + float64((LE_0[i][2]+1)%2)*parllhd[k]
			temp_1[i] = alpha.Get(k-1, LE_1[i][0]) + beta.Get(k, LE_1[i][1]) + float64((LE_1[i][2]+1)%2)*parllhd[k]
		}
		le.Set(k, 0, vlib.Min(temp_0))
		le.Set(k, 1, vlib.Min(temp_1))
	}
}
コード例 #5
0
ファイル: usage.go プロジェクト: wiless/webplot
func main() {

	log.Println("Reading after init")

	go func() {
		s := wm.NewSession("HETNET")

		for i := 0; i < 10; i++ {

			s.Plot(vlib.RandUFVec(10), "holdon", "title=CDF Plot of received signal", "LineWidth=2")
			time.Sleep(5 * time.Second)
		}
	}()
	time.Sleep(4 * time.Second)
	s := wm.NewSession("Single Cell")
	nsamples := 50
	x := vlib.NewVectorF(nsamples)
	for i := 0; i < nsamples; i++ {
		x[i] = float64(i) * 10
	}
	NPLOTS := 3
	for i := 0; i < NPLOTS; i++ {

		// s.Plot(vlib.RandUFVec(10), "handle=4", "holdon", "title=CDF Plot of received signal", "style=+", "LineWidth=2")
		if i < 2 {

			if i == 1 {
				s.PlotXY(x, vlib.RandUFVec(nsamples), "handle=4", "holdon", "title=CDF Plot of received signal", "LineWidth=2")
			} else {
				y := x.Add(5.5)
				s.PlotXY(y, vlib.RandUFVec(nsamples), "handle=4", "holdoff", "title=CDF Plot of received signal", "LineWidth=2")
			}

		} else {
			s.Plot(vlib.RandUFVec(nsamples), "handle=3", "holdon", "title=CDF Plot of received signal", "style=+", "LineWidth=2")
		}
		time.Sleep(4 * time.Second)
	}

	// wait if someone closes

}
コード例 #6
0
ファイル: ltecodec.go プロジェクト: oldmonkABA/turbo
func (l *LTECodec) forward_metric(lgr *matrix.DenseMatrix, la *matrix.DenseMatrix) {

	alpha_t := [][]int{{0, 1}, {3, 2}, {4, 5}, {7, 6}, {1, 0}, {2, 3}, {5, 4}, {6, 7}}
	br_metric := [][]int{{0, 3}, {1, 2}, {1, 2}, {0, 3}, {0, 3}, {1, 2}, {1, 2}, {0, 3}}
	xtemp := vlib.NewVectorF(2)

	var min_m float64
	LEN := lgr.Rows() - 1
	la.Set(0, 0, 0)

	for i := 1; i < 8; i++ {
		la.Set(0, i, 1e8)
	}

	for k := 1; k <= LEN; k++ {
		for i := 0; i < 8; i++ {

			for j := 0; j < 2; j++ {
				xtemp[j] = la.Get(k-1, alpha_t[i][j]) + lgr.Get(k, br_metric[i][j])

				la.Set(k, i, vlib.Min(xtemp))
			}
		}
		min_m = vlib.Min(la.GetRowVector(k).Array())
		for i := 0; i < 8; i++ {
			num := 2

			la.Set(k, i, la.Get(k, i)-min_m)
			if k > LEN-3 {

				diff := LEN - k
				if i >= (int)(num*diff) {
					la.Set(k, i, 1e8)
				}

			}
		}

	}

}
コード例 #7
0
ファイル: ltecodec.go プロジェクト: oldmonkABA/turbo
func (l *LTECodec) backward_metric(lgr *matrix.DenseMatrix, lb *matrix.DenseMatrix) {

	beta_t := [][]int{{0, 4}, {4, 0}, {5, 1}, {1, 5}, {2, 6}, {6, 2}, {7, 3}, {3, 7}}
	br_metric := [][]int{{0, 3}, {0, 3}, {1, 2}, {1, 2}, {1, 2}, {1, 2}, {0, 3}, {0, 3}}
	temp := vlib.NewVectorF(2)
	var min_m float64
	LEN := lgr.Rows() - 1
	var num int
	lb.Set(LEN, 0, 0)
	for i := 1; i < 8; i++ {
		lb.Set(LEN, i, 1e8)
	}
	for k := LEN - 1; k >= 0; k-- {
		for i := 0; i < 8; i++ {
			for j := 0; j < 2; j++ {
				temp[j] = lb.Get(k+1, beta_t[i][j]) + lgr.Get(k+1, br_metric[i][j])
			}
			lb.Set(k, i, vlib.Min(temp))
		}

		min_m = vlib.Min(lb.GetRowVector(k).Array())

		for i := 0; i < 8; i++ {
			num = 2
			lb.Set(k, i, lb.Get(k, i)-min_m)
			if k < 3 {
				diff := float64(2 - k)
				num = num * int(math.Pow(2, diff))
				if i%num != 0 {
					lb.Set(k, i, 1e8)
				}
			}
		}

	}
}