?? d8r4.cpp
字號:
# include <math.h>
# include <iomanip.h>
# include <iostream.h>
void main()
{
//program d8r4
//driver for routine tqli
int np,k,i,j;
double tiny,a[4][4], c[4][4], d[4], e[4], f[4];;
np = 3;
tiny = 0.000001;
a[1][1] = 1.0; a[1][2] = 2.0; a[1][3] = 3.0;
a[2][1] = 2.0; a[2][2] = 2.0; a[2][3] = 3.0;
a[3][1] = 3.0; a[3][2] = 3.0; a[3][3] = 3.0;
for (i = 1; i<=np; i++)
{
for (j = 1; j<=np; j++)
{
c[i][j] = a[i][j];
}
}
tred2(c, np, d, e);
tqli(d, e, np, c);
cout<<endl;
cout<< "Eigenvectors for a real symmetric matrix";
for (i = 1; i<=np; i++)
{
for (j = 1; j<=np; j++)
{
f[j] = 0.0;
for (k = 1; k<=np; k++)
{
f[j] = f[j] + a[j][k] * c[k][i];
}
}
cout<<endl;
cout<< "Eigenvalue "<< i<< " = ";
cout<< setw(10)<<d[i];
cout<<endl;
cout<<endl;
cout<< " vector mtrx*vect. ratio"<<endl;
cout<<endl;
for (j = 1; j<=np; j++)
{
if (fabs(c[j][i]) < tiny )
{
cout<<setw(10)<<c[j][i];
cout<< setw(10)<<f[j];
cout<< "div. by 0";
cout<<endl;
}
else
{
cout<<setw(13)<<c[j][i];
cout<<setw(13)<<f[j];
cout<<setw(13)<<(f[j] / c[j][i])<<endl;
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -