mathjs 10.6.2 → 11.0.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 +74 -1
- package/README.md +1 -1
- package/lib/browser/math.js +2 -41
- package/lib/browser/math.js.LICENSE.txt +43 -0
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/core/create.js +6 -5
- package/lib/cjs/core/function/import.js +4 -14
- package/lib/cjs/core/function/typed.js +54 -12
- 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/dependenciesChainClass.generated.js +3 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesKldivergence.generated.js +3 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesRationalize.generated.js +3 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesResolve.generated.js +3 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSimplify.generated.js +3 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSimplifyConstant.generated.js +56 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSimplifyCore.generated.js +6 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSqrtm.generated.js +3 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesStd.generated.js +3 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesStdTransform.generated.js +3 -0
- package/lib/cjs/entry/dependenciesAny.generated.js +8 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesChainClass.generated.js +3 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesRationalize.generated.js +3 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesResolve.generated.js +3 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesSimplify.generated.js +3 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesSimplifyConstant.generated.js +50 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesSimplifyCore.generated.js +6 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesStd.generated.js +3 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesStdTransform.generated.js +3 -0
- package/lib/cjs/entry/dependenciesNumber.generated.js +8 -0
- package/lib/cjs/entry/impureFunctionsAny.generated.js +87 -61
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +93 -69
- package/lib/cjs/entry/pureFunctionsAny.generated.js +50 -45
- package/lib/cjs/entry/pureFunctionsNumber.generated.js +22 -19
- package/lib/cjs/expression/Parser.js +1 -1
- package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +8 -5
- package/lib/cjs/expression/embeddedDocs/function/algebra/simplifyConstant.js +15 -0
- package/lib/cjs/expression/embeddedDocs/function/algebra/simplifyCore.js +1 -1
- package/lib/cjs/expression/node/AccessorNode.js +216 -173
- package/lib/cjs/expression/node/ArrayNode.js +206 -160
- package/lib/cjs/expression/node/AssignmentNode.js +321 -270
- package/lib/cjs/expression/node/BlockNode.js +223 -172
- package/lib/cjs/expression/node/ConditionalNode.js +253 -193
- package/lib/cjs/expression/node/ConstantNode.js +216 -171
- package/lib/cjs/expression/node/FunctionAssignmentNode.js +258 -196
- package/lib/cjs/expression/node/FunctionNode.js +456 -416
- package/lib/cjs/expression/node/IndexNode.js +256 -210
- package/lib/cjs/expression/node/Node.js +411 -378
- package/lib/cjs/expression/node/ObjectNode.js +223 -178
- package/lib/cjs/expression/node/OperatorNode.js +474 -397
- package/lib/cjs/expression/node/ParenthesisNode.js +189 -143
- package/lib/cjs/expression/node/RangeNode.js +272 -224
- package/lib/cjs/expression/node/RelationalNode.js +246 -195
- package/lib/cjs/expression/node/SymbolNode.js +219 -172
- package/lib/cjs/expression/node/utils/access.js +1 -1
- package/lib/cjs/expression/node/utils/assign.js +1 -1
- package/lib/cjs/expression/operators.js +117 -23
- package/lib/cjs/expression/parse.js +37 -19
- package/lib/cjs/expression/transform/std.transform.js +3 -1
- package/lib/cjs/factoriesAny.js +8 -0
- package/lib/cjs/factoriesNumber.js +10 -1
- package/lib/cjs/function/algebra/decomposition/qr.js +1 -1
- package/lib/cjs/function/algebra/derivative.js +22 -30
- package/lib/cjs/function/algebra/leafCount.js +0 -3
- package/lib/cjs/function/algebra/rationalize.js +78 -108
- package/lib/cjs/function/algebra/resolve.js +53 -16
- package/lib/cjs/function/algebra/simplify/util.js +1 -1
- package/lib/cjs/function/algebra/simplify.js +87 -114
- package/lib/cjs/function/algebra/{simplify/simplifyConstant.js → simplifyConstant.js} +44 -10
- package/lib/cjs/function/algebra/simplifyCore.js +196 -93
- package/lib/cjs/function/algebra/solver/lsolveAll.js +2 -2
- package/lib/cjs/function/algebra/solver/usolveAll.js +2 -2
- package/lib/cjs/function/algebra/symbolicEqual.js +9 -26
- package/lib/cjs/function/arithmetic/abs.js +7 -14
- package/lib/cjs/function/arithmetic/add.js +26 -70
- package/lib/cjs/function/arithmetic/addScalar.js +17 -9
- package/lib/cjs/function/arithmetic/cbrt.js +7 -11
- package/lib/cjs/function/arithmetic/ceil.js +56 -46
- package/lib/cjs/function/arithmetic/cube.js +5 -10
- package/lib/cjs/function/arithmetic/divide.js +7 -7
- package/lib/cjs/function/arithmetic/divideScalar.js +4 -18
- package/lib/cjs/function/arithmetic/dotDivide.js +22 -65
- package/lib/cjs/function/arithmetic/dotMultiply.js +16 -61
- package/lib/cjs/function/arithmetic/dotPow.js +30 -63
- package/lib/cjs/function/arithmetic/exp.js +8 -12
- package/lib/cjs/function/arithmetic/expm1.js +10 -10
- package/lib/cjs/function/arithmetic/fix.js +33 -27
- package/lib/cjs/function/arithmetic/floor.js +56 -46
- package/lib/cjs/function/arithmetic/gcd.js +27 -68
- package/lib/cjs/function/arithmetic/hypot.js +9 -5
- package/lib/cjs/function/arithmetic/invmod.js +1 -1
- package/lib/cjs/function/arithmetic/lcm.js +27 -68
- package/lib/cjs/function/arithmetic/log.js +10 -12
- package/lib/cjs/function/arithmetic/log10.js +5 -3
- package/lib/cjs/function/arithmetic/log1p.js +11 -7
- package/lib/cjs/function/arithmetic/log2.js +5 -3
- package/lib/cjs/function/arithmetic/mod.js +22 -64
- package/lib/cjs/function/arithmetic/multiply.js +40 -35
- package/lib/cjs/function/arithmetic/multiplyScalar.js +2 -9
- package/lib/cjs/function/arithmetic/norm.js +1 -5
- package/lib/cjs/function/arithmetic/nthRoot.js +80 -92
- package/lib/cjs/function/arithmetic/round.js +56 -42
- package/lib/cjs/function/arithmetic/sign.js +14 -10
- package/lib/cjs/function/arithmetic/sqrt.js +5 -9
- package/lib/cjs/function/arithmetic/square.js +6 -10
- package/lib/cjs/function/arithmetic/subtract.js +44 -100
- package/lib/cjs/function/arithmetic/unaryMinus.js +14 -16
- package/lib/cjs/function/arithmetic/unaryPlus.js +6 -4
- package/lib/cjs/function/bitwise/bitAnd.js +17 -61
- package/lib/cjs/function/bitwise/bitNot.js +5 -3
- package/lib/cjs/function/bitwise/bitOr.js +16 -60
- package/lib/cjs/function/bitwise/bitXor.js +17 -61
- package/lib/cjs/function/bitwise/leftShift.js +68 -81
- package/lib/cjs/function/bitwise/rightArithShift.js +68 -81
- package/lib/cjs/function/bitwise/rightLogShift.js +68 -81
- package/lib/cjs/function/bitwise/useMatrixForArrayScalar.js +36 -0
- package/lib/cjs/function/complex/arg.js +5 -3
- package/lib/cjs/function/complex/conj.js +6 -7
- package/lib/cjs/function/complex/im.js +7 -8
- package/lib/cjs/function/complex/re.js +6 -10
- package/lib/cjs/function/logical/and.js +74 -80
- package/lib/cjs/function/logical/not.js +13 -6
- package/lib/cjs/function/logical/or.js +21 -63
- package/lib/cjs/function/logical/xor.js +21 -63
- package/lib/cjs/function/matrix/diff.js +10 -7
- package/lib/cjs/function/matrix/eigs/complexEigs.js +5 -5
- package/lib/cjs/function/matrix/fft.js +2 -2
- package/lib/cjs/function/matrix/matrixFromColumns.js +1 -1
- package/lib/cjs/function/matrix/matrixFromRows.js +1 -1
- package/lib/cjs/function/matrix/ones.js +2 -1
- package/lib/cjs/function/matrix/sqrtm.js +3 -2
- package/lib/cjs/function/matrix/transpose.js +47 -48
- package/lib/cjs/function/matrix/zeros.js +2 -1
- package/lib/cjs/function/probability/factorial.js +5 -3
- package/lib/cjs/function/probability/gamma.js +38 -40
- package/lib/cjs/function/probability/kldivergence.js +5 -2
- package/lib/cjs/function/probability/lgamma.js +30 -30
- package/lib/cjs/function/probability/util/seededRNG.js +2 -2
- package/lib/cjs/function/relational/compare.js +21 -67
- package/lib/cjs/function/relational/compareNatural.js +59 -54
- package/lib/cjs/function/relational/compareText.js +10 -43
- package/lib/cjs/function/relational/compareUnits.js +24 -0
- package/lib/cjs/function/relational/equal.js +19 -80
- package/lib/cjs/function/relational/equalScalar.js +7 -9
- package/lib/cjs/function/relational/larger.js +21 -67
- package/lib/cjs/function/relational/largerEq.js +21 -67
- package/lib/cjs/function/relational/smaller.js +21 -67
- package/lib/cjs/function/relational/smallerEq.js +21 -67
- package/lib/cjs/function/relational/unequal.js +19 -80
- package/lib/cjs/function/special/erf.js +5 -3
- package/lib/cjs/function/statistics/std.js +11 -2
- package/lib/cjs/function/trigonometry/acos.js +4 -8
- package/lib/cjs/function/trigonometry/acosh.js +2 -7
- package/lib/cjs/function/trigonometry/acot.js +4 -8
- package/lib/cjs/function/trigonometry/acoth.js +4 -8
- package/lib/cjs/function/trigonometry/acsc.js +4 -8
- package/lib/cjs/function/trigonometry/acsch.js +4 -8
- package/lib/cjs/function/trigonometry/asec.js +4 -8
- package/lib/cjs/function/trigonometry/asech.js +4 -8
- package/lib/cjs/function/trigonometry/asin.js +4 -9
- package/lib/cjs/function/trigonometry/asinh.js +4 -9
- package/lib/cjs/function/trigonometry/atan.js +4 -9
- package/lib/cjs/function/trigonometry/atan2.js +24 -62
- package/lib/cjs/function/trigonometry/atanh.js +4 -9
- package/lib/cjs/function/trigonometry/cos.js +11 -20
- package/lib/cjs/function/trigonometry/cosh.js +5 -19
- package/lib/cjs/function/trigonometry/cot.js +9 -15
- package/lib/cjs/function/trigonometry/coth.js +4 -15
- package/lib/cjs/function/trigonometry/csc.js +11 -17
- package/lib/cjs/function/trigonometry/csch.js +4 -15
- package/lib/cjs/function/trigonometry/sec.js +11 -17
- package/lib/cjs/function/trigonometry/sech.js +4 -15
- package/lib/cjs/function/trigonometry/sin.js +11 -21
- package/lib/cjs/function/trigonometry/sinh.js +5 -20
- package/lib/cjs/function/trigonometry/tan.js +11 -21
- package/lib/cjs/function/trigonometry/tanh.js +5 -20
- package/lib/cjs/function/trigonometry/trigUnit.js +24 -0
- package/lib/cjs/function/unit/to.js +7 -41
- package/lib/cjs/function/utils/hasNumericValue.js +4 -0
- package/lib/cjs/function/utils/isInteger.js +5 -3
- package/lib/cjs/function/utils/isNegative.js +10 -6
- package/lib/cjs/function/utils/isNumeric.js +5 -3
- package/lib/cjs/function/utils/isPositive.js +10 -6
- package/lib/cjs/function/utils/isPrime.js +5 -3
- package/lib/cjs/function/utils/isZero.js +10 -6
- package/lib/cjs/function/utils/numeric.js +11 -4
- package/lib/cjs/function/utils/typeOf.js +38 -44
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/plain/bignumber/index.js +1 -1
- package/lib/cjs/type/bignumber/BigNumber.js +2 -2
- package/lib/cjs/type/bignumber/function/bignumber.js +6 -4
- package/lib/cjs/type/boolean.js +7 -5
- package/lib/cjs/type/chain/Chain.js +23 -3
- package/lib/cjs/type/complex/Complex.js +18 -14
- package/lib/cjs/type/complex/function/complex.js +6 -4
- package/lib/cjs/type/fraction/Fraction.js +10 -6
- package/lib/cjs/type/fraction/function/fraction.js +6 -4
- package/lib/cjs/type/matrix/DenseMatrix.js +21 -6
- package/lib/cjs/type/matrix/SparseMatrix.js +12 -2
- package/lib/cjs/type/matrix/utils/{algorithm01.js → matAlgo01xDSid.js} +4 -4
- package/lib/cjs/type/matrix/utils/{algorithm02.js → matAlgo02xDS0.js} +5 -5
- package/lib/cjs/type/matrix/utils/{algorithm03.js → matAlgo03xDSf.js} +5 -5
- package/lib/cjs/type/matrix/utils/{algorithm04.js → matAlgo04xSidSid.js} +7 -7
- package/lib/cjs/type/matrix/utils/{algorithm05.js → matAlgo05xSfSf.js} +5 -5
- package/lib/cjs/type/matrix/utils/{algorithm06.js → matAlgo06xS0S0.js} +5 -5
- package/lib/cjs/type/matrix/utils/{algorithm07.js → matAlgo07xSSf.js} +5 -5
- package/lib/cjs/type/matrix/utils/{algorithm08.js → matAlgo08xS0Sid.js} +6 -6
- package/lib/cjs/type/matrix/utils/{algorithm09.js → matAlgo09xS0Sf.js} +5 -5
- package/lib/cjs/type/matrix/utils/{algorithm10.js → matAlgo10xSids.js} +5 -5
- package/lib/cjs/type/matrix/utils/{algorithm11.js → matAlgo11xS0s.js} +5 -5
- package/lib/cjs/type/matrix/utils/{algorithm12.js → matAlgo12xSfs.js} +5 -5
- package/lib/cjs/type/matrix/utils/{algorithm13.js → matAlgo13xDD.js} +5 -5
- package/lib/cjs/type/matrix/utils/{algorithm14.js → matAlgo14xDs.js} +5 -5
- package/lib/cjs/type/matrix/utils/matrixAlgorithmSuite.js +238 -0
- package/lib/cjs/type/number.js +6 -4
- package/lib/cjs/type/string.js +7 -5
- package/lib/cjs/type/unit/Unit.js +69 -21
- package/lib/cjs/type/unit/function/createUnit.js +2 -1
- package/lib/cjs/type/unit/function/unit.js +9 -3
- 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 +27 -25
- 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 +30 -57
- package/lib/cjs/utils/string.js +3 -3
- package/lib/cjs/version.js +1 -1
- package/lib/esm/core/create.js +2 -1
- package/lib/esm/core/function/import.js +2 -12
- package/lib/esm/core/function/typed.js +47 -11
- package/lib/esm/entry/dependenciesAny/dependenciesChainClass.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesKldivergence.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesRationalize.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesResolve.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSimplify.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSimplifyConstant.generated.js +34 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSimplifyCore.generated.js +4 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSqrtm.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesStd.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesStdTransform.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny.generated.js +1 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesChainClass.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesRationalize.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesResolve.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesSimplify.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesSimplifyConstant.generated.js +30 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesSimplifyCore.generated.js +4 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesStd.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesStdTransform.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber.generated.js +1 -0
- package/lib/esm/entry/impureFunctionsAny.generated.js +73 -48
- package/lib/esm/entry/impureFunctionsNumber.generated.js +81 -58
- package/lib/esm/entry/pureFunctionsAny.generated.js +39 -36
- package/lib/esm/entry/pureFunctionsNumber.generated.js +14 -13
- package/lib/esm/expression/embeddedDocs/embeddedDocs.js +2 -0
- package/lib/esm/expression/embeddedDocs/function/algebra/simplifyConstant.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/algebra/simplifyCore.js +1 -1
- package/lib/esm/expression/node/AccessorNode.js +158 -153
- package/lib/esm/expression/node/ArrayNode.js +162 -154
- package/lib/esm/expression/node/AssignmentNode.js +257 -245
- package/lib/esm/expression/node/BlockNode.js +177 -163
- package/lib/esm/expression/node/ConditionalNode.js +197 -174
- package/lib/esm/expression/node/ConstantNode.js +171 -163
- package/lib/esm/expression/node/FunctionAssignmentNode.js +205 -180
- package/lib/esm/expression/node/FunctionNode.js +407 -407
- package/lib/esm/expression/node/IndexNode.js +206 -198
- package/lib/esm/expression/node/Node.js +325 -325
- package/lib/esm/expression/node/ObjectNode.js +166 -157
- package/lib/esm/expression/node/OperatorNode.js +414 -377
- package/lib/esm/expression/node/ParenthesisNode.js +146 -138
- package/lib/esm/expression/node/RangeNode.js +221 -212
- package/lib/esm/expression/node/RelationalNode.js +190 -176
- package/lib/esm/expression/node/SymbolNode.js +161 -152
- package/lib/esm/expression/operators.js +96 -4
- package/lib/esm/expression/parse.js +25 -7
- package/lib/esm/expression/transform/std.transform.js +3 -1
- package/lib/esm/factoriesAny.js +1 -0
- package/lib/esm/factoriesNumber.js +1 -0
- package/lib/esm/function/algebra/derivative.js +22 -30
- package/lib/esm/function/algebra/leafCount.js +0 -3
- package/lib/esm/function/algebra/rationalize.js +83 -114
- package/lib/esm/function/algebra/resolve.js +25 -16
- package/lib/esm/function/algebra/simplify.js +82 -112
- package/lib/esm/function/algebra/{simplify/simplifyConstant.js → simplifyConstant.js} +39 -9
- package/lib/esm/function/algebra/simplifyCore.js +192 -91
- package/lib/esm/function/algebra/symbolicEqual.js +9 -26
- package/lib/esm/function/arithmetic/abs.js +3 -16
- package/lib/esm/function/arithmetic/add.js +21 -65
- package/lib/esm/function/arithmetic/addScalar.js +11 -5
- package/lib/esm/function/arithmetic/cbrt.js +7 -10
- package/lib/esm/function/arithmetic/ceil.js +25 -25
- package/lib/esm/function/arithmetic/cube.js +5 -9
- package/lib/esm/function/arithmetic/divide.js +7 -7
- package/lib/esm/function/arithmetic/divideScalar.js +2 -19
- package/lib/esm/function/arithmetic/dotDivide.js +22 -64
- package/lib/esm/function/arithmetic/dotMultiply.js +16 -60
- package/lib/esm/function/arithmetic/dotPow.js +30 -62
- package/lib/esm/function/arithmetic/exp.js +8 -11
- package/lib/esm/function/arithmetic/expm1.js +10 -9
- package/lib/esm/function/arithmetic/fix.js +17 -17
- package/lib/esm/function/arithmetic/floor.js +25 -25
- package/lib/esm/function/arithmetic/gcd.js +26 -70
- package/lib/esm/function/arithmetic/hypot.js +7 -6
- package/lib/esm/function/arithmetic/lcm.js +26 -70
- package/lib/esm/function/arithmetic/log.js +7 -10
- package/lib/esm/function/arithmetic/log10.js +1 -3
- package/lib/esm/function/arithmetic/log1p.js +4 -6
- package/lib/esm/function/arithmetic/log2.js +1 -3
- package/lib/esm/function/arithmetic/mod.js +21 -62
- package/lib/esm/function/arithmetic/multiply.js +23 -27
- package/lib/esm/function/arithmetic/multiplyScalar.js +2 -13
- package/lib/esm/function/arithmetic/norm.js +0 -4
- package/lib/esm/function/arithmetic/nthRoot.js +38 -73
- package/lib/esm/function/arithmetic/round.js +26 -28
- package/lib/esm/function/arithmetic/sign.js +5 -7
- package/lib/esm/function/arithmetic/sqrt.js +5 -8
- package/lib/esm/function/arithmetic/square.js +6 -9
- package/lib/esm/function/arithmetic/subtract.js +31 -95
- package/lib/esm/function/arithmetic/unaryMinus.js +6 -16
- package/lib/esm/function/arithmetic/unaryPlus.js +2 -4
- package/lib/esm/function/bitwise/bitAnd.js +16 -59
- package/lib/esm/function/bitwise/bitNot.js +1 -3
- package/lib/esm/function/bitwise/bitOr.js +16 -59
- package/lib/esm/function/bitwise/bitXor.js +16 -59
- package/lib/esm/function/bitwise/leftShift.js +38 -60
- package/lib/esm/function/bitwise/rightArithShift.js +38 -60
- package/lib/esm/function/bitwise/rightLogShift.js +38 -60
- package/lib/esm/function/bitwise/useMatrixForArrayScalar.js +13 -0
- package/lib/esm/function/complex/arg.js +1 -3
- package/lib/esm/function/complex/conj.js +3 -12
- package/lib/esm/function/complex/im.js +4 -15
- package/lib/esm/function/complex/re.js +3 -15
- package/lib/esm/function/logical/and.js +35 -57
- package/lib/esm/function/logical/not.js +3 -6
- package/lib/esm/function/logical/or.js +16 -61
- package/lib/esm/function/logical/xor.js +16 -61
- package/lib/esm/function/matrix/diff.js +2 -7
- package/lib/esm/function/matrix/ones.js +2 -1
- package/lib/esm/function/matrix/sqrtm.js +3 -2
- package/lib/esm/function/matrix/transpose.js +47 -50
- package/lib/esm/function/matrix/zeros.js +2 -1
- package/lib/esm/function/probability/factorial.js +1 -3
- package/lib/esm/function/probability/gamma.js +38 -39
- package/lib/esm/function/probability/kldivergence.js +3 -2
- package/lib/esm/function/probability/lgamma.js +29 -29
- package/lib/esm/function/relational/compare.js +21 -67
- package/lib/esm/function/relational/compareNatural.js +54 -49
- package/lib/esm/function/relational/compareText.js +10 -42
- package/lib/esm/function/relational/compareUnits.js +15 -0
- package/lib/esm/function/relational/equal.js +19 -79
- package/lib/esm/function/relational/equalScalar.js +6 -9
- package/lib/esm/function/relational/larger.js +23 -73
- package/lib/esm/function/relational/largerEq.js +23 -73
- package/lib/esm/function/relational/smaller.js +23 -73
- package/lib/esm/function/relational/smallerEq.js +23 -73
- package/lib/esm/function/relational/unequal.js +19 -79
- package/lib/esm/function/special/erf.js +1 -3
- package/lib/esm/function/statistics/std.js +10 -2
- package/lib/esm/function/trigonometry/acos.js +4 -7
- package/lib/esm/function/trigonometry/acosh.js +2 -6
- package/lib/esm/function/trigonometry/acot.js +4 -7
- package/lib/esm/function/trigonometry/acoth.js +4 -7
- package/lib/esm/function/trigonometry/acsc.js +4 -7
- package/lib/esm/function/trigonometry/acsch.js +4 -7
- package/lib/esm/function/trigonometry/asec.js +4 -7
- package/lib/esm/function/trigonometry/asech.js +4 -7
- package/lib/esm/function/trigonometry/asin.js +4 -8
- package/lib/esm/function/trigonometry/asinh.js +4 -8
- package/lib/esm/function/trigonometry/atan.js +4 -8
- package/lib/esm/function/trigonometry/atan2.js +25 -64
- package/lib/esm/function/trigonometry/atanh.js +4 -8
- package/lib/esm/function/trigonometry/cos.js +11 -22
- package/lib/esm/function/trigonometry/cosh.js +5 -20
- package/lib/esm/function/trigonometry/cot.js +10 -20
- package/lib/esm/function/trigonometry/coth.js +6 -20
- package/lib/esm/function/trigonometry/csc.js +12 -22
- package/lib/esm/function/trigonometry/csch.js +6 -20
- package/lib/esm/function/trigonometry/sec.js +12 -22
- package/lib/esm/function/trigonometry/sech.js +6 -20
- package/lib/esm/function/trigonometry/sin.js +11 -23
- package/lib/esm/function/trigonometry/sinh.js +5 -21
- package/lib/esm/function/trigonometry/tan.js +11 -23
- package/lib/esm/function/trigonometry/tanh.js +5 -21
- package/lib/esm/function/trigonometry/trigUnit.js +15 -0
- package/lib/esm/function/unit/to.js +8 -43
- package/lib/esm/function/utils/hasNumericValue.js +2 -0
- package/lib/esm/function/utils/isInteger.js +1 -3
- package/lib/esm/function/utils/isNegative.js +2 -6
- package/lib/esm/function/utils/isNumeric.js +3 -9
- package/lib/esm/function/utils/isPositive.js +2 -6
- package/lib/esm/function/utils/isPrime.js +1 -3
- package/lib/esm/function/utils/isZero.js +2 -6
- package/lib/esm/function/utils/numeric.js +11 -4
- package/lib/esm/function/utils/typeOf.js +38 -44
- package/lib/esm/type/bignumber/function/bignumber.js +1 -3
- package/lib/esm/type/boolean.js +1 -3
- package/lib/esm/type/chain/Chain.js +23 -3
- package/lib/esm/type/complex/Complex.js +4 -0
- package/lib/esm/type/complex/function/complex.js +1 -3
- package/lib/esm/type/fraction/Fraction.js +4 -0
- package/lib/esm/type/fraction/function/fraction.js +1 -3
- package/lib/esm/type/matrix/DenseMatrix.js +15 -1
- package/lib/esm/type/matrix/SparseMatrix.js +9 -0
- package/lib/esm/type/matrix/utils/{algorithm01.js → matAlgo01xDSid.js} +2 -2
- package/lib/esm/type/matrix/utils/{algorithm02.js → matAlgo02xDS0.js} +3 -3
- package/lib/esm/type/matrix/utils/{algorithm03.js → matAlgo03xDSf.js} +3 -3
- package/lib/esm/type/matrix/utils/{algorithm04.js → matAlgo04xSidSid.js} +5 -5
- package/lib/esm/type/matrix/utils/{algorithm05.js → matAlgo05xSfSf.js} +3 -3
- package/lib/esm/type/matrix/utils/{algorithm06.js → matAlgo06xS0S0.js} +3 -3
- package/lib/esm/type/matrix/utils/{algorithm07.js → matAlgo07xSSf.js} +3 -3
- package/lib/esm/type/matrix/utils/{algorithm08.js → matAlgo08xS0Sid.js} +4 -4
- package/lib/esm/type/matrix/utils/{algorithm09.js → matAlgo09xS0Sf.js} +3 -3
- package/lib/esm/type/matrix/utils/{algorithm10.js → matAlgo10xSids.js} +3 -3
- package/lib/esm/type/matrix/utils/{algorithm11.js → matAlgo11xS0s.js} +3 -3
- package/lib/esm/type/matrix/utils/{algorithm12.js → matAlgo12xSfs.js} +3 -3
- package/lib/esm/type/matrix/utils/{algorithm13.js → matAlgo13xDD.js} +3 -3
- package/lib/esm/type/matrix/utils/{algorithm14.js → matAlgo14xDs.js} +3 -3
- package/lib/esm/type/matrix/utils/matrixAlgorithmSuite.js +168 -0
- package/lib/esm/type/number.js +1 -3
- package/lib/esm/type/string.js +1 -3
- package/lib/esm/type/unit/Unit.js +61 -13
- package/lib/esm/type/unit/function/createUnit.js +2 -1
- package/lib/esm/type/unit/function/unit.js +5 -3
- package/lib/esm/utils/is.js +18 -18
- package/lib/esm/utils/snapshot.js +22 -48
- package/lib/esm/version.js +1 -1
- package/package.json +21 -24
- package/types/index.d.ts +202 -181
- package/types/index.ts +264 -57
- package/lib/cjs/utils/polyfills.js +0 -14
- package/lib/esm/utils/polyfills.js +0 -12
|
@@ -4,30 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getAssociativity = getAssociativity;
|
|
7
|
+
exports.getOperator = getOperator;
|
|
7
8
|
exports.getPrecedence = getPrecedence;
|
|
8
9
|
exports.isAssociativeWith = isAssociativeWith;
|
|
9
10
|
exports.properties = void 0;
|
|
10
11
|
|
|
11
12
|
var _object = require("../utils/object.js");
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
// postfix operators are left associative, prefix operators
|
|
22
|
-
// are right associative
|
|
23
|
-
//
|
|
24
|
-
// It's also possible to set the following properties:
|
|
25
|
-
// latexParens: if set to false, this node doesn't need to be enclosed
|
|
26
|
-
// in parentheses when using LaTeX
|
|
27
|
-
// latexLeftParens: if set to false, this !OperatorNode's!
|
|
28
|
-
// left argument doesn't need to be enclosed
|
|
29
|
-
// in parentheses
|
|
30
|
-
// latexRightParens: the same for the right argument
|
|
14
|
+
var _is = require("../utils/is.js");
|
|
15
|
+
|
|
16
|
+
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; } } }; }
|
|
17
|
+
|
|
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
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
31
22
|
var properties = [{
|
|
32
23
|
// assignment
|
|
33
24
|
AssignmentNode: {},
|
|
@@ -44,62 +35,74 @@ var properties = [{
|
|
|
44
35
|
}, {
|
|
45
36
|
// logical or
|
|
46
37
|
'OperatorNode:or': {
|
|
38
|
+
op: 'or',
|
|
47
39
|
associativity: 'left',
|
|
48
40
|
associativeWith: []
|
|
49
41
|
}
|
|
50
42
|
}, {
|
|
51
43
|
// logical xor
|
|
52
44
|
'OperatorNode:xor': {
|
|
45
|
+
op: 'xor',
|
|
53
46
|
associativity: 'left',
|
|
54
47
|
associativeWith: []
|
|
55
48
|
}
|
|
56
49
|
}, {
|
|
57
50
|
// logical and
|
|
58
51
|
'OperatorNode:and': {
|
|
52
|
+
op: 'and',
|
|
59
53
|
associativity: 'left',
|
|
60
54
|
associativeWith: []
|
|
61
55
|
}
|
|
62
56
|
}, {
|
|
63
57
|
// bitwise or
|
|
64
58
|
'OperatorNode:bitOr': {
|
|
59
|
+
op: '|',
|
|
65
60
|
associativity: 'left',
|
|
66
61
|
associativeWith: []
|
|
67
62
|
}
|
|
68
63
|
}, {
|
|
69
64
|
// bitwise xor
|
|
70
65
|
'OperatorNode:bitXor': {
|
|
66
|
+
op: '^|',
|
|
71
67
|
associativity: 'left',
|
|
72
68
|
associativeWith: []
|
|
73
69
|
}
|
|
74
70
|
}, {
|
|
75
71
|
// bitwise and
|
|
76
72
|
'OperatorNode:bitAnd': {
|
|
73
|
+
op: '&',
|
|
77
74
|
associativity: 'left',
|
|
78
75
|
associativeWith: []
|
|
79
76
|
}
|
|
80
77
|
}, {
|
|
81
78
|
// relational operators
|
|
82
79
|
'OperatorNode:equal': {
|
|
80
|
+
op: '==',
|
|
83
81
|
associativity: 'left',
|
|
84
82
|
associativeWith: []
|
|
85
83
|
},
|
|
86
84
|
'OperatorNode:unequal': {
|
|
85
|
+
op: '!=',
|
|
87
86
|
associativity: 'left',
|
|
88
87
|
associativeWith: []
|
|
89
88
|
},
|
|
90
89
|
'OperatorNode:smaller': {
|
|
90
|
+
op: '<',
|
|
91
91
|
associativity: 'left',
|
|
92
92
|
associativeWith: []
|
|
93
93
|
},
|
|
94
94
|
'OperatorNode:larger': {
|
|
95
|
+
op: '>',
|
|
95
96
|
associativity: 'left',
|
|
96
97
|
associativeWith: []
|
|
97
98
|
},
|
|
98
99
|
'OperatorNode:smallerEq': {
|
|
100
|
+
op: '<=',
|
|
99
101
|
associativity: 'left',
|
|
100
102
|
associativeWith: []
|
|
101
103
|
},
|
|
102
104
|
'OperatorNode:largerEq': {
|
|
105
|
+
op: '>=',
|
|
103
106
|
associativity: 'left',
|
|
104
107
|
associativeWith: []
|
|
105
108
|
},
|
|
@@ -110,20 +113,24 @@ var properties = [{
|
|
|
110
113
|
}, {
|
|
111
114
|
// bitshift operators
|
|
112
115
|
'OperatorNode:leftShift': {
|
|
116
|
+
op: '<<',
|
|
113
117
|
associativity: 'left',
|
|
114
118
|
associativeWith: []
|
|
115
119
|
},
|
|
116
120
|
'OperatorNode:rightArithShift': {
|
|
121
|
+
op: '>>',
|
|
117
122
|
associativity: 'left',
|
|
118
123
|
associativeWith: []
|
|
119
124
|
},
|
|
120
125
|
'OperatorNode:rightLogShift': {
|
|
126
|
+
op: '>>>',
|
|
121
127
|
associativity: 'left',
|
|
122
128
|
associativeWith: []
|
|
123
129
|
}
|
|
124
130
|
}, {
|
|
125
131
|
// unit conversion
|
|
126
132
|
'OperatorNode:to': {
|
|
133
|
+
op: 'to',
|
|
127
134
|
associativity: 'left',
|
|
128
135
|
associativeWith: []
|
|
129
136
|
}
|
|
@@ -133,20 +140,24 @@ var properties = [{
|
|
|
133
140
|
}, {
|
|
134
141
|
// addition, subtraction
|
|
135
142
|
'OperatorNode:add': {
|
|
143
|
+
op: '+',
|
|
136
144
|
associativity: 'left',
|
|
137
145
|
associativeWith: ['OperatorNode:add', 'OperatorNode:subtract']
|
|
138
146
|
},
|
|
139
147
|
'OperatorNode:subtract': {
|
|
148
|
+
op: '-',
|
|
140
149
|
associativity: 'left',
|
|
141
150
|
associativeWith: []
|
|
142
151
|
}
|
|
143
152
|
}, {
|
|
144
153
|
// multiply, divide, modulus
|
|
145
154
|
'OperatorNode:multiply': {
|
|
155
|
+
op: '*',
|
|
146
156
|
associativity: 'left',
|
|
147
157
|
associativeWith: ['OperatorNode:multiply', 'OperatorNode:divide', 'Operator:dotMultiply', 'Operator:dotDivide']
|
|
148
158
|
},
|
|
149
159
|
'OperatorNode:divide': {
|
|
160
|
+
op: '/',
|
|
150
161
|
associativity: 'left',
|
|
151
162
|
associativeWith: [],
|
|
152
163
|
latexLeftParens: false,
|
|
@@ -157,34 +168,48 @@ var properties = [{
|
|
|
157
168
|
|
|
158
169
|
},
|
|
159
170
|
'OperatorNode:dotMultiply': {
|
|
171
|
+
op: '.*',
|
|
160
172
|
associativity: 'left',
|
|
161
173
|
associativeWith: ['OperatorNode:multiply', 'OperatorNode:divide', 'OperatorNode:dotMultiply', 'OperatorNode:doDivide']
|
|
162
174
|
},
|
|
163
175
|
'OperatorNode:dotDivide': {
|
|
176
|
+
op: './',
|
|
164
177
|
associativity: 'left',
|
|
165
178
|
associativeWith: []
|
|
166
179
|
},
|
|
167
180
|
'OperatorNode:mod': {
|
|
181
|
+
op: 'mod',
|
|
168
182
|
associativity: 'left',
|
|
169
183
|
associativeWith: []
|
|
170
184
|
}
|
|
185
|
+
}, {
|
|
186
|
+
// Repeat multiplication for implicit multiplication
|
|
187
|
+
'OperatorNode:multiply': {
|
|
188
|
+
associativity: 'left',
|
|
189
|
+
associativeWith: ['OperatorNode:multiply', 'OperatorNode:divide', 'Operator:dotMultiply', 'Operator:dotDivide']
|
|
190
|
+
}
|
|
171
191
|
}, {
|
|
172
192
|
// unary prefix operators
|
|
173
193
|
'OperatorNode:unaryPlus': {
|
|
194
|
+
op: '+',
|
|
174
195
|
associativity: 'right'
|
|
175
196
|
},
|
|
176
197
|
'OperatorNode:unaryMinus': {
|
|
198
|
+
op: '-',
|
|
177
199
|
associativity: 'right'
|
|
178
200
|
},
|
|
179
201
|
'OperatorNode:bitNot': {
|
|
202
|
+
op: '~',
|
|
180
203
|
associativity: 'right'
|
|
181
204
|
},
|
|
182
205
|
'OperatorNode:not': {
|
|
206
|
+
op: 'not',
|
|
183
207
|
associativity: 'right'
|
|
184
208
|
}
|
|
185
209
|
}, {
|
|
186
210
|
// exponentiation
|
|
187
211
|
'OperatorNode:pow': {
|
|
212
|
+
op: '^',
|
|
188
213
|
associativity: 'right',
|
|
189
214
|
associativeWith: [],
|
|
190
215
|
latexRightParens: false // the exponent doesn't need parentheses in
|
|
@@ -193,20 +218,43 @@ var properties = [{
|
|
|
193
218
|
|
|
194
219
|
},
|
|
195
220
|
'OperatorNode:dotPow': {
|
|
221
|
+
op: '.^',
|
|
196
222
|
associativity: 'right',
|
|
197
223
|
associativeWith: []
|
|
198
224
|
}
|
|
199
225
|
}, {
|
|
200
226
|
// factorial
|
|
201
227
|
'OperatorNode:factorial': {
|
|
228
|
+
op: '!',
|
|
202
229
|
associativity: 'left'
|
|
203
230
|
}
|
|
204
231
|
}, {
|
|
205
232
|
// matrix transpose
|
|
206
|
-
'OperatorNode:
|
|
233
|
+
'OperatorNode:ctranspose': {
|
|
234
|
+
op: "'",
|
|
207
235
|
associativity: 'left'
|
|
208
236
|
}
|
|
209
237
|
}];
|
|
238
|
+
/**
|
|
239
|
+
* Returns the first non-parenthesis internal node, but only
|
|
240
|
+
* when the 'parenthesis' option is unset or auto.
|
|
241
|
+
* @param {Node} _node
|
|
242
|
+
* @param {string} parenthesis
|
|
243
|
+
* @return {Node}
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
exports.properties = properties;
|
|
247
|
+
|
|
248
|
+
function unwrapParen(_node, parenthesis) {
|
|
249
|
+
if (!parenthesis || parenthesis !== 'auto') return _node;
|
|
250
|
+
var node = _node;
|
|
251
|
+
|
|
252
|
+
while ((0, _is.isParenthesisNode)(node)) {
|
|
253
|
+
node = node.content;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return node;
|
|
257
|
+
}
|
|
210
258
|
/**
|
|
211
259
|
* Get the precedence of a Node.
|
|
212
260
|
* Higher number for higher precedence, starting with 0.
|
|
@@ -214,12 +262,13 @@ var properties = [{
|
|
|
214
262
|
*
|
|
215
263
|
* @param {Node} _node
|
|
216
264
|
* @param {string} parenthesis
|
|
265
|
+
* @param {string} implicit
|
|
266
|
+
* @param {Node} parent (for determining context for implicit multiplication)
|
|
217
267
|
* @return {number | null}
|
|
218
268
|
*/
|
|
219
269
|
|
|
220
|
-
exports.properties = properties;
|
|
221
270
|
|
|
222
|
-
function getPrecedence(_node, parenthesis) {
|
|
271
|
+
function getPrecedence(_node, parenthesis, implicit, parent) {
|
|
223
272
|
var node = _node;
|
|
224
273
|
|
|
225
274
|
if (parenthesis !== 'keep') {
|
|
@@ -228,14 +277,26 @@ function getPrecedence(_node, parenthesis) {
|
|
|
228
277
|
}
|
|
229
278
|
|
|
230
279
|
var identifier = node.getIdentifier();
|
|
280
|
+
var precedence = null;
|
|
231
281
|
|
|
232
282
|
for (var i = 0; i < properties.length; i++) {
|
|
233
283
|
if (identifier in properties[i]) {
|
|
234
|
-
|
|
284
|
+
precedence = i;
|
|
285
|
+
break;
|
|
286
|
+
}
|
|
287
|
+
} // Bump up precedence of implicit multiplication, except when preceded
|
|
288
|
+
// by a "Rule 2" fraction ( [unaryOp]constant / constant )
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
if (identifier === 'OperatorNode:multiply' && node.implicit && implicit !== 'show') {
|
|
292
|
+
var leftArg = unwrapParen(node.args[0], parenthesis);
|
|
293
|
+
|
|
294
|
+
if (!((0, _is.isConstantNode)(leftArg) && parent && parent.getIdentifier() === 'OperatorNode:divide' && (0, _is.rule2Node)(unwrapParen(parent.args[0], parenthesis))) && !(leftArg.getIdentifier() === 'OperatorNode:divide' && (0, _is.rule2Node)(unwrapParen(leftArg.args[0], parenthesis)) && (0, _is.isConstantNode)(unwrapParen(leftArg.args[1])))) {
|
|
295
|
+
precedence += 1;
|
|
235
296
|
}
|
|
236
297
|
}
|
|
237
298
|
|
|
238
|
-
return
|
|
299
|
+
return precedence;
|
|
239
300
|
}
|
|
240
301
|
/**
|
|
241
302
|
* Get the associativity of an operator (left or right).
|
|
@@ -320,5 +381,38 @@ function isAssociativeWith(nodeA, nodeB, parenthesis) {
|
|
|
320
381
|
} // associativeWith is not defined
|
|
321
382
|
|
|
322
383
|
|
|
384
|
+
return null;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Get the operator associated with a function name.
|
|
388
|
+
* Returns a string with the operator symbol, or null if the
|
|
389
|
+
* input is not the name of a function associated with an
|
|
390
|
+
* operator.
|
|
391
|
+
*
|
|
392
|
+
* @param {string} Function name
|
|
393
|
+
* @return {string | null} Associated operator symbol, if any
|
|
394
|
+
*/
|
|
395
|
+
|
|
396
|
+
|
|
397
|
+
function getOperator(fn) {
|
|
398
|
+
var identifier = 'OperatorNode:' + fn;
|
|
399
|
+
|
|
400
|
+
var _iterator = _createForOfIteratorHelper(properties),
|
|
401
|
+
_step;
|
|
402
|
+
|
|
403
|
+
try {
|
|
404
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
405
|
+
var group = _step.value;
|
|
406
|
+
|
|
407
|
+
if (identifier in group) {
|
|
408
|
+
return group[identifier].op;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
} catch (err) {
|
|
412
|
+
_iterator.e(err);
|
|
413
|
+
} finally {
|
|
414
|
+
_iterator.f();
|
|
415
|
+
}
|
|
416
|
+
|
|
323
417
|
return null;
|
|
324
418
|
}
|
|
@@ -153,16 +153,16 @@ var createParse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
|
153
153
|
var NAMED_DELIMITERS = {
|
|
154
154
|
mod: true,
|
|
155
155
|
to: true,
|
|
156
|
-
in: true,
|
|
156
|
+
"in": true,
|
|
157
157
|
and: true,
|
|
158
158
|
xor: true,
|
|
159
159
|
or: true,
|
|
160
160
|
not: true
|
|
161
161
|
};
|
|
162
162
|
var CONSTANTS = {
|
|
163
|
-
true: true,
|
|
164
|
-
false: false,
|
|
165
|
-
null: null,
|
|
163
|
+
"true": true,
|
|
164
|
+
"false": false,
|
|
165
|
+
"null": null,
|
|
166
166
|
undefined: undefined
|
|
167
167
|
};
|
|
168
168
|
var NUMERIC_CONSTANTS = ['NaN', 'Infinity'];
|
|
@@ -588,7 +588,7 @@ var createParse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
|
588
588
|
|
|
589
589
|
function parseStart(expression, extraNodes) {
|
|
590
590
|
var state = initialState();
|
|
591
|
-
(0, _extends2
|
|
591
|
+
(0, _extends2["default"])(state, {
|
|
592
592
|
expression: expression,
|
|
593
593
|
extraNodes: extraNodes
|
|
594
594
|
});
|
|
@@ -624,7 +624,10 @@ var createParse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
|
624
624
|
|
|
625
625
|
if (state.token !== '' && state.token !== '\n' && state.token !== ';') {
|
|
626
626
|
node = parseAssignment(state);
|
|
627
|
-
|
|
627
|
+
|
|
628
|
+
if (state.comment) {
|
|
629
|
+
node.comment = state.comment;
|
|
630
|
+
}
|
|
628
631
|
} // TODO: simplify this loop
|
|
629
632
|
|
|
630
633
|
|
|
@@ -642,7 +645,11 @@ var createParse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
|
642
645
|
|
|
643
646
|
if (state.token !== '\n' && state.token !== ';' && state.token !== '') {
|
|
644
647
|
node = parseAssignment(state);
|
|
645
|
-
|
|
648
|
+
|
|
649
|
+
if (state.comment) {
|
|
650
|
+
node.comment = state.comment;
|
|
651
|
+
}
|
|
652
|
+
|
|
646
653
|
visible = state.token !== ';';
|
|
647
654
|
blocks.push({
|
|
648
655
|
node: node,
|
|
@@ -656,7 +663,10 @@ var createParse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
|
656
663
|
} else {
|
|
657
664
|
if (!node) {
|
|
658
665
|
node = new ConstantNode(undefined);
|
|
659
|
-
|
|
666
|
+
|
|
667
|
+
if (state.comment) {
|
|
668
|
+
node.comment = state.comment;
|
|
669
|
+
}
|
|
660
670
|
}
|
|
661
671
|
|
|
662
672
|
return node;
|
|
@@ -934,7 +944,7 @@ var createParse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
|
934
944
|
node = parseRange(state);
|
|
935
945
|
var operators = {
|
|
936
946
|
to: 'to',
|
|
937
|
-
in: 'to' // alias of 'to'
|
|
947
|
+
"in": 'to' // alias of 'to'
|
|
938
948
|
|
|
939
949
|
};
|
|
940
950
|
|
|
@@ -1100,8 +1110,10 @@ var createParse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
|
1100
1110
|
}
|
|
1101
1111
|
/**
|
|
1102
1112
|
* Infamous "rule 2" as described in https://github.com/josdejong/mathjs/issues/792#issuecomment-361065370
|
|
1113
|
+
* And as amended in https://github.com/josdejong/mathjs/issues/2370#issuecomment-1054052164
|
|
1103
1114
|
* Explicit division gets higher precedence than implicit multiplication
|
|
1104
|
-
* when the division matches this pattern:
|
|
1115
|
+
* when the division matches this pattern:
|
|
1116
|
+
* [unaryPrefixOp]?[number] / [number] [symbol]
|
|
1105
1117
|
* @return {Node} node
|
|
1106
1118
|
* @private
|
|
1107
1119
|
*/
|
|
@@ -1114,32 +1126,32 @@ var createParse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
|
1114
1126
|
|
|
1115
1127
|
while (true) {
|
|
1116
1128
|
// Match the "number /" part of the pattern "number / number symbol"
|
|
1117
|
-
if (state.token === '/' && (0, _is.
|
|
1129
|
+
if (state.token === '/' && (0, _is.rule2Node)(last)) {
|
|
1118
1130
|
// Look ahead to see if the next token is a number
|
|
1119
|
-
tokenStates.push((0, _extends2
|
|
1131
|
+
tokenStates.push((0, _extends2["default"])({}, state));
|
|
1120
1132
|
getTokenSkipNewline(state); // Match the "number / number" part of the pattern
|
|
1121
1133
|
|
|
1122
1134
|
if (state.tokenType === TOKENTYPE.NUMBER) {
|
|
1123
1135
|
// Look ahead again
|
|
1124
|
-
tokenStates.push((0, _extends2
|
|
1136
|
+
tokenStates.push((0, _extends2["default"])({}, state));
|
|
1125
1137
|
getTokenSkipNewline(state); // Match the "symbol" part of the pattern, or a left parenthesis
|
|
1126
1138
|
|
|
1127
1139
|
if (state.tokenType === TOKENTYPE.SYMBOL || state.token === '(') {
|
|
1128
1140
|
// We've matched the pattern "number / number symbol".
|
|
1129
1141
|
// Rewind once and build the "number / number" node; the symbol will be consumed later
|
|
1130
|
-
(0, _extends2
|
|
1142
|
+
(0, _extends2["default"])(state, tokenStates.pop());
|
|
1131
1143
|
tokenStates.pop();
|
|
1132
1144
|
last = parsePercentage(state);
|
|
1133
1145
|
node = new OperatorNode('/', 'divide', [node, last]);
|
|
1134
1146
|
} else {
|
|
1135
1147
|
// Not a match, so rewind
|
|
1136
1148
|
tokenStates.pop();
|
|
1137
|
-
(0, _extends2
|
|
1149
|
+
(0, _extends2["default"])(state, tokenStates.pop());
|
|
1138
1150
|
break;
|
|
1139
1151
|
}
|
|
1140
1152
|
} else {
|
|
1141
1153
|
// Not a match, so rewind
|
|
1142
|
-
(0, _extends2
|
|
1154
|
+
(0, _extends2["default"])(state, tokenStates.pop());
|
|
1143
1155
|
break;
|
|
1144
1156
|
}
|
|
1145
1157
|
} else {
|
|
@@ -1787,7 +1799,7 @@ var createParse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
|
1787
1799
|
function createSyntaxError(state, message) {
|
|
1788
1800
|
var c = col(state);
|
|
1789
1801
|
var error = new SyntaxError(message + ' (char ' + c + ')');
|
|
1790
|
-
error
|
|
1802
|
+
error["char"] = c;
|
|
1791
1803
|
return error;
|
|
1792
1804
|
}
|
|
1793
1805
|
/**
|
|
@@ -1802,10 +1814,16 @@ var createParse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
|
1802
1814
|
function createError(state, message) {
|
|
1803
1815
|
var c = col(state);
|
|
1804
1816
|
var error = new SyntaxError(message + ' (char ' + c + ')');
|
|
1805
|
-
error
|
|
1817
|
+
error["char"] = c;
|
|
1806
1818
|
return error;
|
|
1807
|
-
}
|
|
1819
|
+
} // Now that we can parse, automatically convert strings to Nodes by parsing
|
|
1820
|
+
|
|
1808
1821
|
|
|
1822
|
+
typed.addConversion({
|
|
1823
|
+
from: 'string',
|
|
1824
|
+
to: 'Node',
|
|
1825
|
+
convert: parse
|
|
1826
|
+
});
|
|
1809
1827
|
return parse;
|
|
1810
1828
|
});
|
|
1811
1829
|
exports.createParse = createParse;
|
|
@@ -14,7 +14,7 @@ var _errorTransform = require("./utils/errorTransform.js");
|
|
|
14
14
|
var _lastDimToZeroBase = require("./utils/lastDimToZeroBase.js");
|
|
15
15
|
|
|
16
16
|
var name = 'std';
|
|
17
|
-
var dependencies = ['typed', 'sqrt', 'variance'];
|
|
17
|
+
var dependencies = ['typed', 'map', 'sqrt', 'variance'];
|
|
18
18
|
/**
|
|
19
19
|
* Attach a transform function to math.std
|
|
20
20
|
* Adds a property transform containing the transform function.
|
|
@@ -25,10 +25,12 @@ var dependencies = ['typed', 'sqrt', 'variance'];
|
|
|
25
25
|
|
|
26
26
|
var createStdTransform = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
|
|
27
27
|
var typed = _ref.typed,
|
|
28
|
+
map = _ref.map,
|
|
28
29
|
sqrt = _ref.sqrt,
|
|
29
30
|
variance = _ref.variance;
|
|
30
31
|
var std = (0, _std.createStd)({
|
|
31
32
|
typed: typed,
|
|
33
|
+
map: map,
|
|
32
34
|
sqrt: sqrt,
|
|
33
35
|
variance: variance
|
|
34
36
|
});
|
package/lib/cjs/factoriesAny.js
CHANGED
|
@@ -1725,6 +1725,12 @@ Object.defineProperty(exports, "createSimplify", {
|
|
|
1725
1725
|
return _simplify.createSimplify;
|
|
1726
1726
|
}
|
|
1727
1727
|
});
|
|
1728
|
+
Object.defineProperty(exports, "createSimplifyConstant", {
|
|
1729
|
+
enumerable: true,
|
|
1730
|
+
get: function get() {
|
|
1731
|
+
return _simplifyConstant.createSimplifyConstant;
|
|
1732
|
+
}
|
|
1733
|
+
});
|
|
1728
1734
|
Object.defineProperty(exports, "createSimplifyCore", {
|
|
1729
1735
|
enumerable: true,
|
|
1730
1736
|
get: function get() {
|
|
@@ -2568,6 +2574,8 @@ var _leafCount = require("./function/algebra/leafCount.js");
|
|
|
2568
2574
|
|
|
2569
2575
|
var _simplify = require("./function/algebra/simplify.js");
|
|
2570
2576
|
|
|
2577
|
+
var _simplifyConstant = require("./function/algebra/simplifyConstant.js");
|
|
2578
|
+
|
|
2571
2579
|
var _simplifyCore = require("./function/algebra/simplifyCore.js");
|
|
2572
2580
|
|
|
2573
2581
|
var _resolve = require("./function/algebra/resolve.js");
|
|
@@ -640,6 +640,12 @@ Object.defineProperty(exports, "createSimplify", {
|
|
|
640
640
|
return _simplify.createSimplify;
|
|
641
641
|
}
|
|
642
642
|
});
|
|
643
|
+
Object.defineProperty(exports, "createSimplifyConstant", {
|
|
644
|
+
enumerable: true,
|
|
645
|
+
get: function get() {
|
|
646
|
+
return _simplifyConstant.createSimplifyConstant;
|
|
647
|
+
}
|
|
648
|
+
});
|
|
643
649
|
Object.defineProperty(exports, "createSimplifyCore", {
|
|
644
650
|
enumerable: true,
|
|
645
651
|
get: function get() {
|
|
@@ -771,7 +777,8 @@ Object.defineProperty(exports, "createVersion", {
|
|
|
771
777
|
return _constants.createVersion;
|
|
772
778
|
}
|
|
773
779
|
});
|
|
774
|
-
exports.
|
|
780
|
+
exports.createXgcd = void 0;
|
|
781
|
+
exports.createXor = void 0;
|
|
775
782
|
|
|
776
783
|
var _index = require("./plain/number/index.js");
|
|
777
784
|
|
|
@@ -797,6 +804,8 @@ var _resolve = require("./function/algebra/resolve.js");
|
|
|
797
804
|
|
|
798
805
|
var _simplify = require("./function/algebra/simplify.js");
|
|
799
806
|
|
|
807
|
+
var _simplifyConstant = require("./function/algebra/simplifyConstant.js");
|
|
808
|
+
|
|
800
809
|
var _simplifyCore = require("./function/algebra/simplifyCore.js");
|
|
801
810
|
|
|
802
811
|
var _derivative = require("./function/algebra/derivative.js");
|
|
@@ -73,7 +73,7 @@ var createQr = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function
|
|
|
73
73
|
* @return {{Q: Array | Matrix, R: Array | Matrix}} Q: the orthogonal
|
|
74
74
|
* matrix and R: the upper triangular matrix
|
|
75
75
|
*/
|
|
76
|
-
return (0, _extends2
|
|
76
|
+
return (0, _extends2["default"])(typed(name, {
|
|
77
77
|
DenseMatrix: function DenseMatrix(m) {
|
|
78
78
|
return _denseQR(m);
|
|
79
79
|
},
|
|
@@ -63,39 +63,26 @@ var createDerivative = /* #__PURE__ */(0, _factory.factory)(name, dependencies,
|
|
|
63
63
|
* be simplified.
|
|
64
64
|
* @return {ConstantNode | SymbolNode | ParenthesisNode | FunctionNode | OperatorNode} The derivative of `expr`
|
|
65
65
|
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
function plainDerivative(expr, variable) {
|
|
67
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
68
|
+
simplify: true
|
|
69
|
+
};
|
|
70
|
+
var constNodes = {};
|
|
71
|
+
constTag(constNodes, expr, variable.name);
|
|
70
72
|
|
|
71
|
-
|
|
73
|
+
var res = _derivative(expr, constNodes);
|
|
72
74
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
'Node, SymbolNode': function NodeSymbolNode(expr, variable) {
|
|
76
|
-
return this(expr, variable, {
|
|
77
|
-
simplify: true
|
|
78
|
-
});
|
|
79
|
-
},
|
|
80
|
-
'string, SymbolNode': function stringSymbolNode(expr, variable) {
|
|
81
|
-
return this(parse(expr), variable);
|
|
82
|
-
},
|
|
83
|
-
'string, SymbolNode, Object': function stringSymbolNodeObject(expr, variable, options) {
|
|
84
|
-
return this(parse(expr), variable, options);
|
|
85
|
-
},
|
|
86
|
-
'string, string': function stringString(expr, variable) {
|
|
87
|
-
return this(parse(expr), parse(variable));
|
|
88
|
-
},
|
|
89
|
-
'string, string, Object': function stringStringObject(expr, variable, options) {
|
|
90
|
-
return this(parse(expr), parse(variable), options);
|
|
91
|
-
},
|
|
92
|
-
'Node, string': function NodeString(expr, variable) {
|
|
93
|
-
return this(expr, parse(variable));
|
|
94
|
-
},
|
|
95
|
-
'Node, string, Object': function NodeStringObject(expr, variable, options) {
|
|
96
|
-
return this(expr, parse(variable), options);
|
|
97
|
-
} // TODO: replace the 8 signatures above with 4 as soon as typed-function supports optional arguments
|
|
75
|
+
return options.simplify ? simplify(res) : res;
|
|
76
|
+
}
|
|
98
77
|
|
|
78
|
+
typed.addConversion({
|
|
79
|
+
from: 'identifier',
|
|
80
|
+
to: 'SymbolNode',
|
|
81
|
+
convert: parse
|
|
82
|
+
});
|
|
83
|
+
var derivative = typed(name, {
|
|
84
|
+
'Node, SymbolNode': plainDerivative,
|
|
85
|
+
'Node, SymbolNode, Object': plainDerivative
|
|
99
86
|
/* TODO: implement and test syntax with order of derivatives -> implement as an option {order: number}
|
|
100
87
|
'Node, SymbolNode, ConstantNode': function (expr, variable, {order}) {
|
|
101
88
|
let res = expr
|
|
@@ -109,6 +96,11 @@ var createDerivative = /* #__PURE__ */(0, _factory.factory)(name, dependencies,
|
|
|
109
96
|
*/
|
|
110
97
|
|
|
111
98
|
});
|
|
99
|
+
typed.removeConversion({
|
|
100
|
+
from: 'identifier',
|
|
101
|
+
to: 'SymbolNode',
|
|
102
|
+
convert: parse
|
|
103
|
+
});
|
|
112
104
|
derivative._simplify = true;
|
|
113
105
|
|
|
114
106
|
derivative.toTex = function (deriv) {
|