Skip to main content
added 102 characters in body
Source Link
Martin R
  • 23.5k
  • 2
  • 36
  • 92
if(dimension == 0) {
    return 0;
}

Mathematically, that is not correct. The determinant of an empty (i.e. zero-dimensional) matrix is one, see for example What is the determinant of []? on Mathematics Stack Exchange.

 

With respect to efficiency: Your program computes the determinant recursively using the Laplace formula and adjugate matrices, which requires \$ O(n!) \$ arithmetic operations, and the creation of many temporary “submatrices”. 

A better method (at least for larger matrices) is Gaussian elimination which requires \$ O(n^3) \$ arithmetic operations, and can operate on a single copy of the original matrix.

if(dimension == 0) {
    return 0;
}

Mathematically, that is not correct. The determinant of an empty (i.e. zero-dimensional) matrix is one, see for example What is the determinant of []? on Mathematics Stack Exchange.

With respect to efficiency: Your program computes the determinant recursively using the Laplace formula and adjugate matrices, which requires \$ O(n!) \$ arithmetic operations. A better method (at least for larger matrices) is Gaussian elimination which requires \$ O(n^3) \$ arithmetic operations.

if(dimension == 0) {
    return 0;
}

Mathematically, that is not correct. The determinant of an empty (i.e. zero-dimensional) matrix is one, see for example What is the determinant of []? on Mathematics Stack Exchange.

 

With respect to efficiency: Your program computes the determinant recursively using the Laplace formula, which requires \$ O(n!) \$ arithmetic operations, and the creation of many temporary “submatrices”. 

A better method (at least for larger matrices) is Gaussian elimination which requires \$ O(n^3) \$ arithmetic operations, and can operate on a single copy of the original matrix.

added 469 characters in body
Source Link
Martin R
  • 23.5k
  • 2
  • 36
  • 92
if(dimension == 0) {
    return 0;
}

Mathematically, that is not correct. The determinant of an empty (i.e. zero-dimensional) matrix is one, see for example What is the determinant of []? on Mathematics Stack Exchange.

With respect to efficiency: Your program computes the determinant recursively using the Laplace formula and adjugate matrices, which requires \$ O(n!) \$ arithmetic operations. A better method (at least for larger matrices) is Gaussian elimination which requires \$ O(n^3) \$ arithmetic operations.

if(dimension == 0) {
    return 0;
}

Mathematically, that is not correct. The determinant of an empty (i.e. zero-dimensional) matrix is one, see for example What is the determinant of []? on Mathematics Stack Exchange.

if(dimension == 0) {
    return 0;
}

Mathematically, that is not correct. The determinant of an empty (i.e. zero-dimensional) matrix is one, see for example What is the determinant of []? on Mathematics Stack Exchange.

With respect to efficiency: Your program computes the determinant recursively using the Laplace formula and adjugate matrices, which requires \$ O(n!) \$ arithmetic operations. A better method (at least for larger matrices) is Gaussian elimination which requires \$ O(n^3) \$ arithmetic operations.

Source Link
Martin R
  • 23.5k
  • 2
  • 36
  • 92

if(dimension == 0) {
    return 0;
}

Mathematically, that is not correct. The determinant of an empty (i.e. zero-dimensional) matrix is one, see for example What is the determinant of []? on Mathematics Stack Exchange.