mathjs 11.7.0 → 11.8.1
Sign up to get free protection for your applications and to get access to all the features.
- package/HISTORY.md +26 -0
- package/README.md +0 -26
- 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/function/typed.js +1 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesDistance.generated.js +2 -2
- package/lib/cjs/entry/pureFunctionsAny.generated.js +2 -2
- package/lib/cjs/expression/Parser.js +1 -1
- package/lib/cjs/expression/function/parser.js +1 -1
- package/lib/cjs/expression/node/FunctionAssignmentNode.js +1 -1
- package/lib/cjs/expression/node/OperatorNode.js +1 -3
- package/lib/cjs/expression/operators.js +19 -4
- package/lib/cjs/expression/transform/filter.transform.js +4 -13
- package/lib/cjs/expression/transform/forEach.transform.js +3 -12
- package/lib/cjs/expression/transform/map.transform.js +4 -13
- package/lib/cjs/factoriesNumber.js +18 -0
- package/lib/cjs/function/algebra/derivative.js +2 -2
- package/lib/cjs/function/algebra/leafCount.js +1 -1
- package/lib/cjs/function/algebra/polynomialRoot.js +1 -1
- package/lib/cjs/function/algebra/rationalize.js +5 -7
- package/lib/cjs/function/algebra/resolve.js +1 -1
- package/lib/cjs/function/algebra/simplify.js +7 -7
- package/lib/cjs/function/algebra/simplifyConstant.js +3 -3
- package/lib/cjs/function/algebra/simplifyCore.js +2 -2
- package/lib/cjs/function/algebra/sparse/csAmd.js +1 -3
- package/lib/cjs/function/algebra/sparse/csLeaf.js +1 -3
- package/lib/cjs/function/algebra/symbolicEqual.js +8 -8
- package/lib/cjs/function/geometry/distance.js +31 -29
- package/lib/cjs/function/matrix/eigs/complexEigs.js +3 -3
- package/lib/cjs/function/matrix/filter.js +2 -11
- package/lib/cjs/function/matrix/forEach.js +3 -12
- package/lib/cjs/function/matrix/map.js +6 -38
- package/lib/cjs/function/matrix/matrixFromColumns.js +1 -1
- package/lib/cjs/function/matrix/matrixFromRows.js +1 -1
- package/lib/cjs/function/matrix/sqrtm.js +1 -1
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/type/bignumber/function/bignumber.js +7 -0
- package/lib/cjs/type/fraction/function/fraction.js +8 -1
- package/lib/cjs/type/matrix/DenseMatrix.js +41 -45
- package/lib/cjs/type/matrix/SparseMatrix.js +39 -41
- package/lib/cjs/type/number.js +7 -3
- package/lib/cjs/type/unit/Unit.js +2 -0
- package/lib/cjs/type/unit/function/splitUnit.js +1 -1
- package/lib/cjs/utils/applyCallback.js +73 -0
- package/lib/cjs/utils/bignumber/formatter.js +4 -3
- package/lib/cjs/utils/lruQueue.js +2 -6
- package/lib/cjs/utils/map.js +1 -1
- package/lib/cjs/utils/snapshot.js +7 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/core/function/typed.js +1 -1
- package/lib/esm/entry/dependenciesAny/dependenciesDistance.generated.js +2 -2
- package/lib/esm/entry/pureFunctionsAny.generated.js +2 -2
- package/lib/esm/expression/Parser.js +1 -1
- package/lib/esm/expression/function/parser.js +1 -1
- package/lib/esm/expression/node/OperatorNode.js +1 -3
- package/lib/esm/expression/operators.js +1 -3
- package/lib/esm/expression/transform/filter.transform.js +4 -13
- package/lib/esm/expression/transform/forEach.transform.js +3 -12
- package/lib/esm/expression/transform/map.transform.js +4 -13
- package/lib/esm/function/algebra/derivative.js +2 -2
- package/lib/esm/function/algebra/leafCount.js +1 -1
- package/lib/esm/function/algebra/polynomialRoot.js +1 -1
- package/lib/esm/function/algebra/rationalize.js +5 -7
- package/lib/esm/function/algebra/resolve.js +1 -1
- package/lib/esm/function/algebra/simplify.js +7 -7
- package/lib/esm/function/algebra/simplifyConstant.js +2 -2
- package/lib/esm/function/algebra/simplifyCore.js +2 -2
- package/lib/esm/function/algebra/sparse/csAmd.js +1 -3
- package/lib/esm/function/algebra/sparse/csLeaf.js +1 -3
- package/lib/esm/function/algebra/symbolicEqual.js +8 -8
- package/lib/esm/function/geometry/distance.js +31 -29
- package/lib/esm/function/matrix/eigs/complexEigs.js +2 -2
- package/lib/esm/function/matrix/filter.js +2 -11
- package/lib/esm/function/matrix/forEach.js +3 -12
- package/lib/esm/function/matrix/map.js +6 -38
- package/lib/esm/function/matrix/sqrtm.js +1 -1
- package/lib/esm/type/bignumber/function/bignumber.js +5 -0
- package/lib/esm/type/fraction/function/fraction.js +6 -1
- package/lib/esm/type/number.js +5 -3
- package/lib/esm/type/unit/Unit.js +2 -0
- package/lib/esm/type/unit/function/splitUnit.js +1 -1
- package/lib/esm/utils/applyCallback.js +67 -0
- package/lib/esm/utils/bignumber/formatter.js +4 -3
- package/lib/esm/utils/lruQueue.js +2 -6
- package/lib/esm/version.js +1 -1
- package/package.json +21 -21
- package/types/index.d.ts +16 -16
@@ -7,14 +7,14 @@ exports.createDistance = void 0;
|
|
7
7
|
var _is = require("../../utils/is.js");
|
8
8
|
var _factory = require("../../utils/factory.js");
|
9
9
|
var name = 'distance';
|
10
|
-
var dependencies = ['typed', 'addScalar', 'subtract', 'divideScalar', 'multiplyScalar', '
|
10
|
+
var dependencies = ['typed', 'addScalar', 'subtract', 'divideScalar', 'multiplyScalar', 'deepEqual', 'sqrt', 'abs'];
|
11
11
|
var createDistance = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
|
12
12
|
var typed = _ref.typed,
|
13
13
|
addScalar = _ref.addScalar,
|
14
14
|
subtract = _ref.subtract,
|
15
15
|
multiplyScalar = _ref.multiplyScalar,
|
16
16
|
divideScalar = _ref.divideScalar,
|
17
|
-
|
17
|
+
deepEqual = _ref.deepEqual,
|
18
18
|
sqrt = _ref.sqrt,
|
19
19
|
abs = _ref.abs;
|
20
20
|
/**
|
@@ -27,21 +27,19 @@ var createDistance = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fu
|
|
27
27
|
* For parametric equation of a 3D line, x0, y0, z0, a, b, c are from: (x−x0, y−y0, z−z0) = t(a, b, c)
|
28
28
|
*
|
29
29
|
* Syntax:
|
30
|
-
*
|
31
|
-
* math.distance(
|
32
|
-
* math.distance(
|
33
|
-
* math.distance(
|
34
|
-
* math.distance(
|
35
|
-
* math.distance([
|
36
|
-
* math.distance([x1,
|
37
|
-
* math.distance(
|
38
|
-
* math.distance([
|
39
|
-
* math.distance(
|
40
|
-
* math.distance(
|
41
|
-
* math.distance(
|
42
|
-
* math.distance(
|
43
|
-
* math.distance([x, y, z], [x0, y0, z0, a, b, c])
|
44
|
-
* math.distance({pointX: 2, pointY: 5, pointZ: 9}, {x0: 4, y0: 6, z0: 3, a: 4, b: 2, c: 0})
|
30
|
+
*
|
31
|
+
* math.distance([x1,y1], [x2,y2])
|
32
|
+
* math.distance({pointOneX, pointOneY}, {pointTwoX, pointTwoY})
|
33
|
+
* math.distance([x1,y1,z1], [x2,y2,z2])
|
34
|
+
* math.distance({pointOneX, pointOneY, pointOneZ}, {pointTwoX, pointTwoY, pointTwoZ})
|
35
|
+
* math.distance([x1,y1,z1,a1], [x2,y2,z2,a2])
|
36
|
+
* math.distance([[x1,y1], [x2,y2], [x3,y3]])
|
37
|
+
* math.distance([[x1,y1,z1], [x2,y2,z2], [x3,y3,z3]])
|
38
|
+
* math.distance([pointX,pointY], [a,b,c])
|
39
|
+
* math.distance([pointX,pointY], [lineOnePtX,lineOnePtY], [lineTwoPtX,lineTwoPtY])
|
40
|
+
* math.distance({pointX, pointY}, {lineOnePtX, lineOnePtY}, {lineTwoPtX, lineTwoPtY})
|
41
|
+
* math.distance([pointX,pointY,pointZ], [x0, y0, z0, a, b, c])
|
42
|
+
* math.distance({pointX, pointY, pointZ}, {x0, y0, z0, a, b, c})
|
45
43
|
*
|
46
44
|
* Examples:
|
47
45
|
* math.distance([0,0], [4,4]) // Returns 5.656854249492381
|
@@ -56,11 +54,11 @@ var createDistance = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fu
|
|
56
54
|
* math.distance([[1, 2], [1, 2], [1, 3]]) // Returns [0, 1, 1]
|
57
55
|
* math.distance([[1,2,4], [1,2,6], [8,1,3]]) // Returns [2, 7.14142842854285, 7.681145747868608]
|
58
56
|
* math.distance([10, 10], [8, 1, 3]) // Returns 11.535230316796387
|
59
|
-
* math.distance([
|
57
|
+
* math.distance([0, 0], [3, 0], [0, 4]) // Returns 2.4
|
60
58
|
* math.distance(
|
61
|
-
* {pointX:
|
62
|
-
* {lineOnePtX:
|
63
|
-
* {lineTwoPtX:
|
59
|
+
* {pointX: 0, pointY: 0},
|
60
|
+
* {lineOnePtX: 3, lineOnePtY: 0},
|
61
|
+
* {lineTwoPtX: 0, lineTwoPtY: 4}) // Returns 2.4
|
64
62
|
* math.distance([2, 3, 1], [1, 1, 2, 5, 0, 1]) // Returns 2.3204774044612857
|
65
63
|
* math.distance(
|
66
64
|
* {pointX: 2, pointY: 3, pointZ: 1},
|
@@ -83,10 +81,12 @@ var createDistance = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fu
|
|
83
81
|
if (!_2d(z)) {
|
84
82
|
throw new TypeError('Array with 2 numbers or BigNumbers expected for third argument');
|
85
83
|
}
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
var
|
84
|
+
if (deepEqual(y, z)) {
|
85
|
+
throw new TypeError('LinePoint1 should not be same with LinePoint2');
|
86
|
+
}
|
87
|
+
var xCoeff = subtract(z[1], y[1]);
|
88
|
+
var yCoeff = subtract(y[0], z[0]);
|
89
|
+
var constant = subtract(multiplyScalar(z[0], y[1]), multiplyScalar(y[0], z[1]));
|
90
90
|
return _distancePointLine2D(x[0], x[1], xCoeff, yCoeff, constant);
|
91
91
|
} else {
|
92
92
|
throw new TypeError('Invalid Arguments: Try again');
|
@@ -103,11 +103,13 @@ var createDistance = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fu
|
|
103
103
|
if (!_2d(z)) {
|
104
104
|
throw new TypeError('Values of lineTwoPtX and lineTwoPtY should be numbers or BigNumbers');
|
105
105
|
}
|
106
|
+
if (deepEqual(_objectToArray(y), _objectToArray(z))) {
|
107
|
+
throw new TypeError('LinePoint1 should not be same with LinePoint2');
|
108
|
+
}
|
106
109
|
if ('pointX' in x && 'pointY' in x && 'lineOnePtX' in y && 'lineOnePtY' in y && 'lineTwoPtX' in z && 'lineTwoPtY' in z) {
|
107
|
-
var
|
108
|
-
var
|
109
|
-
var
|
110
|
-
var constant = x.pointX;
|
110
|
+
var xCoeff = subtract(z.lineTwoPtY, y.lineOnePtY);
|
111
|
+
var yCoeff = subtract(y.lineOnePtX, z.lineTwoPtX);
|
112
|
+
var constant = subtract(multiplyScalar(z.lineTwoPtX, y.lineOnePtY), multiplyScalar(y.lineOnePtX, z.lineTwoPtY));
|
111
113
|
return _distancePointLine2D(x.pointX, x.pointY, xCoeff, yCoeff, constant);
|
112
114
|
} else {
|
113
115
|
throw new TypeError('Key names do not match');
|
@@ -9,7 +9,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
9
9
|
var _object = require("../../../utils/object.js");
|
10
10
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
11
11
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
12
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
12
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
13
13
|
function createComplexEigs(_ref) {
|
14
14
|
var addScalar = _ref.addScalar,
|
15
15
|
subtract = _ref.subtract,
|
@@ -452,7 +452,7 @@ function createComplexEigs(_ref) {
|
|
452
452
|
|
453
453
|
// eigenvalues for which usolve failed (due to numerical error)
|
454
454
|
var failedLambdas = [];
|
455
|
-
var _loop = function _loop(
|
455
|
+
var _loop = function _loop() {
|
456
456
|
var λ = uniqueValues[i];
|
457
457
|
var S = subtract(U, multiply(λ, E)); // the characteristic matrix
|
458
458
|
|
@@ -480,7 +480,7 @@ function createComplexEigs(_ref) {
|
|
480
480
|
})));
|
481
481
|
};
|
482
482
|
for (var i = 0; i < len; i++) {
|
483
|
-
_loop(
|
483
|
+
_loop();
|
484
484
|
}
|
485
485
|
if (failedLambdas.length !== 0) {
|
486
486
|
var err = new Error('Failed to find eigenvectors for the following eigenvalues: ' + failedLambdas.join(', '));
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createFilter = void 0;
|
7
|
+
var _applyCallback = require("../../utils/applyCallback.js");
|
7
8
|
var _array = require("../../utils/array.js");
|
8
|
-
var _function = require("../../utils/function.js");
|
9
9
|
var _factory = require("../../utils/factory.js");
|
10
10
|
var name = 'filter';
|
11
11
|
var dependencies = ['typed'];
|
@@ -61,17 +61,8 @@ var createFilter = /* #__PURE__ */(0, _factory.factory)(name, dependencies, func
|
|
61
61
|
*/
|
62
62
|
exports.createFilter = createFilter;
|
63
63
|
function _filterCallback(x, callback) {
|
64
|
-
// figure out what number of arguments the callback function expects
|
65
|
-
var args = (0, _function.maxArgumentCount)(callback);
|
66
64
|
return (0, _array.filter)(x, function (value, index, array) {
|
67
65
|
// invoke the callback function with the right number of arguments
|
68
|
-
|
69
|
-
return callback(value);
|
70
|
-
} else if (args === 2) {
|
71
|
-
return callback(value, [index]);
|
72
|
-
} else {
|
73
|
-
// 3 or -1
|
74
|
-
return callback(value, [index], array);
|
75
|
-
}
|
66
|
+
return (0, _applyCallback.applyCallback)(callback, value, [index], array, 'filter');
|
76
67
|
});
|
77
68
|
}
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createForEach = void 0;
|
7
|
-
var
|
7
|
+
var _applyCallback = require("../../utils/applyCallback.js");
|
8
8
|
var _array = require("../../utils/array.js");
|
9
9
|
var _factory = require("../../utils/factory.js");
|
10
10
|
var name = 'forEach';
|
@@ -43,15 +43,13 @@ var createForEach = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fun
|
|
43
43
|
});
|
44
44
|
|
45
45
|
/**
|
46
|
-
* forEach for a
|
46
|
+
* forEach for a multidimensional array
|
47
47
|
* @param {Array} array
|
48
48
|
* @param {Function} callback
|
49
49
|
* @private
|
50
50
|
*/
|
51
51
|
exports.createForEach = createForEach;
|
52
52
|
function _forEach(array, callback) {
|
53
|
-
// figure out what number of arguments the callback function expects
|
54
|
-
var args = (0, _function.maxArgumentCount)(callback);
|
55
53
|
var recurse = function recurse(value, index) {
|
56
54
|
if (Array.isArray(value)) {
|
57
55
|
(0, _array.forEach)(value, function (child, i) {
|
@@ -60,14 +58,7 @@ function _forEach(array, callback) {
|
|
60
58
|
});
|
61
59
|
} else {
|
62
60
|
// invoke the callback function with the right number of arguments
|
63
|
-
|
64
|
-
callback(value);
|
65
|
-
} else if (args === 2) {
|
66
|
-
callback(value, index);
|
67
|
-
} else {
|
68
|
-
// 3 or -1
|
69
|
-
callback(value, index, array);
|
70
|
-
}
|
61
|
+
return (0, _applyCallback.applyCallback)(callback, value, index, array, 'forEach');
|
71
62
|
}
|
72
63
|
};
|
73
64
|
recurse(array, []);
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.createMap = void 0;
|
7
|
-
var
|
7
|
+
var _applyCallback = require("../../utils/applyCallback.js");
|
8
8
|
var _factory = require("../../utils/factory.js");
|
9
9
|
var name = 'map';
|
10
10
|
var dependencies = ['typed'];
|
@@ -31,14 +31,9 @@ var createMap = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functio
|
|
31
31
|
* return value * value
|
32
32
|
* }) // returns [1, 4, 9]
|
33
33
|
*
|
34
|
-
* // The
|
35
|
-
*
|
36
|
-
* //
|
37
|
-
* // [This happens because `format` _can_ take a second argument,
|
38
|
-
* // but its semantics don't match that of the 2nd argument `map` provides]
|
39
|
-
*
|
40
|
-
* // To avoid this error, use a function that takes exactly the
|
41
|
-
* // desired arguments:
|
34
|
+
* // The callback is normally called with three arguments:
|
35
|
+
* // callback(value, index, Array)
|
36
|
+
* // If you want to call with only one argument, use:
|
42
37
|
* math.map([1, 2, 3], x => math.format(x)) // returns ['1', '2', '3']
|
43
38
|
*
|
44
39
|
* See also:
|
@@ -68,8 +63,6 @@ var createMap = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functio
|
|
68
63
|
*/
|
69
64
|
exports.createMap = createMap;
|
70
65
|
function _map(array, callback) {
|
71
|
-
// figure out what number of arguments the callback function expects
|
72
|
-
var args = (0, _function.maxArgumentCount)(callback);
|
73
66
|
var recurse = function recurse(value, index) {
|
74
67
|
if (Array.isArray(value)) {
|
75
68
|
return value.map(function (child, i) {
|
@@ -77,33 +70,8 @@ function _map(array, callback) {
|
|
77
70
|
return recurse(child, index.concat(i));
|
78
71
|
});
|
79
72
|
} else {
|
80
|
-
|
81
|
-
|
82
|
-
if (args === 1) {
|
83
|
-
return callback(value);
|
84
|
-
} else if (args === 2) {
|
85
|
-
return callback(value, index);
|
86
|
-
} else {
|
87
|
-
// 3 or -1
|
88
|
-
return callback(value, index, array);
|
89
|
-
}
|
90
|
-
} catch (err) {
|
91
|
-
// But maybe the arguments still weren't right
|
92
|
-
if (err instanceof TypeError && 'data' in err && err.data.category === 'wrongType') {
|
93
|
-
var newmsg = "map attempted to call '".concat(err.data.fn, "(").concat(value);
|
94
|
-
var indexString = JSON.stringify(index);
|
95
|
-
if (args === 2) {
|
96
|
-
newmsg += ',' + indexString;
|
97
|
-
} else if (args !== 1) {
|
98
|
-
newmsg += ",".concat(indexString, ",").concat(array);
|
99
|
-
}
|
100
|
-
newmsg += ")' but argument ".concat(err.data.index + 1, " of type ");
|
101
|
-
newmsg += "".concat(err.data.actual, " does not match expected type ");
|
102
|
-
newmsg += err.data.expected.join(' or ');
|
103
|
-
throw new TypeError(newmsg);
|
104
|
-
}
|
105
|
-
throw err;
|
106
|
-
}
|
73
|
+
// invoke the callback function with the right number of arguments
|
74
|
+
return (0, _applyCallback.applyCallback)(callback, value, index, array, 'map');
|
107
75
|
}
|
108
76
|
};
|
109
77
|
return recurse(array, []);
|
@@ -7,7 +7,7 @@ exports.createMatrixFromColumns = void 0;
|
|
7
7
|
var _factory = require("../../utils/factory.js");
|
8
8
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
9
9
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
11
11
|
var name = 'matrixFromColumns';
|
12
12
|
var dependencies = ['typed', 'matrix', 'flatten', 'size'];
|
13
13
|
var createMatrixFromColumns = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
|
@@ -7,7 +7,7 @@ exports.createMatrixFromRows = void 0;
|
|
7
7
|
var _factory = require("../../utils/factory.js");
|
8
8
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
9
9
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
11
11
|
var name = 'matrixFromRows';
|
12
12
|
var dependencies = ['typed', 'matrix', 'flatten', 'size'];
|
13
13
|
var createMatrixFromRows = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
|
package/lib/cjs/header.js
CHANGED
@@ -6,8 +6,8 @@
|
|
6
6
|
* It features real and complex numbers, units, matrices, a large set of
|
7
7
|
* mathematical functions, and a flexible expression parser.
|
8
8
|
*
|
9
|
-
* @version 11.
|
10
|
-
* @date 2023-
|
9
|
+
* @version 11.8.1
|
10
|
+
* @date 2023-06-13
|
11
11
|
*
|
12
12
|
* @license
|
13
13
|
* Copyright (C) 2013-2023 Jos de Jong <wjosdejong@gmail.com>
|
@@ -67,6 +67,13 @@ var createBignumber = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
|
|
67
67
|
// we assume a BigNumber is immutable
|
68
68
|
return x;
|
69
69
|
},
|
70
|
+
Unit: typed.referToSelf(function (self) {
|
71
|
+
return function (x) {
|
72
|
+
var clone = x.clone();
|
73
|
+
clone.value = self(x.value);
|
74
|
+
return clone;
|
75
|
+
};
|
76
|
+
}),
|
70
77
|
Fraction: function Fraction(x) {
|
71
78
|
return new BigNumber(x.n).div(x.d).times(x.s);
|
72
79
|
},
|
@@ -43,7 +43,7 @@ var createFraction = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fu
|
|
43
43
|
*
|
44
44
|
* bignumber, number, string, unit
|
45
45
|
*
|
46
|
-
* @param {number | string | Fraction | BigNumber | Array | Matrix} [args]
|
46
|
+
* @param {number | string | Fraction | BigNumber | Unit | Array | Matrix} [args]
|
47
47
|
* Arguments specifying the value, or numerator and denominator of
|
48
48
|
* the fraction
|
49
49
|
* @return {Fraction | Array | Matrix} Returns a fraction
|
@@ -71,6 +71,13 @@ var createFraction = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fu
|
|
71
71
|
return x; // fractions are immutable
|
72
72
|
},
|
73
73
|
|
74
|
+
Unit: typed.referToSelf(function (self) {
|
75
|
+
return function (x) {
|
76
|
+
var clone = x.clone();
|
77
|
+
clone.value = self(x.value);
|
78
|
+
return clone;
|
79
|
+
};
|
80
|
+
}),
|
74
81
|
Object: function Object(x) {
|
75
82
|
return new Fraction(x);
|
76
83
|
},
|
@@ -16,7 +16,7 @@ var _factory = require("../../utils/factory.js");
|
|
16
16
|
var _function = require("../../utils/function.js");
|
17
17
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
18
18
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
19
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++)
|
19
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
20
20
|
var name = 'DenseMatrix';
|
21
21
|
var dependencies = ['Matrix'];
|
22
22
|
var createDenseMatrixClass = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
|
@@ -600,51 +600,47 @@ var createDenseMatrixClass = /* #__PURE__ */(0, _factory.factory)(name, dependen
|
|
600
600
|
DenseMatrix.prototype[Symbol.iterator] = /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
601
601
|
var recurse;
|
602
602
|
return _regenerator["default"].wrap(function _callee$(_context2) {
|
603
|
-
while (1) {
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
_context.next = 9;
|
614
|
-
break;
|
615
|
-
}
|
616
|
-
i = 0;
|
617
|
-
case 2:
|
618
|
-
if (!(i < value.length)) {
|
619
|
-
_context.next = 7;
|
620
|
-
break;
|
621
|
-
}
|
622
|
-
return _context.delegateYield(recurse(value[i], index.concat(i)), "t0", 4);
|
623
|
-
case 4:
|
624
|
-
i++;
|
625
|
-
_context.next = 2;
|
626
|
-
break;
|
627
|
-
case 7:
|
628
|
-
_context.next = 11;
|
629
|
-
break;
|
630
|
-
case 9:
|
631
|
-
_context.next = 11;
|
632
|
-
return {
|
633
|
-
value: value,
|
634
|
-
index: index
|
635
|
-
};
|
636
|
-
case 11:
|
637
|
-
case "end":
|
638
|
-
return _context.stop();
|
603
|
+
while (1) switch (_context2.prev = _context2.next) {
|
604
|
+
case 0:
|
605
|
+
recurse = /*#__PURE__*/_regenerator["default"].mark(function recurse(value, index) {
|
606
|
+
var i;
|
607
|
+
return _regenerator["default"].wrap(function recurse$(_context) {
|
608
|
+
while (1) switch (_context.prev = _context.next) {
|
609
|
+
case 0:
|
610
|
+
if (!(0, _is.isArray)(value)) {
|
611
|
+
_context.next = 9;
|
612
|
+
break;
|
639
613
|
}
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
614
|
+
i = 0;
|
615
|
+
case 2:
|
616
|
+
if (!(i < value.length)) {
|
617
|
+
_context.next = 7;
|
618
|
+
break;
|
619
|
+
}
|
620
|
+
return _context.delegateYield(recurse(value[i], index.concat(i)), "t0", 4);
|
621
|
+
case 4:
|
622
|
+
i++;
|
623
|
+
_context.next = 2;
|
624
|
+
break;
|
625
|
+
case 7:
|
626
|
+
_context.next = 11;
|
627
|
+
break;
|
628
|
+
case 9:
|
629
|
+
_context.next = 11;
|
630
|
+
return {
|
631
|
+
value: value,
|
632
|
+
index: index
|
633
|
+
};
|
634
|
+
case 11:
|
635
|
+
case "end":
|
636
|
+
return _context.stop();
|
637
|
+
}
|
638
|
+
}, recurse);
|
639
|
+
});
|
640
|
+
return _context2.delegateYield(recurse(this._data, []), "t0", 2);
|
641
|
+
case 2:
|
642
|
+
case "end":
|
643
|
+
return _context2.stop();
|
648
644
|
}
|
649
645
|
}, _callee, this);
|
650
646
|
});
|
@@ -1028,49 +1028,47 @@ var createSparseMatrixClass = /* #__PURE__ */(0, _factory.factory)(name, depende
|
|
1028
1028
|
SparseMatrix.prototype[Symbol.iterator] = /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
1029
1029
|
var columns, j, k0, k1, k, i;
|
1030
1030
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
1031
|
-
while (1) {
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
_context.next = 2;
|
1036
|
-
break;
|
1037
|
-
}
|
1038
|
-
throw new Error('Cannot iterate a Pattern only matrix');
|
1039
|
-
case 2:
|
1040
|
-
columns = this._size[1];
|
1041
|
-
j = 0;
|
1042
|
-
case 4:
|
1043
|
-
if (!(j < columns)) {
|
1044
|
-
_context.next = 18;
|
1045
|
-
break;
|
1046
|
-
}
|
1047
|
-
k0 = this._ptr[j];
|
1048
|
-
k1 = this._ptr[j + 1];
|
1049
|
-
k = k0;
|
1050
|
-
case 8:
|
1051
|
-
if (!(k < k1)) {
|
1052
|
-
_context.next = 15;
|
1053
|
-
break;
|
1054
|
-
}
|
1055
|
-
// row index
|
1056
|
-
i = this._index[k];
|
1057
|
-
_context.next = 12;
|
1058
|
-
return {
|
1059
|
-
value: this._values[k],
|
1060
|
-
index: [i, j]
|
1061
|
-
};
|
1062
|
-
case 12:
|
1063
|
-
k++;
|
1064
|
-
_context.next = 8;
|
1031
|
+
while (1) switch (_context.prev = _context.next) {
|
1032
|
+
case 0:
|
1033
|
+
if (this._values) {
|
1034
|
+
_context.next = 2;
|
1065
1035
|
break;
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1036
|
+
}
|
1037
|
+
throw new Error('Cannot iterate a Pattern only matrix');
|
1038
|
+
case 2:
|
1039
|
+
columns = this._size[1];
|
1040
|
+
j = 0;
|
1041
|
+
case 4:
|
1042
|
+
if (!(j < columns)) {
|
1043
|
+
_context.next = 18;
|
1069
1044
|
break;
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1045
|
+
}
|
1046
|
+
k0 = this._ptr[j];
|
1047
|
+
k1 = this._ptr[j + 1];
|
1048
|
+
k = k0;
|
1049
|
+
case 8:
|
1050
|
+
if (!(k < k1)) {
|
1051
|
+
_context.next = 15;
|
1052
|
+
break;
|
1053
|
+
}
|
1054
|
+
// row index
|
1055
|
+
i = this._index[k];
|
1056
|
+
_context.next = 12;
|
1057
|
+
return {
|
1058
|
+
value: this._values[k],
|
1059
|
+
index: [i, j]
|
1060
|
+
};
|
1061
|
+
case 12:
|
1062
|
+
k++;
|
1063
|
+
_context.next = 8;
|
1064
|
+
break;
|
1065
|
+
case 15:
|
1066
|
+
j++;
|
1067
|
+
_context.next = 4;
|
1068
|
+
break;
|
1069
|
+
case 18:
|
1070
|
+
case "end":
|
1071
|
+
return _context.stop();
|
1074
1072
|
}
|
1075
1073
|
}, _callee, this);
|
1076
1074
|
});
|
package/lib/cjs/type/number.js
CHANGED
@@ -125,9 +125,13 @@ var createNumber = /* #__PURE__ */(0, _factory.factory)(name, dependencies, func
|
|
125
125
|
Fraction: function Fraction(x) {
|
126
126
|
return x.valueOf();
|
127
127
|
},
|
128
|
-
Unit: function
|
129
|
-
|
130
|
-
|
128
|
+
Unit: typed.referToSelf(function (self) {
|
129
|
+
return function (x) {
|
130
|
+
var clone = x.clone();
|
131
|
+
clone.value = self(x.value);
|
132
|
+
return clone;
|
133
|
+
};
|
134
|
+
}),
|
131
135
|
"null": function _null(x) {
|
132
136
|
return 0;
|
133
137
|
},
|
@@ -3274,6 +3274,8 @@ var createUnitClass = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
|
|
3274
3274
|
watts: 'watt',
|
3275
3275
|
joules: 'joule',
|
3276
3276
|
amperes: 'ampere',
|
3277
|
+
amps: 'ampere',
|
3278
|
+
amp: 'ampere',
|
3277
3279
|
coulombs: 'coulomb',
|
3278
3280
|
volts: 'volt',
|
3279
3281
|
ohms: 'ohm',
|