mathjs 10.6.4 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HISTORY.md +79 -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/construction/index.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 +25 -33
- 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 +90 -115
- 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 +14 -32
- 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 +50 -40
- 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 +34 -28
- package/lib/cjs/function/arithmetic/floor.js +51 -41
- 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 +2 -2
- 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 +83 -95
- package/lib/cjs/function/arithmetic/nthRoots.js +2 -2
- 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 +6 -4
- 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 +69 -82
- package/lib/cjs/function/bitwise/rightArithShift.js +69 -82
- package/lib/cjs/function/bitwise/rightLogShift.js +69 -82
- 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/geometry/distance.js +2 -2
- 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 +11 -8
- 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/rotate.js +5 -5
- 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/string/format.js +2 -2
- package/lib/cjs/function/string/hex.js +1 -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 +6 -11
- package/lib/cjs/function/trigonometry/acoth.js +4 -8
- package/lib/cjs/function/trigonometry/acsc.js +6 -11
- package/lib/cjs/function/trigonometry/acsch.js +4 -8
- package/lib/cjs/function/trigonometry/asec.js +6 -10
- package/lib/cjs/function/trigonometry/asech.js +4 -8
- package/lib/cjs/function/trigonometry/asin.js +5 -10
- package/lib/cjs/function/trigonometry/asinh.js +4 -9
- package/lib/cjs/function/trigonometry/atan.js +5 -11
- package/lib/cjs/function/trigonometry/atan2.js +25 -63
- 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/clone.js +1 -1
- package/lib/cjs/function/utils/hasNumericValue.js +5 -1
- package/lib/cjs/function/utils/isInteger.js +6 -4
- package/lib/cjs/function/utils/isNaN.js +1 -1
- package/lib/cjs/function/utils/isNegative.js +11 -7
- package/lib/cjs/function/utils/isNumeric.js +6 -4
- package/lib/cjs/function/utils/isPositive.js +11 -7
- package/lib/cjs/function/utils/isPrime.js +5 -3
- package/lib/cjs/function/utils/isZero.js +21 -17
- 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 +98 -45
- package/lib/cjs/type/unit/function/createUnit.js +2 -1
- package/lib/cjs/type/unit/function/unit.js +14 -5
- 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/construction/index.js +1 -1
- 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 +25 -33
- 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 +85 -113
- 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 +14 -32
- 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 +18 -18
- package/lib/esm/function/arithmetic/floor.js +26 -26
- package/lib/esm/function/arithmetic/gcd.js +26 -70
- package/lib/esm/function/arithmetic/hypot.js +7 -6
- package/lib/esm/function/arithmetic/invmod.js +1 -1
- 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 +41 -76
- package/lib/esm/function/arithmetic/nthRoots.js +2 -2
- 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 +2 -4
- 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 +39 -61
- package/lib/esm/function/bitwise/rightArithShift.js +39 -61
- package/lib/esm/function/bitwise/rightLogShift.js +39 -61
- 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/geometry/distance.js +2 -2
- 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 +3 -8
- package/lib/esm/function/matrix/ones.js +2 -1
- package/lib/esm/function/matrix/rotate.js +5 -5
- 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/string/format.js +2 -2
- package/lib/esm/function/string/hex.js +1 -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 +6 -10
- package/lib/esm/function/trigonometry/acoth.js +4 -7
- package/lib/esm/function/trigonometry/acsc.js +6 -10
- package/lib/esm/function/trigonometry/acsch.js +4 -7
- package/lib/esm/function/trigonometry/asec.js +6 -9
- package/lib/esm/function/trigonometry/asech.js +4 -7
- package/lib/esm/function/trigonometry/asin.js +5 -9
- package/lib/esm/function/trigonometry/asinh.js +4 -8
- package/lib/esm/function/trigonometry/atan.js +5 -10
- package/lib/esm/function/trigonometry/atan2.js +26 -65
- 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/clone.js +1 -1
- package/lib/esm/function/utils/hasNumericValue.js +3 -1
- package/lib/esm/function/utils/isInteger.js +2 -4
- package/lib/esm/function/utils/isNaN.js +1 -1
- package/lib/esm/function/utils/isNegative.js +3 -7
- package/lib/esm/function/utils/isNumeric.js +4 -10
- package/lib/esm/function/utils/isPositive.js +3 -7
- package/lib/esm/function/utils/isPrime.js +1 -3
- package/lib/esm/function/utils/isZero.js +13 -17
- 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 +85 -36
- package/lib/esm/type/unit/function/createUnit.js +2 -1
- package/lib/esm/type/unit/function/unit.js +10 -5
- 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 +22 -25
- package/types/index.d.ts +211 -180
- package/types/index.ts +358 -144
- package/types/tsconfig.json +4 -1
- package/lib/cjs/utils/polyfills.js +0 -14
- package/lib/esm/utils/polyfills.js +0 -12
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { factory } from '../../../utils/factory.js';
|
|
2
|
+
import { extend } from '../../../utils/object.js';
|
|
3
|
+
import { createMatAlgo13xDD } from './matAlgo13xDD.js';
|
|
4
|
+
import { createMatAlgo14xDs } from './matAlgo14xDs.js';
|
|
5
|
+
var name = 'matrixAlgorithmSuite';
|
|
6
|
+
var dependencies = ['typed', 'matrix'];
|
|
7
|
+
export var createMatrixAlgorithmSuite = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
8
|
+
var {
|
|
9
|
+
typed,
|
|
10
|
+
matrix
|
|
11
|
+
} = _ref;
|
|
12
|
+
var matAlgo13xDD = createMatAlgo13xDD({
|
|
13
|
+
typed
|
|
14
|
+
});
|
|
15
|
+
var matAlgo14xDs = createMatAlgo14xDs({
|
|
16
|
+
typed
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Return a signatures object with the usual boilerplate of
|
|
20
|
+
* matrix algorithms, based on a plain options object with the
|
|
21
|
+
* following properties:
|
|
22
|
+
* elop: function -- the elementwise operation to use, defaults to self
|
|
23
|
+
* SS: function -- the algorithm to apply for two sparse matrices
|
|
24
|
+
* DS: function -- the algorithm to apply for a dense and a sparse matrix
|
|
25
|
+
* SD: function -- algo for a sparse and a dense; defaults to SD flipped
|
|
26
|
+
* Ss: function -- the algorithm to apply for a sparse matrix and scalar
|
|
27
|
+
* sS: function -- algo for scalar and sparse; defaults to Ss flipped
|
|
28
|
+
* scalar: string -- typed-function type for scalars, defaults to 'any'
|
|
29
|
+
*
|
|
30
|
+
* If Ss is not specified, no matrix-scalar signatures are generated.
|
|
31
|
+
*
|
|
32
|
+
* @param {object} options
|
|
33
|
+
* @return {Object<string, function>} signatures
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
return function matrixAlgorithmSuite(options) {
|
|
37
|
+
var elop = options.elop;
|
|
38
|
+
var SD = options.SD || options.DS;
|
|
39
|
+
var matrixSignatures;
|
|
40
|
+
|
|
41
|
+
if (elop) {
|
|
42
|
+
// First the dense ones
|
|
43
|
+
matrixSignatures = {
|
|
44
|
+
'DenseMatrix, DenseMatrix': (x, y) => matAlgo13xDD(x, y, elop),
|
|
45
|
+
'Array, Array': (x, y) => matAlgo13xDD(matrix(x), matrix(y), elop).valueOf(),
|
|
46
|
+
'Array, DenseMatrix': (x, y) => matAlgo13xDD(matrix(x), y, elop),
|
|
47
|
+
'DenseMatrix, Array': (x, y) => matAlgo13xDD(x, matrix(y), elop)
|
|
48
|
+
}; // Now incorporate sparse matrices
|
|
49
|
+
|
|
50
|
+
if (options.SS) {
|
|
51
|
+
matrixSignatures['SparseMatrix, SparseMatrix'] = (x, y) => options.SS(x, y, elop, false);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (options.DS) {
|
|
55
|
+
matrixSignatures['DenseMatrix, SparseMatrix'] = (x, y) => options.DS(x, y, elop, false);
|
|
56
|
+
|
|
57
|
+
matrixSignatures['Array, SparseMatrix'] = (x, y) => options.DS(matrix(x), y, elop, false);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (SD) {
|
|
61
|
+
matrixSignatures['SparseMatrix, DenseMatrix'] = (x, y) => SD(y, x, elop, true);
|
|
62
|
+
|
|
63
|
+
matrixSignatures['SparseMatrix, Array'] = (x, y) => SD(matrix(y), x, elop, true);
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
// No elop, use this
|
|
67
|
+
// First the dense ones
|
|
68
|
+
matrixSignatures = {
|
|
69
|
+
'DenseMatrix, DenseMatrix': typed.referToSelf(self => (x, y) => {
|
|
70
|
+
return matAlgo13xDD(x, y, self);
|
|
71
|
+
}),
|
|
72
|
+
'Array, Array': typed.referToSelf(self => (x, y) => {
|
|
73
|
+
return matAlgo13xDD(matrix(x), matrix(y), self).valueOf();
|
|
74
|
+
}),
|
|
75
|
+
'Array, DenseMatrix': typed.referToSelf(self => (x, y) => {
|
|
76
|
+
return matAlgo13xDD(matrix(x), y, self);
|
|
77
|
+
}),
|
|
78
|
+
'DenseMatrix, Array': typed.referToSelf(self => (x, y) => {
|
|
79
|
+
return matAlgo13xDD(x, matrix(y), self);
|
|
80
|
+
})
|
|
81
|
+
}; // Now incorporate sparse matrices
|
|
82
|
+
|
|
83
|
+
if (options.SS) {
|
|
84
|
+
matrixSignatures['SparseMatrix, SparseMatrix'] = typed.referToSelf(self => (x, y) => {
|
|
85
|
+
return options.SS(x, y, self, false);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (options.DS) {
|
|
90
|
+
matrixSignatures['DenseMatrix, SparseMatrix'] = typed.referToSelf(self => (x, y) => {
|
|
91
|
+
return options.DS(x, y, self, false);
|
|
92
|
+
});
|
|
93
|
+
matrixSignatures['Array, SparseMatrix'] = typed.referToSelf(self => (x, y) => {
|
|
94
|
+
return options.DS(matrix(x), y, self, false);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (SD) {
|
|
99
|
+
matrixSignatures['SparseMatrix, DenseMatrix'] = typed.referToSelf(self => (x, y) => {
|
|
100
|
+
return SD(y, x, self, true);
|
|
101
|
+
});
|
|
102
|
+
matrixSignatures['SparseMatrix, Array'] = typed.referToSelf(self => (x, y) => {
|
|
103
|
+
return SD(matrix(y), x, self, true);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
} // Now add the scalars
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
var scalar = options.scalar || 'any';
|
|
110
|
+
var Ds = options.Ds || options.Ss;
|
|
111
|
+
|
|
112
|
+
if (Ds) {
|
|
113
|
+
if (elop) {
|
|
114
|
+
matrixSignatures['DenseMatrix,' + scalar] = (x, y) => matAlgo14xDs(x, y, elop, false);
|
|
115
|
+
|
|
116
|
+
matrixSignatures[scalar + ', DenseMatrix'] = (x, y) => matAlgo14xDs(y, x, elop, true);
|
|
117
|
+
|
|
118
|
+
matrixSignatures['Array,' + scalar] = (x, y) => matAlgo14xDs(matrix(x), y, elop, false).valueOf();
|
|
119
|
+
|
|
120
|
+
matrixSignatures[scalar + ', Array'] = (x, y) => matAlgo14xDs(matrix(y), x, elop, true).valueOf();
|
|
121
|
+
} else {
|
|
122
|
+
matrixSignatures['DenseMatrix,' + scalar] = typed.referToSelf(self => (x, y) => {
|
|
123
|
+
return matAlgo14xDs(x, y, self, false);
|
|
124
|
+
});
|
|
125
|
+
matrixSignatures[scalar + ', DenseMatrix'] = typed.referToSelf(self => (x, y) => {
|
|
126
|
+
return matAlgo14xDs(y, x, self, true);
|
|
127
|
+
});
|
|
128
|
+
matrixSignatures['Array,' + scalar] = typed.referToSelf(self => (x, y) => {
|
|
129
|
+
return matAlgo14xDs(matrix(x), y, self, false).valueOf();
|
|
130
|
+
});
|
|
131
|
+
matrixSignatures[scalar + ', Array'] = typed.referToSelf(self => (x, y) => {
|
|
132
|
+
return matAlgo14xDs(matrix(y), x, self, true).valueOf();
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
var sS = options.sS !== undefined ? options.sS : options.Ss;
|
|
138
|
+
|
|
139
|
+
if (elop) {
|
|
140
|
+
if (options.Ss) {
|
|
141
|
+
matrixSignatures['SparseMatrix,' + scalar] = (x, y) => options.Ss(x, y, elop, false);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (sS) {
|
|
145
|
+
matrixSignatures[scalar + ', SparseMatrix'] = (x, y) => sS(y, x, elop, true);
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
if (options.Ss) {
|
|
149
|
+
matrixSignatures['SparseMatrix,' + scalar] = typed.referToSelf(self => (x, y) => {
|
|
150
|
+
return options.Ss(x, y, self, false);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (sS) {
|
|
155
|
+
matrixSignatures[scalar + ', SparseMatrix'] = typed.referToSelf(self => (x, y) => {
|
|
156
|
+
return sS(y, x, self, true);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
} // Also pull in the scalar signatures if the operator is a typed function
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
if (elop && elop.signatures) {
|
|
163
|
+
extend(matrixSignatures, elop.signatures);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return matrixSignatures;
|
|
167
|
+
};
|
|
168
|
+
});
|
package/lib/esm/type/number.js
CHANGED
|
@@ -146,9 +146,7 @@ export var createNumber = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
146
146
|
'Unit, string | Unit': function UnitStringUnit(unit, valuelessUnit) {
|
|
147
147
|
return unit.toNumber(valuelessUnit);
|
|
148
148
|
},
|
|
149
|
-
'Array | Matrix':
|
|
150
|
-
return deepMap(x, this);
|
|
151
|
-
}
|
|
149
|
+
'Array | Matrix': typed.referToSelf(self => x => deepMap(x, self))
|
|
152
150
|
}); // reviver function to parse a JSON object like:
|
|
153
151
|
//
|
|
154
152
|
// {"mathjs":"number","value":"2.3"}
|
package/lib/esm/type/string.js
CHANGED
|
@@ -47,9 +47,7 @@ export var createString = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
47
47
|
string: function string(x) {
|
|
48
48
|
return x;
|
|
49
49
|
},
|
|
50
|
-
'Array | Matrix':
|
|
51
|
-
return deepMap(x, this);
|
|
52
|
-
},
|
|
50
|
+
'Array | Matrix': typed.referToSelf(self => x => deepMap(x, self)),
|
|
53
51
|
any: function any(x) {
|
|
54
52
|
return String(x);
|
|
55
53
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
|
|
4
4
|
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; }
|
|
5
5
|
|
|
@@ -37,8 +37,8 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
37
37
|
/**
|
|
38
38
|
* A unit can be constructed in the following ways:
|
|
39
39
|
*
|
|
40
|
-
* const a = new Unit(value,
|
|
41
|
-
* const b = new Unit(null,
|
|
40
|
+
* const a = new Unit(value, valuelessUnit)
|
|
41
|
+
* const b = new Unit(null, valuelessUnit)
|
|
42
42
|
* const c = Unit.parse(str)
|
|
43
43
|
*
|
|
44
44
|
* Example usage:
|
|
@@ -51,10 +51,10 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
51
51
|
* @class Unit
|
|
52
52
|
* @constructor Unit
|
|
53
53
|
* @param {number | BigNumber | Fraction | Complex | boolean} [value] A value like 5.2
|
|
54
|
-
* @param {string}
|
|
54
|
+
* @param {string | Unit} valuelessUnit A unit without value. Can have prefix, like "cm"
|
|
55
55
|
*/
|
|
56
56
|
|
|
57
|
-
function Unit(value,
|
|
57
|
+
function Unit(value, valuelessUnit) {
|
|
58
58
|
if (!(this instanceof Unit)) {
|
|
59
59
|
throw new Error('Constructor must be called with the new operator');
|
|
60
60
|
}
|
|
@@ -63,42 +63,42 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
63
63
|
throw new TypeError('First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined');
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
if (name !== undefined && (typeof name !== 'string' || name === '')) {
|
|
67
|
-
throw new TypeError('Second parameter in Unit constructor must be a string');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (name !== undefined) {
|
|
71
|
-
var u = Unit.parse(name);
|
|
72
|
-
this.units = u.units;
|
|
73
|
-
this.dimensions = u.dimensions;
|
|
74
|
-
} else {
|
|
75
|
-
this.units = [{
|
|
76
|
-
unit: UNIT_NONE,
|
|
77
|
-
prefix: PREFIXES.NONE,
|
|
78
|
-
// link to a list with supported prefixes
|
|
79
|
-
power: 0
|
|
80
|
-
}];
|
|
81
|
-
this.dimensions = [];
|
|
82
|
-
|
|
83
|
-
for (var i = 0; i < BASE_DIMENSIONS.length; i++) {
|
|
84
|
-
this.dimensions[i] = 0;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
this.value = value !== undefined && value !== null ? this._normalize(value) : null;
|
|
89
66
|
this.fixPrefix = false; // if true, function format will not search for the
|
|
90
67
|
// best prefix but leave it as initially provided.
|
|
91
68
|
// fixPrefix is set true by the method Unit.to
|
|
92
69
|
// The justification behind this is that if the constructor is explicitly called,
|
|
93
|
-
// the caller wishes the units to be returned exactly as
|
|
70
|
+
// the caller wishes the units to be returned exactly as supplied.
|
|
94
71
|
|
|
95
72
|
this.skipAutomaticSimplification = true;
|
|
73
|
+
|
|
74
|
+
if (valuelessUnit === undefined) {
|
|
75
|
+
this.units = [];
|
|
76
|
+
this.dimensions = BASE_DIMENSIONS.map(x => 0);
|
|
77
|
+
} else if (typeof valuelessUnit === 'string') {
|
|
78
|
+
var u = Unit.parse(valuelessUnit);
|
|
79
|
+
this.units = u.units;
|
|
80
|
+
this.dimensions = u.dimensions;
|
|
81
|
+
} else if (isUnit(valuelessUnit) && valuelessUnit.value === null) {
|
|
82
|
+
// clone from valuelessUnit
|
|
83
|
+
this.fixPrefix = valuelessUnit.fixPrefix;
|
|
84
|
+
this.skipAutomaticSimplification = valuelessUnit.skipAutomaticSimplification;
|
|
85
|
+
this.dimensions = valuelessUnit.dimensions.slice(0);
|
|
86
|
+
this.units = valuelessUnit.units.map(u => _extends({}, u));
|
|
87
|
+
} else {
|
|
88
|
+
throw new TypeError('Second parameter in Unit constructor must be a string or valueless Unit');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
this.value = this._normalize(value);
|
|
96
92
|
}
|
|
97
93
|
/**
|
|
98
94
|
* Attach type information
|
|
99
95
|
*/
|
|
100
96
|
|
|
101
97
|
|
|
98
|
+
Object.defineProperty(Unit, 'name', {
|
|
99
|
+
value: 'Unit'
|
|
100
|
+
});
|
|
101
|
+
Unit.prototype.constructor = Unit;
|
|
102
102
|
Unit.prototype.type = 'Unit';
|
|
103
103
|
Unit.prototype.isUnit = true; // private variables and functions for the Unit parser
|
|
104
104
|
|
|
@@ -461,6 +461,17 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
461
461
|
|
|
462
462
|
return unit;
|
|
463
463
|
};
|
|
464
|
+
/**
|
|
465
|
+
* Return the type of the value of this unit
|
|
466
|
+
*
|
|
467
|
+
* @memberof Unit
|
|
468
|
+
* @ return {string} type of the value of the unit
|
|
469
|
+
*/
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
Unit.prototype.valueType = function () {
|
|
473
|
+
return typeOf(this.value);
|
|
474
|
+
};
|
|
464
475
|
/**
|
|
465
476
|
* Return whether the unit is derived (such as m/s, or cm^2, but not N)
|
|
466
477
|
* @memberof Unit
|
|
@@ -648,15 +659,16 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
648
659
|
return this.equalBase(other) && equal(this.value, other.value);
|
|
649
660
|
};
|
|
650
661
|
/**
|
|
651
|
-
* Multiply this unit with another one
|
|
662
|
+
* Multiply this unit with another one or with a scalar
|
|
652
663
|
* @memberof Unit
|
|
653
664
|
* @param {Unit} other
|
|
654
665
|
* @return {Unit} product of this unit and the other unit
|
|
655
666
|
*/
|
|
656
667
|
|
|
657
668
|
|
|
658
|
-
Unit.prototype.multiply = function (
|
|
669
|
+
Unit.prototype.multiply = function (_other) {
|
|
659
670
|
var res = this.clone();
|
|
671
|
+
var other = isUnit(_other) ? _other : new Unit(_other);
|
|
660
672
|
|
|
661
673
|
for (var i = 0; i < BASE_DIMENSIONS.length; i++) {
|
|
662
674
|
// Dimensions arrays may be of different lengths. Default to 0.
|
|
@@ -680,19 +692,35 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
680
692
|
res.value = null;
|
|
681
693
|
}
|
|
682
694
|
|
|
683
|
-
|
|
695
|
+
if (isUnit(_other)) {
|
|
696
|
+
res.skipAutomaticSimplification = false;
|
|
697
|
+
}
|
|
698
|
+
|
|
684
699
|
return getNumericIfUnitless(res);
|
|
685
700
|
};
|
|
701
|
+
/**
|
|
702
|
+
* Divide a number by this unit
|
|
703
|
+
*
|
|
704
|
+
* @memberof Unit
|
|
705
|
+
* @param {numeric} numerator
|
|
706
|
+
* @param {unit} result of dividing numerator by this unit
|
|
707
|
+
*/
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
Unit.prototype.divideInto = function (numerator) {
|
|
711
|
+
return new Unit(numerator).divide(this);
|
|
712
|
+
};
|
|
686
713
|
/**
|
|
687
714
|
* Divide this unit by another one
|
|
688
715
|
* @memberof Unit
|
|
689
|
-
* @param {Unit} other
|
|
716
|
+
* @param {Unit | numeric} other
|
|
690
717
|
* @return {Unit} result of dividing this unit by the other unit
|
|
691
718
|
*/
|
|
692
719
|
|
|
693
720
|
|
|
694
|
-
Unit.prototype.divide = function (
|
|
721
|
+
Unit.prototype.divide = function (_other) {
|
|
695
722
|
var res = this.clone();
|
|
723
|
+
var other = isUnit(_other) ? _other : new Unit(_other);
|
|
696
724
|
|
|
697
725
|
for (var i = 0; i < BASE_DIMENSIONS.length; i++) {
|
|
698
726
|
// Dimensions arrays may be of different lengths. Default to 0.
|
|
@@ -718,7 +746,10 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
718
746
|
res.value = null;
|
|
719
747
|
}
|
|
720
748
|
|
|
721
|
-
|
|
749
|
+
if (isUnit(_other)) {
|
|
750
|
+
res.skipAutomaticSimplification = false;
|
|
751
|
+
}
|
|
752
|
+
|
|
722
753
|
return getNumericIfUnitless(res);
|
|
723
754
|
};
|
|
724
755
|
/**
|
|
@@ -787,7 +818,7 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
787
818
|
// To give the correct, but unexpected, results for units with an offset.
|
|
788
819
|
// For example, abs(-283.15 degC) = -263.15 degC !!!
|
|
789
820
|
// We must take the offset into consideration here
|
|
790
|
-
var convert =
|
|
821
|
+
var convert = ret._numberConverter(); // convert to Fraction or BigNumber if needed
|
|
791
822
|
|
|
792
823
|
|
|
793
824
|
var unitValue = convert(ret.units[0].unit.value);
|
|
@@ -3627,6 +3658,23 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
3627
3658
|
return x;
|
|
3628
3659
|
}
|
|
3629
3660
|
};
|
|
3661
|
+
/**
|
|
3662
|
+
* Retrieve the right converter function corresponding with this unit's
|
|
3663
|
+
* value
|
|
3664
|
+
*
|
|
3665
|
+
* @memberof Unit
|
|
3666
|
+
* @return {Function}
|
|
3667
|
+
*/
|
|
3668
|
+
|
|
3669
|
+
Unit.prototype._numberConverter = function () {
|
|
3670
|
+
var convert = Unit.typeConverters[this.valueType()];
|
|
3671
|
+
|
|
3672
|
+
if (convert) {
|
|
3673
|
+
return convert;
|
|
3674
|
+
}
|
|
3675
|
+
|
|
3676
|
+
throw new TypeError('Unsupported Unit value type "' + this.valueType() + '"');
|
|
3677
|
+
};
|
|
3630
3678
|
/**
|
|
3631
3679
|
* Retrieve the right convertor function corresponding with the type
|
|
3632
3680
|
* of provided exampleValue.
|
|
@@ -3636,6 +3684,7 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
3636
3684
|
* @return {Function}
|
|
3637
3685
|
*/
|
|
3638
3686
|
|
|
3687
|
+
|
|
3639
3688
|
Unit._getNumberConverter = function (type) {
|
|
3640
3689
|
if (!Unit.typeConverters[type]) {
|
|
3641
3690
|
throw new TypeError('Unsupported type "' + type + '"');
|
|
@@ -34,9 +34,10 @@ export var createCreateUnit = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
34
34
|
* math.createUnit('foo')
|
|
35
35
|
* math.createUnit('knot', {definition: '0.514444444 m/s', aliases: ['knots', 'kt', 'kts']})
|
|
36
36
|
* math.createUnit('mph', '1 mile/hour')
|
|
37
|
+
* math.createUnit('km', math.unit(1000, 'm'))
|
|
37
38
|
*
|
|
38
39
|
* @param {string} name The name of the new unit. Must be unique. Example: 'knot'
|
|
39
|
-
* @param {string, Unit} definition Definition of the unit in terms of existing units. For example, '0.514444444 m / s'.
|
|
40
|
+
* @param {string, UnitDefinition, Unit} definition Definition of the unit in terms of existing units. For example, '0.514444444 m / s'.
|
|
40
41
|
* @param {Object} options (optional) An object containing any of the following properties:
|
|
41
42
|
* - `prefixes {string}` "none", "short", "long", "binary_short", or "binary_long". The default is "none".
|
|
42
43
|
* - `aliases {Array}` Array of strings. Example: ['knots', 'kt', 'kts']
|
|
@@ -17,10 +17,13 @@ export var createUnitFunction = /* #__PURE__ */factory(name, dependencies, _ref
|
|
|
17
17
|
* Syntax:
|
|
18
18
|
*
|
|
19
19
|
* math.unit(unit : string)
|
|
20
|
-
* math.unit(value : number,
|
|
20
|
+
* math.unit(value : number, valuelessUnit : Unit)
|
|
21
|
+
* math.unit(value : number, valuelessUnit : string)
|
|
21
22
|
*
|
|
22
23
|
* Examples:
|
|
23
24
|
*
|
|
25
|
+
* const kph = math.unit('km/h') // returns Unit km/h (valueless)
|
|
26
|
+
* const v = math.unit(25, kph) // returns Unit 25 km/h
|
|
24
27
|
* const a = math.unit(5, 'cm') // returns Unit 50 mm
|
|
25
28
|
* const b = math.unit('23 kg') // returns Unit 23 kg
|
|
26
29
|
* a.to('m') // returns Unit 0.05 m
|
|
@@ -45,11 +48,13 @@ export var createUnitFunction = /* #__PURE__ */factory(name, dependencies, _ref
|
|
|
45
48
|
allowNoUnits: true
|
|
46
49
|
}); // a unit with value, like '5cm'
|
|
47
50
|
},
|
|
48
|
-
'number | BigNumber | Fraction | Complex, string': function
|
|
51
|
+
'number | BigNumber | Fraction | Complex, string | Unit': function numberBigNumberFractionComplexStringUnit(value, unit) {
|
|
49
52
|
return new Unit(value, unit);
|
|
50
53
|
},
|
|
51
|
-
'
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
'number | BigNumber | Fraction': function numberBigNumberFraction(value) {
|
|
55
|
+
// dimensionless
|
|
56
|
+
return new Unit(value);
|
|
57
|
+
},
|
|
58
|
+
'Array | Matrix': typed.referToSelf(self => x => deepMap(x, self))
|
|
54
59
|
});
|
|
55
60
|
});
|
package/lib/esm/utils/is.js
CHANGED
|
@@ -111,6 +111,20 @@ export function isConditionalNode(x) {
|
|
|
111
111
|
export function isConstantNode(x) {
|
|
112
112
|
return x && x.isConstantNode === true && x.constructor.prototype.isNode === true || false;
|
|
113
113
|
}
|
|
114
|
+
/* Very specialized: returns true for those nodes which in the numerator of
|
|
115
|
+
a fraction means that the division in that fraction has precedence over implicit
|
|
116
|
+
multiplication, e.g. -2/3 x parses as (-2/3) x and 3/4 x parses as (3/4) x but
|
|
117
|
+
6!/8 x parses as 6! / (8x). It is located here because it is shared between
|
|
118
|
+
parse.js and OperatorNode.js (for parsing and printing, respectively).
|
|
119
|
+
|
|
120
|
+
This should *not* be exported from mathjs, unlike most of the tests here.
|
|
121
|
+
Its name does not start with 'is' to prevent utils/snapshot.js from thinking
|
|
122
|
+
it should be exported.
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
export function rule2Node(node) {
|
|
126
|
+
return isConstantNode(node) || isOperatorNode(node) && node.args.length === 1 && isConstantNode(node.args[0]) && '-+~'.includes(node.op);
|
|
127
|
+
}
|
|
114
128
|
export function isFunctionAssignmentNode(x) {
|
|
115
129
|
return x && x.isFunctionAssignmentNode === true && x.constructor.prototype.isNode === true || false;
|
|
116
130
|
}
|
|
@@ -145,26 +159,12 @@ export function typeOf(x) {
|
|
|
145
159
|
var t = typeof x;
|
|
146
160
|
|
|
147
161
|
if (t === 'object') {
|
|
148
|
-
// JavaScript types
|
|
149
162
|
if (x === null) return 'null';
|
|
150
|
-
if (
|
|
151
|
-
if (x instanceof Date) return 'Date';
|
|
152
|
-
if (x instanceof RegExp) return 'RegExp'; // math.js types
|
|
163
|
+
if (isBigNumber(x)) return 'BigNumber'; // Special: weird mashup with Decimal
|
|
153
164
|
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
if (isFraction(x)) return 'Fraction';
|
|
157
|
-
if (isMatrix(x)) return 'Matrix';
|
|
158
|
-
if (isUnit(x)) return 'Unit';
|
|
159
|
-
if (isIndex(x)) return 'Index';
|
|
160
|
-
if (isRange(x)) return 'Range';
|
|
161
|
-
if (isResultSet(x)) return 'ResultSet';
|
|
162
|
-
if (isNode(x)) return x.type;
|
|
163
|
-
if (isChain(x)) return 'Chain';
|
|
164
|
-
if (isHelp(x)) return 'Help';
|
|
165
|
-
return 'Object';
|
|
165
|
+
if (x.constructor && x.constructor.name) return x.constructor.name;
|
|
166
|
+
return 'Object'; // just in case
|
|
166
167
|
}
|
|
167
168
|
|
|
168
|
-
|
|
169
|
-
return t; // can be 'string', 'number', 'boolean', ...
|
|
169
|
+
return t; // can be 'string', 'number', 'boolean', 'function', 'bigint', ...
|
|
170
170
|
}
|
|
@@ -16,6 +16,7 @@ import assert from 'assert';
|
|
|
16
16
|
import * as allIsFunctions from './is.js';
|
|
17
17
|
import { create } from '../core/create.js';
|
|
18
18
|
import { endsWith } from './string.js';
|
|
19
|
+
export var validateTypeOf = allIsFunctions.typeOf;
|
|
19
20
|
export function validateBundle(expectedBundleStructure, bundle) {
|
|
20
21
|
var originalWarn = console.warn;
|
|
21
22
|
|
|
@@ -110,21 +111,21 @@ export function createSnapshotFromFactories(factories) {
|
|
|
110
111
|
var factory = factories[factoryName];
|
|
111
112
|
var name = factory.fn;
|
|
112
113
|
var isTransformFunction = factory.meta && factory.meta.isTransformFunction;
|
|
113
|
-
var isClass = !isLowerCase(name[0]) && validateTypeOf(math[name]) === '
|
|
114
|
+
var isClass = !isLowerCase(name[0]) && validateTypeOf(math[name]) === 'function';
|
|
114
115
|
var dependenciesName = factory.fn + (isTransformFunction ? 'Transform' : '') + 'Dependencies';
|
|
115
|
-
allFactoryFunctions[factoryName] = '
|
|
116
|
+
allFactoryFunctions[factoryName] = 'function';
|
|
116
117
|
allFunctionsConstantsClasses[name] = validateTypeOf(math[name]);
|
|
117
118
|
allDependencyCollections[dependenciesName] = 'Object';
|
|
118
119
|
|
|
119
120
|
if (isTransformFunction) {
|
|
120
|
-
allTransformFunctions[name] = '
|
|
121
|
+
allTransformFunctions[name] = 'function';
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
if (isClass) {
|
|
124
125
|
if (endsWith(name, 'Node')) {
|
|
125
|
-
allNodeClasses[name] = '
|
|
126
|
+
allNodeClasses[name] = 'function';
|
|
126
127
|
} else {
|
|
127
|
-
allClasses[name] = '
|
|
128
|
+
allClasses[name] = 'function';
|
|
128
129
|
}
|
|
129
130
|
} else {
|
|
130
131
|
allFunctionsConstants[name] = validateTypeOf(math[name]);
|
|
@@ -144,37 +145,37 @@ export function createSnapshotFromFactories(factories) {
|
|
|
144
145
|
var allTypeChecks = {};
|
|
145
146
|
Object.keys(allIsFunctions).forEach(name => {
|
|
146
147
|
if (name.indexOf('is') === 0) {
|
|
147
|
-
allTypeChecks[name] = '
|
|
148
|
+
allTypeChecks[name] = 'function';
|
|
148
149
|
}
|
|
149
150
|
});
|
|
150
151
|
var allErrorClasses = {
|
|
151
|
-
ArgumentsError: '
|
|
152
|
-
DimensionError: '
|
|
153
|
-
IndexError: '
|
|
152
|
+
ArgumentsError: 'function',
|
|
153
|
+
DimensionError: 'function',
|
|
154
|
+
IndexError: 'function'
|
|
154
155
|
};
|
|
155
156
|
|
|
156
157
|
var expectedInstanceStructure = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, allFunctionsConstantsClasses), {}, {
|
|
157
|
-
on: '
|
|
158
|
-
off: '
|
|
159
|
-
once: '
|
|
160
|
-
emit: '
|
|
161
|
-
import: '
|
|
162
|
-
config: '
|
|
163
|
-
create: '
|
|
164
|
-
factory: '
|
|
158
|
+
on: 'function',
|
|
159
|
+
off: 'function',
|
|
160
|
+
once: 'function',
|
|
161
|
+
emit: 'function',
|
|
162
|
+
import: 'function',
|
|
163
|
+
config: 'function',
|
|
164
|
+
create: 'function',
|
|
165
|
+
factory: 'function'
|
|
165
166
|
}, allTypeChecks), allErrorClasses), {}, {
|
|
166
167
|
expression: {
|
|
167
168
|
transform: _objectSpread({}, allTransformFunctions),
|
|
168
169
|
mathWithTransform: _objectSpread(_objectSpread({}, exclude(allFunctionsConstants, ['chain'])), {}, {
|
|
169
|
-
config: '
|
|
170
|
+
config: 'function'
|
|
170
171
|
})
|
|
171
172
|
}
|
|
172
173
|
});
|
|
173
174
|
|
|
174
175
|
var expectedES6Structure = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, exclude(allFunctionsConstantsClasses, ['E', 'false', 'Infinity', 'NaN', 'null', 'PI', 'true'])), {}, {
|
|
175
|
-
create: '
|
|
176
|
-
config: '
|
|
177
|
-
factory: '
|
|
176
|
+
create: 'function',
|
|
177
|
+
config: 'function',
|
|
178
|
+
factory: 'function',
|
|
178
179
|
_true: 'boolean',
|
|
179
180
|
_false: 'boolean',
|
|
180
181
|
_null: 'null',
|
|
@@ -189,33 +190,6 @@ export function createSnapshotFromFactories(factories) {
|
|
|
189
190
|
expectedES6Structure
|
|
190
191
|
};
|
|
191
192
|
}
|
|
192
|
-
export function validateTypeOf(x) {
|
|
193
|
-
if (x && x.type === 'Unit') {
|
|
194
|
-
return 'Unit';
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (x && x.type === 'Complex') {
|
|
198
|
-
return 'Complex';
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
if (Array.isArray(x)) {
|
|
202
|
-
return 'Array';
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
if (x === null) {
|
|
206
|
-
return 'null';
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (typeof x === 'function') {
|
|
210
|
-
return 'Function';
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
if (typeof x === 'object') {
|
|
214
|
-
return 'Object';
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
return typeof x;
|
|
218
|
-
}
|
|
219
193
|
|
|
220
194
|
function traverse(obj) {
|
|
221
195
|
var callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (value, path) => {};
|
package/lib/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export var version = '
|
|
1
|
+
export var version = '11.1.0'; // Note: This file is automatically generated when building math.js.
|
|
2
2
|
// Changes made in this file will be overwritten.
|