實對稱正定矩陣求逆矩陣

實對稱正定矩陣求逆矩陣,第1張

實對稱正定矩陣求逆矩陣
根據線性代數理論,實對稱正定矩陣顯然有逆矩陣,而且逆矩陣也是對稱矩陣,即aij=aji(i不等於j).以下爲書上原程序,但運行後結果不對(結果不是對稱矩陣),正確結果爲:
68 -41 -17 10
-41 25 10 -6
-17 10 5 -3
10 -6 -3 2
請將程序稍加脩改,運行結果正確後再答複給我.


#include
#include


int GJ(int,double **);
double **TwoArrayAlloc(int,int);
void TwoArrayFree(double **);

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

生活常識_百科知識_各類知識大全»實對稱正定矩陣求逆矩陣

0條評論

    發表評論

    提供最優質的資源集郃

    立即查看了解詳情