Skip to content

Commit 173ad1b

Browse files
authored
Update MatrixDeterminantLaplaceExpansion.java
1 parent 6e24aaf commit 173ad1b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/main/java/com/williamfiset/algorithms/linearalgebra/MatrixDeterminantLaplaceExpansion.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* This is an implementation of finding the determinant of an nxn matrix using Laplace/cofactor
3-
* expansion. Although this method is mathematically beautiful it is computationally intensive and
3+
* expansion. Although this method is mathematically beautiful, it is computationally intensive and
44
* not practical for matrices beyond the size of 7-8.
55
*
66
* <p>Time Complexity: ~O((n+2)!)
@@ -72,8 +72,7 @@ public static void main(String[] args) {
7272
}
7373
}
7474

75-
// Given an n*n matrix this method finds the determinant
76-
// using Laplace/cofactor expansion.
75+
// Given an n*n matrix, this method finds the determinant using Laplace/cofactor expansion.
7776
// Time Complexity: ~O((n+2)!)
7877
public static double determinant(double[][] matrix) {
7978

@@ -91,7 +90,7 @@ public static double determinant(double[][] matrix) {
9190

9291
// This method uses cofactor expansion to compute the determinant
9392
// of a matrix. Unfortunately, this method is very slow and uses
94-
// A LOT of memory hence it is not too practical for large matrices.
93+
// A LOT of memory, hence it is not too practical for large matrices.
9594
private static double laplace(double[][] m) {
9695

9796
final int n = m.length;
@@ -122,8 +121,9 @@ private static double laplace(double[][] m) {
122121
}
123122

124123
// Constructs a matrix one dimension smaller than the last by
125-
// excluding always the top row and some selected column. This
126-
// method uses a lot of space we called recursively multiple times.
124+
// excluding the top row and some selected column. This
125+
// method ends up consuming a lot of space we called recursively multiple times
126+
// since it allocates meory for a new matrix.
127127
private static double[][] constructMatrix(double[][] m, int skipColumn) {
128128

129129
int n = m.length;

0 commit comments

Comments
 (0)