看书上写了一个矩阵类class Matrix
头文件: #include "Matrix.h"
在C++下用 matrix <long, double> p(4,4)可以用在VC6.0下
头文件: #include "Matrix.h"
但是在VC6。0下编译不通应如何使用
头文件: #include "Matrix.h"
在C++下用 matrix <long, double> p(4,4)可以用在VC6.0下
头文件: #include "Matrix.h"
但是在VC6。0下编译不通应如何使用
解决方案 »
- CListView中插入数据没有显示?
- 在SDK编程种创建对话框遇到得一个问题。请大侠们指点。
- vc6编译出现的问题 刚装上的
- 我想做一个共享打印机队列监控的软件,能不能给点好的建议
- 请问cookie是http协议地一部分吗?有谁能介绍一下,谢谢!
- 请问哪位有JBIG2的代码或资料,敬请告知
- 关于CFormView的问题
- 急!!急
- 求对称加密算法扫盲
- 请问如何用VC6中文版写全E文的程序,我已经将资源指定为E了,可是执行的时候还是有中文的‘确定’按钮,如何将他改成OK?
- 不知道调用规则的请进,以后不需要问了(函数调用规则简介[ZT])
- boundschecker~~的错误不明白....20分钟马上给分
#include "Matrix.h"
using namespace std;#include <math.h>.......void CCReceCommDlg::ProcessData(int length,unsigned char buf*)
{
。
const double T=0.2;
const double t_ax=1;
const double tx=0.5;
long double s = 0.0;
long double f1[4][4]=
{
{1.0,T,T*T/2,0.0},{0.0,1.0,T,0.0},{0.0,0.0,1.0,0.0},{0.0,0.0,0.0,exp(-T/tx)}
};
long double f[4][4]=
{
{1.0,T,(T/t_ax-1+exp(-T/t_ax))*t_ax*t_ax,0.0},{0.0,1.0,(1-exp(-T/t_ax))*t_ax,0.0},{0.0,0.0,exp(-T/t_ax),0.0},{0.0,0.0,0.0,exp(-T/tx)}
};
long double q[4][4]=
{
{0.0,0.0,0.0,0.0},{0.0,0.0,0.0,0.0},{0.0,0.0,0.0,0.0},{0.0,0.0,0.0,0.0}
};
long double eye[4][4]=
{
{1.0,0.0,0.0,0.0},{0.0,1.0,0.0,0.0},{0.0,0.0,1.0,0.0},{0.0,0.0,0.0,1.0}
};
long double r[1][1]={4.5};
long double h[1][4]={1.0,0.0,0.0,1.0};
matrix <long double> pp(4,4);
matrix <long double> pp1(4,4);
matrix <long double> xx(4,1);
matrix <long double> xx1(4,1);
matrix <long double> gg(4,1);
matrix <long double> fft(4,4);
matrix <long double> hht(4,1);
。。
}error C2065: 'matrix' : undeclared identifier以下是matrix.h头文件(部分)#ifndef _MATRIX_H //避免多次编译
#define _MATRIX_H#include <valarray> //模板类valarray的标准头文件
#include <comm.h> //公共头文件
#include <math.h> //数学头文件template <class _Ty>
class matrix //矩阵类matrix
{
typedef matrix<_Ty> _Myt; private:
std::valarray<_Ty> m_Datas; //定义一维数组对象m_Datas size_t m_stRow; //矩阵行数变量
size_t m_stCol; //矩阵列数变量 public:
typedef _Ty value_type;
...........
typedef matrix<float> matrixf;
typedef matrix<double> matrixd;
typedef matrix<long double> matrixld;........
}以下在C++中正常应用#include <iostream>
#include "Matrix.h"
using namespace std;void main()
{
const double t_ax=1;
const double tx=0.5;
const double T=0.2;
long double s = 0.0;
long double f1[4][4]=
{
{1.0,T,T*T/2,0.0},{0.0,1.0,T,0.0},{0.0,0.0,1.0,0.0},{0.0,0.0,0.0,exp(-T/tx)}
};
long double f[4][4]=
{
{1.0,T,(T/t_ax-1+exp(-T/t_ax))*t_ax*t_ax,0.0},{0.0,1.0,(1-exp(-T/t_ax))*t_ax,0.0},{0.0,0.0,exp(-T/t_ax),0.0},{0.0,0.0,0.0,exp(-T/tx)}
};
long double q[4][4]=
{
{0.0,0.0,0.0,0.0},{0.0,0.0,0.0,0.0},{0.0,0.0,0.0,0.0},{0.0,0.0,0.0,0.0}
};
long double eye[4][4]=
{
{1.0,0.0,0.0,0.0},{0.0,1.0,0.0,0.0},{0.0,0.0,1.0,0.0},{0.0,0.0,0.0,1.0}
};
long double r[1][1]={4.5};
long double h[1][4]={1.0,0.0,0.0,1.0};
long double data[10][1]={39153.43,39348.793,39541.08,39740.674,39936.208,40132.354,40328.09,40523.831,40719.298,40915.248};
matrix<long double>pp(4,4),pp1(4,4),xx(4,1),xx1(4,1),gg(4,1);
matrix<long double>fft(4,4),hht(4,1);
matrix<long double>yy(&data[0][0],10,1); yy=0.3*yy;
for (int i=0;i<4;i++)
for(int j=0;j<4;j++)
pp(i,j) =0;
for( i=0;i<4;i++)
xx(i,0) =0;
xx(0,0)=yy(0,0);xx(1,0)=(yy(1,0)-yy(0,0))/T;
matrix<long double>ff(&f[0][0],4,4),ff1(&f1[0][0],4,4),qq(&q[0][0],4,4);
matrix<long double>rr(&r[0][0],1,1),hh(&h[0][0],1,4),eyem(&eye[0][0],4,4);
for (i=0; i<10; i++)
{
long double t = 0.2*i;
cout<<t;
cout.precision(10);
cout.width(15);
cout<<yy(i,0);
cout.width(15);
cout<<xx(0,0);
cout.width(20);
cout<<xx(1,0);
cout.width(20);
cout<<xx(2,0);
cout<<endl;
xx1=ff1*xx;
MatrixTranspose(ff,fft);
pp1=ff*pp*fft+qq;
MatrixTranspose(hh,hht);
//gg=pp1*hht*MatrixInversionGS(hh*pp1*hht+rr);
s=(hh*pp1*hht+rr)(0,0);
gg=pp1*hht*1/s;
pp=(eyem-gg*hh)*pp1;
xx=xx1+gg*(yy(i,0)-hh*xx1);
}
}
{
typedef matrix<_Ty> _Myt; private:
std::valarray<_Ty> m_Datas; //定义一维数组对象m_Datas size_t m_stRow; //矩阵行数变量
size_t m_stCol; //矩阵列数变量 public:
typedef _Ty value_type;
...........
typedef matrix<float> matrixf;
typedef matrix<double> matrixd;
typedef matrix<long double> matrixld;........
}//这个地方是不是少了个分号???
程序见http://expert.csdn.net/Expert/topic/2508/2508011.xml?temp=.9026453
拜托高手!!