mathjs 10.1.1 → 10.2.0
Sign up to get free protection for your applications and to get access to all the features.
- package/HISTORY.md +17 -0
- package/docs/expressions/algebra.md +27 -0
- package/docs/reference/functions/abs.md +6 -0
- package/docs/reference/functions/acos.md +6 -0
- package/docs/reference/functions/acosh.md +6 -0
- package/docs/reference/functions/acot.md +6 -0
- package/docs/reference/functions/acoth.md +6 -0
- package/docs/reference/functions/acsc.md +6 -0
- package/docs/reference/functions/acsch.md +6 -0
- package/docs/reference/functions/add.md +6 -0
- package/docs/reference/functions/and.md +6 -0
- package/docs/reference/functions/apply.md +6 -0
- package/docs/reference/functions/arg.md +6 -0
- package/docs/reference/functions/asec.md +6 -0
- package/docs/reference/functions/asech.md +6 -0
- package/docs/reference/functions/asin.md +6 -0
- package/docs/reference/functions/asinh.md +6 -0
- package/docs/reference/functions/atan.md +6 -0
- package/docs/reference/functions/atan2.md +6 -0
- package/docs/reference/functions/atanh.md +6 -0
- package/docs/reference/functions/bellNumbers.md +6 -0
- package/docs/reference/functions/bin.md +6 -0
- package/docs/reference/functions/bitAnd.md +6 -0
- package/docs/reference/functions/bitNot.md +6 -0
- package/docs/reference/functions/bitOr.md +6 -0
- package/docs/reference/functions/bitXor.md +6 -0
- package/docs/reference/functions/catalan.md +6 -0
- package/docs/reference/functions/cbrt.md +6 -0
- package/docs/reference/functions/ceil.md +6 -0
- package/docs/reference/functions/clone.md +6 -0
- package/docs/reference/functions/column.md +6 -0
- package/docs/reference/functions/combinations.md +6 -0
- package/docs/reference/functions/combinationsWithRep.md +6 -0
- package/docs/reference/functions/compare.md +6 -0
- package/docs/reference/functions/compareNatural.md +6 -0
- package/docs/reference/functions/compareText.md +6 -0
- package/docs/reference/functions/compile.md +6 -0
- package/docs/reference/functions/composition.md +6 -0
- package/docs/reference/functions/concat.md +6 -0
- package/docs/reference/functions/conj.md +6 -0
- package/docs/reference/functions/cos.md +6 -0
- package/docs/reference/functions/cosh.md +6 -0
- package/docs/reference/functions/cot.md +6 -0
- package/docs/reference/functions/coth.md +6 -0
- package/docs/reference/functions/count.md +6 -0
- package/docs/reference/functions/cross.md +6 -0
- package/docs/reference/functions/csc.md +6 -0
- package/docs/reference/functions/csch.md +6 -0
- package/docs/reference/functions/ctranspose.md +6 -0
- package/docs/reference/functions/cube.md +6 -0
- package/docs/reference/functions/deepEqual.md +6 -0
- package/docs/reference/functions/derivative.md +6 -0
- package/docs/reference/functions/det.md +6 -0
- package/docs/reference/functions/diag.md +6 -0
- package/docs/reference/functions/diff.md +6 -0
- package/docs/reference/functions/distance.md +6 -0
- package/docs/reference/functions/divide.md +6 -0
- package/docs/reference/functions/dot.md +6 -0
- package/docs/reference/functions/dotDivide.md +6 -0
- package/docs/reference/functions/dotMultiply.md +6 -0
- package/docs/reference/functions/dotPow.md +6 -0
- package/docs/reference/functions/eigs.md +6 -0
- package/docs/reference/functions/equal.md +6 -0
- package/docs/reference/functions/equalText.md +6 -0
- package/docs/reference/functions/erf.md +6 -0
- package/docs/reference/functions/evaluate.md +6 -0
- package/docs/reference/functions/exp.md +6 -0
- package/docs/reference/functions/expm.md +6 -0
- package/docs/reference/functions/expm1.md +6 -0
- package/docs/reference/functions/factorial.md +6 -0
- package/docs/reference/functions/filter.md +6 -0
- package/docs/reference/functions/fix.md +6 -0
- package/docs/reference/functions/flatten.md +6 -0
- package/docs/reference/functions/floor.md +6 -0
- package/docs/reference/functions/forEach.md +6 -0
- package/docs/reference/functions/format.md +6 -0
- package/docs/reference/functions/gamma.md +6 -0
- package/docs/reference/functions/gcd.md +6 -0
- package/docs/reference/functions/getMatrixDataType.md +6 -0
- package/docs/reference/functions/hasNumericValue.md +6 -0
- package/docs/reference/functions/help.md +6 -0
- package/docs/reference/functions/hex.md +6 -0
- package/docs/reference/functions/hypot.md +6 -0
- package/docs/reference/functions/identity.md +6 -0
- package/docs/reference/functions/im.md +6 -0
- package/docs/reference/functions/intersect.md +6 -0
- package/docs/reference/functions/inv.md +6 -0
- package/docs/reference/functions/invmod.md +6 -0
- package/docs/reference/functions/isInteger.md +6 -0
- package/docs/reference/functions/isNaN.md +6 -0
- package/docs/reference/functions/isNegative.md +6 -0
- package/docs/reference/functions/isNumeric.md +6 -0
- package/docs/reference/functions/isPositive.md +6 -0
- package/docs/reference/functions/isPrime.md +6 -0
- package/docs/reference/functions/isZero.md +6 -0
- package/docs/reference/functions/kldivergence.md +6 -0
- package/docs/reference/functions/kron.md +6 -0
- package/docs/reference/functions/larger.md +6 -0
- package/docs/reference/functions/largerEq.md +6 -0
- package/docs/reference/functions/lcm.md +6 -0
- package/docs/reference/functions/leafCount.md +52 -0
- package/docs/reference/functions/leftShift.md +6 -0
- package/docs/reference/functions/log.md +6 -0
- package/docs/reference/functions/log10.md +6 -0
- package/docs/reference/functions/log1p.md +6 -0
- package/docs/reference/functions/log2.md +6 -0
- package/docs/reference/functions/lsolve.md +6 -0
- package/docs/reference/functions/lsolveAll.md +6 -0
- package/docs/reference/functions/lup.md +6 -0
- package/docs/reference/functions/lusolve.md +6 -0
- package/docs/reference/functions/mad.md +6 -0
- package/docs/reference/functions/map.md +6 -0
- package/docs/reference/functions/matrixFromColumns.md +6 -0
- package/docs/reference/functions/matrixFromFunction.md +6 -0
- package/docs/reference/functions/matrixFromRows.md +6 -0
- package/docs/reference/functions/max.md +6 -0
- package/docs/reference/functions/mean.md +6 -0
- package/docs/reference/functions/median.md +6 -0
- package/docs/reference/functions/min.md +6 -0
- package/docs/reference/functions/mod.md +6 -0
- package/docs/reference/functions/mode.md +6 -0
- package/docs/reference/functions/multinomial.md +6 -0
- package/docs/reference/functions/multiply.md +6 -0
- package/docs/reference/functions/norm.md +6 -0
- package/docs/reference/functions/not.md +6 -0
- package/docs/reference/functions/nthRoot.md +6 -0
- package/docs/reference/functions/nthRoots.md +6 -0
- package/docs/reference/functions/numeric.md +6 -0
- package/docs/reference/functions/oct.md +6 -0
- package/docs/reference/functions/ones.md +6 -0
- package/docs/reference/functions/or.md +6 -0
- package/docs/reference/functions/parser.md +6 -0
- package/docs/reference/functions/partitionSelect.md +6 -0
- package/docs/reference/functions/permutations.md +6 -0
- package/docs/reference/functions/pickRandom.md +6 -0
- package/docs/reference/functions/pow.md +6 -0
- package/docs/reference/functions/print.md +6 -0
- package/docs/reference/functions/prod.md +6 -0
- package/docs/reference/functions/qr.md +6 -0
- package/docs/reference/functions/quantileSeq.md +6 -0
- package/docs/reference/functions/random.md +6 -0
- package/docs/reference/functions/randomInt.md +6 -0
- package/docs/reference/functions/range.md +6 -0
- package/docs/reference/functions/rationalize.md +7 -1
- package/docs/reference/functions/re.md +6 -0
- package/docs/reference/functions/reshape.md +7 -0
- package/docs/reference/functions/resize.md +6 -0
- package/docs/reference/functions/resolve.md +46 -0
- package/docs/reference/functions/rightArithShift.md +6 -0
- package/docs/reference/functions/rightLogShift.md +6 -0
- package/docs/reference/functions/rotate.md +6 -0
- package/docs/reference/functions/rotationMatrix.md +6 -0
- package/docs/reference/functions/round.md +6 -0
- package/docs/reference/functions/row.md +6 -0
- package/docs/reference/functions/sec.md +6 -0
- package/docs/reference/functions/sech.md +6 -0
- package/docs/reference/functions/setCartesian.md +6 -0
- package/docs/reference/functions/setDifference.md +6 -0
- package/docs/reference/functions/setDistinct.md +6 -0
- package/docs/reference/functions/setIntersect.md +6 -0
- package/docs/reference/functions/setIsSubset.md +6 -0
- package/docs/reference/functions/setMultiplicity.md +6 -0
- package/docs/reference/functions/setPowerset.md +6 -0
- package/docs/reference/functions/setSize.md +6 -0
- package/docs/reference/functions/setSymDifference.md +6 -0
- package/docs/reference/functions/setUnion.md +6 -0
- package/docs/reference/functions/sign.md +6 -0
- package/docs/reference/functions/simplify.md +43 -6
- package/docs/reference/functions/simplifyCore.md +50 -0
- package/docs/reference/functions/sin.md +6 -0
- package/docs/reference/functions/sinh.md +6 -0
- package/docs/reference/functions/size.md +6 -0
- package/docs/reference/functions/slu.md +6 -0
- package/docs/reference/functions/smaller.md +6 -0
- package/docs/reference/functions/smallerEq.md +6 -0
- package/docs/reference/functions/sort.md +6 -0
- package/docs/reference/functions/sqrt.md +6 -0
- package/docs/reference/functions/sqrtm.md +6 -0
- package/docs/reference/functions/square.md +6 -0
- package/docs/reference/functions/squeeze.md +6 -0
- package/docs/reference/functions/std.md +6 -0
- package/docs/reference/functions/stirlingS2.md +6 -0
- package/docs/reference/functions/subset.md +6 -0
- package/docs/reference/functions/subtract.md +6 -0
- package/docs/reference/functions/sum.md +6 -0
- package/docs/reference/functions/tan.md +6 -0
- package/docs/reference/functions/tanh.md +6 -0
- package/docs/reference/functions/to.md +6 -0
- package/docs/reference/functions/trace.md +6 -0
- package/docs/reference/functions/transpose.md +6 -0
- package/docs/reference/functions/typeOf.md +6 -0
- package/docs/reference/functions/unaryMinus.md +6 -0
- package/docs/reference/functions/unaryPlus.md +6 -0
- package/docs/reference/functions/unequal.md +6 -0
- package/docs/reference/functions/usolve.md +6 -0
- package/docs/reference/functions/usolveAll.md +6 -0
- package/docs/reference/functions/variance.md +6 -0
- package/docs/reference/functions/xgcd.md +6 -0
- package/docs/reference/functions/xor.md +6 -0
- package/docs/reference/functions/zeros.md +6 -0
- package/docs/reference/functions.md +3 -0
- package/lib/browser/math.js +6 -6
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/core/create.js +4 -4
- package/lib/cjs/core/function/import.js +3 -3
- package/lib/cjs/core/function/typed.js +2 -2
- package/lib/cjs/defaultInstance.js +3 -3
- package/lib/cjs/entry/allFactoriesAny.js +1 -1
- package/lib/cjs/entry/allFactoriesNumber.js +1 -1
- package/lib/cjs/entry/configReadonly.js +1 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesLeafCount.generated.js +23 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesRationalize.generated.js +3 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesResolve.generated.js +32 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSimplify.generated.js +6 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSimplifyCore.generated.js +65 -0
- package/lib/cjs/entry/dependenciesAny.generated.js +24 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesRationalize.generated.js +3 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesResolve.generated.js +32 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesSimplify.generated.js +6 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesSimplifyCore.generated.js +65 -0
- package/lib/cjs/entry/dependenciesNumber.generated.js +16 -0
- package/lib/cjs/entry/impureFunctionsAny.generated.js +67 -29
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +96 -64
- package/lib/cjs/entry/pureFunctionsAny.generated.js +53 -55
- package/lib/cjs/entry/pureFunctionsNumber.generated.js +46 -48
- package/lib/cjs/expression/Help.js +4 -0
- package/lib/cjs/expression/Parser.js +1 -1
- package/lib/cjs/expression/embeddedDocs/core/typed.js +1 -1
- package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +14 -5
- package/lib/cjs/expression/embeddedDocs/function/algebra/leafCount.js +15 -0
- package/lib/cjs/expression/embeddedDocs/function/algebra/resolve.js +16 -0
- package/lib/cjs/expression/embeddedDocs/function/algebra/simplify.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/algebra/simplifyCore.js +15 -0
- package/lib/cjs/expression/node/FunctionNode.js +7 -7
- package/lib/cjs/expression/node/IndexNode.js +1 -1
- package/lib/cjs/expression/node/Node.js +3 -3
- package/lib/cjs/expression/node/ObjectNode.js +1 -1
- package/lib/cjs/expression/node/utils/access.js +1 -1
- package/lib/cjs/expression/node/utils/assign.js +1 -1
- package/lib/cjs/expression/parse.js +13 -13
- package/lib/cjs/factoriesAny.js +24 -0
- package/lib/cjs/factoriesNumber.js +16 -0
- package/lib/cjs/function/algebra/decomposition/qr.js +1 -1
- package/lib/cjs/function/algebra/leafCount.js +66 -0
- package/lib/cjs/function/algebra/rationalize.js +24 -41
- package/lib/cjs/function/algebra/resolve.js +106 -0
- package/lib/cjs/function/algebra/simplify/simplifyConstant.js +5 -5
- package/lib/cjs/function/algebra/simplify/util.js +171 -33
- package/lib/cjs/function/algebra/simplify.js +554 -207
- package/lib/cjs/function/algebra/{simplify/simplifyCore.js → simplifyCore.js} +67 -43
- package/lib/cjs/function/algebra/solver/lsolveAll.js +2 -2
- package/lib/cjs/function/algebra/solver/usolveAll.js +2 -2
- package/lib/cjs/function/arithmetic/ceil.js +3 -3
- package/lib/cjs/function/arithmetic/floor.js +3 -3
- package/lib/cjs/function/arithmetic/invmod.js +1 -1
- package/lib/cjs/function/arithmetic/norm.js +1 -1
- package/lib/cjs/function/arithmetic/round.js +1 -1
- package/lib/cjs/function/matrix/eigs/complexEigs.js +5 -5
- package/lib/cjs/function/matrix/matrixFromColumns.js +1 -1
- package/lib/cjs/function/matrix/matrixFromRows.js +1 -1
- package/lib/cjs/function/probability/util/seededRNG.js +2 -2
- package/lib/cjs/function/relational/compareNatural.js +6 -6
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/plain/bignumber/index.js +1 -1
- package/lib/cjs/plain/number/combinations.js +18 -6
- package/lib/cjs/type/bignumber/BigNumber.js +2 -2
- package/lib/cjs/type/bignumber/function/bignumber.js +1 -1
- package/lib/cjs/type/boolean.js +2 -2
- package/lib/cjs/type/complex/Complex.js +14 -14
- package/lib/cjs/type/complex/function/complex.js +1 -1
- package/lib/cjs/type/fraction/Fraction.js +6 -6
- package/lib/cjs/type/fraction/function/fraction.js +1 -1
- package/lib/cjs/type/matrix/DenseMatrix.js +5 -5
- package/lib/cjs/type/matrix/SparseMatrix.js +2 -2
- package/lib/cjs/type/number.js +1 -1
- package/lib/cjs/type/string.js +2 -2
- package/lib/cjs/type/unit/Unit.js +8 -8
- package/lib/cjs/utils/customs.js +2 -2
- package/lib/cjs/utils/emitter.js +1 -1
- package/lib/cjs/utils/function.js +2 -2
- package/lib/cjs/utils/is.js +6 -6
- package/lib/cjs/utils/latex.js +3 -3
- package/lib/cjs/utils/lruQueue.js +1 -1
- package/lib/cjs/utils/map.js +3 -3
- package/lib/cjs/utils/object.js +2 -2
- package/lib/cjs/utils/snapshot.js +7 -7
- package/lib/cjs/utils/string.js +2 -2
- package/lib/cjs/version.js +1 -1
- package/lib/esm/entry/dependenciesAny/dependenciesLeafCount.generated.js +12 -0
- package/lib/esm/entry/dependenciesAny/dependenciesRationalize.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesResolve.generated.js +18 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSimplify.generated.js +4 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSimplifyCore.generated.js +40 -0
- package/lib/esm/entry/dependenciesAny.generated.js +3 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesRationalize.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesResolve.generated.js +18 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesSimplify.generated.js +4 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesSimplifyCore.generated.js +40 -0
- package/lib/esm/entry/dependenciesNumber.generated.js +2 -0
- package/lib/esm/entry/impureFunctionsAny.generated.js +57 -22
- package/lib/esm/entry/impureFunctionsNumber.generated.js +83 -53
- package/lib/esm/entry/pureFunctionsAny.generated.js +42 -42
- package/lib/esm/entry/pureFunctionsNumber.generated.js +32 -32
- package/lib/esm/expression/Help.js +4 -0
- package/lib/esm/expression/embeddedDocs/core/typed.js +1 -1
- package/lib/esm/expression/embeddedDocs/embeddedDocs.js +6 -0
- package/lib/esm/expression/embeddedDocs/function/algebra/leafCount.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/algebra/resolve.js +9 -0
- package/lib/esm/expression/embeddedDocs/function/algebra/simplify.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/algebra/simplifyCore.js +8 -0
- package/lib/esm/factoriesAny.js +3 -0
- package/lib/esm/factoriesNumber.js +2 -0
- package/lib/esm/function/algebra/leafCount.js +59 -0
- package/lib/esm/function/algebra/rationalize.js +24 -40
- package/lib/esm/function/algebra/resolve.js +95 -0
- package/lib/esm/function/algebra/simplify/simplifyConstant.js +3 -3
- package/lib/esm/function/algebra/simplify/util.js +170 -34
- package/lib/esm/function/algebra/simplify.js +549 -202
- package/lib/esm/function/algebra/{simplify/simplifyCore.js → simplifyCore.js} +60 -44
- package/lib/esm/plain/number/combinations.js +18 -6
- package/lib/esm/version.js +1 -1
- package/package.json +15 -10
- package/types/index.d.ts +44 -2
- package/lib/cjs/function/algebra/simplify/resolve.js +0 -76
- package/lib/esm/function/algebra/simplify/resolve.js +0 -67
@@ -5,12 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.createSimplifyCore = void 0;
|
7
7
|
|
8
|
-
var _is = require("
|
8
|
+
var _is = require("../../utils/is.js");
|
9
9
|
|
10
|
-
var
|
10
|
+
var _util = require("./simplify/util.js");
|
11
|
+
|
12
|
+
var _factory = require("../../utils/factory.js");
|
11
13
|
|
12
14
|
var name = 'simplifyCore';
|
13
|
-
var dependencies = ['equal', 'isZero', 'add', 'subtract', 'multiply', 'divide', 'pow', 'AccessorNode', 'ArrayNode', 'ConstantNode', 'FunctionNode', 'IndexNode', 'ObjectNode', 'OperatorNode', 'ParenthesisNode'];
|
15
|
+
var dependencies = ['equal', 'isZero', 'add', 'subtract', 'multiply', 'divide', 'pow', 'AccessorNode', 'ArrayNode', 'ConstantNode', 'FunctionNode', 'IndexNode', 'ObjectNode', 'OperatorNode', 'ParenthesisNode', 'SymbolNode'];
|
14
16
|
var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
|
15
17
|
var equal = _ref.equal,
|
16
18
|
isZero = _ref.isZero,
|
@@ -26,15 +28,18 @@ var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies
|
|
26
28
|
IndexNode = _ref.IndexNode,
|
27
29
|
ObjectNode = _ref.ObjectNode,
|
28
30
|
OperatorNode = _ref.OperatorNode,
|
29
|
-
ParenthesisNode = _ref.ParenthesisNode
|
31
|
+
ParenthesisNode = _ref.ParenthesisNode,
|
32
|
+
SymbolNode = _ref.SymbolNode;
|
30
33
|
var node0 = new ConstantNode(0);
|
31
34
|
var node1 = new ConstantNode(1);
|
32
35
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
}
|
36
|
+
var _createUtil = (0, _util.createUtil)({
|
37
|
+
FunctionNode: FunctionNode,
|
38
|
+
OperatorNode: OperatorNode,
|
39
|
+
SymbolNode: SymbolNode
|
40
|
+
}),
|
41
|
+
hasProperty = _createUtil.hasProperty,
|
42
|
+
isCommutative = _createUtil.isCommutative;
|
38
43
|
/**
|
39
44
|
* simplifyCore() performs single pass simplification suitable for
|
40
45
|
* applications requiring ultimate performance. In contrast, simplify()
|
@@ -43,31 +48,54 @@ var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies
|
|
43
48
|
*
|
44
49
|
* Syntax:
|
45
50
|
*
|
46
|
-
*
|
51
|
+
* simplifyCore(expr)
|
47
52
|
*
|
48
53
|
* Examples:
|
49
54
|
*
|
50
55
|
* const f = math.parse('2 * 1 * x ^ (2 - 1)')
|
51
|
-
* math.
|
52
|
-
* math.simplify('2 * 1 * x ^ (2 - 1)', [math.
|
56
|
+
* math.simpifyCore(f) // Node {2 * x}
|
57
|
+
* math.simplify('2 * 1 * x ^ (2 - 1)', [math.simplifyCore]) // Node {2 * x}
|
53
58
|
*
|
54
59
|
* See also:
|
55
60
|
*
|
56
|
-
* derivative
|
61
|
+
* simplify, resolve, derivative
|
57
62
|
*
|
58
63
|
* @param {Node} node
|
59
64
|
* The expression to be simplified
|
65
|
+
* @param {Object} options
|
66
|
+
* Simplification options, as per simplify()
|
67
|
+
* @return {Node} Returns expression with basic simplifications applied
|
60
68
|
*/
|
61
69
|
|
62
70
|
|
63
|
-
function simplifyCore(node) {
|
64
|
-
|
65
|
-
var a0 = simplifyCore(node.args[0]);
|
71
|
+
function simplifyCore(node, options) {
|
72
|
+
var context = options ? options.context : undefined;
|
66
73
|
|
67
|
-
|
68
|
-
|
69
|
-
|
74
|
+
if (hasProperty(node, 'trivial', context)) {
|
75
|
+
// This node does nothing if it has only one argument, so if so,
|
76
|
+
// return that argument simplified
|
77
|
+
if ((0, _is.isFunctionNode)(node) && node.args.length === 1) {
|
78
|
+
return simplifyCore(node.args[0], options);
|
79
|
+
} // For other node types, we try the generic methods
|
80
|
+
|
81
|
+
|
82
|
+
var simpChild = false;
|
83
|
+
var childCount = 0;
|
84
|
+
node.forEach(function (c) {
|
85
|
+
++childCount;
|
86
|
+
|
87
|
+
if (childCount === 1) {
|
88
|
+
simpChild = simplifyCore(c, options);
|
89
|
+
}
|
90
|
+
});
|
91
|
+
|
92
|
+
if (childCount === 1) {
|
93
|
+
return simpChild;
|
70
94
|
}
|
95
|
+
}
|
96
|
+
|
97
|
+
if ((0, _is.isOperatorNode)(node) && node.isUnary()) {
|
98
|
+
var a0 = simplifyCore(node.args[0], options);
|
71
99
|
|
72
100
|
if (node.op === '-') {
|
73
101
|
// unary minus
|
@@ -82,9 +110,9 @@ var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies
|
|
82
110
|
return new OperatorNode(node.op, node.fn, [a0]);
|
83
111
|
}
|
84
112
|
} else if ((0, _is.isOperatorNode)(node) && node.isBinary()) {
|
85
|
-
var _a = simplifyCore(node.args[0]);
|
113
|
+
var _a = simplifyCore(node.args[0], options);
|
86
114
|
|
87
|
-
var a1 = simplifyCore(node.args[1]);
|
115
|
+
var a1 = simplifyCore(node.args[1], options);
|
88
116
|
|
89
117
|
if (node.op === '+') {
|
90
118
|
if ((0, _is.isConstantNode)(_a)) {
|
@@ -120,7 +148,7 @@ var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies
|
|
120
148
|
}
|
121
149
|
|
122
150
|
if ((0, _is.isOperatorNode)(a1) && a1.isUnary() && a1.op === '-') {
|
123
|
-
return simplifyCore(new OperatorNode('+', 'add', [_a, a1.args[0]]));
|
151
|
+
return simplifyCore(new OperatorNode('+', 'add', [_a, a1.args[0]]), options);
|
124
152
|
}
|
125
153
|
|
126
154
|
return new OperatorNode(node.op, node.fn, [_a, a1]);
|
@@ -141,7 +169,7 @@ var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies
|
|
141
169
|
return node0;
|
142
170
|
} else if (equal(a1.value, 1)) {
|
143
171
|
return _a;
|
144
|
-
} else if ((0, _is.isOperatorNode)(_a) && _a.isBinary() && _a.op === node.op) {
|
172
|
+
} else if ((0, _is.isOperatorNode)(_a) && _a.isBinary() && _a.op === node.op && isCommutative(node, context)) {
|
145
173
|
var a00 = _a.args[0];
|
146
174
|
|
147
175
|
if ((0, _is.isConstantNode)(a00)) {
|
@@ -150,7 +178,11 @@ var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies
|
|
150
178
|
}
|
151
179
|
}
|
152
180
|
|
153
|
-
|
181
|
+
if (isCommutative(node, context)) {
|
182
|
+
return new OperatorNode(node.op, node.fn, [a1, _a], node.implicit); // constants on left
|
183
|
+
} else {
|
184
|
+
return new OperatorNode(node.op, node.fn, [_a, a1], node.implicit);
|
185
|
+
}
|
154
186
|
}
|
155
187
|
|
156
188
|
return new OperatorNode(node.op, node.fn, [_a, a1], node.implicit);
|
@@ -186,33 +218,25 @@ var createSimplifyCore = /* #__PURE__ */(0, _factory.factory)(name, dependencies
|
|
186
218
|
|
187
219
|
return new OperatorNode(node.op, node.fn, [_a, a1]);
|
188
220
|
}
|
189
|
-
} else if ((0, _is.isParenthesisNode)(node)) {
|
190
|
-
var c = simplifyCore(node.content);
|
191
|
-
|
192
|
-
if ((0, _is.isParenthesisNode)(c) || (0, _is.isSymbolNode)(c) || (0, _is.isConstantNode)(c)) {
|
193
|
-
return c;
|
194
|
-
}
|
195
|
-
|
196
|
-
return new ParenthesisNode(c);
|
197
221
|
} else if ((0, _is.isFunctionNode)(node)) {
|
198
|
-
return new FunctionNode(simplifyCore(node.fn),
|
222
|
+
return new FunctionNode(simplifyCore(node.fn), node.args.map(function (n) {
|
223
|
+
return simplifyCore(n, options);
|
224
|
+
}));
|
199
225
|
} else if ((0, _is.isArrayNode)(node)) {
|
200
|
-
return new ArrayNode(
|
226
|
+
return new ArrayNode(node.items.map(function (n) {
|
227
|
+
return simplifyCore(n, options);
|
228
|
+
}));
|
201
229
|
} else if ((0, _is.isAccessorNode)(node)) {
|
202
|
-
|
203
|
-
|
204
|
-
if ((0, _is.isParenthesisNode)(obj)) {
|
205
|
-
obj = obj.content;
|
206
|
-
}
|
207
|
-
|
208
|
-
return new AccessorNode(obj, simplifyCore(node.index));
|
230
|
+
return new AccessorNode(simplifyCore(node.object, options), simplifyCore(node.index, options));
|
209
231
|
} else if ((0, _is.isIndexNode)(node)) {
|
210
|
-
return new IndexNode(
|
232
|
+
return new IndexNode(node.dimensions.map(function (n) {
|
233
|
+
return simplifyCore(n, options);
|
234
|
+
}));
|
211
235
|
} else if ((0, _is.isObjectNode)(node)) {
|
212
236
|
var newProps = {};
|
213
237
|
|
214
238
|
for (var prop in node.properties) {
|
215
|
-
newProps[prop] = simplifyCore(node.properties[prop]);
|
239
|
+
newProps[prop] = simplifyCore(node.properties[prop], options);
|
216
240
|
}
|
217
241
|
|
218
242
|
return new ObjectNode(newProps);
|
@@ -107,7 +107,7 @@ var createLsolveAll = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
|
|
107
107
|
}
|
108
108
|
} else if (k === 0) {
|
109
109
|
// singular row, RHS is zero
|
110
|
-
var bNew = (0, _toConsumableArray2
|
110
|
+
var bNew = (0, _toConsumableArray2.default)(b);
|
111
111
|
bNew[i] = 1;
|
112
112
|
|
113
113
|
for (var _j = i + 1; _j < columns; _j++) {
|
@@ -187,7 +187,7 @@ var createLsolveAll = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
|
|
187
187
|
}
|
188
188
|
} else if (k === 0) {
|
189
189
|
// singular row, RHS is zero
|
190
|
-
var bNew = (0, _toConsumableArray2
|
190
|
+
var bNew = (0, _toConsumableArray2.default)(b);
|
191
191
|
bNew[i] = 1;
|
192
192
|
|
193
193
|
for (var _j3 = 0, _lastIndex2 = iIndices.length; _j3 < _lastIndex2; _j3++) {
|
@@ -107,7 +107,7 @@ var createUsolveAll = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
|
|
107
107
|
}
|
108
108
|
} else if (k === 0) {
|
109
109
|
// singular row, RHS is zero
|
110
|
-
var bNew = (0, _toConsumableArray2
|
110
|
+
var bNew = (0, _toConsumableArray2.default)(b);
|
111
111
|
bNew[i] = 1;
|
112
112
|
|
113
113
|
for (var _j = i - 1; _j >= 0; _j--) {
|
@@ -187,7 +187,7 @@ var createUsolveAll = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
|
|
187
187
|
}
|
188
188
|
} else if (k === 0) {
|
189
189
|
// singular row, RHS is zero
|
190
|
-
var bNew = (0, _toConsumableArray2
|
190
|
+
var bNew = (0, _toConsumableArray2.default)(b);
|
191
191
|
bNew[i] = 1; // loop upper triangular
|
192
192
|
|
193
193
|
for (var _j3 = 0, _lastIndex2 = iIndices.length; _j3 < _lastIndex2; _j3++) {
|
@@ -91,7 +91,7 @@ var createCeil = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functi
|
|
91
91
|
return round(x, n);
|
92
92
|
} else {
|
93
93
|
var _$split = "".concat(x, "e").split('e'),
|
94
|
-
_$split2 = (0, _slicedToArray2
|
94
|
+
_$split2 = (0, _slicedToArray2.default)(_$split, 2),
|
95
95
|
number = _$split2[0],
|
96
96
|
exponent = _$split2[1];
|
97
97
|
|
@@ -99,7 +99,7 @@ var createCeil = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functi
|
|
99
99
|
|
100
100
|
var _$split3 = "".concat(result, "e").split('e');
|
101
101
|
|
102
|
-
var _$split4 = (0, _slicedToArray2
|
102
|
+
var _$split4 = (0, _slicedToArray2.default)(_$split3, 2);
|
103
103
|
|
104
104
|
number = _$split4[0];
|
105
105
|
exponent = _$split4[1];
|
@@ -123,7 +123,7 @@ var createCeil = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functi
|
|
123
123
|
if ((0, _nearlyEqual.nearlyEqual)(x, round(x, n), config.epsilon)) {
|
124
124
|
return round(x, n);
|
125
125
|
} else {
|
126
|
-
return x.toDecimalPlaces(n.toNumber(), _decimal
|
126
|
+
return x.toDecimalPlaces(n.toNumber(), _decimal.default.ROUND_CEIL);
|
127
127
|
}
|
128
128
|
},
|
129
129
|
Fraction: function Fraction(x) {
|
@@ -88,7 +88,7 @@ var createFloor = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
88
88
|
return round(x, n);
|
89
89
|
} else {
|
90
90
|
var _$split = "".concat(x, "e").split('e'),
|
91
|
-
_$split2 = (0, _slicedToArray2
|
91
|
+
_$split2 = (0, _slicedToArray2.default)(_$split, 2),
|
92
92
|
number = _$split2[0],
|
93
93
|
exponent = _$split2[1];
|
94
94
|
|
@@ -96,7 +96,7 @@ var createFloor = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
96
96
|
|
97
97
|
var _$split3 = "".concat(result, "e").split('e');
|
98
98
|
|
99
|
-
var _$split4 = (0, _slicedToArray2
|
99
|
+
var _$split4 = (0, _slicedToArray2.default)(_$split3, 2);
|
100
100
|
|
101
101
|
number = _$split4[0];
|
102
102
|
exponent = _$split4[1];
|
@@ -120,7 +120,7 @@ var createFloor = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
120
120
|
if ((0, _nearlyEqual.nearlyEqual)(x, round(x, n), config.epsilon)) {
|
121
121
|
return round(x, n);
|
122
122
|
} else {
|
123
|
-
return x.toDecimalPlaces(n.toNumber(), _decimal
|
123
|
+
return x.toDecimalPlaces(n.toNumber(), _decimal.default.ROUND_FLOOR);
|
124
124
|
}
|
125
125
|
},
|
126
126
|
Fraction: function Fraction(x) {
|
@@ -60,7 +60,7 @@ var createInvmod = /* #__PURE__ */(0, _factory.factory)(name, dependencies, func
|
|
60
60
|
res = res.valueOf();
|
61
61
|
|
62
62
|
var _res = res,
|
63
|
-
_res2 = (0, _slicedToArray2
|
63
|
+
_res2 = (0, _slicedToArray2.default)(_res, 2),
|
64
64
|
gcd = _res2[0],
|
65
65
|
inv = _res2[1];
|
66
66
|
|
@@ -25,7 +25,7 @@ var _index = require("../../plain/number/index.js");
|
|
25
25
|
|
26
26
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
27
27
|
|
28
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2
|
28
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
29
29
|
|
30
30
|
var NO_INT = 'Number of decimals in function round must be an integer';
|
31
31
|
var name = 'round';
|
@@ -11,7 +11,7 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
11
11
|
|
12
12
|
var _object = require("../../../utils/object.js");
|
13
13
|
|
14
|
-
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
|
14
|
+
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; } } }; }
|
15
15
|
|
16
16
|
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); }
|
17
17
|
|
@@ -80,7 +80,7 @@ function createComplexEigs(_ref) {
|
|
80
80
|
|
81
81
|
if (findVectors) {
|
82
82
|
vectors = findEigenvectors(arr, N, C, values, prec, type);
|
83
|
-
vectors = matrixFromColumns.apply(void 0, (0, _toConsumableArray2
|
83
|
+
vectors = matrixFromColumns.apply(void 0, (0, _toConsumableArray2.default)(vectors));
|
84
84
|
}
|
85
85
|
|
86
86
|
return {
|
@@ -360,7 +360,7 @@ function createComplexEigs(_ref) {
|
|
360
360
|
} else if (n === 2 || smaller(abs(arr[n - 2][n - 3]), prec)) {
|
361
361
|
lastConvergenceBefore = 0;
|
362
362
|
var ll = eigenvalues2x2(arr[n - 2][n - 2], arr[n - 2][n - 1], arr[n - 1][n - 2], arr[n - 1][n - 1]);
|
363
|
-
lambdas.push.apply(lambdas, (0, _toConsumableArray2
|
363
|
+
lambdas.push.apply(lambdas, (0, _toConsumableArray2.default)(ll)); // keep track of transformations
|
364
364
|
|
365
365
|
if (findVectors) {
|
366
366
|
Sdiag.unshift(jordanBase2x2(arr[n - 2][n - 2], arr[n - 2][n - 1], arr[n - 1][n - 2], arr[n - 1][n - 1], ll[0], ll[1], prec, type));
|
@@ -488,7 +488,7 @@ function createComplexEigs(_ref) {
|
|
488
488
|
solutions.push(approxVec);
|
489
489
|
}
|
490
490
|
|
491
|
-
vectors.push.apply(vectors, (0, _toConsumableArray2
|
491
|
+
vectors.push.apply(vectors, (0, _toConsumableArray2.default)(solutions.map(function (v) {
|
492
492
|
return flatten(v);
|
493
493
|
})));
|
494
494
|
}
|
@@ -568,7 +568,7 @@ function createComplexEigs(_ref) {
|
|
568
568
|
for (var i = 0; i < arr.length; i++) {
|
569
569
|
var _arr$i;
|
570
570
|
|
571
|
-
(_arr$i = arr[i]).push.apply(_arr$i, (0, _toConsumableArray2
|
571
|
+
(_arr$i = arr[i]).push.apply(_arr$i, (0, _toConsumableArray2.default)(Array(N - arr[i].length).fill(0)));
|
572
572
|
} // add rows
|
573
573
|
|
574
574
|
|
@@ -7,7 +7,7 @@ exports.createMatrixFromColumns = void 0;
|
|
7
7
|
|
8
8
|
var _factory = require("../../utils/factory.js");
|
9
9
|
|
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
|
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
|
|
12
12
|
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); }
|
13
13
|
|
@@ -7,7 +7,7 @@ exports.createMatrixFromRows = void 0;
|
|
7
7
|
|
8
8
|
var _factory = require("../../utils/factory.js");
|
9
9
|
|
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
|
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
|
|
12
12
|
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); }
|
13
13
|
|
@@ -9,13 +9,13 @@ exports.createRng = createRng;
|
|
9
9
|
|
10
10
|
var _seedrandom = _interopRequireDefault(require("seedrandom"));
|
11
11
|
|
12
|
-
var singletonRandom = /* #__PURE__ */(0, _seedrandom
|
12
|
+
var singletonRandom = /* #__PURE__ */(0, _seedrandom.default)(Date.now());
|
13
13
|
|
14
14
|
function createRng(randomSeed) {
|
15
15
|
var random; // create a new random generator with given seed
|
16
16
|
|
17
17
|
function setSeed(seed) {
|
18
|
-
random = seed === null ? singletonRandom : (0, _seedrandom
|
18
|
+
random = seed === null ? singletonRandom : (0, _seedrandom.default)(String(seed));
|
19
19
|
} // initialize a seeded pseudo random number generator with config's random seed
|
20
20
|
|
21
21
|
|
@@ -101,7 +101,7 @@ var createCompareNatural = /* #__PURE__ */(0, _factory.factory)(name, dependenci
|
|
101
101
|
// c can be number, BigNumber, or Fraction
|
102
102
|
return c > 0 ? 1 : -1; // return a number
|
103
103
|
} else {
|
104
|
-
return (0, _javascriptNaturalSort
|
104
|
+
return (0, _javascriptNaturalSort.default)(typeX, typeY);
|
105
105
|
}
|
106
106
|
} // matrix types
|
107
107
|
|
@@ -112,13 +112,13 @@ var createCompareNatural = /* #__PURE__ */(0, _factory.factory)(name, dependenci
|
|
112
112
|
if (c !== 0) {
|
113
113
|
return c;
|
114
114
|
} else {
|
115
|
-
return (0, _javascriptNaturalSort
|
115
|
+
return (0, _javascriptNaturalSort.default)(typeX, typeY);
|
116
116
|
}
|
117
117
|
} // in case of different types, order by name of type, i.e. 'BigNumber' < 'Complex'
|
118
118
|
|
119
119
|
|
120
120
|
if (typeX !== typeY) {
|
121
|
-
return (0, _javascriptNaturalSort
|
121
|
+
return (0, _javascriptNaturalSort.default)(typeX, typeY);
|
122
122
|
}
|
123
123
|
|
124
124
|
if (typeX === 'Complex') {
|
@@ -139,7 +139,7 @@ var createCompareNatural = /* #__PURE__ */(0, _factory.factory)(name, dependenci
|
|
139
139
|
}
|
140
140
|
|
141
141
|
if (typeX === 'string') {
|
142
|
-
return (0, _javascriptNaturalSort
|
142
|
+
return (0, _javascriptNaturalSort.default)(x, y);
|
143
143
|
}
|
144
144
|
|
145
145
|
if (typeX === 'Object') {
|
@@ -252,8 +252,8 @@ var createCompareNatural = /* #__PURE__ */(0, _factory.factory)(name, dependenci
|
|
252
252
|
var keysX = Object.keys(x);
|
253
253
|
var keysY = Object.keys(y); // compare keys
|
254
254
|
|
255
|
-
keysX.sort(_javascriptNaturalSort
|
256
|
-
keysY.sort(_javascriptNaturalSort
|
255
|
+
keysX.sort(_javascriptNaturalSort.default);
|
256
|
+
keysY.sort(_javascriptNaturalSort.default);
|
257
257
|
var c = compareArrays(compareNatural, keysX, keysY);
|
258
258
|
|
259
259
|
if (c !== 0) {
|
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 10.
|
10
|
-
* @date 2022-
|
9
|
+
* @version 10.2.0
|
10
|
+
* @date 2022-03-01
|
11
11
|
*
|
12
12
|
* @license
|
13
13
|
* Copyright (C) 2013-2022 Jos de Jong <wjosdejong@gmail.com>
|
@@ -27,7 +27,7 @@ Object.keys(_arithmetic).forEach(function (key) {
|
|
27
27
|
});
|
28
28
|
|
29
29
|
// TODO: this is ugly. Instead, be able to pass your own isBigNumber function to typed?
|
30
|
-
var BigNumber = _decimal
|
30
|
+
var BigNumber = _decimal.default.clone();
|
31
31
|
|
32
32
|
BigNumber.prototype.isBigNumber = true;
|
33
33
|
|
@@ -23,15 +23,27 @@ function combinationsNumber(n, k) {
|
|
23
23
|
}
|
24
24
|
|
25
25
|
var nMinusk = n - k;
|
26
|
-
var
|
26
|
+
var answer = 1;
|
27
|
+
var firstnumerator = k < nMinusk ? nMinusk + 1 : k + 1;
|
28
|
+
var nextdivisor = 2;
|
29
|
+
var lastdivisor = k < nMinusk ? k : nMinusk; // balance multiplications and divisions to try to keep intermediate values
|
30
|
+
// in exact-integer range as long as possible
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
|
32
|
+
for (var nextnumerator = firstnumerator; nextnumerator <= n; ++nextnumerator) {
|
33
|
+
answer *= nextnumerator;
|
34
|
+
|
35
|
+
while (nextdivisor <= lastdivisor && answer % nextdivisor === 0) {
|
36
|
+
answer /= nextdivisor;
|
37
|
+
++nextdivisor;
|
38
|
+
}
|
39
|
+
} // for big n, k, floating point may have caused weirdness in remainder
|
40
|
+
|
41
|
+
|
42
|
+
if (nextdivisor <= lastdivisor) {
|
43
|
+
answer /= (0, _product.product)(nextdivisor, lastdivisor);
|
31
44
|
}
|
32
45
|
|
33
|
-
|
34
|
-
return prodrange / (0, _product.product)(1, nMinusk);
|
46
|
+
return answer;
|
35
47
|
}
|
36
48
|
|
37
49
|
combinationsNumber.signature = 'number, number';
|
@@ -17,9 +17,9 @@ var createBigNumberClass = /* #__PURE__ */(0, _factory.factory)(name, dependenci
|
|
17
17
|
var on = _ref.on,
|
18
18
|
config = _ref.config;
|
19
19
|
|
20
|
-
var BigNumber = _decimal
|
20
|
+
var BigNumber = _decimal.default.clone({
|
21
21
|
precision: config.precision,
|
22
|
-
modulo: _decimal
|
22
|
+
modulo: _decimal.default.EUCLID
|
23
23
|
});
|
24
24
|
|
25
25
|
BigNumber.prototype = Object.create(BigNumber.prototype);
|
@@ -79,7 +79,7 @@ var createBignumber = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
|
|
79
79
|
Fraction: function Fraction(x) {
|
80
80
|
return new BigNumber(x.n).div(x.d).times(x.s);
|
81
81
|
},
|
82
|
-
|
82
|
+
null: function _null(x) {
|
83
83
|
return new BigNumber(0);
|
84
84
|
},
|
85
85
|
'Array | Matrix': function ArrayMatrix(x) {
|
package/lib/cjs/type/boolean.js
CHANGED
@@ -45,13 +45,13 @@ var createBoolean = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fun
|
|
45
45
|
'': function _() {
|
46
46
|
return false;
|
47
47
|
},
|
48
|
-
|
48
|
+
boolean: function boolean(x) {
|
49
49
|
return x;
|
50
50
|
},
|
51
51
|
number: function number(x) {
|
52
52
|
return !!x;
|
53
53
|
},
|
54
|
-
|
54
|
+
null: function _null(x) {
|
55
55
|
return false;
|
56
56
|
},
|
57
57
|
BigNumber: function BigNumber(x) {
|