资源简介
自适应线性单元,模型结构,最小均方误差LMS算法
代码片段和文件信息
#include
#include
using namespace std;
void main()
{
double u = 2.0/1600.0;
const int N = 10004;
const int M = 15 ;
const int L = 200;
int i = 0;
int j = 0;
int k = 0;
int a[N];
int d[N];
// double ah[N+4];
double x[N+4];
double y[N];
double e[N];
int c[N];
double w[M];
double s[L];
for (i=0; i {
s[i] = 0;
}
for (i=0; i<18; i++)
{
d[i] = 0;
}
for (i=0; i {
e[i] = 0;
y[i] = 0;
c[i] = 0;
}
for (i=0; i {
w[i] = 0.0;
}
w[7] = 1.0;
FILE* file0;
FILE* file1;
FILE* file2;
FILE* file3;
FILE* file4;
file0 = fopen(“d:\\aaaa.dat“ “r“);
file1 = fopen(“d:\\yyyy.dat“ “w“);
file2 = fopen(“d:\\xxxx.dat“ “r“);
file3 = fopen(“d:\\ssss.dat“ “w“);
file4 = fopen(“d:\\eeee.dat“ “w“);
for (i=0; i {
fscanf(file0 “%d“ a+i);
}
for (i=0; i {
fscanf(file2 “%lf“ x+i);
}
fclose(file2);
fclose(file0);
for (i=18; i {
d[i] = a[i-9];
}
/* for (i=18; i {
double y0 = 0.0;
double sum1 = 0;
double sum2 = 0;
for (j=0; j {
y0 += w[j] * x[i-j];
}
e[i] = d[i] - y0;
y[i] = y0;
for (i=18; i {
sum1 += e[i] * e[i];
sum2 = (double)sum1 / (N-18);
}
s[0] = sqrt(sum2);
}
*/
for (k=0; k {
double sum1 = 0 sum2 = 0 sum3 = 0 ee = 0.0;
int sum0 = 0 sum4 = 0;
for (i=18; i {
double y0 = 0.0 y1 = 0.0;
for (j=0; j {
y0 += w[j] * x[i-j];
}
e[i] = d[i] - y0;
y[i] = y0;
for (j=0; j {
w[j] = w[j] + u * e[i] * x[i-j];
}
/*
sum3 += e[i];
sum4 += 1;
if (sum4 % 9986 == 0)
{
ee = (double)sum3 / 9986;
// cout << ee << endl;
sum4 = 0;
sum3 = 0;
}
for (j=0; j {
sum3 += e[i] * x[i-j];
ee = sum3 / M;
}
*/
}
for (i=18; i {
double y1 = 0.0;
for (j=0; j {
y1 += w[j] * x[i-j];
}
e[i] = d[i] - y1;
sum1 += e[i] * e[i];
y[i] = y1;
if (y[i] > 0)
c[i] = 1;
else
c[i] = -1;
if (d[i] != c[i])
sum0 += 1;
}
sum2 = (double)sum1 / (N-18);
// double sum4 = sum3 / (N-18);
// double sum5 = u * sum4;
// cout << sum5 << endl;
// cout << sum << endl;
double error = (double)sum0 / (N-18);
// cout << “error = “ << error << endl;
s[k] = sqrt(sum2);
fprintf(file3 “%f\n“ s[k]);
fprintf(file4 “%f\n“ error);
}
for (i=0; i {
fprintf(file1 “%f\n“ w[i]);
}
fclose(file4);
fclose(file3);
fclose(file1);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 2827 2007-08-22 14:19 自适应信道均衡\0.cpp
文件 4257 2007-07-31 16:49 自适应信道均衡\0lms.dsp
文件 531 2007-07-31 16:37 自适应信道均衡\0lms.dsw
文件 41984 2010-04-08 20:24 自适应信道均衡\0lms.ncb
文件 53760 2010-04-08 20:24 自适应信道均衡\0lms.opt
文件 242 2007-08-22 14:15 自适应信道均衡\0lms.plg
文件 16010 2007-08-22 14:14 自适应信道均衡\Debug\0.obj
文件 266292 2007-08-22 14:14 自适应信道均衡\Debug\0lms.exe
文件 1115136 2007-08-22 14:14 自适应信道均衡\Debug\0lms.pdb
文件 110592 2007-08-22 14:14 自适应信道均衡\Debug\vc60.pdb
目录 0 2010-04-08 20:25 自适应信道均衡\Debug
目录 0 2010-04-08 20:25 自适应信道均衡
----------- --------- ---------- ----- ----
1611631 12
- 上一篇:音乐跑马灯C语言程序
- 下一篇:用MFC+mysql做的培训中心收费系统
评论
共有 条评论