Skip to main content
Code Review

Return to Answer

added 102 characters in body
Source Link
Martin R
  • 24.2k
  • 2
  • 37
  • 95
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
  • 24.2k
  • 2
  • 37
  • 95
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
  • 24.2k
  • 2
  • 37
  • 95
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.

lang-cpp

AltStyle によって変換されたページ (->オリジナル) /