ml-matrix 6.1.2 → 6.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/History.md +36 -0
- package/README.md +6 -6
- package/matrix.d.ts +106 -70
- package/matrix.js +822 -668
- package/matrix.umd.js +1 -0
- package/package.json +21 -12
- package/src/correlation.js +17 -7
- package/src/covariance.js +10 -6
- package/src/dc/cholesky.js +20 -16
- package/src/dc/evd.js +45 -45
- package/src/dc/lu.js +32 -32
- package/src/dc/nipals.js +135 -0
- package/src/dc/qr.js +24 -24
- package/src/dc/svd.js +48 -48
- package/src/dc/util.js +1 -1
- package/src/determinant.js +2 -2
- package/src/index.js +4 -3
- package/src/inspect.js +2 -2
- package/src/linearDependencies.js +14 -14
- package/src/mathOperations.js +147 -147
- package/src/matrix.js +234 -233
- package/src/pseudoInverse.js +5 -5
- package/src/stat.js +33 -33
- package/src/util.js +8 -8
- package/src/views/selection.js +28 -28
- package/src/views/sub.js +28 -28
- package/src/wrap/WrapperMatrix1D.js +2 -2
package/History.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
|
+
## [6.4.1](https://github.com/mljs/matrix/compare/v6.4.0...v6.4.1) (2019-09-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* correctly ready elements in QR#orthogonalMatrix ([2f527a3](https://github.com/mljs/matrix/commit/2f527a3))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# [6.4.0](https://github.com/mljs/matrix/compare/v6.3.0...v6.4.0) (2019-08-16)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* add CholeskyDecomposition.isPositiveDefinite method ([#94](https://github.com/mljs/matrix/issues/94)) ([6bb33a9](https://github.com/mljs/matrix/commit/6bb33a9))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# [6.3.0](https://github.com/mljs/matrix/compare/v6.2.0...v6.3.0) (2019-08-16)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* add UMD build ([#92](https://github.com/mljs/matrix/issues/92)) ([3b82b07](https://github.com/mljs/matrix/commit/3b82b07))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [6.2.0](https://github.com/mljs/matrix/compare/v6.1.2...v6.2.0) (2019-07-20)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* add NIPALS loop for factorization ([#91](https://github.com/mljs/matrix/issues/91)) ([043c8b6](https://github.com/mljs/matrix/commit/043c8b6))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
1
37
|
## [6.1.2](https://github.com/mljs/matrix/compare/v6.1.1...v6.1.2) (2019-06-29)
|
|
2
38
|
|
|
3
39
|
|
package/README.md
CHANGED
|
@@ -110,7 +110,7 @@ const {
|
|
|
110
110
|
linearDependencies,
|
|
111
111
|
QrDecomposition,
|
|
112
112
|
LuDecomposition,
|
|
113
|
-
CholeskyDecomposition
|
|
113
|
+
CholeskyDecomposition,
|
|
114
114
|
} = require('ml-matrix');
|
|
115
115
|
|
|
116
116
|
//===========================
|
|
@@ -157,7 +157,7 @@ var error = Matrix.sub(b, A.mmul(x)); // The error enables to evaluate the solut
|
|
|
157
157
|
// QR Decomposition
|
|
158
158
|
|
|
159
159
|
var A = new Matrix([[2, 3, 5], [4, 1, 6], [1, 3, 0]]);
|
|
160
|
-
var QR = QrDecomposition(A);
|
|
160
|
+
var QR = new QrDecomposition(A);
|
|
161
161
|
var Q = QR.orthogonalMatrix;
|
|
162
162
|
var R = QR.upperTriangularMatrix;
|
|
163
163
|
// So you have the QR decomposition. If you multiply Q by R, you'll see that A = Q.R, with Q orthogonal and R upper triangular
|
|
@@ -165,7 +165,7 @@ var R = QR.upperTriangularMatrix;
|
|
|
165
165
|
// LU Decomposition
|
|
166
166
|
|
|
167
167
|
var A = new Matrix([[2, 3, 5], [4, 1, 6], [1, 3, 0]]);
|
|
168
|
-
var LU = LuDecomposition(A);
|
|
168
|
+
var LU = new LuDecomposition(A);
|
|
169
169
|
var L = LU.lowerTriangularMatrix;
|
|
170
170
|
var U = LU.upperTriangularMatrix;
|
|
171
171
|
var P = LU.pivotPermutationVector;
|
|
@@ -174,13 +174,13 @@ var P = LU.pivotPermutationVector;
|
|
|
174
174
|
// Cholesky Decomposition
|
|
175
175
|
|
|
176
176
|
var A = new Matrix([[2, 3, 5], [4, 1, 6], [1, 3, 0]]);
|
|
177
|
-
var cholesky = CholeskyDecomposition(A);
|
|
177
|
+
var cholesky = new CholeskyDecomposition(A);
|
|
178
178
|
var L = cholesky.lowerTriangularMatrix;
|
|
179
179
|
|
|
180
180
|
// Eigenvalues & eigenvectors
|
|
181
181
|
|
|
182
182
|
var A = new Matrix([[2, 3, 5], [4, 1, 6], [1, 3, 0]]);
|
|
183
|
-
var e = EigenvalueDecomposition(A);
|
|
183
|
+
var e = new EigenvalueDecomposition(A);
|
|
184
184
|
var real = e.realEigenvalues;
|
|
185
185
|
var imaginary = e.imaginaryEigenvalues;
|
|
186
186
|
var vectors = e.eigenvectorMatrix;
|
|
@@ -195,7 +195,7 @@ var A = new Matrix([
|
|
|
195
195
|
[0, 1, 6, 0],
|
|
196
196
|
[0, 3, 0, 1],
|
|
197
197
|
[0, 0, 1, 0],
|
|
198
|
-
[0, 1, 2, 0]
|
|
198
|
+
[0, 1, 2, 0],
|
|
199
199
|
]);
|
|
200
200
|
var dependencies = linearDependencies(A); // dependencies is a matrix with the dependencies of the rows. When we look row by row, we see that the first row is [0, 0, 0, 0, 0], so it means that the first row is independent, and the second row is [ 0, 0, 0, 4, 1 ], i.e the second row = 4 times the 4th row + the 5th row.
|
|
201
201
|
```
|
package/matrix.d.ts
CHANGED
|
@@ -5,49 +5,51 @@ type MatrixDimension = 'row' | 'column';
|
|
|
5
5
|
export interface IRandomOptions {
|
|
6
6
|
/**
|
|
7
7
|
* Random number generator.
|
|
8
|
-
*
|
|
8
|
+
* @default `Math.random`
|
|
9
9
|
*/
|
|
10
10
|
random: () => number;
|
|
11
11
|
}
|
|
12
12
|
export interface IRandomIntOptions {
|
|
13
13
|
/**
|
|
14
14
|
* Minimum value.
|
|
15
|
-
*
|
|
15
|
+
* @default `0`
|
|
16
16
|
*/
|
|
17
17
|
min: number;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Maximum value.
|
|
21
|
-
*
|
|
21
|
+
* @default `1000`
|
|
22
22
|
*/
|
|
23
23
|
max: number;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* Random number generator.
|
|
27
|
-
*
|
|
27
|
+
* @default `Math.random`
|
|
28
28
|
*/
|
|
29
29
|
random: () => number;
|
|
30
30
|
}
|
|
31
31
|
export interface IRepeatOptions {
|
|
32
32
|
/**
|
|
33
33
|
* Number of times the rows should be repeated.
|
|
34
|
-
*
|
|
34
|
+
* @default `1`
|
|
35
35
|
*/
|
|
36
36
|
rows?: number;
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Number of times the columns should be repeated.
|
|
40
|
-
*
|
|
40
|
+
* @default `1`
|
|
41
41
|
*/
|
|
42
42
|
columns?: number;
|
|
43
43
|
}
|
|
44
44
|
export interface IScaleOptions {
|
|
45
45
|
/**
|
|
46
|
-
* Minimum scaled value.
|
|
46
|
+
* Minimum scaled value.
|
|
47
|
+
* @default `0`
|
|
47
48
|
*/
|
|
48
49
|
min?: number;
|
|
49
50
|
/**
|
|
50
|
-
* Maximum scaled value.
|
|
51
|
+
* Maximum scaled value.
|
|
52
|
+
* @default `1`
|
|
51
53
|
*/
|
|
52
54
|
max?: number;
|
|
53
55
|
}
|
|
@@ -76,18 +78,18 @@ export interface IScaleByOptions {
|
|
|
76
78
|
|
|
77
79
|
export interface ICovarianceOptions {
|
|
78
80
|
/**
|
|
79
|
-
*
|
|
81
|
+
* @default `true`
|
|
80
82
|
*/
|
|
81
83
|
center?: boolean;
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
export interface ICorrelationOptions {
|
|
85
87
|
/**
|
|
86
|
-
*
|
|
88
|
+
* @default `true`
|
|
87
89
|
*/
|
|
88
90
|
center?: boolean;
|
|
89
91
|
/**
|
|
90
|
-
*
|
|
92
|
+
* @default `true`
|
|
91
93
|
*/
|
|
92
94
|
scale?: boolean;
|
|
93
95
|
}
|
|
@@ -108,17 +110,17 @@ export abstract class AbstractMatrix {
|
|
|
108
110
|
*/
|
|
109
111
|
readonly columns: number;
|
|
110
112
|
|
|
111
|
-
/**
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
/**
|
|
114
|
+
* Constructs a matrix with the chosen dimensions from a 1D array.
|
|
115
|
+
* @param newRows - Number of rows.
|
|
116
|
+
* @param newColumns - Number of columns.
|
|
117
|
+
* @param newData - A 1D array containing data for the matrix.
|
|
118
|
+
* @returns The new matrix.
|
|
119
|
+
*/
|
|
118
120
|
static from1DArray(
|
|
119
121
|
newRows: number,
|
|
120
122
|
newColumns: number,
|
|
121
|
-
newData: number[]
|
|
123
|
+
newData: number[],
|
|
122
124
|
): Matrix;
|
|
123
125
|
|
|
124
126
|
/**
|
|
@@ -159,15 +161,11 @@ export abstract class AbstractMatrix {
|
|
|
159
161
|
* @param options - Options object.
|
|
160
162
|
* @returns The new matrix.
|
|
161
163
|
*/
|
|
162
|
-
static rand(
|
|
163
|
-
rows: number,
|
|
164
|
-
columns: number,
|
|
165
|
-
options?: IRandomOptions
|
|
166
|
-
): Matrix;
|
|
164
|
+
static rand(rows: number, columns: number, options?: IRandomOptions): Matrix;
|
|
167
165
|
static random(
|
|
168
166
|
rows: number,
|
|
169
167
|
columns: number,
|
|
170
|
-
options?: IRandomOptions
|
|
168
|
+
options?: IRandomOptions,
|
|
171
169
|
): Matrix;
|
|
172
170
|
|
|
173
171
|
/**
|
|
@@ -179,14 +177,14 @@ export abstract class AbstractMatrix {
|
|
|
179
177
|
static randInt(
|
|
180
178
|
rows: number,
|
|
181
179
|
columns: number,
|
|
182
|
-
options?: IRandomIntOptions
|
|
180
|
+
options?: IRandomIntOptions,
|
|
183
181
|
): Matrix;
|
|
184
182
|
|
|
185
183
|
/**
|
|
186
184
|
* Creates an identity matrix with the given dimension. Values of the diagonal will be 1 and others will be 0.
|
|
187
185
|
* @param rows - Number of rows.
|
|
188
|
-
* @param columns - Number of columns. Default: rows
|
|
189
|
-
* @param value - Value to fill the diagonal with. Default: 1
|
|
186
|
+
* @param columns - Number of columns. Default: `rows`.
|
|
187
|
+
* @param value - Value to fill the diagonal with. Default: `1`.
|
|
190
188
|
* @returns - The new identity matrix.
|
|
191
189
|
*/
|
|
192
190
|
static eye(rows: number, columns?: number, value?: number): Matrix;
|
|
@@ -217,8 +215,8 @@ export abstract class AbstractMatrix {
|
|
|
217
215
|
|
|
218
216
|
/**
|
|
219
217
|
* Returns a matrix whose elements are the maximum between `matrix1` and `matrix2`.
|
|
220
|
-
* @param matrix1
|
|
221
|
-
* @param matrix2
|
|
218
|
+
* @param matrix1
|
|
219
|
+
* @param matrix2
|
|
222
220
|
*/
|
|
223
221
|
static max(matrix1: MaybeMatrix, matrix2: MaybeMatrix): Matrix;
|
|
224
222
|
|
|
@@ -318,7 +316,7 @@ export abstract class AbstractMatrix {
|
|
|
318
316
|
/**
|
|
319
317
|
* Creates a new matrix that is a repetition of the current matrix. New matrix has rows times the number of
|
|
320
318
|
* rows of the original matrix, and columns times the number of columns of the original matrix.
|
|
321
|
-
*
|
|
319
|
+
*
|
|
322
320
|
* @example
|
|
323
321
|
* var matrix = new Matrix([[1, 2]]);
|
|
324
322
|
* matrix.repeat({ rows: 2 }); // [[1, 2], [1, 2]]
|
|
@@ -569,7 +567,7 @@ export abstract class AbstractMatrix {
|
|
|
569
567
|
scaleRows(options?: IScaleOptions): Matrix;
|
|
570
568
|
|
|
571
569
|
/**
|
|
572
|
-
* Returns a new column-by-column scaled matrix.
|
|
570
|
+
* Returns a new column-by-column scaled matrix.
|
|
573
571
|
* @param options
|
|
574
572
|
* @example
|
|
575
573
|
* var matrix = new Matrix([[1, 2], [-1, 0]]);
|
|
@@ -621,31 +619,31 @@ export abstract class AbstractMatrix {
|
|
|
621
619
|
startRow: number,
|
|
622
620
|
endRow: number,
|
|
623
621
|
startColumn: number,
|
|
624
|
-
endColumn: number
|
|
622
|
+
endColumn: number,
|
|
625
623
|
): Matrix;
|
|
626
624
|
|
|
627
625
|
/**
|
|
628
626
|
* Returns a subset of the matrix based on an array of row indices.
|
|
629
627
|
* @param indices - Array containing the row indices.
|
|
630
|
-
* @param startColumn - First column index. Default: 0
|
|
631
|
-
* @param endColumn - Last column index. Default: columns - 1
|
|
628
|
+
* @param startColumn - First column index. Default: `0`.
|
|
629
|
+
* @param endColumn - Last column index. Default: `this.columns - 1`.
|
|
632
630
|
*/
|
|
633
631
|
subMatrixRow(
|
|
634
632
|
indices: number[],
|
|
635
633
|
startColumn?: number,
|
|
636
|
-
endColumn?: number
|
|
634
|
+
endColumn?: number,
|
|
637
635
|
): Matrix;
|
|
638
636
|
|
|
639
637
|
/**
|
|
640
638
|
* Returns a subset of the matrix based on an array of column indices.
|
|
641
639
|
* @param indices - Array containing the column indices.
|
|
642
|
-
* @param startRow - First row index. Default: 0
|
|
643
|
-
* @param endRow - Last row index. Default: rows - 1
|
|
640
|
+
* @param startRow - First row index. Default: `0`.
|
|
641
|
+
* @param endRow - Last row index. Default: `this.rows - 1`.
|
|
644
642
|
*/
|
|
645
643
|
subMatrixColumn(
|
|
646
644
|
indices: number[],
|
|
647
645
|
startRow?: number,
|
|
648
|
-
endRow?: number
|
|
646
|
+
endRow?: number,
|
|
649
647
|
): Matrix;
|
|
650
648
|
|
|
651
649
|
/**
|
|
@@ -657,7 +655,7 @@ export abstract class AbstractMatrix {
|
|
|
657
655
|
setSubMatrix(
|
|
658
656
|
matrix: MaybeMatrix | number[],
|
|
659
657
|
startRow: number,
|
|
660
|
-
startColumn: number
|
|
658
|
+
startColumn: number,
|
|
661
659
|
): this;
|
|
662
660
|
|
|
663
661
|
/**
|
|
@@ -737,7 +735,7 @@ export abstract class AbstractMatrix {
|
|
|
737
735
|
*/
|
|
738
736
|
standardDeviation(
|
|
739
737
|
by: MatrixDimension,
|
|
740
|
-
options?: IVarianceByOptions
|
|
738
|
+
options?: IVarianceByOptions,
|
|
741
739
|
): number[];
|
|
742
740
|
|
|
743
741
|
/**
|
|
@@ -806,13 +804,10 @@ export abstract class AbstractMatrix {
|
|
|
806
804
|
static leftShift(matrix: MaybeMatrix, value: ScalarOrMatrix): Matrix;
|
|
807
805
|
static signPropagatingRightShift(
|
|
808
806
|
matrix: MaybeMatrix,
|
|
809
|
-
value: ScalarOrMatrix
|
|
807
|
+
value: ScalarOrMatrix,
|
|
810
808
|
): Matrix;
|
|
811
809
|
static rightShift(matrix: MaybeMatrix, value: ScalarOrMatrix): Matrix;
|
|
812
|
-
static zeroFillRightShift(
|
|
813
|
-
matrix: MaybeMatrix,
|
|
814
|
-
value: ScalarOrMatrix
|
|
815
|
-
): Matrix;
|
|
810
|
+
static zeroFillRightShift(matrix: MaybeMatrix, value: ScalarOrMatrix): Matrix;
|
|
816
811
|
|
|
817
812
|
// Functional operators (one arg)
|
|
818
813
|
// inplace
|
|
@@ -919,7 +914,7 @@ export class MatrixSelectionView extends AbstractMatrix {
|
|
|
919
914
|
constructor(
|
|
920
915
|
matrix: AbstractMatrix,
|
|
921
916
|
rowIndices: number[],
|
|
922
|
-
columnIndices: number[]
|
|
917
|
+
columnIndices: number[],
|
|
923
918
|
);
|
|
924
919
|
}
|
|
925
920
|
|
|
@@ -929,7 +924,7 @@ export class MatrixSubView extends AbstractMatrix {
|
|
|
929
924
|
startRow: number,
|
|
930
925
|
endRow: number,
|
|
931
926
|
startColumn: number,
|
|
932
|
-
endColumn: number
|
|
927
|
+
endColumn: number,
|
|
933
928
|
);
|
|
934
929
|
}
|
|
935
930
|
|
|
@@ -939,14 +934,14 @@ export class MatrixTransposeView extends AbstractMatrix {
|
|
|
939
934
|
|
|
940
935
|
export interface IWrap1DOptions {
|
|
941
936
|
/**
|
|
942
|
-
*
|
|
937
|
+
* @default: `1`
|
|
943
938
|
*/
|
|
944
939
|
rows?: number;
|
|
945
940
|
}
|
|
946
941
|
|
|
947
942
|
export function wrap(
|
|
948
943
|
array: number[],
|
|
949
|
-
options?: IWrap1DOptions
|
|
944
|
+
options?: IWrap1DOptions,
|
|
950
945
|
): WrapperMatrix1D;
|
|
951
946
|
|
|
952
947
|
export function wrap(twoDAray: number[][]): WrapperMatrix2D;
|
|
@@ -960,18 +955,20 @@ export class WrapperMatrix2D extends AbstractMatrix {
|
|
|
960
955
|
}
|
|
961
956
|
|
|
962
957
|
/**
|
|
963
|
-
* @param
|
|
958
|
+
* @param leftHandSide
|
|
959
|
+
* @param rightHandSide
|
|
960
|
+
* @param useSVD - Default: `false`.
|
|
964
961
|
*/
|
|
965
962
|
export function solve(
|
|
966
963
|
leftHandSide: MaybeMatrix,
|
|
967
964
|
rightHandSide: MaybeMatrix,
|
|
968
|
-
useSVD?: boolean
|
|
965
|
+
useSVD?: boolean,
|
|
969
966
|
): Matrix;
|
|
970
967
|
|
|
971
968
|
/**
|
|
972
969
|
* Computes the inverse of a matrix.
|
|
973
970
|
* @param matrix - Matrix to invert.
|
|
974
|
-
* @param useSVD - Use the singular value decomposition to compute the inverse. Default: false
|
|
971
|
+
* @param useSVD - Use the singular value decomposition to compute the inverse. Default: `false`.
|
|
975
972
|
*/
|
|
976
973
|
export function inverse(matrix: MaybeMatrix, useSVD?: boolean): Matrix;
|
|
977
974
|
|
|
@@ -984,13 +981,13 @@ export function determinant(matrix: MaybeMatrix): number;
|
|
|
984
981
|
export interface ILinearDependenciesOptions {
|
|
985
982
|
/**
|
|
986
983
|
* If an absolute value is inferior to this threshold, it will equals zero.
|
|
987
|
-
*
|
|
984
|
+
* @default `10e-10`
|
|
988
985
|
*/
|
|
989
986
|
thresholdValue?: number;
|
|
990
987
|
|
|
991
988
|
/**
|
|
992
989
|
* If the error is inferior to that threshold, the linear combination found is accepted and the row is dependent from other rows.
|
|
993
|
-
*
|
|
990
|
+
* @default `10e-10`
|
|
994
991
|
*/
|
|
995
992
|
thresholdError?: number;
|
|
996
993
|
}
|
|
@@ -1005,55 +1002,52 @@ export interface ILinearDependenciesOptions {
|
|
|
1005
1002
|
*/
|
|
1006
1003
|
export function linearDependencies(
|
|
1007
1004
|
matrix: MaybeMatrix,
|
|
1008
|
-
options?: ILinearDependenciesOptions
|
|
1005
|
+
options?: ILinearDependenciesOptions,
|
|
1009
1006
|
): Matrix;
|
|
1010
1007
|
|
|
1011
1008
|
/**
|
|
1012
1009
|
* Returns inverse of a matrix if it exists or the pseudoinverse.
|
|
1013
1010
|
* @param matrix
|
|
1014
|
-
* @param threshold - Threshold for taking inverse of singular values. Default: Number.EPSILON
|
|
1011
|
+
* @param threshold - Threshold for taking inverse of singular values. Default: `Number.EPSILON`.
|
|
1015
1012
|
* @returns - The (pseudo)inverted matrix.
|
|
1016
1013
|
*/
|
|
1017
|
-
export function pseudoInverse(
|
|
1018
|
-
matrix: MaybeMatrix,
|
|
1019
|
-
threshold?: number
|
|
1020
|
-
): Matrix;
|
|
1014
|
+
export function pseudoInverse(matrix: MaybeMatrix, threshold?: number): Matrix;
|
|
1021
1015
|
|
|
1022
1016
|
export function covariance(
|
|
1023
1017
|
matrix: MaybeMatrix,
|
|
1024
|
-
options?: ICovarianceOptions
|
|
1018
|
+
options?: ICovarianceOptions,
|
|
1025
1019
|
): Matrix;
|
|
1026
1020
|
|
|
1027
1021
|
export function covariance(
|
|
1028
1022
|
xMatrix: MaybeMatrix,
|
|
1029
1023
|
yMatrix: MaybeMatrix,
|
|
1030
|
-
options?: ICovarianceOptions
|
|
1024
|
+
options?: ICovarianceOptions,
|
|
1031
1025
|
): Matrix;
|
|
1032
1026
|
|
|
1033
1027
|
export function correlation(
|
|
1034
1028
|
matrix: MaybeMatrix,
|
|
1035
|
-
options?: ICorrelationOptions
|
|
1029
|
+
options?: ICorrelationOptions,
|
|
1036
1030
|
): Matrix;
|
|
1037
1031
|
|
|
1038
1032
|
export function correlation(
|
|
1039
1033
|
xMatrix: MaybeMatrix,
|
|
1040
1034
|
yMatrix: MaybeMatrix,
|
|
1041
|
-
options?: ICorrelationOptions
|
|
1035
|
+
options?: ICorrelationOptions,
|
|
1042
1036
|
): Matrix;
|
|
1043
1037
|
|
|
1044
1038
|
export interface ISVDOptions {
|
|
1045
1039
|
/**
|
|
1046
|
-
*
|
|
1040
|
+
* @default `true`
|
|
1047
1041
|
*/
|
|
1048
1042
|
computeLeftSingularVectors?: boolean;
|
|
1049
1043
|
|
|
1050
1044
|
/**
|
|
1051
|
-
*
|
|
1045
|
+
* @default `true`
|
|
1052
1046
|
*/
|
|
1053
1047
|
computeRightSingularVectors?: boolean;
|
|
1054
1048
|
|
|
1055
1049
|
/**
|
|
1056
|
-
*
|
|
1050
|
+
* @default `false`
|
|
1057
1051
|
*/
|
|
1058
1052
|
autoTranspose?: boolean;
|
|
1059
1053
|
}
|
|
@@ -1096,7 +1090,7 @@ export { SingularValueDecomposition as SVD };
|
|
|
1096
1090
|
|
|
1097
1091
|
export interface IEVDOptions {
|
|
1098
1092
|
/**
|
|
1099
|
-
*
|
|
1093
|
+
* @default `false`
|
|
1100
1094
|
*/
|
|
1101
1095
|
assumeSymmetric?: boolean;
|
|
1102
1096
|
}
|
|
@@ -1119,10 +1113,11 @@ export { EigenvalueDecomposition as EVD };
|
|
|
1119
1113
|
*/
|
|
1120
1114
|
export class CholeskyDecomposition {
|
|
1121
1115
|
/**
|
|
1122
|
-
*
|
|
1116
|
+
*
|
|
1123
1117
|
* @param value - The matrix to decompose
|
|
1124
1118
|
*/
|
|
1125
1119
|
constructor(value: MaybeMatrix);
|
|
1120
|
+
isPositiveDefinite(): boolean;
|
|
1126
1121
|
solve(value: Matrix): Matrix;
|
|
1127
1122
|
readonly lowerTriangularMatrix: Matrix;
|
|
1128
1123
|
}
|
|
@@ -1165,3 +1160,44 @@ export class QrDecomposition {
|
|
|
1165
1160
|
}
|
|
1166
1161
|
|
|
1167
1162
|
export { QrDecomposition as QR };
|
|
1163
|
+
|
|
1164
|
+
export interface INipalsOptions {
|
|
1165
|
+
/**
|
|
1166
|
+
* A column vector of length `X.rows` that contains known labels for supervised PLS.
|
|
1167
|
+
*/
|
|
1168
|
+
Y?: MaybeMatrix | number[];
|
|
1169
|
+
/**
|
|
1170
|
+
* The maximum number of allowed iterations before beraking the loop if convergence is not achieved.
|
|
1171
|
+
* @default 1000
|
|
1172
|
+
*/
|
|
1173
|
+
maxIterations?: boolean;
|
|
1174
|
+
/**
|
|
1175
|
+
* Termination criteria
|
|
1176
|
+
* @default 1e-10
|
|
1177
|
+
*/
|
|
1178
|
+
terminationCriteria?: number;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
export class Nipals {
|
|
1182
|
+
/**
|
|
1183
|
+
* Implementation of the NIPALS algorithm.
|
|
1184
|
+
* Geladi, P and Kowalski, B.R. (1986)
|
|
1185
|
+
* Partial least squares and regression:
|
|
1186
|
+
* a tutorial.
|
|
1187
|
+
* Analytica Chimica Acta 185, 1-17.
|
|
1188
|
+
* @param X - A matrix to be factored
|
|
1189
|
+
* @param options
|
|
1190
|
+
*/
|
|
1191
|
+
constructor(X: MaybeMatrix, options?: INipalsOptions);
|
|
1192
|
+
w: Matrix;
|
|
1193
|
+
s: Matrix;
|
|
1194
|
+
t: number;
|
|
1195
|
+
xResidual: Matrix;
|
|
1196
|
+
p: Matrix;
|
|
1197
|
+
q: Matrix;
|
|
1198
|
+
u: number;
|
|
1199
|
+
yResidual: Matrix;
|
|
1200
|
+
betas: number;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
export { Nipals as NIPALS };
|