V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  itfanr  ›  全部回复第 61 页 / 共 64 页
回复总数  1266
1 ... 53  54  55  56  57  58  59  60  61  62 ... 64  
2013-08-08 14:55:06 +08:00
回复了 itfanr 创建的主题 Linux 为什么我安装了UBUNTU后,win7里面的东西就可以被访问了?
@jamesxu 所以不安全。。。
2013-08-08 12:51:49 +08:00
回复了 itfanr 创建的主题 程序员 十句话内说出各种编程语言的特点
@kurtis 十句话内就行。。。
2013-08-08 12:51:08 +08:00
回复了 itfanr 创建的主题 程序员 十句话内说出各种编程语言的特点
@kasp 额 你用php写个软件呗 哈哈 它注定只能做web
2013-08-08 12:49:39 +08:00
回复了 itfanr 创建的主题 程序员 十句话内说出各种编程语言的特点
@cdfmr 什么语言啊这是?
2013-08-07 21:22:14 +08:00
回复了 itfanr 创建的主题 C C语言如何用指针的指针打印二维数组?
@pright 你说的非常对 嗯嗯
2013-08-07 10:30:20 +08:00
回复了 itfanr 创建的主题 C C语言如何用指针的指针打印二维数组?
@xiaoye5200 额 不是有没有必要 我只是有个疑惑,大家帮忙而已啊
2013-08-06 17:13:29 +08:00
回复了 itfanr 创建的主题 Linux 请问linaro 13.04的默认更新源是什么?
deb http://ports.ubuntu.com/ubuntu-ports/ quantal main universe
deb-src http://ports.ubuntu.com/ubuntu-ports/ quantal main universe
2013-08-06 16:12:01 +08:00
回复了 itfanr 创建的主题 C C语言如何用指针的指针打印二维数组?
@xiaoye5200 指针的指针呢
2013-08-05 23:32:06 +08:00
回复了 itfanr 创建的主题 C C语言内存出现 -1.#IND00 是怎么回事?
@detailyang glist是什么?我也想高亮啊 这里不行 很郁闷
2013-08-05 20:57:46 +08:00
回复了 itfanr 创建的主题 C C语言内存出现 -1.#IND00 是怎么回事?
@timonwong 代码我贴了
2013-08-05 20:57:21 +08:00
回复了 itfanr 创建的主题 C C语言内存出现 -1.#IND00 是怎么回事?
@xdeng 代码我贴了
2013-08-05 20:55:17 +08:00
回复了 itfanr 创建的主题 C C语言内存出现 -1.#IND00 是怎么回事?
用到了两个主要文件,在main里面调用turbo_decode函数:
//部分main代码:
double ** soft_out ;
soft_out = (double **)malloc(sizeof(double *) * inter_num);

for (int soft_out_i =0; soft_out_i < inter_num ; soft_out_i++)
{
soft_out[soft_out_i] = (double *)malloc(sizeof(double)* frame_size);
}
turbo_decode(Lc ,g,ispunctured ,pattern ,decode_method ,receive ,soft_out) ;



//1.decode.cpp

#include "stdafx.h"
#include "tools.h"
#include <math.h>
#include <string.h>
#include "decode.h"
#include "decode.h"

void turbo_decode(double Lc ,int g[][4] ,int ispunctured ,const int pattern [] ,int decode_method ,const double * receive , double **soft_out){

if (ispunctured)//删余
{
//
}
else
{
/*double e_info [frame_size+3] ;
double die_info [frame_size+3] ;
double so [frame_size+3 ] ;
double so1 [frame_size+3] ;*/
double in1 [2][frame_size+3] ;
double in2 [2][frame_size+3] ;

for (int i=0; i<frame_size+3; i++)
{
in1[0][i] = receive[3 * i] ;
in1[1][i] = receive[3 * i + 1] ;
in2[1][i] = receive[3 * i + 2] ;
}

for(int i=0 ;i< frame_size+3 ; i++){
in2[0][i] = in1[0][pattern[i]-1];//交织 因为交织的数组为(1-1024,故减1)
}

double * e_info = (double *)malloc(sizeof(double) * (frame_size+3) );
double * die_info = (double *)malloc(sizeof(double) * (frame_size+3) );
double * so = (double *)malloc(sizeof(double) * (frame_size+3) );
double so1 [frame_size+3] ;

for (int i=0; i<frame_size+3; i++)
{
e_info[i] = 0 ;
}

for (int inter = 0 ; inter< inter_num; inter++)//开始迭代
{

// printf(" \n\n inter = %d\n\n ", inter) ;

for(int i=0 ;i< frame_size+3 ; i++){ //解交织
die_info [pattern[i]-1] = e_info[i] ;
}
// printf("before decoder 1---------die_info[0] = %lf \n", die_info[0] ) ;

maxLogMap(in1, g, Lc, (const double *)die_info, e_info, so) ; //

//rintf("after decoder 1---------e_info[0] = %lf \n", e_info[0] ) ;


for(int i=0 ;i< frame_size+3 ; i++){
die_info[i] = e_info[pattern[i]-1] ;//交织
}

// printf("before decoder 2---------die_info[0] = %lf \n", die_info[0] ) ;

maxLogMap(in2 , g, Lc, (const double *) die_info, e_info, so) ; //改变了e_info

//rintf("after decoder 2 ---------e_info[0] = %lf \n", e_info[0] ) ;

for(int i=0 ;i< frame_size+3 ; i++){ //解交织
so1 [(pattern[i]-1)] = so[i] ;
}

for (int i1 = 0 ; i1<frame_size ; i1++)//舍去最后的三个数字
{
soft_out[inter][i1] = so1[i1] ;
}

}

free(e_info) ;
e_info = NULL ;
free(die_info) ;
die_info = NULL ;
free(so) ;
so=NULL;
}//else 结束
}

void genTrellis(int g[][4],int lstate [][8] , int nstate [][8],int lpara[][8],int npara[][8]){

int k = 4 ;
int m =k-1 ;
int in = 0 ;
int state_temp [3] ;//input0和input1都用
int state[3] ;//input0和input1都用

int *gp1 = &g[0][1] ;//g(1,2:end)
int *gp2 = &g[1][0] ;//g(2,:)
int para = 0 ;
int state0_temp1 [4] ;
int state0_temp2[3] ;

int state1_temp1[4] ;
int state1_temp2[3] ;
int nstate_index ;

for (int i=0 ;i<8 ;i++ )
{
de2bi(i,state_temp) ;

//input 0
fliplr(state,state_temp,3) ;
in = (matrix_Mul(gp1,state,3)%2)^0 ;
state0_temp1[0] = in ;
for (int j = 1; j<4 ; j++)
{
state0_temp1[j] = state[j-1] ;
}
para = matrix_Mul(gp2,state0_temp1,4)%2 ;
right_shift(in,state,3) ;

fliplr(state0_temp2,state,3) ;
nstate_index = bi2de(state0_temp2, 3) ;
nstate[0][i] = nstate_index +1 ;
lpara[0][nstate_index] = 2 * para -1 ;
lstate[0][nstate_index] = i+1 ;


//input 1
fliplr(state,state_temp,3) ; //重置state
in = (matrix_Mul(gp1, state,3)%2)^1 ;
state1_temp1[0] = in ;
for (int j = 1; j<4 ; j++)
{
state1_temp1[j] = state[j-1] ;
}
para = matrix_Mul(gp2,state1_temp1,4 )%2 ;
right_shift(in,state,3) ;

fliplr(state1_temp2, state, 3) ;
nstate_index = bi2de(state1_temp2, 3);
nstate[1][i] = nstate_index +1 ;
lpara[1][nstate_index] = 2* para - 1 ;
lstate[1][nstate_index] = i+1 ;
}
//以下产生npara

for (int i = 0 ; i<2 ;i++)
{
for (int j=0; j<8; j++)
{
//找到上一个状态
int state_temp ;
state_temp = lstate[i][j] ;
int para_temp ;
para_temp = lpara[i][j] ;
npara[i][state_temp-1] = para_temp ;
}
}

}

2.subdecode.cpp

#include "stdafx.h"
#include "tools.h"
#include <math.h>
#include "decode.h"

double maxVect(const double vect[], int vect_len) ;
void maxLogMap(const double input[][frame_size+3] , int g[][4],double Lc,const double * pri_info, double * e_info, double *so ) {
//产生网格
int lstate [2][8];
int nstate [2][8] ;
int lpara [2][8] ;
int npara [2][8] ;

genTrellis(g, lstate , nstate, lpara, npara) ;

//主要译码部分
const int nstates = 8 ;
//alpha beta gamma 初始化
double alpha[frame_size +3][nstates] , beta[frame_size +3+1][nstates] ;
double gamma0[frame_size +3][nstates], gamma1[frame_size +3][nstates] ;

const int infinity = 1000 ;
alpha[0][0] = 0 ;
for (int st = 1; st<nstates; st++)
{
alpha [0][st] = -infinity ;//初始化第1行
}
//beta
double log_temp = 1.0/8 ;
for (int beta_col = 0; beta_col<nstates; beta_col++ )
{
beta[frame_size +3][beta_col] = log(log_temp) ; //初始化最后一行
}
//------------------------------------------------------------------------------------

for (int i = 0; i<frame_size +3; i++)
{
for (int st = 0; st<nstates; st++)
{
double mul_temp ;
mul_temp = -1 * input[0][i] + lpara[0][st] * input[1][i] ; //输入0
gamma0[i][st] = -1 * pri_info[i]/2 + Lc/2 * mul_temp ;

mul_temp = 1 * input[0][i] + lpara[1][st] * input[1][i] ; //输入1
gamma1[i][st] = pri_info[i]/2 + Lc/2 * mul_temp ;
}

}

//--------------------------------------------------------------------------------------

for (int i = 1; i<frame_size +3; i++)
{
int lstate_temp1 ,lstate_temp2 ;
double data0 ,data1 ;
for (int st = 0; st<nstates; st++ )
{
lstate_temp1 = lstate[0][st] -1;
data0 = gamma0[i-1][st] + alpha[i-1][lstate_temp1] ;

lstate_temp2 = lstate[1][st]-1 ;
data1 = gamma1[i-1][st] + alpha[i-1][lstate_temp2] ;

alpha[i][st] = (data0>data1 ? data0 :data1 );

}
}
//------------------------------------------------------------------------------------------------------------

for (int i = frame_size +3-1; i>0 ; i--)
{
int data0, data1 ;
int nstate_temp0,nstate_temp1 ;
for (int st = 0 ; st<nstates; st++)
{
nstate_temp0 = nstate[0][st] -1;
data0 = gamma0[i][nstate_temp0] + beta[i+1][nstate_temp0] ;

nstate_temp1 = nstate[1][st] -1;
data1 = gamma1[i][nstate_temp1] + beta[i+1][nstate_temp1] ;

beta[i][st] = (data0>data1 ? data0 :data1 );

}
}

//----------------------------------------------------------------------------------------------------------------
double temp0[nstates] = {0} ;
double temp1[nstates] ={0 };
double so_temp [frame_size+3] = {0};

for (int i=0; i<frame_size +3; i++)
{
int lstate_temp1, lstate_temp2 ;
for (int st = 0 ; st<nstates; st++)
{
lstate_temp1 = lstate[0][st] -1 ;
lstate_temp2 = lstate[1][st] -1;

temp0[st] = gamma0[i][st] + alpha[i][lstate_temp1] + beta[i+1][st] ;
temp1[st] = gamma1[i][st] + alpha[i][lstate_temp2] + beta[i+1][st] ;
}
so_temp [i] = maxVect(temp1,nstates) - maxVect(temp0, nstates) ;

}

//----------------------------------------------------------------------------

for (int i =0; i<frame_size+3; i++)
{
so[i] = so_temp[i] ;
}

for (int i = 0; i<frame_size +3; i++)
{
e_info[i] = so[i] - pri_info[i] - Lc * input[0][i] ;
}


}

double maxVect(const double vect[], int vect_len){

double max = vect[0] ;
int i = 1 ;
while (i<vect_len)
{
if(vect[i]>=max ){
max = vect[i] ;
}
i++ ;
}
return max ;
}
2013-08-05 20:39:47 +08:00
回复了 itfanr 创建的主题 C C语言内存出现 -1.#IND00 是怎么回事?
@timonwong 可是为什么我500可以,1000就不行了。不可能出现除数为0的啊!
2013-08-05 20:39:04 +08:00
回复了 itfanr 创建的主题 C C语言内存出现 -1.#IND00 是怎么回事?
@xdeng 怎么发私信?能告诉我你邮箱吗?
2013-08-05 17:24:22 +08:00
回复了 itfanr 创建的主题 C C语言内存出现 -1.#IND00 是怎么回事?
@aoyoo 自己程序发送 不通过其他方式 send() receive() 函数而已 我做的通信算法
2013-08-05 16:36:12 +08:00
回复了 itfanr 创建的主题 C C语言如何用指针的指针打印二维数组?
@pright 变长数组?vc好像不支持吧?至少为const
2013-08-04 18:33:13 +08:00
回复了 itfanr 创建的主题 C C语言如何用指针的指针打印二维数组?
@icenan2 mark 改天我试试啊
2013-08-04 10:46:24 +08:00
回复了 itfanr 创建的主题 C C语言如何用指针的指针打印二维数组?
@timonwong 那你说我的想法能不能用子函数实现?
2013-08-04 10:43:08 +08:00
回复了 itfanr 创建的主题 C C语言如何用指针的指针打印二维数组?
void main(){

int a [3] [2] = {{1,2},{3,4},{5,6}} ;
int *pa ;
int **ppa ;
for (int i = 0 ;i<3; i++)
{
for (pa = a[i]; pa - a[i]<2; pa++)
{
ppa = &pa ;
printf("%d ", **ppa) ;
}
}

}
2013-08-04 10:34:27 +08:00
回复了 itfanr 创建的主题 C C语言如何用指针的指针打印二维数组?
@sNullp why?
1 ... 53  54  55  56  57  58  59  60  61  62 ... 64  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3233 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 27ms · UTC 13:14 · PVG 21:14 · LAX 05:14 · JFK 08:14
Developed with CodeLauncher
♥ Do have faith in what you're doing.