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
|
@@ -52,8 +52,9 @@ export var createRow = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
52
52
|
}
|
|
53
53
|
validateIndex(row, value.size()[0]);
|
|
54
54
|
var columnRange = range(0, value.size()[1]);
|
|
55
|
-
var index = new Index(row, columnRange);
|
|
55
|
+
var index = new Index([row], columnRange);
|
|
56
56
|
var result = value.subset(index);
|
|
57
|
+
// once config.legacySubset just return result
|
|
57
58
|
return isMatrix(result) ? result : matrix([[result]]);
|
|
58
59
|
}
|
|
59
60
|
});
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { arraySize } from '../../utils/array.js';
|
|
2
2
|
import { factory } from '../../utils/factory.js';
|
|
3
|
-
import { noMatrix } from '../../utils/noop.js';
|
|
4
3
|
var name = 'size';
|
|
5
|
-
var dependencies = ['typed'
|
|
4
|
+
var dependencies = ['typed'];
|
|
6
5
|
export var createSize = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
7
6
|
var {
|
|
8
|
-
typed
|
|
9
|
-
config,
|
|
10
|
-
matrix
|
|
7
|
+
typed
|
|
11
8
|
} = _ref;
|
|
12
9
|
/**
|
|
13
|
-
* Calculate the size of a matrix or scalar.
|
|
10
|
+
* Calculate the size of a matrix or scalar. Always returns an Array containing numbers.
|
|
11
|
+
*
|
|
12
|
+
* Note that in mathjs v14 and older, function size could return a Matrix depending on
|
|
13
|
+
* the input type and configuration.
|
|
14
14
|
*
|
|
15
15
|
* Syntax:
|
|
16
16
|
*
|
|
@@ -30,19 +30,13 @@ export var createSize = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
30
30
|
* count, resize, squeeze, subset
|
|
31
31
|
*
|
|
32
32
|
* @param {boolean | number | Complex | Unit | string | Array | Matrix} x A matrix
|
|
33
|
-
* @return {Array
|
|
33
|
+
* @return {Array} A vector with size of `x`.
|
|
34
34
|
*/
|
|
35
35
|
return typed(name, {
|
|
36
|
-
Matrix:
|
|
37
|
-
return x.create(x.size(), 'number');
|
|
38
|
-
},
|
|
36
|
+
Matrix: x => x.size(),
|
|
39
37
|
Array: arraySize,
|
|
40
|
-
string:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
'number | Complex | BigNumber | Unit | boolean | null': function number__Complex__BigNumber__Unit__boolean__null(x) {
|
|
44
|
-
// scalar
|
|
45
|
-
return config.matrix === 'Array' ? [] : matrix ? matrix([], 'dense', 'number') : noMatrix();
|
|
46
|
-
}
|
|
38
|
+
string: x => [x.length],
|
|
39
|
+
// scalar
|
|
40
|
+
'number | Complex | BigNumber | Unit | boolean | null': _x => []
|
|
47
41
|
});
|
|
48
42
|
});
|
|
@@ -25,8 +25,8 @@ export var createSubset = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
25
25
|
* // get a subset
|
|
26
26
|
* const d = [[1, 2], [3, 4]]
|
|
27
27
|
* math.subset(d, math.index(1, 0)) // returns 3
|
|
28
|
-
* math.subset(d, math.index([0, 1], 1)) // returns [[2], [4]]
|
|
29
|
-
* math.subset(d, math.index([false, true], 0)) // returns [[3]]
|
|
28
|
+
* math.subset(d, math.index([0, 1], [1])) // returns [[2], [4]]
|
|
29
|
+
* math.subset(d, math.index([false, true], [0])) // returns [[3]]
|
|
30
30
|
*
|
|
31
31
|
* // replace a subset
|
|
32
32
|
* const e = []
|
|
@@ -36,9 +36,9 @@ export var createSubset = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
36
36
|
*
|
|
37
37
|
* // get submatrix using ranges
|
|
38
38
|
* const M = [
|
|
39
|
-
* [1,2,3],
|
|
40
|
-
* [4,5,6],
|
|
41
|
-
* [7,8,9]
|
|
39
|
+
* [1, 2, 3],
|
|
40
|
+
* [4, 5, 6],
|
|
41
|
+
* [7, 8, 9]
|
|
42
42
|
* ]
|
|
43
43
|
* math.subset(M, math.index(math.range(0,2), math.range(0,3))) // [[1, 2, 3], [4, 5, 6]]
|
|
44
44
|
*
|
|
@@ -117,7 +117,7 @@ export var createSubset = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
117
117
|
if (typeof replacement === 'string') {
|
|
118
118
|
throw new Error('can\'t boradcast a string');
|
|
119
119
|
}
|
|
120
|
-
if (index.
|
|
120
|
+
if (index.isScalar()) {
|
|
121
121
|
return replacement;
|
|
122
122
|
}
|
|
123
123
|
var indexSize = index.size();
|
|
@@ -159,9 +159,14 @@ function _getSubstring(str, index) {
|
|
|
159
159
|
validateIndex(index.max()[0], strLen);
|
|
160
160
|
var range = index.dimension(0);
|
|
161
161
|
var substr = '';
|
|
162
|
-
|
|
162
|
+
function callback(v) {
|
|
163
163
|
substr += str.charAt(v);
|
|
164
|
-
}
|
|
164
|
+
}
|
|
165
|
+
if (Number.isInteger(range)) {
|
|
166
|
+
callback(range);
|
|
167
|
+
} else {
|
|
168
|
+
range.forEach(callback);
|
|
169
|
+
}
|
|
165
170
|
return substr;
|
|
166
171
|
}
|
|
167
172
|
|
|
@@ -195,7 +200,7 @@ function _setSubstring(str, index, replacement, defaultValue) {
|
|
|
195
200
|
defaultValue = ' ';
|
|
196
201
|
}
|
|
197
202
|
var range = index.dimension(0);
|
|
198
|
-
var len = range.size()[0];
|
|
203
|
+
var len = Number.isInteger(range) ? 1 : range.size()[0];
|
|
199
204
|
if (len !== replacement.length) {
|
|
200
205
|
throw new DimensionError(range.size()[0], replacement.length);
|
|
201
206
|
}
|
|
@@ -210,9 +215,14 @@ function _setSubstring(str, index, replacement, defaultValue) {
|
|
|
210
215
|
for (var i = 0; i < strLen; i++) {
|
|
211
216
|
chars[i] = str.charAt(i);
|
|
212
217
|
}
|
|
213
|
-
|
|
218
|
+
function callback(v, i) {
|
|
214
219
|
chars[v] = replacement.charAt(i[0]);
|
|
215
|
-
}
|
|
220
|
+
}
|
|
221
|
+
if (Number.isInteger(range)) {
|
|
222
|
+
callback(range, [0]);
|
|
223
|
+
} else {
|
|
224
|
+
range.forEach(callback);
|
|
225
|
+
}
|
|
216
226
|
|
|
217
227
|
// initialize undefined characters with a space
|
|
218
228
|
if (chars.length > strLen) {
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { factory } from '../../utils/factory.js';
|
|
2
|
+
import { isInteger } from '../../utils/number.js';
|
|
3
|
+
var name = 'bernoulli';
|
|
4
|
+
var dependencies = ['typed', 'config', 'isInteger', 'number', '?BigNumber', '?Fraction'];
|
|
5
|
+
export var createBernoulli = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
6
|
+
var {
|
|
7
|
+
typed,
|
|
8
|
+
config,
|
|
9
|
+
number,
|
|
10
|
+
BigNumber: _BigNumber,
|
|
11
|
+
Fraction
|
|
12
|
+
} = _ref;
|
|
13
|
+
/**
|
|
14
|
+
* Return the `n`th Bernoulli number, for positive integers `n`
|
|
15
|
+
*
|
|
16
|
+
* Syntax:
|
|
17
|
+
*
|
|
18
|
+
* math.bernoulli(n)
|
|
19
|
+
*
|
|
20
|
+
* Examples:
|
|
21
|
+
*
|
|
22
|
+
* math.bernoulli(1) // returns -0.5
|
|
23
|
+
* // All other odd Bernoulli numbers are 0:
|
|
24
|
+
* math.bernoulli(7) // returns 0
|
|
25
|
+
* math.bernoulli(math.bignumber(6)) // value bignumber(1).div(42)
|
|
26
|
+
* // Produces exact rationals for bigint or fraction input:
|
|
27
|
+
* math.bernoulli(8n) // Fraction -1,30
|
|
28
|
+
* math.bernoulli(math.fraction(10)) // Fraction 5,66
|
|
29
|
+
*
|
|
30
|
+
* See also:
|
|
31
|
+
*
|
|
32
|
+
* combinations, gamma, stirlingS2
|
|
33
|
+
*
|
|
34
|
+
* @param {number | BigNumber | bigint | Fraction} n
|
|
35
|
+
* Index of the Bernoulli number
|
|
36
|
+
* @return {number | BigNumber | Fraction}
|
|
37
|
+
* nth Bernoulli number, of a type corresponding to the argument n
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
var numberCache = [undefined];
|
|
41
|
+
var fractionCache = [undefined];
|
|
42
|
+
var bigCache = [undefined];
|
|
43
|
+
var cachedPrecision = 50;
|
|
44
|
+
return typed(name, {
|
|
45
|
+
number: index => _bernoulli(index, n => n, numberCache, (a, b) => a + b, (a, b) => a * b, (a, b) => a / b),
|
|
46
|
+
'bigint | Fraction': index => _bernoulli(number(index), n => new Fraction(n), fractionCache, (a, b) => a.add(b), (a, b) => a.mul(b), (a, b) => a.div(b)),
|
|
47
|
+
BigNumber: index => {
|
|
48
|
+
if (config.precision !== cachedPrecision) {
|
|
49
|
+
bigCache = [undefined];
|
|
50
|
+
cachedPrecision = config.precision;
|
|
51
|
+
}
|
|
52
|
+
return _bernoulli(number(index), n => new _BigNumber(n), bigCache, (a, b) => a.add(b), (a, b) => a.mul(b), (a, b) => a.div(b));
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Underlying implementation, with all operations passed in.
|
|
59
|
+
* Parameters:
|
|
60
|
+
* 1. index: a (positive integer) number specifying which Bernoulli number
|
|
61
|
+
* to compute.
|
|
62
|
+
* 2. promote: a function that takes an integer number and returns
|
|
63
|
+
* the desired type for the Bernoulli number values.
|
|
64
|
+
* 3. A: a cache array of partial computation data that _bernoulli should use.
|
|
65
|
+
* Different cache arrays should be provided for different types.
|
|
66
|
+
* 4. plus: a function that adds two values of the desired type.
|
|
67
|
+
* 5. times: a function that multiplies two values of the desired type.
|
|
68
|
+
* 6. divide: a function that divides one value of the desired type by another.
|
|
69
|
+
*/
|
|
70
|
+
function _bernoulli(index, promote, A, plus, times, divide) {
|
|
71
|
+
if (index < 0 || !isInteger(index)) {
|
|
72
|
+
throw new RangeError('Bernoulli index must be nonnegative integer');
|
|
73
|
+
}
|
|
74
|
+
if (index === 0) return promote(1);
|
|
75
|
+
if (index === 1) return divide(promote(-1), promote(2));
|
|
76
|
+
if (index % 2 === 1) return promote(0);
|
|
77
|
+
// We proceed as in https://math.stackexchange.com/a/2844337
|
|
78
|
+
// (by no means the most efficient, but very simple to implement)
|
|
79
|
+
// A cache entry consists of a triple
|
|
80
|
+
// [cotangent coefficient a_n, prefactor, Bernouilli number B_2n]
|
|
81
|
+
var one = promote(1);
|
|
82
|
+
if (A.length === 1) {
|
|
83
|
+
A.push([divide(one, promote(-3)), divide(one, promote(-2)), divide(one, promote(6))]);
|
|
84
|
+
}
|
|
85
|
+
var half = index / 2;
|
|
86
|
+
var zero = promote(0);
|
|
87
|
+
var two = promote(2);
|
|
88
|
+
while (A.length <= half) {
|
|
89
|
+
var i = A.length; // next cotangent coefficient to compute
|
|
90
|
+
var lim = Math.floor((i + 1) / 2);
|
|
91
|
+
var a = zero;
|
|
92
|
+
for (var m = 1; m < lim; ++m) {
|
|
93
|
+
a = plus(a, times(A[m][0], A[i - m][0]));
|
|
94
|
+
}
|
|
95
|
+
a = times(a, two);
|
|
96
|
+
if (i % 2 === 0) a = plus(a, times(A[lim][0], A[lim][0]));
|
|
97
|
+
a = divide(a, promote(-(2 * i + 1)));
|
|
98
|
+
var prefactor = divide(times(A[i - 1][1], promote(-i * (2 * i - 1))), two);
|
|
99
|
+
A.push([a, prefactor, times(prefactor, a)]);
|
|
100
|
+
}
|
|
101
|
+
return A[half][2];
|
|
102
|
+
}
|
|
@@ -4,7 +4,7 @@ import { createMatAlgo07xSSf } from '../../type/matrix/utils/matAlgo07xSSf.js';
|
|
|
4
4
|
import { createMatAlgo12xSfs } from '../../type/matrix/utils/matAlgo12xSfs.js';
|
|
5
5
|
import { createMatrixAlgorithmSuite } from '../../type/matrix/utils/matrixAlgorithmSuite.js';
|
|
6
6
|
var name = 'equal';
|
|
7
|
-
var dependencies = ['typed', 'matrix', 'equalScalar', 'DenseMatrix', '
|
|
7
|
+
var dependencies = ['typed', 'matrix', 'equalScalar', 'DenseMatrix', 'SparseMatrix'];
|
|
8
8
|
export var createEqual = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
9
9
|
var {
|
|
10
10
|
typed,
|
|
@@ -27,8 +27,7 @@ export var createEqual = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
27
27
|
});
|
|
28
28
|
var matrixAlgorithmSuite = createMatrixAlgorithmSuite({
|
|
29
29
|
typed,
|
|
30
|
-
matrix
|
|
31
|
-
concat
|
|
30
|
+
matrix
|
|
32
31
|
});
|
|
33
32
|
|
|
34
33
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { factory } from '../../utils/factory.js';
|
|
2
2
|
var name = 'zeta';
|
|
3
|
-
var dependencies = ['typed', 'config', 'multiply', 'pow', 'divide', 'factorial', 'equal', 'smallerEq', 'isNegative', 'gamma', 'sin', 'subtract', 'add', '?Complex', '?BigNumber', 'pi'];
|
|
3
|
+
var dependencies = ['typed', 'config', 'multiply', 'pow', 'divide', 'factorial', 'equal', 'smallerEq', 'isBounded', 'isNegative', 'gamma', 'sin', 'subtract', 'add', '?Complex', '?BigNumber', 'pi'];
|
|
4
4
|
export var createZeta = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
5
5
|
var {
|
|
6
6
|
typed,
|
|
@@ -11,6 +11,7 @@ export var createZeta = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
11
11
|
factorial,
|
|
12
12
|
equal,
|
|
13
13
|
smallerEq,
|
|
14
|
+
isBounded,
|
|
14
15
|
isNegative,
|
|
15
16
|
gamma,
|
|
16
17
|
sin,
|
|
@@ -69,7 +70,7 @@ export var createZeta = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
69
70
|
if (equal(s, 1)) {
|
|
70
71
|
return createValue(NaN);
|
|
71
72
|
}
|
|
72
|
-
if (!
|
|
73
|
+
if (!isBounded(s)) {
|
|
73
74
|
return isNegative(s) ? createValue(NaN) : createValue(1);
|
|
74
75
|
}
|
|
75
76
|
return zeta(s, createValue, determineDigits, s => s);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { factory } from '../../utils/factory.js';
|
|
2
|
+
var name = 'isBounded';
|
|
3
|
+
var dependencies = ['typed'];
|
|
4
|
+
export var createIsBounded = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
5
|
+
var {
|
|
6
|
+
typed
|
|
7
|
+
} = _ref;
|
|
8
|
+
/**
|
|
9
|
+
* Test whether a value is bounded. For scalars, this test is equivalent
|
|
10
|
+
* to the isFinite finiteness test. On the other hand, a Matrix or Array
|
|
11
|
+
* is defined to be bounded if every entry is finite.
|
|
12
|
+
*
|
|
13
|
+
* Syntax:
|
|
14
|
+
*
|
|
15
|
+
* math.isBounded(x)
|
|
16
|
+
*
|
|
17
|
+
* Examples:
|
|
18
|
+
*
|
|
19
|
+
* math.isBounded(0) // returns true
|
|
20
|
+
* math.isBounded(NaN) // returns false
|
|
21
|
+
* math.isBounded(math.bignumber(Infinity)) // returns false
|
|
22
|
+
* math.isBounded(math.fraction(1,3)) // returns true
|
|
23
|
+
* math.isBounded(math.complex('2 - 4i')) // returns true
|
|
24
|
+
* math.isBounded(-10000000000000000n) // returns true
|
|
25
|
+
* math.isBounded(undefined) // returns false
|
|
26
|
+
* math.isBounded(null) // returns false
|
|
27
|
+
* math.isBounded([0.001, -3n, 0]) // returns true
|
|
28
|
+
* math.isBounded([2, -Infinity, -3]) // returns false
|
|
29
|
+
*
|
|
30
|
+
* See also:
|
|
31
|
+
*
|
|
32
|
+
* isFinite, isNumeric, isPositive, isNegative, isNaN
|
|
33
|
+
*
|
|
34
|
+
* @param {number | BigNumber | bigint | Complex | Fraction | Unit | Array | Matrix} x Value to be tested
|
|
35
|
+
* @return {boolean} Returns true when `x` is bounded.
|
|
36
|
+
*/
|
|
37
|
+
return typed(name, {
|
|
38
|
+
number: n => Number.isFinite(n),
|
|
39
|
+
'BigNumber | Complex': x => x.isFinite(),
|
|
40
|
+
'bigint | Fraction': () => true,
|
|
41
|
+
'null | undefined': () => false,
|
|
42
|
+
Unit: typed.referToSelf(self => x => self(x.value)),
|
|
43
|
+
'Array | Matrix': typed.referToSelf(self => A => {
|
|
44
|
+
if (!Array.isArray(A)) A = A.valueOf();
|
|
45
|
+
return A.every(entry => self(entry));
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { factory } from '../../utils/factory.js';
|
|
2
|
+
var name = 'isFinite';
|
|
3
|
+
var dependencies = ['typed', 'isBounded', 'map'];
|
|
4
|
+
export var createIsFinite = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
5
|
+
var {
|
|
6
|
+
typed,
|
|
7
|
+
isBounded,
|
|
8
|
+
map
|
|
9
|
+
} = _ref;
|
|
10
|
+
/**
|
|
11
|
+
* Test whether a value is finite.
|
|
12
|
+
*
|
|
13
|
+
* Operates elementwise on Array and Matrix values. To test if all entries
|
|
14
|
+
* of an Array or Matrix are finite, use isBounded.
|
|
15
|
+
*
|
|
16
|
+
* Syntax:
|
|
17
|
+
*
|
|
18
|
+
* math.isFinite(x)
|
|
19
|
+
*
|
|
20
|
+
* Examples:
|
|
21
|
+
*
|
|
22
|
+
* math.isFinite(0) // returns true
|
|
23
|
+
* math.isFinite(NaN) // returns false
|
|
24
|
+
* math.isFinite(math.bignumber(Infinity)) // returns false
|
|
25
|
+
* math.isFinite(math.fraction(1,3)) // returns true
|
|
26
|
+
* math.isFinite(math.complex('2 - 4i')) // returns true
|
|
27
|
+
* math.isFinite(-10000000000000000n) // returns true
|
|
28
|
+
* math.isFinite(undefined) // returns false
|
|
29
|
+
* math.isFinite(null) // returns false
|
|
30
|
+
* math.isFinite([0.001, -3n, 0]) // Array [true, true, true]
|
|
31
|
+
* math.isFinite([2, -Infinity, -3]) // Array [true, false, true]
|
|
32
|
+
*
|
|
33
|
+
* See also:
|
|
34
|
+
*
|
|
35
|
+
* isBounded isNumeric, isPositive, isNegative, isNaN
|
|
36
|
+
*
|
|
37
|
+
* @param {number | BigNumber | bigint | Complex | Fraction | Unit | Array | Matrix} x Value to be tested
|
|
38
|
+
* @return {boolean | Array | Matrix}
|
|
39
|
+
*/
|
|
40
|
+
return typed(name, {
|
|
41
|
+
'Array | Matrix': A => map(A, isBounded),
|
|
42
|
+
any: x => isBounded(x)
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { deepMap } from '../../utils/collection.js';
|
|
2
|
-
import { isInteger as isIntegerNumber } from '../../utils/number.js';
|
|
3
2
|
import { factory } from '../../utils/factory.js';
|
|
4
3
|
var name = 'isInteger';
|
|
5
|
-
var dependencies = ['typed'];
|
|
4
|
+
var dependencies = ['typed', 'equal'];
|
|
6
5
|
export var createIsInteger = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
7
6
|
var {
|
|
8
|
-
typed
|
|
7
|
+
typed,
|
|
8
|
+
equal
|
|
9
9
|
} = _ref;
|
|
10
10
|
/**
|
|
11
11
|
* Test whether a value is an integer number.
|
|
@@ -37,18 +37,10 @@ export var createIsInteger = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
37
37
|
* Throws an error in case of an unknown data type.
|
|
38
38
|
*/
|
|
39
39
|
return typed(name, {
|
|
40
|
-
number:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return x.isInt();
|
|
45
|
-
},
|
|
46
|
-
bigint: function bigint(x) {
|
|
47
|
-
return true;
|
|
48
|
-
},
|
|
49
|
-
Fraction: function Fraction(x) {
|
|
50
|
-
return x.d === 1n;
|
|
51
|
-
},
|
|
40
|
+
number: n => Number.isFinite(n) ? equal(n, Math.round(n)) : false,
|
|
41
|
+
BigNumber: b => b.isFinite() ? equal(b.round(), b) : false,
|
|
42
|
+
bigint: b => true,
|
|
43
|
+
Fraction: r => r.d === 1n,
|
|
52
44
|
'Array | Matrix': typed.referToSelf(self => x => deepMap(x, self))
|
|
53
45
|
});
|
|
54
46
|
});
|
|
@@ -30,7 +30,7 @@ export var createIsNaN = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
30
30
|
*
|
|
31
31
|
* See also:
|
|
32
32
|
*
|
|
33
|
-
* isNumeric, isNegative, isPositive, isZero, isInteger
|
|
33
|
+
* isNumeric, isNegative, isPositive, isZero, isInteger, isFinite, isBounded
|
|
34
34
|
*
|
|
35
35
|
* @param {number | BigNumber | bigint | Fraction | Unit | Array | Matrix} x Value to be tested
|
|
36
36
|
* @return {boolean} Returns true when `x` is NaN.
|
|
@@ -29,7 +29,7 @@ export var createIsNumeric = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
29
29
|
*
|
|
30
30
|
* See also:
|
|
31
31
|
*
|
|
32
|
-
* isZero, isPositive, isNegative, isInteger, hasNumericValue
|
|
32
|
+
* isZero, isPositive, isNegative, isInteger, hasNumericValue, isFinite, isBounded
|
|
33
33
|
*
|
|
34
34
|
* @param {*} x Value to be tested
|
|
35
35
|
* @return {boolean} Returns true when `x` is a `number`, `BigNumber`,
|
package/lib/esm/json/replacer.js
CHANGED
|
@@ -16,7 +16,7 @@ export var createReplacer = /* #__PURE__ */factory(name, dependencies, () => {
|
|
|
16
16
|
*/
|
|
17
17
|
return function replacer(key, value) {
|
|
18
18
|
// the numeric values Infinitiy, -Infinity, and NaN cannot be serialized to JSON
|
|
19
|
-
if (typeof value === 'number' && (!isFinite(value) || isNaN(value))) {
|
|
19
|
+
if (typeof value === 'number' && (!Number.isFinite(value) || isNaN(value))) {
|
|
20
20
|
return {
|
|
21
21
|
mathjs: 'number',
|
|
22
22
|
value: String(value)
|
|
@@ -6,7 +6,7 @@ export function gammaNumber(n) {
|
|
|
6
6
|
var x;
|
|
7
7
|
if (isInteger(n)) {
|
|
8
8
|
if (n <= 0) {
|
|
9
|
-
return isFinite(n) ? Infinity : NaN;
|
|
9
|
+
return Number.isFinite(n) ? Infinity : NaN;
|
|
10
10
|
}
|
|
11
11
|
if (n > 171) {
|
|
12
12
|
return Infinity; // Will overflow
|
|
@@ -53,7 +53,7 @@ export var lgammaSeries = [1.000000000190015, 76.18009172947146, -86.50532032941
|
|
|
53
53
|
export function lgammaNumber(n) {
|
|
54
54
|
if (n < 0) return NaN;
|
|
55
55
|
if (n === 0) return Infinity;
|
|
56
|
-
if (!isFinite(n)) return n;
|
|
56
|
+
if (!Number.isFinite(n)) return n;
|
|
57
57
|
if (n < 0.5) {
|
|
58
58
|
// Use Euler's reflection formula:
|
|
59
59
|
// gamma(z) = PI / (sin(PI * z) * gamma(1 - z))
|
|
@@ -14,7 +14,7 @@ export function acotNumber(x) {
|
|
|
14
14
|
}
|
|
15
15
|
acotNumber.signature = n1;
|
|
16
16
|
export function acothNumber(x) {
|
|
17
|
-
return isFinite(x) ? (Math.log((x + 1) / x) + Math.log(x / (x - 1))) / 2 : 0;
|
|
17
|
+
return Number.isFinite(x) ? (Math.log((x + 1) / x) + Math.log(x / (x - 1))) / 2 : 0;
|
|
18
18
|
}
|
|
19
19
|
acothNumber.signature = n1;
|
|
20
20
|
export function acscNumber(x) {
|
|
@@ -46,7 +46,7 @@ export var createFraction = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
46
46
|
*/
|
|
47
47
|
return typed('fraction', {
|
|
48
48
|
number: function number(x) {
|
|
49
|
-
if (!isFinite(x) || isNaN(x)) {
|
|
49
|
+
if (!Number.isFinite(x) || isNaN(x)) {
|
|
50
50
|
throw new Error(x + ' cannot be represented as a fraction');
|
|
51
51
|
}
|
|
52
52
|
return new Fraction(x);
|
|
@@ -8,10 +8,11 @@ import { DimensionError } from '../../error/DimensionError.js';
|
|
|
8
8
|
import { factory } from '../../utils/factory.js';
|
|
9
9
|
import { optimizeCallback } from '../../utils/optimizeCallback.js';
|
|
10
10
|
var name = 'DenseMatrix';
|
|
11
|
-
var dependencies = ['Matrix'];
|
|
11
|
+
var dependencies = ['Matrix', 'config'];
|
|
12
12
|
export var createDenseMatrixClass = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
13
13
|
var {
|
|
14
|
-
Matrix
|
|
14
|
+
Matrix,
|
|
15
|
+
config
|
|
15
16
|
} = _ref;
|
|
16
17
|
/**
|
|
17
18
|
* Dense Matrix implementation. A regular, dense matrix, supporting multi-dimensional matrices. This is the default matrix type.
|
|
@@ -221,7 +222,7 @@ export var createDenseMatrixClass = /* #__PURE__ */factory(name, dependencies, _
|
|
|
221
222
|
if (!isIndex(index)) {
|
|
222
223
|
throw new TypeError('Invalid index');
|
|
223
224
|
}
|
|
224
|
-
var isScalar = index.isScalar();
|
|
225
|
+
var isScalar = config.legacySubset ? index.size().every(idx => idx === 1) : index.isScalar();
|
|
225
226
|
if (isScalar) {
|
|
226
227
|
// return a scalar
|
|
227
228
|
return matrix.get(index.min());
|
|
@@ -241,12 +242,12 @@ export var createDenseMatrixClass = /* #__PURE__ */factory(name, dependencies, _
|
|
|
241
242
|
}
|
|
242
243
|
|
|
243
244
|
// retrieve submatrix
|
|
244
|
-
var returnMatrix = new DenseMatrix(
|
|
245
|
+
var returnMatrix = new DenseMatrix();
|
|
245
246
|
var submatrix = _getSubmatrix(matrix._data, index);
|
|
246
247
|
returnMatrix._size = submatrix.size;
|
|
247
248
|
returnMatrix._datatype = matrix._datatype;
|
|
248
249
|
returnMatrix._data = submatrix.data;
|
|
249
|
-
return returnMatrix;
|
|
250
|
+
return config.legacySubset ? returnMatrix.reshape(index.size()) : returnMatrix;
|
|
250
251
|
}
|
|
251
252
|
}
|
|
252
253
|
|
|
@@ -264,22 +265,30 @@ export var createDenseMatrixClass = /* #__PURE__ */factory(name, dependencies, _
|
|
|
264
265
|
var size = Array(maxDepth);
|
|
265
266
|
return {
|
|
266
267
|
data: getSubmatrixRecursive(data),
|
|
267
|
-
size
|
|
268
|
+
size: size.filter(x => x !== null)
|
|
268
269
|
};
|
|
269
270
|
function getSubmatrixRecursive(data) {
|
|
270
271
|
var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
271
|
-
var
|
|
272
|
-
|
|
272
|
+
var dims = index.dimension(depth);
|
|
273
|
+
function _mapIndex(dim, callback) {
|
|
274
|
+
// applies a callback for when the index is a Number or a Matrix
|
|
275
|
+
if (isNumber(dim)) return callback(dim);else return dim.map(callback).valueOf();
|
|
276
|
+
}
|
|
277
|
+
if (isNumber(dims)) {
|
|
278
|
+
size[depth] = null;
|
|
279
|
+
} else {
|
|
280
|
+
size[depth] = dims.size()[0];
|
|
281
|
+
}
|
|
273
282
|
if (depth < maxDepth) {
|
|
274
|
-
return
|
|
275
|
-
validateIndex(
|
|
276
|
-
return getSubmatrixRecursive(data[
|
|
277
|
-
})
|
|
283
|
+
return _mapIndex(dims, dimIndex => {
|
|
284
|
+
validateIndex(dimIndex, data.length);
|
|
285
|
+
return getSubmatrixRecursive(data[dimIndex], depth + 1);
|
|
286
|
+
});
|
|
278
287
|
} else {
|
|
279
|
-
return
|
|
280
|
-
validateIndex(
|
|
281
|
-
return data[
|
|
282
|
-
})
|
|
288
|
+
return _mapIndex(dims, dimIndex => {
|
|
289
|
+
validateIndex(dimIndex, data.length);
|
|
290
|
+
return data[dimIndex];
|
|
291
|
+
});
|
|
283
292
|
}
|
|
284
293
|
}
|
|
285
294
|
}
|
|
@@ -306,18 +315,18 @@ export var createDenseMatrixClass = /* #__PURE__ */factory(name, dependencies, _
|
|
|
306
315
|
var isScalar = index.isScalar();
|
|
307
316
|
|
|
308
317
|
// calculate the size of the submatrix, and convert it into an Array if needed
|
|
309
|
-
var
|
|
318
|
+
var submatrixSize;
|
|
310
319
|
if (isMatrix(submatrix)) {
|
|
311
|
-
|
|
320
|
+
submatrixSize = submatrix.size();
|
|
312
321
|
submatrix = submatrix.valueOf();
|
|
313
322
|
} else {
|
|
314
|
-
|
|
323
|
+
submatrixSize = arraySize(submatrix);
|
|
315
324
|
}
|
|
316
325
|
if (isScalar) {
|
|
317
326
|
// set a scalar
|
|
318
327
|
|
|
319
328
|
// check whether submatrix is a scalar
|
|
320
|
-
if (
|
|
329
|
+
if (submatrixSize.length !== 0) {
|
|
321
330
|
throw new TypeError('Scalar expected');
|
|
322
331
|
}
|
|
323
332
|
matrix.set(index.min(), submatrix, defaultValue);
|
|
@@ -325,26 +334,26 @@ export var createDenseMatrixClass = /* #__PURE__ */factory(name, dependencies, _
|
|
|
325
334
|
// set a submatrix
|
|
326
335
|
|
|
327
336
|
// broadcast submatrix
|
|
328
|
-
if (!deepStrictEqual(
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
337
|
+
if (!deepStrictEqual(submatrixSize, iSize)) {
|
|
338
|
+
if (submatrixSize.length === 0) {
|
|
339
|
+
submatrix = broadcastTo([submatrix], iSize);
|
|
340
|
+
} else {
|
|
341
|
+
try {
|
|
333
342
|
submatrix = broadcastTo(submatrix, iSize);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
|
|
343
|
+
} catch (error) {}
|
|
344
|
+
}
|
|
345
|
+
submatrixSize = arraySize(submatrix);
|
|
337
346
|
}
|
|
338
347
|
|
|
339
348
|
// validate dimensions
|
|
340
349
|
if (iSize.length < matrix._size.length) {
|
|
341
350
|
throw new DimensionError(iSize.length, matrix._size.length, '<');
|
|
342
351
|
}
|
|
343
|
-
if (
|
|
352
|
+
if (submatrixSize.length < iSize.length) {
|
|
344
353
|
// calculate number of missing outer dimensions
|
|
345
354
|
var i = 0;
|
|
346
355
|
var outer = 0;
|
|
347
|
-
while (iSize[i] === 1 &&
|
|
356
|
+
while (iSize[i] === 1 && submatrixSize[i] === 1) {
|
|
348
357
|
i++;
|
|
349
358
|
}
|
|
350
359
|
while (iSize[i] === 1) {
|
|
@@ -353,12 +362,12 @@ export var createDenseMatrixClass = /* #__PURE__ */factory(name, dependencies, _
|
|
|
353
362
|
}
|
|
354
363
|
|
|
355
364
|
// unsqueeze both outer and inner dimensions
|
|
356
|
-
submatrix = unsqueeze(submatrix, iSize.length, outer,
|
|
365
|
+
submatrix = unsqueeze(submatrix, iSize.length, outer, submatrixSize);
|
|
357
366
|
}
|
|
358
367
|
|
|
359
368
|
// check whether the size of the submatrix matches the index size
|
|
360
|
-
if (!deepStrictEqual(iSize,
|
|
361
|
-
throw new DimensionError(iSize,
|
|
369
|
+
if (!deepStrictEqual(iSize, submatrixSize)) {
|
|
370
|
+
throw new DimensionError(iSize, submatrixSize, '>');
|
|
362
371
|
}
|
|
363
372
|
|
|
364
373
|
// enlarge matrix when needed
|
|
@@ -387,16 +396,18 @@ export var createDenseMatrixClass = /* #__PURE__ */factory(name, dependencies, _
|
|
|
387
396
|
function setSubmatrixRecursive(data, submatrix) {
|
|
388
397
|
var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
389
398
|
var range = index.dimension(depth);
|
|
399
|
+
var recursiveCallback = (rangeIndex, i) => {
|
|
400
|
+
validateIndex(rangeIndex, data.length);
|
|
401
|
+
setSubmatrixRecursive(data[rangeIndex], submatrix[i[0]], depth + 1);
|
|
402
|
+
};
|
|
403
|
+
var finalCallback = (rangeIndex, i) => {
|
|
404
|
+
validateIndex(rangeIndex, data.length);
|
|
405
|
+
data[rangeIndex] = submatrix[i[0]];
|
|
406
|
+
};
|
|
390
407
|
if (depth < maxDepth) {
|
|
391
|
-
range
|
|
392
|
-
validateIndex(rangeIndex, data.length);
|
|
393
|
-
setSubmatrixRecursive(data[rangeIndex], submatrix[i[0]], depth + 1);
|
|
394
|
-
});
|
|
408
|
+
if (isNumber(range)) recursiveCallback(range, [0]);else range.forEach(recursiveCallback);
|
|
395
409
|
} else {
|
|
396
|
-
range
|
|
397
|
-
validateIndex(rangeIndex, data.length);
|
|
398
|
-
data[rangeIndex] = submatrix[i[0]];
|
|
399
|
-
});
|
|
410
|
+
if (isNumber(range)) finalCallback(range, [0]);else range.forEach(finalCallback);
|
|
400
411
|
}
|
|
401
412
|
}
|
|
402
413
|
}
|