mathjs 14.9.1 → 15.1.0
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 +35 -0
- package/README.md +1 -1
- package/lib/browser/math.js +1 -1
- package/lib/browser/math.js.LICENSE.txt +2 -2
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/core/config.js +5 -1
- package/lib/cjs/core/function/config.js +4 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesBernoulli.generated.js +25 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesConstantNode.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesEqual.generated.js +0 -2
- package/lib/cjs/entry/dependenciesAny/dependenciesIsBounded.generated.js +17 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesIsFinite.generated.js +21 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesIsInteger.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSimplifyConstant.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSize.generated.js +0 -2
- package/lib/cjs/entry/dependenciesAny/dependenciesUnitClass.generated.js +0 -2
- package/lib/cjs/entry/dependenciesAny/dependenciesZeta.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny.generated.js +21 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesBernoulli.generated.js +21 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesConstantNode.generated.js +2 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesIsBounded.generated.js +17 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesIsFinite.generated.js +21 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesSimplifyConstant.generated.js +2 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesSize.generated.js +0 -2
- package/lib/cjs/entry/dependenciesNumber/dependenciesZeta.generated.js +2 -0
- package/lib/cjs/entry/dependenciesNumber.generated.js +21 -0
- package/lib/cjs/entry/impureFunctionsAny.generated.js +223 -218
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +82 -77
- package/lib/cjs/entry/pureFunctionsAny.generated.js +717 -702
- package/lib/cjs/entry/pureFunctionsNumber.generated.js +155 -142
- package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +6 -0
- package/lib/cjs/expression/embeddedDocs/function/combinatorics/stirlingS2.js +2 -2
- package/lib/cjs/expression/embeddedDocs/function/probability/bernoulli.js +14 -0
- package/lib/cjs/expression/embeddedDocs/function/utils/isBounded.js +14 -0
- package/lib/cjs/expression/embeddedDocs/function/utils/isFinite.js +14 -0
- package/lib/cjs/expression/embeddedDocs/function/utils/isNaN.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/utils/isNumeric.js +1 -1
- package/lib/cjs/expression/node/AccessorNode.js +36 -7
- package/lib/cjs/expression/node/ConstantNode.js +4 -4
- package/lib/cjs/expression/node/FunctionNode.js +20 -5
- package/lib/cjs/expression/node/IndexNode.js +1 -1
- package/lib/cjs/expression/parse.js +74 -46
- package/lib/cjs/factoriesAny.js +21 -0
- package/lib/cjs/factoriesNumber.js +23 -2
- package/lib/cjs/function/algebra/simplifyConstant.js +3 -2
- package/lib/cjs/function/algebra/sylvester.js +6 -5
- package/lib/cjs/function/arithmetic/nthRoots.js +5 -1
- package/lib/cjs/function/logical/nullish.js +2 -2
- package/lib/cjs/function/matrix/column.js +2 -1
- package/lib/cjs/function/matrix/dot.js +4 -9
- package/lib/cjs/function/matrix/flatten.js +6 -3
- package/lib/cjs/function/matrix/kron.js +31 -30
- package/lib/cjs/function/matrix/row.js +2 -1
- package/lib/cjs/function/matrix/size.js +11 -17
- package/lib/cjs/function/matrix/subset.js +21 -11
- package/lib/cjs/function/probability/bernoulli.js +108 -0
- package/lib/cjs/function/relational/equal.js +2 -3
- package/lib/cjs/function/special/zeta.js +3 -2
- package/lib/cjs/function/utils/isBounded.js +54 -0
- package/lib/cjs/function/utils/isFinite.js +50 -0
- package/lib/cjs/function/utils/isInteger.js +7 -15
- package/lib/cjs/function/utils/isNaN.js +1 -1
- package/lib/cjs/function/utils/isNumeric.js +1 -1
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/json/replacer.js +1 -1
- package/lib/cjs/plain/number/probability.js +2 -2
- package/lib/cjs/plain/number/trigonometry.js +1 -1
- package/lib/cjs/type/fraction/function/fraction.js +1 -1
- package/lib/cjs/type/matrix/DenseMatrix.js +52 -41
- package/lib/cjs/type/matrix/MatrixIndex.js +19 -20
- package/lib/cjs/type/matrix/SparseMatrix.js +37 -11
- package/lib/cjs/type/unit/Unit.js +12 -8
- package/lib/cjs/utils/number.js +7 -7
- package/lib/cjs/utils/optimizeCallback.js +13 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/core/config.js +5 -1
- package/lib/esm/core/function/config.js +4 -0
- package/lib/esm/entry/dependenciesAny/dependenciesBernoulli.generated.js +18 -0
- package/lib/esm/entry/dependenciesAny/dependenciesConstantNode.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesEqual.generated.js +0 -2
- package/lib/esm/entry/dependenciesAny/dependenciesIsBounded.generated.js +10 -0
- package/lib/esm/entry/dependenciesAny/dependenciesIsFinite.generated.js +14 -0
- package/lib/esm/entry/dependenciesAny/dependenciesIsInteger.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSimplifyConstant.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSize.generated.js +0 -2
- package/lib/esm/entry/dependenciesAny/dependenciesUnitClass.generated.js +0 -2
- package/lib/esm/entry/dependenciesAny/dependenciesZeta.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny.generated.js +3 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesBernoulli.generated.js +14 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesConstantNode.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesIsBounded.generated.js +10 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesIsFinite.generated.js +14 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesSimplifyConstant.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesSize.generated.js +0 -2
- package/lib/esm/entry/dependenciesNumber/dependenciesZeta.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber.generated.js +3 -0
- package/lib/esm/entry/impureFunctionsAny.generated.js +225 -220
- package/lib/esm/entry/impureFunctionsNumber.generated.js +84 -79
- package/lib/esm/entry/pureFunctionsAny.generated.js +714 -699
- package/lib/esm/entry/pureFunctionsNumber.generated.js +154 -141
- package/lib/esm/expression/embeddedDocs/embeddedDocs.js +6 -0
- package/lib/esm/expression/embeddedDocs/function/combinatorics/stirlingS2.js +2 -2
- package/lib/esm/expression/embeddedDocs/function/probability/bernoulli.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/utils/isBounded.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/utils/isFinite.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/utils/isNaN.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/utils/isNumeric.js +1 -1
- package/lib/esm/expression/node/AccessorNode.js +36 -7
- package/lib/esm/expression/node/ConstantNode.js +4 -4
- package/lib/esm/expression/node/FunctionNode.js +20 -5
- package/lib/esm/expression/node/IndexNode.js +1 -1
- package/lib/esm/expression/parse.js +74 -46
- package/lib/esm/factoriesAny.js +3 -0
- package/lib/esm/factoriesNumber.js +3 -0
- package/lib/esm/function/algebra/simplifyConstant.js +3 -2
- package/lib/esm/function/algebra/sylvester.js +6 -5
- package/lib/esm/function/arithmetic/nthRoots.js +5 -1
- package/lib/esm/function/logical/nullish.js +2 -2
- package/lib/esm/function/matrix/column.js +2 -1
- package/lib/esm/function/matrix/dot.js +4 -9
- package/lib/esm/function/matrix/flatten.js +6 -3
- package/lib/esm/function/matrix/kron.js +31 -30
- package/lib/esm/function/matrix/row.js +2 -1
- package/lib/esm/function/matrix/size.js +11 -17
- package/lib/esm/function/matrix/subset.js +21 -11
- package/lib/esm/function/probability/bernoulli.js +102 -0
- package/lib/esm/function/relational/equal.js +2 -3
- package/lib/esm/function/special/zeta.js +3 -2
- package/lib/esm/function/utils/isBounded.js +48 -0
- package/lib/esm/function/utils/isFinite.js +44 -0
- package/lib/esm/function/utils/isInteger.js +7 -15
- package/lib/esm/function/utils/isNaN.js +1 -1
- package/lib/esm/function/utils/isNumeric.js +1 -1
- package/lib/esm/json/replacer.js +1 -1
- package/lib/esm/plain/number/probability.js +2 -2
- package/lib/esm/plain/number/trigonometry.js +1 -1
- package/lib/esm/type/fraction/function/fraction.js +1 -1
- package/lib/esm/type/matrix/DenseMatrix.js +52 -41
- package/lib/esm/type/matrix/MatrixIndex.js +20 -21
- package/lib/esm/type/matrix/SparseMatrix.js +37 -11
- package/lib/esm/type/unit/Unit.js +12 -8
- package/lib/esm/utils/number.js +7 -7
- package/lib/esm/utils/optimizeCallback.js +13 -1
- package/lib/esm/version.js +1 -1
- package/package.json +8 -8
- package/types/index.d.ts +535 -223
|
@@ -16,7 +16,7 @@ function gammaNumber(n) {
|
|
|
16
16
|
let x;
|
|
17
17
|
if ((0, _number.isInteger)(n)) {
|
|
18
18
|
if (n <= 0) {
|
|
19
|
-
return isFinite(n) ? Infinity : NaN;
|
|
19
|
+
return Number.isFinite(n) ? Infinity : NaN;
|
|
20
20
|
}
|
|
21
21
|
if (n > 171) {
|
|
22
22
|
return Infinity; // Will overflow
|
|
@@ -63,7 +63,7 @@ const lgammaSeries = exports.lgammaSeries = [1.000000000190015, 76.1800917294714
|
|
|
63
63
|
function lgammaNumber(n) {
|
|
64
64
|
if (n < 0) return NaN;
|
|
65
65
|
if (n === 0) return Infinity;
|
|
66
|
-
if (!isFinite(n)) return n;
|
|
66
|
+
if (!Number.isFinite(n)) return n;
|
|
67
67
|
if (n < 0.5) {
|
|
68
68
|
// Use Euler's reflection formula:
|
|
69
69
|
// gamma(z) = PI / (sin(PI * z) * gamma(1 - z))
|
|
@@ -44,7 +44,7 @@ function acotNumber(x) {
|
|
|
44
44
|
}
|
|
45
45
|
acotNumber.signature = n1;
|
|
46
46
|
function acothNumber(x) {
|
|
47
|
-
return isFinite(x) ? (Math.log((x + 1) / x) + Math.log(x / (x - 1))) / 2 : 0;
|
|
47
|
+
return Number.isFinite(x) ? (Math.log((x + 1) / x) + Math.log(x / (x - 1))) / 2 : 0;
|
|
48
48
|
}
|
|
49
49
|
acothNumber.signature = n1;
|
|
50
50
|
function acscNumber(x) {
|
|
@@ -52,7 +52,7 @@ const createFraction = exports.createFraction = /* #__PURE__ */(0, _factory.fact
|
|
|
52
52
|
*/
|
|
53
53
|
return typed('fraction', {
|
|
54
54
|
number: function (x) {
|
|
55
|
-
if (!isFinite(x) || isNaN(x)) {
|
|
55
|
+
if (!Number.isFinite(x) || isNaN(x)) {
|
|
56
56
|
throw new Error(x + ' cannot be represented as a fraction');
|
|
57
57
|
}
|
|
58
58
|
return new Fraction(x);
|
|
@@ -15,10 +15,11 @@ var _optimizeCallback = require("../../utils/optimizeCallback.js");
|
|
|
15
15
|
// deno-lint-ignore-file no-this-alias
|
|
16
16
|
|
|
17
17
|
const name = 'DenseMatrix';
|
|
18
|
-
const dependencies = ['Matrix'];
|
|
18
|
+
const dependencies = ['Matrix', 'config'];
|
|
19
19
|
const createDenseMatrixClass = exports.createDenseMatrixClass = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
|
20
20
|
let {
|
|
21
|
-
Matrix
|
|
21
|
+
Matrix,
|
|
22
|
+
config
|
|
22
23
|
} = _ref;
|
|
23
24
|
/**
|
|
24
25
|
* Dense Matrix implementation. A regular, dense matrix, supporting multi-dimensional matrices. This is the default matrix type.
|
|
@@ -228,7 +229,7 @@ const createDenseMatrixClass = exports.createDenseMatrixClass = /* #__PURE__ */(
|
|
|
228
229
|
if (!(0, _is.isIndex)(index)) {
|
|
229
230
|
throw new TypeError('Invalid index');
|
|
230
231
|
}
|
|
231
|
-
const isScalar = index.isScalar();
|
|
232
|
+
const isScalar = config.legacySubset ? index.size().every(idx => idx === 1) : index.isScalar();
|
|
232
233
|
if (isScalar) {
|
|
233
234
|
// return a scalar
|
|
234
235
|
return matrix.get(index.min());
|
|
@@ -248,12 +249,12 @@ const createDenseMatrixClass = exports.createDenseMatrixClass = /* #__PURE__ */(
|
|
|
248
249
|
}
|
|
249
250
|
|
|
250
251
|
// retrieve submatrix
|
|
251
|
-
const returnMatrix = new DenseMatrix(
|
|
252
|
+
const returnMatrix = new DenseMatrix();
|
|
252
253
|
const submatrix = _getSubmatrix(matrix._data, index);
|
|
253
254
|
returnMatrix._size = submatrix.size;
|
|
254
255
|
returnMatrix._datatype = matrix._datatype;
|
|
255
256
|
returnMatrix._data = submatrix.data;
|
|
256
|
-
return returnMatrix;
|
|
257
|
+
return config.legacySubset ? returnMatrix.reshape(index.size()) : returnMatrix;
|
|
257
258
|
}
|
|
258
259
|
}
|
|
259
260
|
|
|
@@ -271,22 +272,30 @@ const createDenseMatrixClass = exports.createDenseMatrixClass = /* #__PURE__ */(
|
|
|
271
272
|
const size = Array(maxDepth);
|
|
272
273
|
return {
|
|
273
274
|
data: getSubmatrixRecursive(data),
|
|
274
|
-
size
|
|
275
|
+
size: size.filter(x => x !== null)
|
|
275
276
|
};
|
|
276
277
|
function getSubmatrixRecursive(data) {
|
|
277
278
|
let depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
278
|
-
const
|
|
279
|
-
|
|
279
|
+
const dims = index.dimension(depth);
|
|
280
|
+
function _mapIndex(dim, callback) {
|
|
281
|
+
// applies a callback for when the index is a Number or a Matrix
|
|
282
|
+
if ((0, _is.isNumber)(dim)) return callback(dim);else return dim.map(callback).valueOf();
|
|
283
|
+
}
|
|
284
|
+
if ((0, _is.isNumber)(dims)) {
|
|
285
|
+
size[depth] = null;
|
|
286
|
+
} else {
|
|
287
|
+
size[depth] = dims.size()[0];
|
|
288
|
+
}
|
|
280
289
|
if (depth < maxDepth) {
|
|
281
|
-
return
|
|
282
|
-
(0, _array.validateIndex)(
|
|
283
|
-
return getSubmatrixRecursive(data[
|
|
284
|
-
})
|
|
290
|
+
return _mapIndex(dims, dimIndex => {
|
|
291
|
+
(0, _array.validateIndex)(dimIndex, data.length);
|
|
292
|
+
return getSubmatrixRecursive(data[dimIndex], depth + 1);
|
|
293
|
+
});
|
|
285
294
|
} else {
|
|
286
|
-
return
|
|
287
|
-
(0, _array.validateIndex)(
|
|
288
|
-
return data[
|
|
289
|
-
})
|
|
295
|
+
return _mapIndex(dims, dimIndex => {
|
|
296
|
+
(0, _array.validateIndex)(dimIndex, data.length);
|
|
297
|
+
return data[dimIndex];
|
|
298
|
+
});
|
|
290
299
|
}
|
|
291
300
|
}
|
|
292
301
|
}
|
|
@@ -313,18 +322,18 @@ const createDenseMatrixClass = exports.createDenseMatrixClass = /* #__PURE__ */(
|
|
|
313
322
|
const isScalar = index.isScalar();
|
|
314
323
|
|
|
315
324
|
// calculate the size of the submatrix, and convert it into an Array if needed
|
|
316
|
-
let
|
|
325
|
+
let submatrixSize;
|
|
317
326
|
if ((0, _is.isMatrix)(submatrix)) {
|
|
318
|
-
|
|
327
|
+
submatrixSize = submatrix.size();
|
|
319
328
|
submatrix = submatrix.valueOf();
|
|
320
329
|
} else {
|
|
321
|
-
|
|
330
|
+
submatrixSize = (0, _array.arraySize)(submatrix);
|
|
322
331
|
}
|
|
323
332
|
if (isScalar) {
|
|
324
333
|
// set a scalar
|
|
325
334
|
|
|
326
335
|
// check whether submatrix is a scalar
|
|
327
|
-
if (
|
|
336
|
+
if (submatrixSize.length !== 0) {
|
|
328
337
|
throw new TypeError('Scalar expected');
|
|
329
338
|
}
|
|
330
339
|
matrix.set(index.min(), submatrix, defaultValue);
|
|
@@ -332,26 +341,26 @@ const createDenseMatrixClass = exports.createDenseMatrixClass = /* #__PURE__ */(
|
|
|
332
341
|
// set a submatrix
|
|
333
342
|
|
|
334
343
|
// broadcast submatrix
|
|
335
|
-
if (!(0, _object.deepStrictEqual)(
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
344
|
+
if (!(0, _object.deepStrictEqual)(submatrixSize, iSize)) {
|
|
345
|
+
if (submatrixSize.length === 0) {
|
|
346
|
+
submatrix = (0, _array.broadcastTo)([submatrix], iSize);
|
|
347
|
+
} else {
|
|
348
|
+
try {
|
|
340
349
|
submatrix = (0, _array.broadcastTo)(submatrix, iSize);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
|
|
350
|
+
} catch (error) {}
|
|
351
|
+
}
|
|
352
|
+
submatrixSize = (0, _array.arraySize)(submatrix);
|
|
344
353
|
}
|
|
345
354
|
|
|
346
355
|
// validate dimensions
|
|
347
356
|
if (iSize.length < matrix._size.length) {
|
|
348
357
|
throw new _DimensionError.DimensionError(iSize.length, matrix._size.length, '<');
|
|
349
358
|
}
|
|
350
|
-
if (
|
|
359
|
+
if (submatrixSize.length < iSize.length) {
|
|
351
360
|
// calculate number of missing outer dimensions
|
|
352
361
|
let i = 0;
|
|
353
362
|
let outer = 0;
|
|
354
|
-
while (iSize[i] === 1 &&
|
|
363
|
+
while (iSize[i] === 1 && submatrixSize[i] === 1) {
|
|
355
364
|
i++;
|
|
356
365
|
}
|
|
357
366
|
while (iSize[i] === 1) {
|
|
@@ -360,12 +369,12 @@ const createDenseMatrixClass = exports.createDenseMatrixClass = /* #__PURE__ */(
|
|
|
360
369
|
}
|
|
361
370
|
|
|
362
371
|
// unsqueeze both outer and inner dimensions
|
|
363
|
-
submatrix = (0, _array.unsqueeze)(submatrix, iSize.length, outer,
|
|
372
|
+
submatrix = (0, _array.unsqueeze)(submatrix, iSize.length, outer, submatrixSize);
|
|
364
373
|
}
|
|
365
374
|
|
|
366
375
|
// check whether the size of the submatrix matches the index size
|
|
367
|
-
if (!(0, _object.deepStrictEqual)(iSize,
|
|
368
|
-
throw new _DimensionError.DimensionError(iSize,
|
|
376
|
+
if (!(0, _object.deepStrictEqual)(iSize, submatrixSize)) {
|
|
377
|
+
throw new _DimensionError.DimensionError(iSize, submatrixSize, '>');
|
|
369
378
|
}
|
|
370
379
|
|
|
371
380
|
// enlarge matrix when needed
|
|
@@ -394,16 +403,18 @@ const createDenseMatrixClass = exports.createDenseMatrixClass = /* #__PURE__ */(
|
|
|
394
403
|
function setSubmatrixRecursive(data, submatrix) {
|
|
395
404
|
let depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
396
405
|
const range = index.dimension(depth);
|
|
406
|
+
const recursiveCallback = (rangeIndex, i) => {
|
|
407
|
+
(0, _array.validateIndex)(rangeIndex, data.length);
|
|
408
|
+
setSubmatrixRecursive(data[rangeIndex], submatrix[i[0]], depth + 1);
|
|
409
|
+
};
|
|
410
|
+
const finalCallback = (rangeIndex, i) => {
|
|
411
|
+
(0, _array.validateIndex)(rangeIndex, data.length);
|
|
412
|
+
data[rangeIndex] = submatrix[i[0]];
|
|
413
|
+
};
|
|
397
414
|
if (depth < maxDepth) {
|
|
398
|
-
|
|
399
|
-
(0, _array.validateIndex)(rangeIndex, data.length);
|
|
400
|
-
setSubmatrixRecursive(data[rangeIndex], submatrix[i[0]], depth + 1);
|
|
401
|
-
});
|
|
415
|
+
if ((0, _is.isNumber)(range)) recursiveCallback(range, [0]);else range.forEach(recursiveCallback);
|
|
402
416
|
} else {
|
|
403
|
-
|
|
404
|
-
(0, _array.validateIndex)(rangeIndex, data.length);
|
|
405
|
-
data[rangeIndex] = submatrix[i[0]];
|
|
406
|
-
});
|
|
417
|
+
if ((0, _is.isNumber)(range)) finalCallback(range, [0]);else range.forEach(finalCallback);
|
|
407
418
|
}
|
|
408
419
|
}
|
|
409
420
|
}
|
|
@@ -37,7 +37,7 @@ const createIndexClass = exports.createIndexClass = /* #__PURE__ */(0, _factory.
|
|
|
37
37
|
* @Constructor Index
|
|
38
38
|
* @param {...*} ranges
|
|
39
39
|
*/
|
|
40
|
-
function Index(
|
|
40
|
+
function Index() {
|
|
41
41
|
if (!(this instanceof Index)) {
|
|
42
42
|
throw new SyntaxError('Constructor must be called with the new operator');
|
|
43
43
|
}
|
|
@@ -45,7 +45,7 @@ const createIndexClass = exports.createIndexClass = /* #__PURE__ */(0, _factory.
|
|
|
45
45
|
this._sourceSize = [];
|
|
46
46
|
this._isScalar = true;
|
|
47
47
|
for (let i = 0, ii = arguments.length; i < ii; i++) {
|
|
48
|
-
const arg = arguments[i];
|
|
48
|
+
const arg = i < 0 || arguments.length <= i ? undefined : arguments[i];
|
|
49
49
|
const argIsArray = (0, _is.isArray)(arg);
|
|
50
50
|
const argIsMatrix = (0, _is.isMatrix)(arg);
|
|
51
51
|
const argType = typeof arg;
|
|
@@ -56,6 +56,7 @@ const createIndexClass = exports.createIndexClass = /* #__PURE__ */(0, _factory.
|
|
|
56
56
|
} else if (argIsArray || argIsMatrix) {
|
|
57
57
|
// create matrix
|
|
58
58
|
let m;
|
|
59
|
+
this._isScalar = false;
|
|
59
60
|
if (getMatrixDataType(arg) === 'boolean') {
|
|
60
61
|
if (argIsArray) m = _createImmutableMatrix(_booleansArrayToNumbersForIndex(arg).valueOf());
|
|
61
62
|
if (argIsMatrix) m = _createImmutableMatrix(_booleansArrayToNumbersForIndex(arg._data).valueOf());
|
|
@@ -64,16 +65,10 @@ const createIndexClass = exports.createIndexClass = /* #__PURE__ */(0, _factory.
|
|
|
64
65
|
m = _createImmutableMatrix(arg.valueOf());
|
|
65
66
|
}
|
|
66
67
|
this._dimensions.push(m);
|
|
67
|
-
// size
|
|
68
|
-
const size = m.size();
|
|
69
|
-
// scalar
|
|
70
|
-
if (size.length !== 1 || size[0] !== 1 || sourceSize !== null) {
|
|
71
|
-
this._isScalar = false;
|
|
72
|
-
}
|
|
73
68
|
} else if (argType === 'number') {
|
|
74
|
-
this._dimensions.push(
|
|
69
|
+
this._dimensions.push(arg);
|
|
75
70
|
} else if (argType === 'bigint') {
|
|
76
|
-
this._dimensions.push(
|
|
71
|
+
this._dimensions.push(Number(arg));
|
|
77
72
|
} else if (argType === 'string') {
|
|
78
73
|
// object property (arguments.count should be 1)
|
|
79
74
|
this._dimensions.push(arg);
|
|
@@ -93,12 +88,15 @@ const createIndexClass = exports.createIndexClass = /* #__PURE__ */(0, _factory.
|
|
|
93
88
|
function _createImmutableMatrix(arg) {
|
|
94
89
|
// loop array elements
|
|
95
90
|
for (let i = 0, l = arg.length; i < l; i++) {
|
|
96
|
-
if (
|
|
91
|
+
if (!(0, _is.isNumber)(arg[i]) || !(0, _number.isInteger)(arg[i])) {
|
|
97
92
|
throw new TypeError('Index parameters must be positive integer numbers');
|
|
98
93
|
}
|
|
99
94
|
}
|
|
100
95
|
// create matrix
|
|
101
|
-
|
|
96
|
+
const matrix = new ImmutableDenseMatrix();
|
|
97
|
+
matrix._data = arg;
|
|
98
|
+
matrix._size = [arg.length];
|
|
99
|
+
return matrix;
|
|
102
100
|
}
|
|
103
101
|
|
|
104
102
|
/**
|
|
@@ -136,7 +134,7 @@ const createIndexClass = exports.createIndexClass = /* #__PURE__ */(0, _factory.
|
|
|
136
134
|
const size = [];
|
|
137
135
|
for (let i = 0, ii = this._dimensions.length; i < ii; i++) {
|
|
138
136
|
const d = this._dimensions[i];
|
|
139
|
-
size[i] =
|
|
137
|
+
size[i] = (0, _is.isString)(d) || (0, _is.isNumber)(d) ? 1 : d.size()[0];
|
|
140
138
|
}
|
|
141
139
|
return size;
|
|
142
140
|
};
|
|
@@ -150,7 +148,7 @@ const createIndexClass = exports.createIndexClass = /* #__PURE__ */(0, _factory.
|
|
|
150
148
|
const values = [];
|
|
151
149
|
for (let i = 0, ii = this._dimensions.length; i < ii; i++) {
|
|
152
150
|
const range = this._dimensions[i];
|
|
153
|
-
values[i] =
|
|
151
|
+
values[i] = (0, _is.isString)(range) || (0, _is.isNumber)(range) ? range : range.max();
|
|
154
152
|
}
|
|
155
153
|
return values;
|
|
156
154
|
};
|
|
@@ -164,7 +162,7 @@ const createIndexClass = exports.createIndexClass = /* #__PURE__ */(0, _factory.
|
|
|
164
162
|
const values = [];
|
|
165
163
|
for (let i = 0, ii = this._dimensions.length; i < ii; i++) {
|
|
166
164
|
const range = this._dimensions[i];
|
|
167
|
-
values[i] =
|
|
165
|
+
values[i] = (0, _is.isString)(range) || (0, _is.isNumber)(range) ? range : range.min();
|
|
168
166
|
}
|
|
169
167
|
return values;
|
|
170
168
|
};
|
|
@@ -189,10 +187,11 @@ const createIndexClass = exports.createIndexClass = /* #__PURE__ */(0, _factory.
|
|
|
189
187
|
* @returns {Range | null} range
|
|
190
188
|
*/
|
|
191
189
|
Index.prototype.dimension = function (dim) {
|
|
192
|
-
|
|
190
|
+
var _this$_dimensions$dim;
|
|
191
|
+
if (!(0, _is.isNumber)(dim)) {
|
|
193
192
|
return null;
|
|
194
193
|
}
|
|
195
|
-
return this._dimensions[dim]
|
|
194
|
+
return (_this$_dimensions$dim = this._dimensions[dim]) !== null && _this$_dimensions$dim !== void 0 ? _this$_dimensions$dim : null;
|
|
196
195
|
};
|
|
197
196
|
|
|
198
197
|
/**
|
|
@@ -200,7 +199,7 @@ const createIndexClass = exports.createIndexClass = /* #__PURE__ */(0, _factory.
|
|
|
200
199
|
* @returns {boolean} Returns true if the index is an object property
|
|
201
200
|
*/
|
|
202
201
|
Index.prototype.isObjectProperty = function () {
|
|
203
|
-
return this._dimensions.length === 1 &&
|
|
202
|
+
return this._dimensions.length === 1 && (0, _is.isString)(this._dimensions[0]);
|
|
204
203
|
};
|
|
205
204
|
|
|
206
205
|
/**
|
|
@@ -234,7 +233,7 @@ const createIndexClass = exports.createIndexClass = /* #__PURE__ */(0, _factory.
|
|
|
234
233
|
const array = [];
|
|
235
234
|
for (let i = 0, ii = this._dimensions.length; i < ii; i++) {
|
|
236
235
|
const dimension = this._dimensions[i];
|
|
237
|
-
array.push(
|
|
236
|
+
array.push((0, _is.isString)(dimension) || (0, _is.isNumber)(dimension) ? dimension : dimension.toArray());
|
|
238
237
|
}
|
|
239
238
|
return array;
|
|
240
239
|
};
|
|
@@ -256,7 +255,7 @@ const createIndexClass = exports.createIndexClass = /* #__PURE__ */(0, _factory.
|
|
|
256
255
|
const strings = [];
|
|
257
256
|
for (let i = 0, ii = this._dimensions.length; i < ii; i++) {
|
|
258
257
|
const dimension = this._dimensions[i];
|
|
259
|
-
if (
|
|
258
|
+
if ((0, _is.isString)(dimension)) {
|
|
260
259
|
strings.push(JSON.stringify(dimension));
|
|
261
260
|
} else {
|
|
262
261
|
strings.push(dimension.toString());
|
|
@@ -21,9 +21,27 @@ const createSparseMatrixClass = exports.createSparseMatrixClass = /* #__PURE__ *
|
|
|
21
21
|
Matrix
|
|
22
22
|
} = _ref;
|
|
23
23
|
/**
|
|
24
|
-
* Sparse Matrix implementation. This type implements
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* Sparse Matrix implementation. This type (currently) implements 2D
|
|
25
|
+
* matrices only via the format known as
|
|
26
|
+
* [Compressed Column Storage](https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_(CSC_or_CCS)).
|
|
27
|
+
*
|
|
28
|
+
* The structure/invariants of the internal data should be:
|
|
29
|
+
* 1. _values is an array of the nonzero values in order from top to bottom
|
|
30
|
+
* (of each column), left to right.
|
|
31
|
+
* 2. _index is an array of row numbers, of the same length as and
|
|
32
|
+
* corresponding positionally to _values.
|
|
33
|
+
* 3. _ptr is an array of length one more than the number of columns. For j
|
|
34
|
+
* less than the number of columns, the "half-open" span of indices
|
|
35
|
+
* _ptr[j] to _ptr[j+1] (i.e. including _ptr[j] if it is less than
|
|
36
|
+
* _ptr[j+1], but never including _ptr[j+1]) are the indices in _values
|
|
37
|
+
* of the nonzero elements in column j. Note there are no nonzero elements
|
|
38
|
+
* in column j exactly when _ptr[j] === _ptr[j+1], and that the final
|
|
39
|
+
* entry in _ptr is always exactly the number of nonzero entries in the
|
|
40
|
+
* matrix.
|
|
41
|
+
* 4. _size is a length-2 array consisting of the number of rows followed by
|
|
42
|
+
* the number of columns.
|
|
43
|
+
* 5. _datatype, if set, is the mathjs typeOf value of all entries of the
|
|
44
|
+
* SparseMatrix.
|
|
27
45
|
* @class SparseMatrix
|
|
28
46
|
*/
|
|
29
47
|
function SparseMatrix(data, datatype) {
|
|
@@ -141,7 +159,9 @@ const createSparseMatrixClass = exports.createSparseMatrixClass = /* #__PURE__ *
|
|
|
141
159
|
} while (j < columns);
|
|
142
160
|
}
|
|
143
161
|
// store number of values in ptr
|
|
144
|
-
matrix._ptr.
|
|
162
|
+
while (matrix._ptr.length <= columns) {
|
|
163
|
+
matrix._ptr.push(matrix._index.length);
|
|
164
|
+
}
|
|
145
165
|
// size
|
|
146
166
|
matrix._size = [rows, columns];
|
|
147
167
|
}
|
|
@@ -304,12 +324,13 @@ const createSparseMatrixClass = exports.createSparseMatrixClass = /* #__PURE__ *
|
|
|
304
324
|
const pv = [];
|
|
305
325
|
|
|
306
326
|
// loop rows in resulting matrix
|
|
307
|
-
|
|
327
|
+
function rowsCallback(i, r) {
|
|
308
328
|
// update permutation vector
|
|
309
329
|
pv[i] = r[0];
|
|
310
330
|
// mark i in workspace
|
|
311
331
|
w[i] = true;
|
|
312
|
-
}
|
|
332
|
+
}
|
|
333
|
+
if (Number.isInteger(rows)) rowsCallback(rows, [0]);else rows.forEach(rowsCallback);
|
|
313
334
|
|
|
314
335
|
// result matrix arrays
|
|
315
336
|
const values = mvalues ? [] : undefined;
|
|
@@ -317,7 +338,7 @@ const createSparseMatrixClass = exports.createSparseMatrixClass = /* #__PURE__ *
|
|
|
317
338
|
const ptr = [];
|
|
318
339
|
|
|
319
340
|
// loop columns in result matrix
|
|
320
|
-
|
|
341
|
+
function columnsCallback(j) {
|
|
321
342
|
// update ptr
|
|
322
343
|
ptr.push(index.length);
|
|
323
344
|
// loop values in column j
|
|
@@ -334,7 +355,8 @@ const createSparseMatrixClass = exports.createSparseMatrixClass = /* #__PURE__ *
|
|
|
334
355
|
}
|
|
335
356
|
}
|
|
336
357
|
}
|
|
337
|
-
}
|
|
358
|
+
}
|
|
359
|
+
if (Number.isInteger(columns)) columnsCallback(columns);else columns.forEach(columnsCallback);
|
|
338
360
|
// update ptr
|
|
339
361
|
ptr.push(index.length);
|
|
340
362
|
|
|
@@ -408,7 +430,7 @@ const createSparseMatrixClass = exports.createSparseMatrixClass = /* #__PURE__ *
|
|
|
408
430
|
if (iSize.length === 1) {
|
|
409
431
|
// if the replacement index only has 1 dimension, go trough each one and set its value
|
|
410
432
|
const range = index.dimension(0);
|
|
411
|
-
range
|
|
433
|
+
_forEachIndex(range, (dataIndex, subIndex) => {
|
|
412
434
|
(0, _array.validateIndex)(dataIndex);
|
|
413
435
|
matrix.set([dataIndex, 0], submatrix[subIndex[0]], defaultValue);
|
|
414
436
|
});
|
|
@@ -416,9 +438,9 @@ const createSparseMatrixClass = exports.createSparseMatrixClass = /* #__PURE__ *
|
|
|
416
438
|
// if the replacement index has 2 dimensions, go through each one and set the value in the correct index
|
|
417
439
|
const firstDimensionRange = index.dimension(0);
|
|
418
440
|
const secondDimensionRange = index.dimension(1);
|
|
419
|
-
firstDimensionRange
|
|
441
|
+
_forEachIndex(firstDimensionRange, (firstDataIndex, firstSubIndex) => {
|
|
420
442
|
(0, _array.validateIndex)(firstDataIndex);
|
|
421
|
-
secondDimensionRange
|
|
443
|
+
_forEachIndex(secondDimensionRange, (secondDataIndex, secondSubIndex) => {
|
|
422
444
|
(0, _array.validateIndex)(secondDataIndex);
|
|
423
445
|
matrix.set([firstDataIndex, secondDataIndex], submatrix[firstSubIndex[0]][secondSubIndex[0]], defaultValue);
|
|
424
446
|
});
|
|
@@ -426,6 +448,10 @@ const createSparseMatrixClass = exports.createSparseMatrixClass = /* #__PURE__ *
|
|
|
426
448
|
}
|
|
427
449
|
}
|
|
428
450
|
return matrix;
|
|
451
|
+
function _forEachIndex(index, callback) {
|
|
452
|
+
// iterate cases where index is a Matrix or a Number
|
|
453
|
+
if ((0, _is.isNumber)(index)) callback(index, [0]);else index.forEach(callback);
|
|
454
|
+
}
|
|
429
455
|
}
|
|
430
456
|
|
|
431
457
|
/**
|
|
@@ -13,7 +13,7 @@ var _string = require("../../utils/string.js");
|
|
|
13
13
|
var _object = require("../../utils/object.js");
|
|
14
14
|
var _constants = require("../../utils/bignumber/constants.js");
|
|
15
15
|
const name = 'Unit';
|
|
16
|
-
const dependencies = ['?on', 'config', 'addScalar', 'subtractScalar', 'multiplyScalar', 'divideScalar', 'pow', 'abs', 'fix', 'round', 'equal', 'isNumeric', 'format', '
|
|
16
|
+
const dependencies = ['?on', 'config', 'addScalar', 'subtractScalar', 'multiplyScalar', 'divideScalar', 'pow', 'abs', 'fix', 'round', 'equal', 'isNumeric', 'format', 'number', 'Complex', 'BigNumber', 'Fraction'];
|
|
17
17
|
const createUnitClass = exports.createUnitClass = /* #__PURE__ */(0, _factory.factory)(name, dependencies, _ref => {
|
|
18
18
|
let {
|
|
19
19
|
on,
|
|
@@ -29,13 +29,15 @@ const createUnitClass = exports.createUnitClass = /* #__PURE__ */(0, _factory.fa
|
|
|
29
29
|
equal,
|
|
30
30
|
isNumeric,
|
|
31
31
|
format,
|
|
32
|
-
toBest,
|
|
33
32
|
number,
|
|
34
33
|
Complex,
|
|
35
34
|
BigNumber,
|
|
36
35
|
Fraction
|
|
37
36
|
} = _ref;
|
|
38
37
|
const toNumber = number;
|
|
38
|
+
const fixPrefixDefault = false;
|
|
39
|
+
const skipAutomaticSimplificationDefault = true;
|
|
40
|
+
|
|
39
41
|
/**
|
|
40
42
|
* A unit can be constructed in the following ways:
|
|
41
43
|
*
|
|
@@ -62,13 +64,13 @@ const createUnitClass = exports.createUnitClass = /* #__PURE__ */(0, _factory.fa
|
|
|
62
64
|
if (!(value === null || value === undefined || isNumeric(value) || (0, _is.isComplex)(value))) {
|
|
63
65
|
throw new TypeError('First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined');
|
|
64
66
|
}
|
|
65
|
-
this.fixPrefix =
|
|
67
|
+
this.fixPrefix = fixPrefixDefault; // if true, function format will not search for the
|
|
66
68
|
// best prefix but leave it as initially provided.
|
|
67
69
|
// fixPrefix is set true by the method Unit.to
|
|
68
70
|
|
|
69
71
|
// The justification behind this is that if the constructor is explicitly called,
|
|
70
72
|
// the caller wishes the units to be returned exactly as supplied.
|
|
71
|
-
this.skipAutomaticSimplification =
|
|
73
|
+
this.skipAutomaticSimplification = skipAutomaticSimplificationDefault;
|
|
72
74
|
if (valuelessUnit === undefined) {
|
|
73
75
|
this.units = [];
|
|
74
76
|
this.dimensions = BASE_DIMENSIONS.map(x => 0);
|
|
@@ -862,14 +864,15 @@ const createUnitClass = exports.createUnitClass = /* #__PURE__ */(0, _factory.fa
|
|
|
862
864
|
* Get a JSON representation of the unit
|
|
863
865
|
* @memberof Unit
|
|
864
866
|
* @returns {Object} Returns a JSON object structured as:
|
|
865
|
-
* `{"mathjs": "Unit", "value": 2, "unit": "cm", "fixPrefix": false}`
|
|
867
|
+
* `{"mathjs": "Unit", "value": 2, "unit": "cm", "fixPrefix": false, "skipSimp": true}`
|
|
866
868
|
*/
|
|
867
869
|
Unit.prototype.toJSON = function () {
|
|
868
870
|
return {
|
|
869
871
|
mathjs: 'Unit',
|
|
870
872
|
value: this._denormalize(this.value),
|
|
871
873
|
unit: this.units.length > 0 ? this.formatUnits() : null,
|
|
872
|
-
fixPrefix: this.fixPrefix
|
|
874
|
+
fixPrefix: this.fixPrefix,
|
|
875
|
+
skipSimp: this.skipAutomaticSimplification
|
|
873
876
|
};
|
|
874
877
|
};
|
|
875
878
|
|
|
@@ -881,9 +884,10 @@ const createUnitClass = exports.createUnitClass = /* #__PURE__ */(0, _factory.fa
|
|
|
881
884
|
* @return {Unit}
|
|
882
885
|
*/
|
|
883
886
|
Unit.fromJSON = function (json) {
|
|
884
|
-
var _json$unit;
|
|
887
|
+
var _json$unit, _json$fixPrefix, _json$skipSimp;
|
|
885
888
|
const unit = new Unit(json.value, (_json$unit = json.unit) !== null && _json$unit !== void 0 ? _json$unit : undefined);
|
|
886
|
-
unit.fixPrefix = json.fixPrefix
|
|
889
|
+
unit.fixPrefix = (_json$fixPrefix = json.fixPrefix) !== null && _json$fixPrefix !== void 0 ? _json$fixPrefix : fixPrefixDefault;
|
|
890
|
+
unit.skipAutomaticSimplification = (_json$skipSimp = json.skipSimp) !== null && _json$skipSimp !== void 0 ? _json$skipSimp : skipAutomaticSimplificationDefault;
|
|
887
891
|
return unit;
|
|
888
892
|
};
|
|
889
893
|
|
package/lib/cjs/utils/number.js
CHANGED
|
@@ -36,7 +36,7 @@ function isInteger(value) {
|
|
|
36
36
|
if (typeof value === 'boolean') {
|
|
37
37
|
return true;
|
|
38
38
|
}
|
|
39
|
-
return isFinite(value) ? value === Math.round(value) : false;
|
|
39
|
+
return Number.isFinite(value) ? value === Math.round(value) : false;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
@@ -128,7 +128,7 @@ const cbrt = exports.cbrt = Math.cbrt || function cbrt(x) {
|
|
|
128
128
|
if (negate) {
|
|
129
129
|
x = -x;
|
|
130
130
|
}
|
|
131
|
-
if (isFinite(x)) {
|
|
131
|
+
if (Number.isFinite(x)) {
|
|
132
132
|
result = Math.exp(Math.log(x) / 3);
|
|
133
133
|
// from https://en.wikipedia.org/wiki/Cube_root#Numerical_methods
|
|
134
134
|
result = (x / (result * result) + 2 * result) / 3;
|
|
@@ -404,7 +404,7 @@ function splitNumber(value) {
|
|
|
404
404
|
* @param {number} [precision] Optional number of significant figures to return.
|
|
405
405
|
*/
|
|
406
406
|
function toEngineering(value, precision) {
|
|
407
|
-
if (isNaN(value) || !isFinite(value)) {
|
|
407
|
+
if (isNaN(value) || !Number.isFinite(value)) {
|
|
408
408
|
return String(value);
|
|
409
409
|
}
|
|
410
410
|
const split = splitNumber(value);
|
|
@@ -453,7 +453,7 @@ function toEngineering(value, precision) {
|
|
|
453
453
|
* decimal point. null by default.
|
|
454
454
|
*/
|
|
455
455
|
function toFixed(value, precision) {
|
|
456
|
-
if (isNaN(value) || !isFinite(value)) {
|
|
456
|
+
if (isNaN(value) || !Number.isFinite(value)) {
|
|
457
457
|
return String(value);
|
|
458
458
|
}
|
|
459
459
|
const splitValue = splitNumber(value);
|
|
@@ -488,7 +488,7 @@ function toFixed(value, precision) {
|
|
|
488
488
|
* is used.
|
|
489
489
|
*/
|
|
490
490
|
function toExponential(value, precision) {
|
|
491
|
-
if (isNaN(value) || !isFinite(value)) {
|
|
491
|
+
if (isNaN(value) || !Number.isFinite(Number(value))) {
|
|
492
492
|
return String(value);
|
|
493
493
|
}
|
|
494
494
|
|
|
@@ -519,7 +519,7 @@ function toExponential(value, precision) {
|
|
|
519
519
|
* @return {string}
|
|
520
520
|
*/
|
|
521
521
|
function toPrecision(value, precision, options) {
|
|
522
|
-
if (isNaN(value) || !isFinite(value)) {
|
|
522
|
+
if (isNaN(value) || !Number.isFinite(value)) {
|
|
523
523
|
return String(value);
|
|
524
524
|
}
|
|
525
525
|
|
|
@@ -658,7 +658,7 @@ function nearlyEqual(a, b) {
|
|
|
658
658
|
if (isNaN(a) || isNaN(b)) {
|
|
659
659
|
return false;
|
|
660
660
|
}
|
|
661
|
-
if (!isFinite(a) || !isFinite(b)) {
|
|
661
|
+
if (!Number.isFinite(a) || !Number.isFinite(b)) {
|
|
662
662
|
return a === b;
|
|
663
663
|
}
|
|
664
664
|
if (a === b) {
|
|
@@ -23,7 +23,19 @@ function optimizeCallback(callback, array, name, isUnary) {
|
|
|
23
23
|
if (isUnary) {
|
|
24
24
|
numberOfArguments = 1;
|
|
25
25
|
} else {
|
|
26
|
-
const
|
|
26
|
+
const size = array.isMatrix ? array.size() : (0, _array.arraySize)(array);
|
|
27
|
+
|
|
28
|
+
// Check the size of the last dimension to see if the array/matrix is empty
|
|
29
|
+
const isEmpty = size.length ? size[size.length - 1] === 0 : true;
|
|
30
|
+
if (isEmpty) {
|
|
31
|
+
// don't optimize callbacks for empty arrays/matrix, as they will never be called
|
|
32
|
+
// and in fact will throw an exception when we try to access the first element below
|
|
33
|
+
return {
|
|
34
|
+
isUnary,
|
|
35
|
+
fn: callback
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const firstIndex = size.map(() => 0);
|
|
27
39
|
const firstValue = array.isMatrix ? array.get(firstIndex) : (0, _array.get)(array, firstIndex);
|
|
28
40
|
numberOfArguments = _findNumberOfArgumentsTyped(callback, firstValue, firstIndex, array);
|
|
29
41
|
}
|
package/lib/cjs/version.js
CHANGED
|
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.version = void 0;
|
|
7
|
-
const version = exports.version = '
|
|
7
|
+
const version = exports.version = '15.1.0';
|
|
8
8
|
// Note: This file is automatically generated when building math.js.
|
|
9
9
|
// Changes made in this file will be overwritten.
|
package/lib/esm/core/config.js
CHANGED
|
@@ -21,5 +21,9 @@ export var DEFAULT_CONFIG = {
|
|
|
21
21
|
predictable: false,
|
|
22
22
|
// random seed for seeded pseudo random number generation
|
|
23
23
|
// null = randomly seed
|
|
24
|
-
randomSeed: null
|
|
24
|
+
randomSeed: null,
|
|
25
|
+
// legacy behavior for matrix subset. When true, the subset function
|
|
26
|
+
// returns a matrix or array with the same size as the index (except for scalars).
|
|
27
|
+
// When false, it returns a matrix or array with a size depending on the type of index.
|
|
28
|
+
legacySubset: false
|
|
25
29
|
};
|
|
@@ -59,6 +59,10 @@ export function configFactory(config, emit) {
|
|
|
59
59
|
delete optionsFix.epsilon;
|
|
60
60
|
return _config(optionsFix);
|
|
61
61
|
}
|
|
62
|
+
if (options.legacySubset === true) {
|
|
63
|
+
// this if is only for backwards compatibility, it can be removed in the future.
|
|
64
|
+
console.warn('Warning: The configuration option "legacySubset" is for compatibility only and might be deprecated in the future.');
|
|
65
|
+
}
|
|
62
66
|
var prev = clone(config);
|
|
63
67
|
|
|
64
68
|
// validate some of the options
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THIS FILE IS AUTO-GENERATED
|
|
3
|
+
* DON'T MAKE CHANGES HERE
|
|
4
|
+
*/
|
|
5
|
+
import { BigNumberDependencies } from './dependenciesBigNumberClass.generated.js';
|
|
6
|
+
import { FractionDependencies } from './dependenciesFractionClass.generated.js';
|
|
7
|
+
import { isIntegerDependencies } from './dependenciesIsInteger.generated.js';
|
|
8
|
+
import { numberDependencies } from './dependenciesNumber.generated.js';
|
|
9
|
+
import { typedDependencies } from './dependenciesTyped.generated.js';
|
|
10
|
+
import { createBernoulli } from '../../factoriesAny.js';
|
|
11
|
+
export var bernoulliDependencies = {
|
|
12
|
+
BigNumberDependencies,
|
|
13
|
+
FractionDependencies,
|
|
14
|
+
isIntegerDependencies,
|
|
15
|
+
numberDependencies,
|
|
16
|
+
typedDependencies,
|
|
17
|
+
createBernoulli
|
|
18
|
+
};
|