//#include "iostream.h"
#include "stdio.h"
#include <stdlib.h>
#include "math.h"
#include "awgn.h"
#include <iomanip>
#include <time.h>
#include "iostream"
#define pi 3.1415926535897
#define nbSubframes 1
#define nbRBsPerSubframe 2
#define nbSubcarriersPerRB 12
#define nbOFDMSymbolsPerRB 7
#define FFTlength 512
using namespace std;
void Error(char *message)
{
fprintf(stderr,"Error: %s\n",message);
exit(1);
}
double **_Alloc2(int r,int c)
{
double *x,**y;
int n;
x=(double *)calloc(r*c,sizeof(double));
y=(double **)calloc(r,sizeof(double *));
for(n=0;n<=r-1;n++)
{
y[n]=&x[c*n];
}
return y;
}
void _Alloc2Free(double **x)
{
free(x[0]);
free(x);
}
double _random(void)
{
int a;
double r;
a=rand()%32767;
r=(a+0.000001)/32767.00;
return r;
}
double _sta(double mu,double sigma)
{
double _random(void);
int i;
double r,sum=0.0;
if(sigma<=0.0)
Error("Sigma<=0.0 in _sta!");
for(i=1;i<=12;i++)
sum=sum+_random();
r=(sum-6.00)*sigma+mu;
return r;
}
double _sta2(double mu,double sigma)
{
double r1,r2;
r1=_random();
r2=_random();
return sqrt(-2*log(r1))*cos(2*pi*r2)*sigma+mu ;
}
double **AWGN::MakeNoise()
{
double **Noise;
Noise= _Alloc2(row, col);
for(int i = 0; i < row; i++)
for(int j = 0; j < col; j++)
Noise[i][j] = _sta2(mu, sigma);
return Noise;
}
struct compx
{
double real;
double imag;
};
struct compx EE(struct compx b1,struct compx b2)
{
struct compx b3 ;
b3.real=b1.real*b2.real-b1.imag*b2.imag ;
b3.imag=b1.real*b2.imag+b1.imag*b2.real ;
return(b3);
}
struct compx div(struct compx b1,struct compx b2)
{
struct compx b3;
b3.real=(b1.real*b2.real+b1.imag*b2.imag)/(b2.real*b2.real+b2.imag*b2.imag);
b3.imag=(b1.imag*b2.real-b1.real*b2.imag)/(b2.real*b2.real+b2.imag*b2.imag);
return(b3);
}
void FFT(struct compx *xin,int N)
{
int f,m,LH,nm,i,k,j,L;
double p , ps ;
int le,B,ip;
struct compx w,t;
LH=N/2;
f=N;
for(m=1;(f=f/2)!=1;m++){;}
nm=N-2;
j=N/2;
for(i=1;i<=nm;i++)
{
if(i<j)
{
t=xin[j];xin[j]=xin[i];xin[i]=t;
}
k=LH;
while(j>=k)
{
j=j-k;k=k/2;
}
j=j+k;
}
{
for(L=1;L<=m;L++)
{
le=pow(2.0,L);
B=le/2;
for(j=0;j<=B-1;j++)
{
p=pow(2.0,m-L)*j;
ps=2*pi/N*p;
w.real=cos(ps);
w.imag=-sin(ps);
for(i=j;i<=N-1;i=i+le)
{
ip=i+B;
t=EE(xin[ip],w);
xin[ip].real=xin[i].real-t.real;
xin[ip].imag=xin[i].imag-t.imag;
xin[i].real=xin[i].real+t.real;
xin[i].imag=xin[i].imag+t.imag;
}
}
}
}
return;
}
void IFFT(struct compx *xin,int N)
{
int f,m,LH,nm,i,k,j,L;
double p , ps ;
int le,B,ip;
struct compx w,t;
LH=N/2;
f=N;
for(m=1;(f=f/2)!=1;m++){;}
nm=N-2;
j=N/2;
for(i=1;i<=nm;i++)
{
if(i<j)
{
t=xin[j];xin[j]=xin[i];xin[i]=t;
}
k=LH;
while(j>=k)
{
j=j-k;k=k/2;
}
j=j+k;
}
{
for(L=1;L<=m;L++)
{
le=pow(2.0,L);
B=le/2;
for(j=0;j<=B-1;j++)
{
p=pow(2.0,m-L)*j;
ps=2*pi/N*p;
w.real=cos(ps);
w.imag=sin(ps);
for(i=j;i<=N-1;i=i+le)
{
ip=i+B;
t=EE(xin[ip],w);
xin[ip].real=xin[i].real-t.real;
xin[ip].imag=xin[i].imag-t.imag;
xin[i].real=xin[i].real+t.real;
xin[i].imag=xin[i].imag+t.imag;
}
}
}
}
for(i=0;i<N;i++)
{
xin[i].real=xin[i].real/N;
xin[i].imag=xin[i].imag/N;
}
return;
}
void _free2(double **x)
{
free(x[0]);
free(x);
}
void fun_fft(int data,double FDSubframe[FFTlength][8])
{
int phi[30][12] = {-1,1,3,-3,3,3,1,1,3,1,-3,3,1,1,3,3,3,-1,1,-3,-3,1,-3,3,1,1,-3,-3,-3,-1,-3,-3,1,-3,1,-1,-1,1,1,1,1,-1,-3,-3,1,-3,3,-1,-1,3,1,-1,1,-1,-3,-1,1,-1,1,3,1,-3,3,-1,-1,1,1,-1,-1,3,-3,1,-1,3,-3,-3,-3,3,1,-1,3,3,-3,1,-3,-1,-1,-1,1,-3,3,-1,1,-3,3,1,1,-3,3,1,-1,-1,-1,1,1,3,-1,1,1,-3,-1,3,3,-1,-3,1,1,1,1,1,-1,3,-1,1,1,-3,-3,-1,-3,-3,3,-1,3,1,-1,-1,3,3,-3,1,3,1,3,3,1,-3,1,1,-3,1,1,1,-3,-3,-3,1,3,3,-3,3,-3,1,1,3,-1,-3,3,3,-3,1,-1,-3,-1,3,1,3,3,3,-1,1,3,-1,1,-3,-1,-1,1,1,3,1,-1,-3,1,3,1,-1,1,3,3,3,-1,-1,3,-1,-3,1,1,3,-3,3,-3,-3,3,1,3,-1,-3,3,1,1,-3,1,-3,-3,-1,-1,1,-3,-1,3,1,3,1,-1,-1,3,-3,-1,-3,-1,-1,-3,1,1,1,1,3,1,-1,1,-3,-1,-1,3,-1,1,-3,-3,-3,-3,-3,1,-1,-3,1,1,-3,-3,-3,-3,-1,3,-3,1,-3,3,1,1,-1,-3,-1,-3,1,-1,1,3,-1,1,1,1,3,1,3,3,-1,1,-1,-3,-3,1,1,-3,3,3,1,3,3,1,-3,-1,-1,3,1,3,-3,-3,3,-3,1,-1,-1,3,-1,-3,-3,-1,-3,-1,-3,3,1,-1,1,3,-3,-3,-1,3,-3,3,-1,3,3,-3,3,3,-1,-1,3,-3,-3,-1,-1,-3,-1,3,-3,3,1,-1};
int u1[8]={29,7,19,15,27,23,14,1},modData,j,k,m,s;
double data_column[12][8],data_row1[8][12],alpha[12];
double FDSubframe1[12][8]={0};
double FDSubframe_slot1[FFTlength][4]={0},FDSubframe_slot2[FFTlength][4]={0};
for(j=0;j<12;j++)
alpha[j]=pi*j/6;
if(data==0)modData=1;
else modData=-1;
s=nbOFDMSymbolsPerRB * nbRBsPerSubframe * nbSubframes - 3*nbRBsPerSubframe * nbSubframes;
for(j=0;j<s;j++)
{
m=u1[j]-1;
for(k=0;k<12;k++)
{
data_row1[j][k]=phi[m][k]*pi/4+alpha[k];
}
}
for(j=0;j<12;j++)
{
for(k=0;k<s;k++)
data_column[j][k]=modData*data_row1[k][j];
}
for(j=0;j<12;j++)
{
for(k=0;k<8;k++)
{
FDSubframe1[j][k]=data_column[j][k];
}
}
for(j=0;j<12;j++)
{
for(k=0;k<4;k++)
{
FDSubframe_slot1[j][k]=FDSubframe1[j][k];
}
}
for(j=FFTlength-12;j<FFTlength;j++)
{
for(k=0;k<4;k++)
{
FDSubframe_slot2[j][k]=FDSubframe1[j-FFTlength+12][k+4];
}
}
for(j=0;j<12;j++)
{
for(k=0;k<4;k++)
{
FDSubframe[j][k]=FDSubframe_slot1[j][k];
}
}
for(j=FFTlength-12;j<FFTlength;j++)
{
for(k=4;k<8;k++)
{
FDSubframe[j][k]=FDSubframe_slot2[j][k-4];
}
}
}
void fun_refer(double FDsubframe[][8],double FDFrame_Final[][14])
{
int phi[30][12] = {-1,1,3,-3,3,3,1,1,3,1,-3,3,1,1,3,3,3,-1,1,-3,-3,1,-3,3,1,1,-3,-3,-3,-1,-3,-3,1,-3,1,-1,-1,1,1,1,1,-1,-3,-3,1,-3,3,-1,-1,3,1,-1,1,-1,-3,-1,1,-1,1,3,1,-3,3,-1,-1,1,1,-1,-1,3,-3,1,-1,3,-3,-3,-3,3,1,-1,3,3,-3,1,-3,-1,-1,-1,1,-3,3,-1,1,-3,3,1,1,-3,3,1,-1,-1,-1,1,1,3,-1,1,1,-3,-1,3,3,-1,-3,1,1,1,1,1,-1,3,-1,1,1,-3,-3,-1,-3,-3,3,-1,3,1,-1,-1,3,3,-3,1,3,1,3,3,1,-3,1,1,-3,1,1,1,-3,-3,-3,1,3,3,-3,3,-3,1,1,3,-1,-3,3,3,-3,1,-1,-3,-1,3,1,3,3,3,-1,1,3,-1,1,-3,-1,-1,1,1,3,1,-1,-3,1,3,1,-1,1,3,3,3,-1,-1,3,-1,-3,1,1,3,-3,3,-3,-3,3,1,3,-1,-3,3,1,1,-3,1,-3,-3,-1,-1,1,-3,-1,3,1,3,1,-1,-1,3,-3,-1,-3,-1,-1,-3,1,1,1,1,3,1,-1,1,-3,-1,-1,3,-1,1,-3,-3,-3,-3,-3,1,-1,-3,1,1,-3,-3,-3,-3,-1,3,-3,1,-3,3,1,1,-1,-3,-1,-3,1,-1,1,3,-1,1,1,1,3,1,3,3,-1,1,-1,-3,-3,1,1,-3,3,3,1,3,3,1,-3,-1,-1,3,1,3,-3,-3,3,-3,1,-1,-1,3,-1,-3,-3,-1,-3,-1,-3,3,1,-1,1,3,-3,-3,-1,3,-3,3,-1,3,3,-3,3,3,-1,-1,3,-3,-3,-1,-1,-3,-1,3,-3,3,1,-1};
double alpha[12];
double r[6][12]={0},r_temp1[FFTlength][3]={0},r_temp2[FFTlength][3]={0},shapedFrame1[7672]={0};
int u2[6]={29,7,19,15,27,23},j,k,a,b;
for(j=0;j<12;j++)
alpha[j]=pi*j/6;
for(j=0;j<6;j++)
{
a=u2[j]-1;
for(k=0;k<12;k++)
{
r[j][k]=alpha[k]+phi[a][k]*pi/4;
}
}
for(k=0;k<3;k++)
{
for(j=0;j<12;j++)
{
r_temp1[j][k]=r[k][j];
}
}
for(k=0;k<3;k++)
{
for(j=FFTlength-12;j<FFTlength;j++)
{
r_temp2[j][k]=r[3+k][j-FFTlength+12];
}
}
for(b =0;b<FFTlength;b++)
{
for(j=0;j<2;j++)
{
FDFrame_Final[b][j]=FDsubframe[b][j];}
for(j=2;j<5;j++)
{
FDFrame_Final[b][j]=r_temp1[b][j-2];
}
for(j=5;j<7;j++)
{
FDFrame_Final[b][j]=FDsubframe[b][j-3];
}
for(j=7;j<9;j++)
{
FDFrame_Final[b][j]=FDsu
PUCCH.rar_ PUCCH_LTE Visual _LTE 上行_pucch dmrs_uplink pucch cha
版权申诉
36 浏览量
2022-09-19
17:52:59
上传
评论
收藏 571KB RAR 举报
林当时
- 粉丝: 93
- 资源: 1万+
最新资源
- 基于SSM写的停车场管理系统,加入了车牌识别和数据分析+源码+文档说明
- stream-response.txt
- Python库d和OpenCV来实现眼部闭合检测,主要用于评估用户是否眨眼
- 使用Python库dlib和OpenCV来实现面部特征点的检测和标注
- 强大好用的人体关键点标注工具
- mmexport1713375197200.png
- LP.mlx
- 17期基础网络笔记.one
- bugreport-venus-TKQ1.220829.002-2024-04-18-00-45-35.zip
- bitnami-redmine-4.1.1-2-linux-x64-installer.run(实测可用)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈