File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 2
2
3
3
module . exports = abstractMatrix ;
4
4
5
+ var LuDecomposition = require ( './dc/lu' ) ;
5
6
var arrayUtils = require ( 'ml-array-utils' ) ;
6
7
var util = require ( './util' ) ;
7
8
var MatrixTransposeView = require ( './views/transpose' ) ;
@@ -1511,7 +1512,6 @@ function abstractMatrix(superCtor) {
1511
1512
*
1512
1513
* @return {number }
1513
1514
*/
1514
-
1515
1515
det ( ) {
1516
1516
if ( this . isSquare ( ) ) {
1517
1517
if ( this . columns === 2 ) {
@@ -1539,9 +1539,8 @@ function abstractMatrix(superCtor) {
1539
1539
return a * subMatrix0 . det ( ) - b * subMatrix1 . det ( ) + c * subMatrix2 . det ( ) ;
1540
1540
1541
1541
} else {
1542
- // general purpose determinant
1543
-
1544
- throw Error ( 'Not implemented yet' ) ;
1542
+ // general purpose determinant using the LU decomposition
1543
+ return new LuDecomposition ( this , { skipCheck :true } ) . determinant ;
1545
1544
}
1546
1545
1547
1546
} else {
Original file line number Diff line number Diff line change 3
3
var Matrix = require ( '../matrix' ) ;
4
4
5
5
// https://github.com/lutzroeder/Mapack/blob/master/Source/LuDecomposition.cs
6
- function LuDecomposition ( matrix ) {
6
+ function LuDecomposition ( matrix , options ) {
7
7
if ( ! ( this instanceof LuDecomposition ) ) {
8
8
return new LuDecomposition ( matrix ) ;
9
9
}
10
- matrix = Matrix . checkMatrix ( matrix ) ;
10
+
11
+ options = options || { } ;
12
+
13
+ if ( ! options . skipCheck ) {
14
+ matrix = Matrix . checkMatrix ( matrix ) ;
15
+ }
11
16
12
17
var lu = matrix . clone ( ) ,
13
18
rows = lu . rows ,
You can’t perform that action at this time.
0 commit comments