题目
实对称正定矩阵求逆矩阵
根据线性代数理论,实对称正定矩阵显然有逆矩阵,而且逆矩阵也是对称矩阵,即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
提问时间:2021-01-02
答案
应当对称:
#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
#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
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
- 1已知x1x2是关于x的一元二次方程x²+(m+1)x+m+6=0的两实数根且x1²+先²=5求m的值是多少?
- 2《相见欢》李煜,这首词的中心思想是什么?也就是主旨
- 3求高中数学选修参数方程公式和常见变形?
- 4carbon dioxide是什么意思
- 5《我心中的那一丝牵挂》 作文 写牵挂舟曲人民!至少650字 快,
- 6已知b/a=d/c≠1,求证:a+b/a−b=c+d/c−d.
- 7who is my dad
- 8将盛有锡块的坩埚放在电炉上加热,锡在逐渐熔化的过程中要( ) A.不断吸热,温度不断上升 B.不断吸热,温度保持不变 C.不断放热,温度保持不变 D.不断放热,温度不断上升
- 9even if even though 后面的虚拟语气
- 10学校食堂运来一堆煤,计划每天烧煤50千克,6.5天烧完,实际10天才烧完.实际每天比计划少烧煤多少千克?
热门考点
- 1夏天,冬天,秋天,春天用英文写出.
- 2下列句子哪一个正确?
- 3a>0,b>0,log4 a=log6 a=log9 (a+b)=t 求a/b的值.
- 4杠杆在什么情况下都是力臂乘以力矩=力臂乘以力矩?这句话对不对了,为什么?
- 5铅笔的六个优点
- 6螺旋测微器读数,固定尺的半刻度似露非露的(可动尺零刻度在上或在下),如何判断已经过了半刻度线?
- 7Many children play a game called “trick or treat”.同义句
- 81.8gH2O(O的相对原子质量为18)中含有的中子数等于多少克D2O(O的相对原子质量为16)所含的中子数
- 9已知函数Y=3sin(2x-π/3),x∈【-π/3,0】求值域
- 10“请你用一句话概括这一章” 的英语怎么说?