应当对称:
#include
#include
#include
#include
#define N 4
double A[N][N]={{68,-41,-17,10 },{-41,25 ,10 ,-6 },{-17,10,5,-3
},{10,-6,-3,2 }};
void swap(double *a,double *b){double c; c= *a; *a= *b; *b= c;};
int DinV(double A[N][N],int n)
{
int i,j,k;
double d;
int JS[N],IS[N];
for (k=0;k
实对称正定矩阵求逆矩阵
实对称正定矩阵求逆矩阵
根据线性代数理论,实对称正定矩阵显然有逆矩阵,而且逆矩阵也是对称矩阵,即aij=aji(i不等于j).以下为书上原程序,但运行后结果不对(结果不是对称矩阵),正确结果为:
68 -41 -17 10
-41 25 10 -6
-17 10 5 -3
10 -6 -3 2
请将程序稍加修改,运行结果正确后再答复给我.
/* 试验未通过 */
/* 正定矩阵求逆 */
#include
#include
/* #include*/
/* 新系数的计算公式:*/
int GJ(int,double **); /* a11'=1/a11 */
double **TwoArrayAlloc(int,int); /* a1j'=-a1j/a11 j=2,3,...,n */
void TwoArrayFree(double **); /* ai1'=ai1/a11 i=2,3,...,n */
/* aij'=aij-ai1*a1j/a11 i,j=2,3,...,n */
void main()
{
int i,j,n;
double **a;
n=4;
a=TwoArrayAlloc(n,n);
a[0][0]=5; a[0][1]=7; a[0][2]=6; a[0][3]=5;
a[1][0]=7; a[1][1]=10; a[1][2]=8; a[1][3]=7;
a[2][0]=6; a[2][1]=8; a[2][2]=10; a[2][3]=9;
a[3][0]=5; a[3][1]=7; a[3][2]=9; a[3][3]=10;
if(!GJ(n,a))
{
printf("矩阵求逆失败\n");
exit(1);
}
printf("该矩阵的逆为:\n");
for(i=0;i
根据线性代数理论,实对称正定矩阵显然有逆矩阵,而且逆矩阵也是对称矩阵,即aij=aji(i不等于j).以下为书上原程序,但运行后结果不对(结果不是对称矩阵),正确结果为:
68 -41 -17 10
-41 25 10 -6
-17 10 5 -3
10 -6 -3 2
请将程序稍加修改,运行结果正确后再答复给我.
/* 试验未通过 */
/* 正定矩阵求逆 */
#include
#include
/* #include*/
/* 新系数的计算公式:*/
int GJ(int,double **); /* a11'=1/a11 */
double **TwoArrayAlloc(int,int); /* a1j'=-a1j/a11 j=2,3,...,n */
void TwoArrayFree(double **); /* ai1'=ai1/a11 i=2,3,...,n */
/* aij'=aij-ai1*a1j/a11 i,j=2,3,...,n */
void main()
{
int i,j,n;
double **a;
n=4;
a=TwoArrayAlloc(n,n);
a[0][0]=5; a[0][1]=7; a[0][2]=6; a[0][3]=5;
a[1][0]=7; a[1][1]=10; a[1][2]=8; a[1][3]=7;
a[2][0]=6; a[2][1]=8; a[2][2]=10; a[2][3]=9;
a[3][0]=5; a[3][1]=7; a[3][2]=9; a[3][3]=10;
if(!GJ(n,a))
{
printf("矩阵求逆失败\n");
exit(1);
}
printf("该矩阵的逆为:\n");
for(i=0;i
其他人气:231 ℃时间:2020-02-04 03:20:28
优质解答
我来回答
类似推荐
猜你喜欢
- 1甲,乙两车分别从A.B两地同时出发,相对而行,结果在距两地中点60千米处相遇.已知甲比乙多行20%.A.B两地之间
- 2麻烦看看这题_____,we went swimming in the river.
- 348和32的最大公因数是_,最小公倍数是_.
- 4there a pair of shoes填is还是are
- 5三人在郊游时,一共喝了9瓶纯净水.买纯净水时,甲付了5瓶的钱,乙付了4瓶的钱,按人数平均计算,丙应该拿
- 6汽车在水平公路上自A向B做匀减速直线运动停于B点,初速度为3m/s,加速度为1m/s^2.若汽车在某一秒内通过了2m的位移,则在这一秒前汽车已运动了多少米?
- 7二氧化碳和氢气反应生成乙烯和水的化学方程式!
- 8英语翻译
- 9the poor man is made______very late every night A.work B.to work C.working D.worked
- 10司马光砸缸之后