为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

qwpC++求特征值idr

2017-11-14 16页 doc 36KB 25阅读

用户头像

is_003124

暂无简介

举报
qwpC++求特征值idrqwpC++求特征值idr #include #include #include #include //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //class Matrix定义矩阵类 const int Max_xy=20; //矩阵的最大维数 class Matrix { private: double data[Max_xy][Max_xy]; unsigned x,y; //x,y; public...
qwpC++求特征值idr
qwpC++求特征值idr #include #include #include #include //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //class Matrix定义矩阵类 const int Max_xy=20; //矩阵的最大维数 class Matrix { private: double data[Max_xy][Max_xy]; unsigned x,y; //x,y; public: Matrix(); //默认构造函数 Matrix(const Matrix & source); //拷贝构造函数 void creat(); //输入矩阵 void init(); void transpose(); //矩阵转置 void show(); //输入此矩阵 double mode() const; //求一维矩阵的长度 void check_shiduichen(); //检查是否为是对称矩阵 void creat_unit(unsigned i); //生成i行单位矩阵 void set_x(unsigned xx); //设置行数 void set_y(unsigned yy); //设置列数 unsigned get_x(); //得到行数 unsigned get_y(); //得到列数 void shucheng(double changshu); //数乘运算 void setdata(unsigned i,unsigned j,double source); //定位输入数据 double getdata(unsigned i,unsigned j); //定位得到数据 void sturm(); //求特征值 unsigned sturm_s(double m); //计算sturm系列的同好数 Matrix operator = (const Matrix & right); friend Matrix & operator + (const Matrix & left,const Matrix & right); //重载+号 friend Matrix & operator - (const Matrix & left,const Matrix & right); //重载-号 friend Matrix & operator * (const Matrix & left,const Matrix & right); //重载乘号 friend ostream& operator <<(ostream & os,const Matrix & source); //重载输出 friend void Householder(Matrix & source); //用Householde矩阵将实对称矩阵化为三对角矩阵 }; Matrix temp_Matrix; //全局变量Matrix //=================================================================== //--------------------默认构造函数 Matrix::Matrix() { init(); } //----------------------------拷贝构造函数 Matrix::Matrix(const Matrix & source) { init(); x=source.x; y=source.y; for(unsigned i=0;i>x; cout<<"列数:"; cin>>y; for(unsigned i=0;i>data[i][j]; } } //----------------------------------------------输出矩阵 void Matrix::show() { unsigned i,j; cout<<"\n\n矩阵表示如下:"; for(i=0;imaxhang) maxhang=s; } a=-maxhang; b=maxhang; m=sturm_s(a)-sturm_s(b); for(i=1;i<=m;i++) { a=-maxhang; b=maxhang; do { r=0.5*(a+b); if(sturm_s(r)>=i) a=r; else b=r; } while(fabs(a-b)>1e-11); cout<<"\n特征值"<1e-14) temp[i]=1; else if(p[i]<-1e-14) temp[i]=-1; else temp[i]=temp[i-1]; for(i=1,m=0;i<=x;i++) if(temp[i]+temp[i-1]!=0) m++; return m; } void main() { Matrix a; a.creat(); cout<<"输入的矩阵为:"; cout<
/
本文档为【qwpC++求特征值idr】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索