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/src/mathOperations.js
CHANGED
|
@@ -5,8 +5,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
AbstractMatrix.prototype.addS = function addS(value) {
|
|
8
|
-
for (
|
|
9
|
-
for (
|
|
8
|
+
for (let i = 0; i < this.rows; i++) {
|
|
9
|
+
for (let j = 0; j < this.columns; j++) {
|
|
10
10
|
this.set(i, j, this.get(i, j) + value);
|
|
11
11
|
}
|
|
12
12
|
}
|
|
@@ -19,8 +19,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
19
19
|
this.columns !== matrix.columns) {
|
|
20
20
|
throw new RangeError('Matrices dimensions must be equal');
|
|
21
21
|
}
|
|
22
|
-
for (
|
|
23
|
-
for (
|
|
22
|
+
for (let i = 0; i < this.rows; i++) {
|
|
23
|
+
for (let j = 0; j < this.columns; j++) {
|
|
24
24
|
this.set(i, j, this.get(i, j) + matrix.get(i, j));
|
|
25
25
|
}
|
|
26
26
|
}
|
|
@@ -28,7 +28,7 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
28
28
|
};
|
|
29
29
|
|
|
30
30
|
AbstractMatrix.add = function add(matrix, value) {
|
|
31
|
-
|
|
31
|
+
const newMatrix = new Matrix(matrix);
|
|
32
32
|
return newMatrix.add(value);
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -38,8 +38,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
AbstractMatrix.prototype.subS = function subS(value) {
|
|
41
|
-
for (
|
|
42
|
-
for (
|
|
41
|
+
for (let i = 0; i < this.rows; i++) {
|
|
42
|
+
for (let j = 0; j < this.columns; j++) {
|
|
43
43
|
this.set(i, j, this.get(i, j) - value);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -52,8 +52,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
52
52
|
this.columns !== matrix.columns) {
|
|
53
53
|
throw new RangeError('Matrices dimensions must be equal');
|
|
54
54
|
}
|
|
55
|
-
for (
|
|
56
|
-
for (
|
|
55
|
+
for (let i = 0; i < this.rows; i++) {
|
|
56
|
+
for (let j = 0; j < this.columns; j++) {
|
|
57
57
|
this.set(i, j, this.get(i, j) - matrix.get(i, j));
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -61,7 +61,7 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
AbstractMatrix.sub = function sub(matrix, value) {
|
|
64
|
-
|
|
64
|
+
const newMatrix = new Matrix(matrix);
|
|
65
65
|
return newMatrix.sub(value);
|
|
66
66
|
};
|
|
67
67
|
AbstractMatrix.prototype.subtract = AbstractMatrix.prototype.sub;
|
|
@@ -75,8 +75,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
AbstractMatrix.prototype.mulS = function mulS(value) {
|
|
78
|
-
for (
|
|
79
|
-
for (
|
|
78
|
+
for (let i = 0; i < this.rows; i++) {
|
|
79
|
+
for (let j = 0; j < this.columns; j++) {
|
|
80
80
|
this.set(i, j, this.get(i, j) * value);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -89,8 +89,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
89
89
|
this.columns !== matrix.columns) {
|
|
90
90
|
throw new RangeError('Matrices dimensions must be equal');
|
|
91
91
|
}
|
|
92
|
-
for (
|
|
93
|
-
for (
|
|
92
|
+
for (let i = 0; i < this.rows; i++) {
|
|
93
|
+
for (let j = 0; j < this.columns; j++) {
|
|
94
94
|
this.set(i, j, this.get(i, j) * matrix.get(i, j));
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -98,7 +98,7 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
AbstractMatrix.mul = function mul(matrix, value) {
|
|
101
|
-
|
|
101
|
+
const newMatrix = new Matrix(matrix);
|
|
102
102
|
return newMatrix.mul(value);
|
|
103
103
|
};
|
|
104
104
|
AbstractMatrix.prototype.multiply = AbstractMatrix.prototype.mul;
|
|
@@ -112,8 +112,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
AbstractMatrix.prototype.divS = function divS(value) {
|
|
115
|
-
for (
|
|
116
|
-
for (
|
|
115
|
+
for (let i = 0; i < this.rows; i++) {
|
|
116
|
+
for (let j = 0; j < this.columns; j++) {
|
|
117
117
|
this.set(i, j, this.get(i, j) / value);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
@@ -126,8 +126,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
126
126
|
this.columns !== matrix.columns) {
|
|
127
127
|
throw new RangeError('Matrices dimensions must be equal');
|
|
128
128
|
}
|
|
129
|
-
for (
|
|
130
|
-
for (
|
|
129
|
+
for (let i = 0; i < this.rows; i++) {
|
|
130
|
+
for (let j = 0; j < this.columns; j++) {
|
|
131
131
|
this.set(i, j, this.get(i, j) / matrix.get(i, j));
|
|
132
132
|
}
|
|
133
133
|
}
|
|
@@ -135,7 +135,7 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
135
135
|
};
|
|
136
136
|
|
|
137
137
|
AbstractMatrix.div = function div(matrix, value) {
|
|
138
|
-
|
|
138
|
+
const newMatrix = new Matrix(matrix);
|
|
139
139
|
return newMatrix.div(value);
|
|
140
140
|
};
|
|
141
141
|
AbstractMatrix.prototype.divide = AbstractMatrix.prototype.div;
|
|
@@ -149,8 +149,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
149
149
|
};
|
|
150
150
|
|
|
151
151
|
AbstractMatrix.prototype.modS = function modS(value) {
|
|
152
|
-
for (
|
|
153
|
-
for (
|
|
152
|
+
for (let i = 0; i < this.rows; i++) {
|
|
153
|
+
for (let j = 0; j < this.columns; j++) {
|
|
154
154
|
this.set(i, j, this.get(i, j) % value);
|
|
155
155
|
}
|
|
156
156
|
}
|
|
@@ -163,8 +163,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
163
163
|
this.columns !== matrix.columns) {
|
|
164
164
|
throw new RangeError('Matrices dimensions must be equal');
|
|
165
165
|
}
|
|
166
|
-
for (
|
|
167
|
-
for (
|
|
166
|
+
for (let i = 0; i < this.rows; i++) {
|
|
167
|
+
for (let j = 0; j < this.columns; j++) {
|
|
168
168
|
this.set(i, j, this.get(i, j) % matrix.get(i, j));
|
|
169
169
|
}
|
|
170
170
|
}
|
|
@@ -172,7 +172,7 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
172
172
|
};
|
|
173
173
|
|
|
174
174
|
AbstractMatrix.mod = function mod(matrix, value) {
|
|
175
|
-
|
|
175
|
+
const newMatrix = new Matrix(matrix);
|
|
176
176
|
return newMatrix.mod(value);
|
|
177
177
|
};
|
|
178
178
|
AbstractMatrix.prototype.modulus = AbstractMatrix.prototype.mod;
|
|
@@ -186,8 +186,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
186
186
|
};
|
|
187
187
|
|
|
188
188
|
AbstractMatrix.prototype.andS = function andS(value) {
|
|
189
|
-
for (
|
|
190
|
-
for (
|
|
189
|
+
for (let i = 0; i < this.rows; i++) {
|
|
190
|
+
for (let j = 0; j < this.columns; j++) {
|
|
191
191
|
this.set(i, j, this.get(i, j) & value);
|
|
192
192
|
}
|
|
193
193
|
}
|
|
@@ -200,8 +200,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
200
200
|
this.columns !== matrix.columns) {
|
|
201
201
|
throw new RangeError('Matrices dimensions must be equal');
|
|
202
202
|
}
|
|
203
|
-
for (
|
|
204
|
-
for (
|
|
203
|
+
for (let i = 0; i < this.rows; i++) {
|
|
204
|
+
for (let j = 0; j < this.columns; j++) {
|
|
205
205
|
this.set(i, j, this.get(i, j) & matrix.get(i, j));
|
|
206
206
|
}
|
|
207
207
|
}
|
|
@@ -209,7 +209,7 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
209
209
|
};
|
|
210
210
|
|
|
211
211
|
AbstractMatrix.and = function and(matrix, value) {
|
|
212
|
-
|
|
212
|
+
const newMatrix = new Matrix(matrix);
|
|
213
213
|
return newMatrix.and(value);
|
|
214
214
|
};
|
|
215
215
|
|
|
@@ -219,8 +219,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
219
219
|
};
|
|
220
220
|
|
|
221
221
|
AbstractMatrix.prototype.orS = function orS(value) {
|
|
222
|
-
for (
|
|
223
|
-
for (
|
|
222
|
+
for (let i = 0; i < this.rows; i++) {
|
|
223
|
+
for (let j = 0; j < this.columns; j++) {
|
|
224
224
|
this.set(i, j, this.get(i, j) | value);
|
|
225
225
|
}
|
|
226
226
|
}
|
|
@@ -233,8 +233,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
233
233
|
this.columns !== matrix.columns) {
|
|
234
234
|
throw new RangeError('Matrices dimensions must be equal');
|
|
235
235
|
}
|
|
236
|
-
for (
|
|
237
|
-
for (
|
|
236
|
+
for (let i = 0; i < this.rows; i++) {
|
|
237
|
+
for (let j = 0; j < this.columns; j++) {
|
|
238
238
|
this.set(i, j, this.get(i, j) | matrix.get(i, j));
|
|
239
239
|
}
|
|
240
240
|
}
|
|
@@ -242,7 +242,7 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
242
242
|
};
|
|
243
243
|
|
|
244
244
|
AbstractMatrix.or = function or(matrix, value) {
|
|
245
|
-
|
|
245
|
+
const newMatrix = new Matrix(matrix);
|
|
246
246
|
return newMatrix.or(value);
|
|
247
247
|
};
|
|
248
248
|
|
|
@@ -252,8 +252,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
252
252
|
};
|
|
253
253
|
|
|
254
254
|
AbstractMatrix.prototype.xorS = function xorS(value) {
|
|
255
|
-
for (
|
|
256
|
-
for (
|
|
255
|
+
for (let i = 0; i < this.rows; i++) {
|
|
256
|
+
for (let j = 0; j < this.columns; j++) {
|
|
257
257
|
this.set(i, j, this.get(i, j) ^ value);
|
|
258
258
|
}
|
|
259
259
|
}
|
|
@@ -266,8 +266,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
266
266
|
this.columns !== matrix.columns) {
|
|
267
267
|
throw new RangeError('Matrices dimensions must be equal');
|
|
268
268
|
}
|
|
269
|
-
for (
|
|
270
|
-
for (
|
|
269
|
+
for (let i = 0; i < this.rows; i++) {
|
|
270
|
+
for (let j = 0; j < this.columns; j++) {
|
|
271
271
|
this.set(i, j, this.get(i, j) ^ matrix.get(i, j));
|
|
272
272
|
}
|
|
273
273
|
}
|
|
@@ -275,7 +275,7 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
275
275
|
};
|
|
276
276
|
|
|
277
277
|
AbstractMatrix.xor = function xor(matrix, value) {
|
|
278
|
-
|
|
278
|
+
const newMatrix = new Matrix(matrix);
|
|
279
279
|
return newMatrix.xor(value);
|
|
280
280
|
};
|
|
281
281
|
|
|
@@ -285,8 +285,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
285
285
|
};
|
|
286
286
|
|
|
287
287
|
AbstractMatrix.prototype.leftShiftS = function leftShiftS(value) {
|
|
288
|
-
for (
|
|
289
|
-
for (
|
|
288
|
+
for (let i = 0; i < this.rows; i++) {
|
|
289
|
+
for (let j = 0; j < this.columns; j++) {
|
|
290
290
|
this.set(i, j, this.get(i, j) << value);
|
|
291
291
|
}
|
|
292
292
|
}
|
|
@@ -299,8 +299,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
299
299
|
this.columns !== matrix.columns) {
|
|
300
300
|
throw new RangeError('Matrices dimensions must be equal');
|
|
301
301
|
}
|
|
302
|
-
for (
|
|
303
|
-
for (
|
|
302
|
+
for (let i = 0; i < this.rows; i++) {
|
|
303
|
+
for (let j = 0; j < this.columns; j++) {
|
|
304
304
|
this.set(i, j, this.get(i, j) << matrix.get(i, j));
|
|
305
305
|
}
|
|
306
306
|
}
|
|
@@ -308,7 +308,7 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
308
308
|
};
|
|
309
309
|
|
|
310
310
|
AbstractMatrix.leftShift = function leftShift(matrix, value) {
|
|
311
|
-
|
|
311
|
+
const newMatrix = new Matrix(matrix);
|
|
312
312
|
return newMatrix.leftShift(value);
|
|
313
313
|
};
|
|
314
314
|
|
|
@@ -318,8 +318,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
318
318
|
};
|
|
319
319
|
|
|
320
320
|
AbstractMatrix.prototype.signPropagatingRightShiftS = function signPropagatingRightShiftS(value) {
|
|
321
|
-
for (
|
|
322
|
-
for (
|
|
321
|
+
for (let i = 0; i < this.rows; i++) {
|
|
322
|
+
for (let j = 0; j < this.columns; j++) {
|
|
323
323
|
this.set(i, j, this.get(i, j) >> value);
|
|
324
324
|
}
|
|
325
325
|
}
|
|
@@ -332,8 +332,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
332
332
|
this.columns !== matrix.columns) {
|
|
333
333
|
throw new RangeError('Matrices dimensions must be equal');
|
|
334
334
|
}
|
|
335
|
-
for (
|
|
336
|
-
for (
|
|
335
|
+
for (let i = 0; i < this.rows; i++) {
|
|
336
|
+
for (let j = 0; j < this.columns; j++) {
|
|
337
337
|
this.set(i, j, this.get(i, j) >> matrix.get(i, j));
|
|
338
338
|
}
|
|
339
339
|
}
|
|
@@ -341,7 +341,7 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
341
341
|
};
|
|
342
342
|
|
|
343
343
|
AbstractMatrix.signPropagatingRightShift = function signPropagatingRightShift(matrix, value) {
|
|
344
|
-
|
|
344
|
+
const newMatrix = new Matrix(matrix);
|
|
345
345
|
return newMatrix.signPropagatingRightShift(value);
|
|
346
346
|
};
|
|
347
347
|
|
|
@@ -351,8 +351,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
351
351
|
};
|
|
352
352
|
|
|
353
353
|
AbstractMatrix.prototype.rightShiftS = function rightShiftS(value) {
|
|
354
|
-
for (
|
|
355
|
-
for (
|
|
354
|
+
for (let i = 0; i < this.rows; i++) {
|
|
355
|
+
for (let j = 0; j < this.columns; j++) {
|
|
356
356
|
this.set(i, j, this.get(i, j) >>> value);
|
|
357
357
|
}
|
|
358
358
|
}
|
|
@@ -365,8 +365,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
365
365
|
this.columns !== matrix.columns) {
|
|
366
366
|
throw new RangeError('Matrices dimensions must be equal');
|
|
367
367
|
}
|
|
368
|
-
for (
|
|
369
|
-
for (
|
|
368
|
+
for (let i = 0; i < this.rows; i++) {
|
|
369
|
+
for (let j = 0; j < this.columns; j++) {
|
|
370
370
|
this.set(i, j, this.get(i, j) >>> matrix.get(i, j));
|
|
371
371
|
}
|
|
372
372
|
}
|
|
@@ -374,7 +374,7 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
374
374
|
};
|
|
375
375
|
|
|
376
376
|
AbstractMatrix.rightShift = function rightShift(matrix, value) {
|
|
377
|
-
|
|
377
|
+
const newMatrix = new Matrix(matrix);
|
|
378
378
|
return newMatrix.rightShift(value);
|
|
379
379
|
};
|
|
380
380
|
AbstractMatrix.prototype.zeroFillRightShift = AbstractMatrix.prototype.rightShift;
|
|
@@ -383,8 +383,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
383
383
|
AbstractMatrix.zeroFillRightShift = AbstractMatrix.rightShift;
|
|
384
384
|
|
|
385
385
|
AbstractMatrix.prototype.not = function not() {
|
|
386
|
-
for (
|
|
387
|
-
for (
|
|
386
|
+
for (let i = 0; i < this.rows; i++) {
|
|
387
|
+
for (let j = 0; j < this.columns; j++) {
|
|
388
388
|
this.set(i, j, ~(this.get(i, j)));
|
|
389
389
|
}
|
|
390
390
|
}
|
|
@@ -392,13 +392,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
392
392
|
};
|
|
393
393
|
|
|
394
394
|
AbstractMatrix.not = function not(matrix) {
|
|
395
|
-
|
|
395
|
+
const newMatrix = new Matrix(matrix);
|
|
396
396
|
return newMatrix.not();
|
|
397
397
|
};
|
|
398
398
|
|
|
399
399
|
AbstractMatrix.prototype.abs = function abs() {
|
|
400
|
-
for (
|
|
401
|
-
for (
|
|
400
|
+
for (let i = 0; i < this.rows; i++) {
|
|
401
|
+
for (let j = 0; j < this.columns; j++) {
|
|
402
402
|
this.set(i, j, Math.abs(this.get(i, j)));
|
|
403
403
|
}
|
|
404
404
|
}
|
|
@@ -406,13 +406,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
406
406
|
};
|
|
407
407
|
|
|
408
408
|
AbstractMatrix.abs = function abs(matrix) {
|
|
409
|
-
|
|
409
|
+
const newMatrix = new Matrix(matrix);
|
|
410
410
|
return newMatrix.abs();
|
|
411
411
|
};
|
|
412
412
|
|
|
413
413
|
AbstractMatrix.prototype.acos = function acos() {
|
|
414
|
-
for (
|
|
415
|
-
for (
|
|
414
|
+
for (let i = 0; i < this.rows; i++) {
|
|
415
|
+
for (let j = 0; j < this.columns; j++) {
|
|
416
416
|
this.set(i, j, Math.acos(this.get(i, j)));
|
|
417
417
|
}
|
|
418
418
|
}
|
|
@@ -420,13 +420,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
420
420
|
};
|
|
421
421
|
|
|
422
422
|
AbstractMatrix.acos = function acos(matrix) {
|
|
423
|
-
|
|
423
|
+
const newMatrix = new Matrix(matrix);
|
|
424
424
|
return newMatrix.acos();
|
|
425
425
|
};
|
|
426
426
|
|
|
427
427
|
AbstractMatrix.prototype.acosh = function acosh() {
|
|
428
|
-
for (
|
|
429
|
-
for (
|
|
428
|
+
for (let i = 0; i < this.rows; i++) {
|
|
429
|
+
for (let j = 0; j < this.columns; j++) {
|
|
430
430
|
this.set(i, j, Math.acosh(this.get(i, j)));
|
|
431
431
|
}
|
|
432
432
|
}
|
|
@@ -434,13 +434,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
434
434
|
};
|
|
435
435
|
|
|
436
436
|
AbstractMatrix.acosh = function acosh(matrix) {
|
|
437
|
-
|
|
437
|
+
const newMatrix = new Matrix(matrix);
|
|
438
438
|
return newMatrix.acosh();
|
|
439
439
|
};
|
|
440
440
|
|
|
441
441
|
AbstractMatrix.prototype.asin = function asin() {
|
|
442
|
-
for (
|
|
443
|
-
for (
|
|
442
|
+
for (let i = 0; i < this.rows; i++) {
|
|
443
|
+
for (let j = 0; j < this.columns; j++) {
|
|
444
444
|
this.set(i, j, Math.asin(this.get(i, j)));
|
|
445
445
|
}
|
|
446
446
|
}
|
|
@@ -448,13 +448,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
448
448
|
};
|
|
449
449
|
|
|
450
450
|
AbstractMatrix.asin = function asin(matrix) {
|
|
451
|
-
|
|
451
|
+
const newMatrix = new Matrix(matrix);
|
|
452
452
|
return newMatrix.asin();
|
|
453
453
|
};
|
|
454
454
|
|
|
455
455
|
AbstractMatrix.prototype.asinh = function asinh() {
|
|
456
|
-
for (
|
|
457
|
-
for (
|
|
456
|
+
for (let i = 0; i < this.rows; i++) {
|
|
457
|
+
for (let j = 0; j < this.columns; j++) {
|
|
458
458
|
this.set(i, j, Math.asinh(this.get(i, j)));
|
|
459
459
|
}
|
|
460
460
|
}
|
|
@@ -462,13 +462,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
462
462
|
};
|
|
463
463
|
|
|
464
464
|
AbstractMatrix.asinh = function asinh(matrix) {
|
|
465
|
-
|
|
465
|
+
const newMatrix = new Matrix(matrix);
|
|
466
466
|
return newMatrix.asinh();
|
|
467
467
|
};
|
|
468
468
|
|
|
469
469
|
AbstractMatrix.prototype.atan = function atan() {
|
|
470
|
-
for (
|
|
471
|
-
for (
|
|
470
|
+
for (let i = 0; i < this.rows; i++) {
|
|
471
|
+
for (let j = 0; j < this.columns; j++) {
|
|
472
472
|
this.set(i, j, Math.atan(this.get(i, j)));
|
|
473
473
|
}
|
|
474
474
|
}
|
|
@@ -476,13 +476,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
476
476
|
};
|
|
477
477
|
|
|
478
478
|
AbstractMatrix.atan = function atan(matrix) {
|
|
479
|
-
|
|
479
|
+
const newMatrix = new Matrix(matrix);
|
|
480
480
|
return newMatrix.atan();
|
|
481
481
|
};
|
|
482
482
|
|
|
483
483
|
AbstractMatrix.prototype.atanh = function atanh() {
|
|
484
|
-
for (
|
|
485
|
-
for (
|
|
484
|
+
for (let i = 0; i < this.rows; i++) {
|
|
485
|
+
for (let j = 0; j < this.columns; j++) {
|
|
486
486
|
this.set(i, j, Math.atanh(this.get(i, j)));
|
|
487
487
|
}
|
|
488
488
|
}
|
|
@@ -490,13 +490,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
490
490
|
};
|
|
491
491
|
|
|
492
492
|
AbstractMatrix.atanh = function atanh(matrix) {
|
|
493
|
-
|
|
493
|
+
const newMatrix = new Matrix(matrix);
|
|
494
494
|
return newMatrix.atanh();
|
|
495
495
|
};
|
|
496
496
|
|
|
497
497
|
AbstractMatrix.prototype.cbrt = function cbrt() {
|
|
498
|
-
for (
|
|
499
|
-
for (
|
|
498
|
+
for (let i = 0; i < this.rows; i++) {
|
|
499
|
+
for (let j = 0; j < this.columns; j++) {
|
|
500
500
|
this.set(i, j, Math.cbrt(this.get(i, j)));
|
|
501
501
|
}
|
|
502
502
|
}
|
|
@@ -504,13 +504,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
504
504
|
};
|
|
505
505
|
|
|
506
506
|
AbstractMatrix.cbrt = function cbrt(matrix) {
|
|
507
|
-
|
|
507
|
+
const newMatrix = new Matrix(matrix);
|
|
508
508
|
return newMatrix.cbrt();
|
|
509
509
|
};
|
|
510
510
|
|
|
511
511
|
AbstractMatrix.prototype.ceil = function ceil() {
|
|
512
|
-
for (
|
|
513
|
-
for (
|
|
512
|
+
for (let i = 0; i < this.rows; i++) {
|
|
513
|
+
for (let j = 0; j < this.columns; j++) {
|
|
514
514
|
this.set(i, j, Math.ceil(this.get(i, j)));
|
|
515
515
|
}
|
|
516
516
|
}
|
|
@@ -518,13 +518,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
518
518
|
};
|
|
519
519
|
|
|
520
520
|
AbstractMatrix.ceil = function ceil(matrix) {
|
|
521
|
-
|
|
521
|
+
const newMatrix = new Matrix(matrix);
|
|
522
522
|
return newMatrix.ceil();
|
|
523
523
|
};
|
|
524
524
|
|
|
525
525
|
AbstractMatrix.prototype.clz32 = function clz32() {
|
|
526
|
-
for (
|
|
527
|
-
for (
|
|
526
|
+
for (let i = 0; i < this.rows; i++) {
|
|
527
|
+
for (let j = 0; j < this.columns; j++) {
|
|
528
528
|
this.set(i, j, Math.clz32(this.get(i, j)));
|
|
529
529
|
}
|
|
530
530
|
}
|
|
@@ -532,13 +532,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
532
532
|
};
|
|
533
533
|
|
|
534
534
|
AbstractMatrix.clz32 = function clz32(matrix) {
|
|
535
|
-
|
|
535
|
+
const newMatrix = new Matrix(matrix);
|
|
536
536
|
return newMatrix.clz32();
|
|
537
537
|
};
|
|
538
538
|
|
|
539
539
|
AbstractMatrix.prototype.cos = function cos() {
|
|
540
|
-
for (
|
|
541
|
-
for (
|
|
540
|
+
for (let i = 0; i < this.rows; i++) {
|
|
541
|
+
for (let j = 0; j < this.columns; j++) {
|
|
542
542
|
this.set(i, j, Math.cos(this.get(i, j)));
|
|
543
543
|
}
|
|
544
544
|
}
|
|
@@ -546,13 +546,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
546
546
|
};
|
|
547
547
|
|
|
548
548
|
AbstractMatrix.cos = function cos(matrix) {
|
|
549
|
-
|
|
549
|
+
const newMatrix = new Matrix(matrix);
|
|
550
550
|
return newMatrix.cos();
|
|
551
551
|
};
|
|
552
552
|
|
|
553
553
|
AbstractMatrix.prototype.cosh = function cosh() {
|
|
554
|
-
for (
|
|
555
|
-
for (
|
|
554
|
+
for (let i = 0; i < this.rows; i++) {
|
|
555
|
+
for (let j = 0; j < this.columns; j++) {
|
|
556
556
|
this.set(i, j, Math.cosh(this.get(i, j)));
|
|
557
557
|
}
|
|
558
558
|
}
|
|
@@ -560,13 +560,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
560
560
|
};
|
|
561
561
|
|
|
562
562
|
AbstractMatrix.cosh = function cosh(matrix) {
|
|
563
|
-
|
|
563
|
+
const newMatrix = new Matrix(matrix);
|
|
564
564
|
return newMatrix.cosh();
|
|
565
565
|
};
|
|
566
566
|
|
|
567
567
|
AbstractMatrix.prototype.exp = function exp() {
|
|
568
|
-
for (
|
|
569
|
-
for (
|
|
568
|
+
for (let i = 0; i < this.rows; i++) {
|
|
569
|
+
for (let j = 0; j < this.columns; j++) {
|
|
570
570
|
this.set(i, j, Math.exp(this.get(i, j)));
|
|
571
571
|
}
|
|
572
572
|
}
|
|
@@ -574,13 +574,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
574
574
|
};
|
|
575
575
|
|
|
576
576
|
AbstractMatrix.exp = function exp(matrix) {
|
|
577
|
-
|
|
577
|
+
const newMatrix = new Matrix(matrix);
|
|
578
578
|
return newMatrix.exp();
|
|
579
579
|
};
|
|
580
580
|
|
|
581
581
|
AbstractMatrix.prototype.expm1 = function expm1() {
|
|
582
|
-
for (
|
|
583
|
-
for (
|
|
582
|
+
for (let i = 0; i < this.rows; i++) {
|
|
583
|
+
for (let j = 0; j < this.columns; j++) {
|
|
584
584
|
this.set(i, j, Math.expm1(this.get(i, j)));
|
|
585
585
|
}
|
|
586
586
|
}
|
|
@@ -588,13 +588,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
588
588
|
};
|
|
589
589
|
|
|
590
590
|
AbstractMatrix.expm1 = function expm1(matrix) {
|
|
591
|
-
|
|
591
|
+
const newMatrix = new Matrix(matrix);
|
|
592
592
|
return newMatrix.expm1();
|
|
593
593
|
};
|
|
594
594
|
|
|
595
595
|
AbstractMatrix.prototype.floor = function floor() {
|
|
596
|
-
for (
|
|
597
|
-
for (
|
|
596
|
+
for (let i = 0; i < this.rows; i++) {
|
|
597
|
+
for (let j = 0; j < this.columns; j++) {
|
|
598
598
|
this.set(i, j, Math.floor(this.get(i, j)));
|
|
599
599
|
}
|
|
600
600
|
}
|
|
@@ -602,13 +602,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
602
602
|
};
|
|
603
603
|
|
|
604
604
|
AbstractMatrix.floor = function floor(matrix) {
|
|
605
|
-
|
|
605
|
+
const newMatrix = new Matrix(matrix);
|
|
606
606
|
return newMatrix.floor();
|
|
607
607
|
};
|
|
608
608
|
|
|
609
609
|
AbstractMatrix.prototype.fround = function fround() {
|
|
610
|
-
for (
|
|
611
|
-
for (
|
|
610
|
+
for (let i = 0; i < this.rows; i++) {
|
|
611
|
+
for (let j = 0; j < this.columns; j++) {
|
|
612
612
|
this.set(i, j, Math.fround(this.get(i, j)));
|
|
613
613
|
}
|
|
614
614
|
}
|
|
@@ -616,13 +616,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
616
616
|
};
|
|
617
617
|
|
|
618
618
|
AbstractMatrix.fround = function fround(matrix) {
|
|
619
|
-
|
|
619
|
+
const newMatrix = new Matrix(matrix);
|
|
620
620
|
return newMatrix.fround();
|
|
621
621
|
};
|
|
622
622
|
|
|
623
623
|
AbstractMatrix.prototype.log = function log() {
|
|
624
|
-
for (
|
|
625
|
-
for (
|
|
624
|
+
for (let i = 0; i < this.rows; i++) {
|
|
625
|
+
for (let j = 0; j < this.columns; j++) {
|
|
626
626
|
this.set(i, j, Math.log(this.get(i, j)));
|
|
627
627
|
}
|
|
628
628
|
}
|
|
@@ -630,13 +630,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
630
630
|
};
|
|
631
631
|
|
|
632
632
|
AbstractMatrix.log = function log(matrix) {
|
|
633
|
-
|
|
633
|
+
const newMatrix = new Matrix(matrix);
|
|
634
634
|
return newMatrix.log();
|
|
635
635
|
};
|
|
636
636
|
|
|
637
637
|
AbstractMatrix.prototype.log1p = function log1p() {
|
|
638
|
-
for (
|
|
639
|
-
for (
|
|
638
|
+
for (let i = 0; i < this.rows; i++) {
|
|
639
|
+
for (let j = 0; j < this.columns; j++) {
|
|
640
640
|
this.set(i, j, Math.log1p(this.get(i, j)));
|
|
641
641
|
}
|
|
642
642
|
}
|
|
@@ -644,13 +644,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
644
644
|
};
|
|
645
645
|
|
|
646
646
|
AbstractMatrix.log1p = function log1p(matrix) {
|
|
647
|
-
|
|
647
|
+
const newMatrix = new Matrix(matrix);
|
|
648
648
|
return newMatrix.log1p();
|
|
649
649
|
};
|
|
650
650
|
|
|
651
651
|
AbstractMatrix.prototype.log10 = function log10() {
|
|
652
|
-
for (
|
|
653
|
-
for (
|
|
652
|
+
for (let i = 0; i < this.rows; i++) {
|
|
653
|
+
for (let j = 0; j < this.columns; j++) {
|
|
654
654
|
this.set(i, j, Math.log10(this.get(i, j)));
|
|
655
655
|
}
|
|
656
656
|
}
|
|
@@ -658,13 +658,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
658
658
|
};
|
|
659
659
|
|
|
660
660
|
AbstractMatrix.log10 = function log10(matrix) {
|
|
661
|
-
|
|
661
|
+
const newMatrix = new Matrix(matrix);
|
|
662
662
|
return newMatrix.log10();
|
|
663
663
|
};
|
|
664
664
|
|
|
665
665
|
AbstractMatrix.prototype.log2 = function log2() {
|
|
666
|
-
for (
|
|
667
|
-
for (
|
|
666
|
+
for (let i = 0; i < this.rows; i++) {
|
|
667
|
+
for (let j = 0; j < this.columns; j++) {
|
|
668
668
|
this.set(i, j, Math.log2(this.get(i, j)));
|
|
669
669
|
}
|
|
670
670
|
}
|
|
@@ -672,13 +672,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
672
672
|
};
|
|
673
673
|
|
|
674
674
|
AbstractMatrix.log2 = function log2(matrix) {
|
|
675
|
-
|
|
675
|
+
const newMatrix = new Matrix(matrix);
|
|
676
676
|
return newMatrix.log2();
|
|
677
677
|
};
|
|
678
678
|
|
|
679
679
|
AbstractMatrix.prototype.round = function round() {
|
|
680
|
-
for (
|
|
681
|
-
for (
|
|
680
|
+
for (let i = 0; i < this.rows; i++) {
|
|
681
|
+
for (let j = 0; j < this.columns; j++) {
|
|
682
682
|
this.set(i, j, Math.round(this.get(i, j)));
|
|
683
683
|
}
|
|
684
684
|
}
|
|
@@ -686,13 +686,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
686
686
|
};
|
|
687
687
|
|
|
688
688
|
AbstractMatrix.round = function round(matrix) {
|
|
689
|
-
|
|
689
|
+
const newMatrix = new Matrix(matrix);
|
|
690
690
|
return newMatrix.round();
|
|
691
691
|
};
|
|
692
692
|
|
|
693
693
|
AbstractMatrix.prototype.sign = function sign() {
|
|
694
|
-
for (
|
|
695
|
-
for (
|
|
694
|
+
for (let i = 0; i < this.rows; i++) {
|
|
695
|
+
for (let j = 0; j < this.columns; j++) {
|
|
696
696
|
this.set(i, j, Math.sign(this.get(i, j)));
|
|
697
697
|
}
|
|
698
698
|
}
|
|
@@ -700,13 +700,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
700
700
|
};
|
|
701
701
|
|
|
702
702
|
AbstractMatrix.sign = function sign(matrix) {
|
|
703
|
-
|
|
703
|
+
const newMatrix = new Matrix(matrix);
|
|
704
704
|
return newMatrix.sign();
|
|
705
705
|
};
|
|
706
706
|
|
|
707
707
|
AbstractMatrix.prototype.sin = function sin() {
|
|
708
|
-
for (
|
|
709
|
-
for (
|
|
708
|
+
for (let i = 0; i < this.rows; i++) {
|
|
709
|
+
for (let j = 0; j < this.columns; j++) {
|
|
710
710
|
this.set(i, j, Math.sin(this.get(i, j)));
|
|
711
711
|
}
|
|
712
712
|
}
|
|
@@ -714,13 +714,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
714
714
|
};
|
|
715
715
|
|
|
716
716
|
AbstractMatrix.sin = function sin(matrix) {
|
|
717
|
-
|
|
717
|
+
const newMatrix = new Matrix(matrix);
|
|
718
718
|
return newMatrix.sin();
|
|
719
719
|
};
|
|
720
720
|
|
|
721
721
|
AbstractMatrix.prototype.sinh = function sinh() {
|
|
722
|
-
for (
|
|
723
|
-
for (
|
|
722
|
+
for (let i = 0; i < this.rows; i++) {
|
|
723
|
+
for (let j = 0; j < this.columns; j++) {
|
|
724
724
|
this.set(i, j, Math.sinh(this.get(i, j)));
|
|
725
725
|
}
|
|
726
726
|
}
|
|
@@ -728,13 +728,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
728
728
|
};
|
|
729
729
|
|
|
730
730
|
AbstractMatrix.sinh = function sinh(matrix) {
|
|
731
|
-
|
|
731
|
+
const newMatrix = new Matrix(matrix);
|
|
732
732
|
return newMatrix.sinh();
|
|
733
733
|
};
|
|
734
734
|
|
|
735
735
|
AbstractMatrix.prototype.sqrt = function sqrt() {
|
|
736
|
-
for (
|
|
737
|
-
for (
|
|
736
|
+
for (let i = 0; i < this.rows; i++) {
|
|
737
|
+
for (let j = 0; j < this.columns; j++) {
|
|
738
738
|
this.set(i, j, Math.sqrt(this.get(i, j)));
|
|
739
739
|
}
|
|
740
740
|
}
|
|
@@ -742,13 +742,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
742
742
|
};
|
|
743
743
|
|
|
744
744
|
AbstractMatrix.sqrt = function sqrt(matrix) {
|
|
745
|
-
|
|
745
|
+
const newMatrix = new Matrix(matrix);
|
|
746
746
|
return newMatrix.sqrt();
|
|
747
747
|
};
|
|
748
748
|
|
|
749
749
|
AbstractMatrix.prototype.tan = function tan() {
|
|
750
|
-
for (
|
|
751
|
-
for (
|
|
750
|
+
for (let i = 0; i < this.rows; i++) {
|
|
751
|
+
for (let j = 0; j < this.columns; j++) {
|
|
752
752
|
this.set(i, j, Math.tan(this.get(i, j)));
|
|
753
753
|
}
|
|
754
754
|
}
|
|
@@ -756,13 +756,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
756
756
|
};
|
|
757
757
|
|
|
758
758
|
AbstractMatrix.tan = function tan(matrix) {
|
|
759
|
-
|
|
759
|
+
const newMatrix = new Matrix(matrix);
|
|
760
760
|
return newMatrix.tan();
|
|
761
761
|
};
|
|
762
762
|
|
|
763
763
|
AbstractMatrix.prototype.tanh = function tanh() {
|
|
764
|
-
for (
|
|
765
|
-
for (
|
|
764
|
+
for (let i = 0; i < this.rows; i++) {
|
|
765
|
+
for (let j = 0; j < this.columns; j++) {
|
|
766
766
|
this.set(i, j, Math.tanh(this.get(i, j)));
|
|
767
767
|
}
|
|
768
768
|
}
|
|
@@ -770,13 +770,13 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
770
770
|
};
|
|
771
771
|
|
|
772
772
|
AbstractMatrix.tanh = function tanh(matrix) {
|
|
773
|
-
|
|
773
|
+
const newMatrix = new Matrix(matrix);
|
|
774
774
|
return newMatrix.tanh();
|
|
775
775
|
};
|
|
776
776
|
|
|
777
777
|
AbstractMatrix.prototype.trunc = function trunc() {
|
|
778
|
-
for (
|
|
779
|
-
for (
|
|
778
|
+
for (let i = 0; i < this.rows; i++) {
|
|
779
|
+
for (let j = 0; j < this.columns; j++) {
|
|
780
780
|
this.set(i, j, Math.trunc(this.get(i, j)));
|
|
781
781
|
}
|
|
782
782
|
}
|
|
@@ -784,12 +784,12 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
784
784
|
};
|
|
785
785
|
|
|
786
786
|
AbstractMatrix.trunc = function trunc(matrix) {
|
|
787
|
-
|
|
787
|
+
const newMatrix = new Matrix(matrix);
|
|
788
788
|
return newMatrix.trunc();
|
|
789
789
|
};
|
|
790
790
|
|
|
791
791
|
AbstractMatrix.pow = function pow(matrix, arg0) {
|
|
792
|
-
|
|
792
|
+
const newMatrix = new Matrix(matrix);
|
|
793
793
|
return newMatrix.pow(arg0);
|
|
794
794
|
};
|
|
795
795
|
|
|
@@ -799,8 +799,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
799
799
|
};
|
|
800
800
|
|
|
801
801
|
AbstractMatrix.prototype.powS = function powS(value) {
|
|
802
|
-
for (
|
|
803
|
-
for (
|
|
802
|
+
for (let i = 0; i < this.rows; i++) {
|
|
803
|
+
for (let j = 0; j < this.columns; j++) {
|
|
804
804
|
this.set(i, j, Math.pow(this.get(i, j), value));
|
|
805
805
|
}
|
|
806
806
|
}
|
|
@@ -813,8 +813,8 @@ export function installMathOperations(AbstractMatrix, Matrix) {
|
|
|
813
813
|
this.columns !== matrix.columns) {
|
|
814
814
|
throw new RangeError('Matrices dimensions must be equal');
|
|
815
815
|
}
|
|
816
|
-
for (
|
|
817
|
-
for (
|
|
816
|
+
for (let i = 0; i < this.rows; i++) {
|
|
817
|
+
for (let j = 0; j < this.columns; j++) {
|
|
818
818
|
this.set(i, j, Math.pow(this.get(i, j), matrix.get(i, j)));
|
|
819
819
|
}
|
|
820
820
|
}
|