主题:离散信道迭代算法 我的毕业论文 有附件
题目是:离散无记忆信道容量的迭代算法
我有 源码及算法的扫描件 需要的 加我QQ 372943841
高手加我 重谢~
算法如下
算法:
Algorithm 1: 信道容量的迭代算法
1. proceduce CHANNEL CAPACITY(r,s,(Pji))
2. initialize:信元分布Pi=1/r ,相对误差门限δ,C= -∞
3. repeat
4. Φij ← PiPji/∑PiPji (i=1到r)
5. Pi ← exp(∑Pjilog2Φij)(j=1到s)/ ∑(i=1到r) exp(∑Pjilog2Φij) (j=1到s)
6. C ← log2[∑(i=1到r) exp(∑Pjilog2Φij) (j=1到s)]
7.until |△C|/C<=δ
8.output P*=(Pi)r,C
9.end procedure
我现在有个 C的源码 如下:
代码
/********************************
* Author : QiaoXiaoYu
* Date : 2008-2-4
* Copyright :
* Purpose : Caculate the capacity of a given channe !
* *******************************
# include <stdio.h>
# include <math.h>
# include <stdlib.h>
# include <unistd.h>
# include <values.h>
# define DELTA 1e – 6 /* delta,threshold */
int main (void)
{
register int i,j;
register int k;
int r,s;
}
float * p_i=NULL;
float ** p_ji=NULL;
float ** phi_ij=NULL;
folat C,C_pre,validate;
float * sum=NULL;
float p_j;
/* Read the number of input symbol : r,
* and the number of output symbol : s */
fscanf (stdin,"%d",&r);
fscanf (stdin,"%d",&s);
/* Allocation memory for p_i,p_ji and phi_ij */
p-i = (float *) calloc (r,sizeof(float));
p_ji=(float **) calloc (r,sizeof(float));
for (i=0;i<r;i++)
phi_ij[i]=(float *) calloc (s,sizeof(float))
/* Read the channel transition priobability matrix p_ji */
for (i=0;i<r;i++)
for(j=0;j<s;j++)
fscanf (stdin,"%f",&p_ji[i][j]);
/* Validate the input data */
for (i=0;i<r;i++)
{
validate =0.0;
for (j=0;j<s;j++)
{
validate +=p_ji[i][j];
}
if (fabs(validate -1.0) >DELTA)
{
fprintf(stdout,"Invalid input data .\n");
Exit (-1);
}
}
fprintf(stdout,"Starting . . . \ n");
/* Initialize the p_i and phi_ij */
for (i=0;i<r;i++)
{
P_i[j]=1.0 /(float) r;
}
/* Initialize C and iteration counter : k,and temprory variable */
C=-MAXFLOAT ; /* MAXFLOAT was ddefined in <values.h> */
k=0;
sum=(float*) calloc (r,sizeof(float));
/* Start iterate */
do
{
k++;
/* Calculate phi_ij(k) first */
for (j=0;j<s;j++)
{
p-j=0.0;
for(i=0;i<r;i++)
p_j += p_i[i]*p_ji[i][j];
if(fabs(p_j)>=DELTA)
for(i=0;i<r;i++)
phi_ij[i][j]=p_i[i]*p_ji[i][j]/p_j;
else
for(i=0;i<r;i++)
phi_ij[i][j]=0.0;
}
/* Calculate p_i(k+1) then */
p-j=0.0
for (i=0;i<r;i++)
{
sum[i]=0.0;
for (j=0;j<s;j++)
{
/* Prevent divided by zero */
if (fabs (phi_ij[i][j])>=DELTA)
sum[i]+=p_ji[i][j]*log2(phi_ij[i][j])/log2(2.0);
}
sum[i]=pow(2.0,sum[i]);
p_j+=sum[i];
}
for (i=0;i<r;i++)
{
p_i[i]=sum[i]/p_j;
}
/* And C(k+1) */
C_pre=C;
C=log2(p_j)/log2(2.0);
}
while (fabs(C-C_pre)/C>DELTA);
free(sum);
sum=NULL;
/*Output the result */
fprintf(stdout,"The iteration number is %d.\n\n",k);
fprintf(stdout,"The capacity of the channel is %.6f bit /symbol .\n\n",C);
fprintf(stdout,"The best input probability distribution is :\n");
for (i=0;i<r;i++)
fprintf (stdout,"%.6f",p_i[i]);
fprintf (stdout,"\n");
/* Free the memory we allocation before with stack sequence*/
for(i=s-1;i>=0;i--)
{
free (phi_ij[i]);
phi_ij[i]=NULL;
}
free(phi_ij);
phi_ij=NULL;
for (i=r-1;i>=0;i--)
{
free(p_ji[i]);
p_ji[i]=NULL;
}
free(p_ji);
p_ji=NULL;
free(p_i);
p_i=NULL;
exit(0);
}
现在需要 转换成 VC++的代码
我很着急啊
哪位能指点一下啊
不胜感激~
我有 源码及算法的扫描件 需要的 加我QQ 372943841
高手加我 重谢~
我有 源码及算法的扫描件 需要的 加我QQ 372943841
高手加我 重谢~
算法如下
算法:
Algorithm 1: 信道容量的迭代算法
1. proceduce CHANNEL CAPACITY(r,s,(Pji))
2. initialize:信元分布Pi=1/r ,相对误差门限δ,C= -∞
3. repeat
4. Φij ← PiPji/∑PiPji (i=1到r)
5. Pi ← exp(∑Pjilog2Φij)(j=1到s)/ ∑(i=1到r) exp(∑Pjilog2Φij) (j=1到s)
6. C ← log2[∑(i=1到r) exp(∑Pjilog2Φij) (j=1到s)]
7.until |△C|/C<=δ
8.output P*=(Pi)r,C
9.end procedure
我现在有个 C的源码 如下:
代码
/********************************
* Author : QiaoXiaoYu
* Date : 2008-2-4
* Copyright :
* Purpose : Caculate the capacity of a given channe !
* *******************************
# include <stdio.h>
# include <math.h>
# include <stdlib.h>
# include <unistd.h>
# include <values.h>
# define DELTA 1e – 6 /* delta,threshold */
int main (void)
{
register int i,j;
register int k;
int r,s;
}
float * p_i=NULL;
float ** p_ji=NULL;
float ** phi_ij=NULL;
folat C,C_pre,validate;
float * sum=NULL;
float p_j;
/* Read the number of input symbol : r,
* and the number of output symbol : s */
fscanf (stdin,"%d",&r);
fscanf (stdin,"%d",&s);
/* Allocation memory for p_i,p_ji and phi_ij */
p-i = (float *) calloc (r,sizeof(float));
p_ji=(float **) calloc (r,sizeof(float));
for (i=0;i<r;i++)
phi_ij[i]=(float *) calloc (s,sizeof(float))
/* Read the channel transition priobability matrix p_ji */
for (i=0;i<r;i++)
for(j=0;j<s;j++)
fscanf (stdin,"%f",&p_ji[i][j]);
/* Validate the input data */
for (i=0;i<r;i++)
{
validate =0.0;
for (j=0;j<s;j++)
{
validate +=p_ji[i][j];
}
if (fabs(validate -1.0) >DELTA)
{
fprintf(stdout,"Invalid input data .\n");
Exit (-1);
}
}
fprintf(stdout,"Starting . . . \ n");
/* Initialize the p_i and phi_ij */
for (i=0;i<r;i++)
{
P_i[j]=1.0 /(float) r;
}
/* Initialize C and iteration counter : k,and temprory variable */
C=-MAXFLOAT ; /* MAXFLOAT was ddefined in <values.h> */
k=0;
sum=(float*) calloc (r,sizeof(float));
/* Start iterate */
do
{
k++;
/* Calculate phi_ij(k) first */
for (j=0;j<s;j++)
{
p-j=0.0;
for(i=0;i<r;i++)
p_j += p_i[i]*p_ji[i][j];
if(fabs(p_j)>=DELTA)
for(i=0;i<r;i++)
phi_ij[i][j]=p_i[i]*p_ji[i][j]/p_j;
else
for(i=0;i<r;i++)
phi_ij[i][j]=0.0;
}
/* Calculate p_i(k+1) then */
p-j=0.0
for (i=0;i<r;i++)
{
sum[i]=0.0;
for (j=0;j<s;j++)
{
/* Prevent divided by zero */
if (fabs (phi_ij[i][j])>=DELTA)
sum[i]+=p_ji[i][j]*log2(phi_ij[i][j])/log2(2.0);
}
sum[i]=pow(2.0,sum[i]);
p_j+=sum[i];
}
for (i=0;i<r;i++)
{
p_i[i]=sum[i]/p_j;
}
/* And C(k+1) */
C_pre=C;
C=log2(p_j)/log2(2.0);
}
while (fabs(C-C_pre)/C>DELTA);
free(sum);
sum=NULL;
/*Output the result */
fprintf(stdout,"The iteration number is %d.\n\n",k);
fprintf(stdout,"The capacity of the channel is %.6f bit /symbol .\n\n",C);
fprintf(stdout,"The best input probability distribution is :\n");
for (i=0;i<r;i++)
fprintf (stdout,"%.6f",p_i[i]);
fprintf (stdout,"\n");
/* Free the memory we allocation before with stack sequence*/
for(i=s-1;i>=0;i--)
{
free (phi_ij[i]);
phi_ij[i]=NULL;
}
free(phi_ij);
phi_ij=NULL;
for (i=r-1;i>=0;i--)
{
free(p_ji[i]);
p_ji[i]=NULL;
}
free(p_ji);
p_ji=NULL;
free(p_i);
p_i=NULL;
exit(0);
}
现在需要 转换成 VC++的代码
我很着急啊
哪位能指点一下啊
不胜感激~
我有 源码及算法的扫描件 需要的 加我QQ 372943841
高手加我 重谢~