for (i = 0; i < T; i++)
{
for (j = 0; j < T; j++)
{
H1[i][j] = complex(H1_re[i][j], H1_im[i][j]);
}//服从（0,1）分布
}

``````for (i = 0; i < T; i++)
{
for (j = 0; j < T; j++)
{
H2[i][j] = complex<double>(H2_re[i][j], H2_im[i][j]);
}//服从（0,1）分布
}

for (i = 0; i < T; i++)
{
for (j = 0; j < 1; j++)
{
}
}
//cout<<Y<<endl;

for (i = 0; i < T; i++)
{
N[0][0] = complex<double>(0.707*sqrt(sigma_2)*noise_re[i], 0.707*sqrt(sigma_2)*noise_im[i]);

}//服从（0，sigma_2）分布

G = 1 / double(sqrt(abs(H1[0][0])*abs(H1[0][0]) + sigma_2));
//cout << G << endl;
//cout << H1  << endl;
//cout << H2  << endl;

Y2 = G*Y1[0][0];
//cout << Y2 << endl;
//cout << Y1 << endl;

Y3 = H2*Y2 + N;
//cout <<Y3<< endl;
//cout << Y2 << endl;
//cout << N << endl;
//cout <<  h2_re[0]  << endl;

for(j=0;j<M;j++)
{
S = complex<double>(s_re[j], s_im[j]);

distance[j] = norm(Y3- H1[0][0]*H2[0][0]*G*S);
}
//cout <<  h1_re[0]  << endl;
//cout << y3_re1[0] << endl;
//cout << G << endl;
//cout <<distance[0] << endl;
//cout <<s_re[0] << endl;
//cout <<s_im[0] << endl;

index=0;
min_dis=distance[0];
for(j=0;j<M;j++)
{
if(j>0 && distance[j]<distance[index])
{
index=j;

}

}

for(int d=0;d<L;d++)
{
x_msg_hat[d] = B[index][d];

}

//cout << x_msg_hat[0] << endl;
``````
``````

``````

1个回答