找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 1103|回复: 7

求助:关于n阶行列式的计算!

[复制链接]
发表于 2009-11-3 02:26:25 | 显示全部楼层 |阅读模式 IP:江苏扬州
a11 a12 a13 a14
a21 a22 a23 a24
a31 a32 a33 a34
a41 a42 a43 a44

假设一个二维数组中存储了以上行列式,应该怎样计算该行列式的值呀?
发表于 2009-11-3 02:26:26 | 显示全部楼层 IP:江苏扬州
怎么计算?加还是乘?
回复

使用道具 举报

发表于 2009-11-3 02:26:27 | 显示全部楼层 IP:江苏扬州
看来没有学习线性代数呀!
你这个问题用一般的递归算法就可以了。
找个算法分析看看。
回复

使用道具 举报

发表于 2009-11-3 02:26:28 | 显示全部楼层 IP:江苏扬州
见《线性代数》
回复

使用道具 举报

发表于 2009-11-3 02:26:29 | 显示全部楼层 IP:江苏扬州
看来没有说清楚,计算行列式我当然会,我要的是具体到c++上应该怎么算,能否给段代码出来
回复

使用道具 举报

发表于 2009-11-3 02:26:32 | 显示全部楼层 IP:江苏扬州
学高代时就有体会:不断的重复那么一件事!
乘完加,加完乘的,化三角呗!
回复

使用道具 举报

发表于 2009-11-3 02:26:34 | 显示全部楼层 IP:江苏扬州
see http://en.wikipedia.org/wiki/Determinant
As far as I know, there are at least 3 methods:
0. Leibniz formula --- calculate all n! products and sum them up;
1. Recur on minors;
2. Gaussian elimination.
回复

使用道具 举报

发表于 2009-11-3 02:26:35 | 显示全部楼层 IP:江苏扬州
/*---------------------------------------------------------------------------
File name: determinant.c
Author: HJin (email: fish_sea_bird [at] yahoo [dot] com )
Created on: 10/29/2007 20:38:40
Environment: WinXPSP2 En Pro + VS2005 v8.0.50727.762

use the uppper-triangulation process to calculate the
determinant of a matrix.
*/
#include <stdio.h>
#include <math.h>
#define N 3
#define EPS 1e-10
void PrintMatrix(double a[][N])
{
int i, j;
for (i = 0; i < N; ++i)
{
for (j = 0; j < N; ++j)
{
printf("%8.4g ", a[i][j]);
}
printf("\n");
}
printf("\n");
}
/*
* divides a row of a by the divisor. divisor != 0.0.
*/
void DivideRow(double a[][N], int r, double divisor)
{
int j;
for (j = 0; j < N; ++j)
{
a[r][j] /= divisor;
}
}
/*
* row1 := row 1 - row2.
*/
void SubtractRow(double a[][N], int r1, int r2)
{
int j;
for (j = 0; j < N; ++j)
{
a[r1][j] -= a[r2][j];
}
}
/*
* Upper-triangulates a matrix.
* returns the determinant of the matrix.
*/
double LU(double a[][N])
{
int i, j, k;
double factor = 1.0;
double temp;
// skip row 0
for (i = 1; i < N; ++i)
{
for (j = 0; j < i; ++j)
{
if (i != j)
{
temp = a[i][j];
if (fabs(temp) > EPS)
{
DivideRow(a, i, temp);
factor *= temp;
}
}
temp = a[j][j];
if (fabs(temp) > EPS && fabs(temp - 1.0) > EPS)
{
DivideRow(a, j, temp);
factor *= temp;
}
if (fabs(a[i][j]) > EPS)
{
SubtractRow(a, i, j);
}
for (k = 0; k < N; ++k)
{
if (fabs(a[k][k]) <= EPS)
{
return 0.0;
}
}
}
}
a[N-1][N-1] *= factor;
return a[N-1][N-1];
}
double multDia(double a[][N])
{
int i;
double factor = 1.0;
for (i = 0; i < N; ++i)
{
factor *= a[i][i];
}
return factor;
}
int main()
{
double a[N][N] =
{
{8, 0, 1},
{2, 1, 3},
{5, 3, 9}
};
double factor;
PrintMatrix(a);
factor = LU(a);
PrintMatrix(a);
printf("determinant = %g.\n", factor);
return 0;
}
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 09:24 , Processed in 0.180364 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表