了解矩阵的特定函数行列式

Understanding of a specific function Determinant of a Matrix

我在网上找到了一个计算矩阵行列式的程序:

 /*
 * C++ Program to Find the Determinant of a Given Matrix
 */
#include<iostream>
#include<math.h>
#include<conio.h>
using namespace std;
double d = 0;
double det(int n, double mat[10][10])
{
    int c, subi, i, j, subj;
    double submat[10][10];  
    if (n == 2) 
    {
        return( (mat[0][0] * mat[1][1]) - (mat[1][0] * mat[0][1]));
    }
    else
    {  
        for(c = 0; c < n; c++)
        {  
            subi = 0;  
            for(i = 1; i < n; i++)
            {  
                subj = 0;
                for(j = 0; j < n; j++)
                {    
                    if (j == c)
                    {
                        continue;
                    }
                    submat[subi][subj] = mat[i][j];
                    subj++;
                }
                subi++;
            }
        d = d + (pow(-1 ,c) * mat[0][c] * det(n - 1 ,submat));
        }
    }
    return d;
}
int main()
{
    int n;
    cout<<"enter the order of matrix" ;
    cin>>n;
    double mat[10][10];
    int i, j;
    cout<<"enter the elements"<<endl;
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            cin>>mat[i][j];
        }
    }
    cout<<"\ndeterminant"<<det(n,mat);
    getch();
}

来源:http://www.sanfoundry.com/cpp-program-find-determinant-given-matrix/

我想从中学习,但我不明白。有没有link高斯消元?否则你知道哪个进程使用这个算法吗?

提前感谢任何可能帮助我的人

这是一种使用拉佩斯展开式的算法,它通过计算 (n-1) x (n-1) 次小数的 n 个行列式递归地计算 n x n 矩阵的行列式。 2 x 2矩阵的行列式应该是显而易见的。

有更好的方法可以做到这一点,例如 LU 分解。

程序使用递归函数创建子矩阵并计算子矩阵为 2x2 时的行列式。

当程序具有子矩阵的行列式时,它会对其求和并减去它,正如您在 Wikipedia page 中看到的有关行列式的内容。

最后,递归函数returns完整矩阵的行列式