Skip to content

Commit ab706b9

Browse files
committed
fix: Matrix and Lu circular dependency
1 parent f211a1f commit ab706b9

File tree

10 files changed

+15
-22
lines changed

10 files changed

+15
-22
lines changed

src/abstractMatrix.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,7 @@ function abstractMatrix(superCtor) {
15351535
return a * subMatrix0.det() - b * subMatrix1.det() + c * subMatrix2.det();
15361536
} else {
15371537
// general purpose determinant using the LU decomposition
1538-
return new LuDecomposition(this, {skipCheck: true}).determinant;
1538+
return new LuDecomposition(this).determinant;
15391539
}
15401540

15411541
} else {

src/dc/cholesky.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var Matrix = require('../matrix');
3+
var Matrix = require('../matrix').Matrix;
44

55
// https://github.com/lutzroeder/Mapack/blob/master/Source/CholeskyDecomposition.cs
66
function CholeskyDecomposition(value) {

src/dc/evd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const Matrix = require('../matrix');
3+
const Matrix = require('../matrix').Matrix;
44
const util = require('./util');
55
const hypotenuse = util.hypotenuse;
66
const getFilled2DArray = util.getFilled2DArray;

src/dc/lu.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33
var Matrix = require('../matrix');
44

55
// https://github.com/lutzroeder/Mapack/blob/master/Source/LuDecomposition.cs
6-
function LuDecomposition(matrix, options) {
6+
function LuDecomposition(matrix) {
77
if (!(this instanceof LuDecomposition)) {
88
return new LuDecomposition(matrix);
99
}
1010

11-
options = options || {};
12-
13-
if (!options.skipCheck) {
14-
matrix = Matrix.checkMatrix(matrix);
15-
}
11+
matrix = Matrix.Matrix.checkMatrix(matrix);
1612

1713
var lu = matrix.clone(),
1814
rows = lu.rows,
@@ -103,7 +99,7 @@ LuDecomposition.prototype = {
10399
var data = this.LU,
104100
rows = data.rows,
105101
columns = data.columns,
106-
X = new Matrix(rows, columns);
102+
X = new Matrix.Matrix(rows, columns);
107103
for (var i = 0; i < rows; i++) {
108104
for (var j = 0; j < columns; j++) {
109105
if (i > j) {
@@ -121,7 +117,7 @@ LuDecomposition.prototype = {
121117
var data = this.LU,
122118
rows = data.rows,
123119
columns = data.columns,
124-
X = new Matrix(rows, columns);
120+
X = new Matrix.Matrix(rows, columns);
125121
for (var i = 0; i < rows; i++) {
126122
for (var j = 0; j < columns; j++) {
127123
if (i <= j) {
@@ -137,7 +133,7 @@ LuDecomposition.prototype = {
137133
return this.pivotVector.slice();
138134
},
139135
solve: function (value) {
140-
value = Matrix.checkMatrix(value);
136+
value = Matrix.Matrix.checkMatrix(value);
141137

142138
var lu = this.LU,
143139
rows = lu.rows;

src/dc/qr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var Matrix = require('../matrix');
3+
var Matrix = require('../matrix').Matrix;
44
var hypotenuse = require('./util').hypotenuse;
55

66
//https://github.com/lutzroeder/Mapack/blob/master/Source/QrDecomposition.cs

src/dc/svd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var Matrix = require('../matrix');
3+
var Matrix = require('../matrix').Matrix;
44
var util = require('./util');
55
var hypotenuse = util.hypotenuse;
66
var getFilled2DArray = util.getFilled2DArray;

src/decompositions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
var Matrix = require('./matrix');
3+
var Matrix = require('./matrix').Matrix;
44

55
var SingularValueDecomposition = require('./dc/svd');
66
var EigenvalueDecomposition = require('./dc/evd');

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
'use strict';
22

3-
module.exports = require('./matrix');
3+
module.exports = require('./matrix').Matrix;
44
module.exports.Decompositions = module.exports.DC = require('./decompositions');

src/matrix.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,5 @@ class Matrix extends abstractMatrix(Array) {
137137
}
138138
}
139139

140-
module.exports = Matrix;
140+
exports.Matrix = Matrix;
141141
Matrix.abstractMatrix = abstractMatrix;

src/views/base.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22

33
var abstractMatrix = require('../abstractMatrix');
4-
var Matrix;
4+
var Matrix = require('../matrix');
55

66
class BaseView extends abstractMatrix() {
77
constructor(matrix, rows, columns) {
@@ -12,10 +12,7 @@ class BaseView extends abstractMatrix() {
1212
}
1313

1414
static get [Symbol.species]() {
15-
if (!Matrix) {
16-
Matrix = require('../matrix');
17-
}
18-
return Matrix;
15+
return Matrix.Matrix;
1916
}
2017
}
2118

0 commit comments

Comments
 (0)