mathjs 10.1.1 → 10.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/HISTORY.md +43 -0
- package/docs/expressions/algebra.md +27 -0
- package/docs/expressions/syntax.md +31 -2
- package/docs/reference/functions/abs.md +6 -0
- package/docs/reference/functions/acos.md +6 -0
- package/docs/reference/functions/acosh.md +6 -0
- package/docs/reference/functions/acot.md +6 -0
- package/docs/reference/functions/acoth.md +6 -0
- package/docs/reference/functions/acsc.md +6 -0
- package/docs/reference/functions/acsch.md +6 -0
- package/docs/reference/functions/add.md +6 -0
- package/docs/reference/functions/and.md +6 -0
- package/docs/reference/functions/apply.md +6 -0
- package/docs/reference/functions/arg.md +6 -0
- package/docs/reference/functions/asec.md +6 -0
- package/docs/reference/functions/asech.md +6 -0
- package/docs/reference/functions/asin.md +6 -0
- package/docs/reference/functions/asinh.md +6 -0
- package/docs/reference/functions/atan.md +6 -0
- package/docs/reference/functions/atan2.md +6 -0
- package/docs/reference/functions/atanh.md +6 -0
- package/docs/reference/functions/bellNumbers.md +6 -0
- package/docs/reference/functions/bin.md +6 -0
- package/docs/reference/functions/bitAnd.md +6 -0
- package/docs/reference/functions/bitNot.md +6 -0
- package/docs/reference/functions/bitOr.md +6 -0
- package/docs/reference/functions/bitXor.md +6 -0
- package/docs/reference/functions/catalan.md +6 -0
- package/docs/reference/functions/cbrt.md +6 -0
- package/docs/reference/functions/ceil.md +6 -0
- package/docs/reference/functions/clone.md +6 -0
- package/docs/reference/functions/column.md +6 -0
- package/docs/reference/functions/combinations.md +6 -0
- package/docs/reference/functions/combinationsWithRep.md +6 -0
- package/docs/reference/functions/compare.md +6 -0
- package/docs/reference/functions/compareNatural.md +6 -0
- package/docs/reference/functions/compareText.md +6 -0
- package/docs/reference/functions/compile.md +6 -0
- package/docs/reference/functions/composition.md +6 -0
- package/docs/reference/functions/concat.md +6 -0
- package/docs/reference/functions/conj.md +6 -0
- package/docs/reference/functions/cos.md +6 -0
- package/docs/reference/functions/cosh.md +6 -0
- package/docs/reference/functions/cot.md +6 -0
- package/docs/reference/functions/coth.md +6 -0
- package/docs/reference/functions/count.md +6 -0
- package/docs/reference/functions/cross.md +6 -0
- package/docs/reference/functions/csc.md +6 -0
- package/docs/reference/functions/csch.md +6 -0
- package/docs/reference/functions/ctranspose.md +6 -0
- package/docs/reference/functions/cube.md +6 -0
- package/docs/reference/functions/cumsum.md +57 -0
- package/docs/reference/functions/deepEqual.md +6 -0
- package/docs/reference/functions/derivative.md +6 -0
- package/docs/reference/functions/det.md +6 -0
- package/docs/reference/functions/diag.md +6 -0
- package/docs/reference/functions/diff.md +6 -0
- package/docs/reference/functions/distance.md +6 -0
- package/docs/reference/functions/divide.md +6 -0
- package/docs/reference/functions/dot.md +6 -0
- package/docs/reference/functions/dotDivide.md +6 -0
- package/docs/reference/functions/dotMultiply.md +6 -0
- package/docs/reference/functions/dotPow.md +6 -0
- package/docs/reference/functions/eigs.md +6 -0
- package/docs/reference/functions/equal.md +6 -0
- package/docs/reference/functions/equalText.md +6 -0
- package/docs/reference/functions/erf.md +6 -0
- package/docs/reference/functions/evaluate.md +6 -0
- package/docs/reference/functions/exp.md +6 -0
- package/docs/reference/functions/expm.md +6 -0
- package/docs/reference/functions/expm1.md +6 -0
- package/docs/reference/functions/factorial.md +6 -0
- package/docs/reference/functions/filter.md +6 -0
- package/docs/reference/functions/fix.md +6 -0
- package/docs/reference/functions/flatten.md +6 -0
- package/docs/reference/functions/floor.md +6 -0
- package/docs/reference/functions/forEach.md +6 -0
- package/docs/reference/functions/format.md +7 -1
- package/docs/reference/functions/gamma.md +6 -0
- package/docs/reference/functions/gcd.md +6 -0
- package/docs/reference/functions/getMatrixDataType.md +6 -0
- package/docs/reference/functions/hasNumericValue.md +6 -0
- package/docs/reference/functions/help.md +6 -0
- package/docs/reference/functions/hex.md +6 -0
- package/docs/reference/functions/hypot.md +6 -0
- package/docs/reference/functions/identity.md +6 -0
- package/docs/reference/functions/im.md +6 -0
- package/docs/reference/functions/intersect.md +6 -0
- package/docs/reference/functions/inv.md +6 -0
- package/docs/reference/functions/invmod.md +6 -0
- package/docs/reference/functions/isInteger.md +6 -0
- package/docs/reference/functions/isNaN.md +6 -0
- package/docs/reference/functions/isNegative.md +6 -0
- package/docs/reference/functions/isNumeric.md +6 -0
- package/docs/reference/functions/isPositive.md +6 -0
- package/docs/reference/functions/isPrime.md +6 -0
- package/docs/reference/functions/isZero.md +6 -0
- package/docs/reference/functions/kldivergence.md +6 -0
- package/docs/reference/functions/kron.md +6 -0
- package/docs/reference/functions/larger.md +6 -0
- package/docs/reference/functions/largerEq.md +6 -0
- package/docs/reference/functions/lcm.md +6 -0
- package/docs/reference/functions/leafCount.md +52 -0
- package/docs/reference/functions/leftShift.md +6 -0
- package/docs/reference/functions/log.md +6 -0
- package/docs/reference/functions/log10.md +6 -0
- package/docs/reference/functions/log1p.md +6 -0
- package/docs/reference/functions/log2.md +6 -0
- package/docs/reference/functions/lsolve.md +6 -0
- package/docs/reference/functions/lsolveAll.md +6 -0
- package/docs/reference/functions/lup.md +6 -0
- package/docs/reference/functions/lusolve.md +6 -0
- package/docs/reference/functions/mad.md +6 -0
- package/docs/reference/functions/map.md +28 -5
- package/docs/reference/functions/matrixFromColumns.md +6 -0
- package/docs/reference/functions/matrixFromFunction.md +6 -0
- package/docs/reference/functions/matrixFromRows.md +6 -0
- package/docs/reference/functions/max.md +6 -0
- package/docs/reference/functions/mean.md +6 -0
- package/docs/reference/functions/median.md +6 -0
- package/docs/reference/functions/min.md +6 -0
- package/docs/reference/functions/mod.md +6 -0
- package/docs/reference/functions/mode.md +6 -0
- package/docs/reference/functions/multinomial.md +6 -0
- package/docs/reference/functions/multiply.md +6 -0
- package/docs/reference/functions/norm.md +6 -0
- package/docs/reference/functions/not.md +6 -0
- package/docs/reference/functions/nthRoot.md +6 -0
- package/docs/reference/functions/nthRoots.md +6 -0
- package/docs/reference/functions/numeric.md +6 -0
- package/docs/reference/functions/oct.md +6 -0
- package/docs/reference/functions/ones.md +6 -0
- package/docs/reference/functions/or.md +6 -0
- package/docs/reference/functions/parser.md +6 -0
- package/docs/reference/functions/partitionSelect.md +6 -0
- package/docs/reference/functions/permutations.md +6 -0
- package/docs/reference/functions/pickRandom.md +6 -0
- package/docs/reference/functions/pow.md +6 -0
- package/docs/reference/functions/print.md +6 -0
- package/docs/reference/functions/prod.md +6 -0
- package/docs/reference/functions/qr.md +6 -0
- package/docs/reference/functions/quantileSeq.md +6 -0
- package/docs/reference/functions/random.md +6 -0
- package/docs/reference/functions/randomInt.md +6 -0
- package/docs/reference/functions/range.md +6 -0
- package/docs/reference/functions/rationalize.md +7 -1
- package/docs/reference/functions/re.md +6 -0
- package/docs/reference/functions/reshape.md +7 -0
- package/docs/reference/functions/resize.md +6 -0
- package/docs/reference/functions/resolve.md +46 -0
- package/docs/reference/functions/rightArithShift.md +6 -0
- package/docs/reference/functions/rightLogShift.md +6 -0
- package/docs/reference/functions/rotate.md +6 -0
- package/docs/reference/functions/rotationMatrix.md +6 -0
- package/docs/reference/functions/round.md +6 -0
- package/docs/reference/functions/row.md +6 -0
- package/docs/reference/functions/sec.md +6 -0
- package/docs/reference/functions/sech.md +6 -0
- package/docs/reference/functions/setCartesian.md +6 -0
- package/docs/reference/functions/setDifference.md +6 -0
- package/docs/reference/functions/setDistinct.md +6 -0
- package/docs/reference/functions/setIntersect.md +6 -0
- package/docs/reference/functions/setIsSubset.md +6 -0
- package/docs/reference/functions/setMultiplicity.md +6 -0
- package/docs/reference/functions/setPowerset.md +6 -0
- package/docs/reference/functions/setSize.md +6 -0
- package/docs/reference/functions/setSymDifference.md +6 -0
- package/docs/reference/functions/setUnion.md +6 -0
- package/docs/reference/functions/sign.md +6 -0
- package/docs/reference/functions/simplify.md +43 -6
- package/docs/reference/functions/simplifyCore.md +50 -0
- package/docs/reference/functions/sin.md +6 -0
- package/docs/reference/functions/sinh.md +6 -0
- package/docs/reference/functions/size.md +6 -0
- package/docs/reference/functions/slu.md +6 -0
- package/docs/reference/functions/smaller.md +6 -0
- package/docs/reference/functions/smallerEq.md +6 -0
- package/docs/reference/functions/sort.md +6 -0
- package/docs/reference/functions/sqrt.md +6 -0
- package/docs/reference/functions/sqrtm.md +6 -0
- package/docs/reference/functions/square.md +6 -0
- package/docs/reference/functions/squeeze.md +6 -0
- package/docs/reference/functions/std.md +6 -0
- package/docs/reference/functions/stirlingS2.md +6 -0
- package/docs/reference/functions/subset.md +16 -2
- package/docs/reference/functions/subtract.md +6 -0
- package/docs/reference/functions/sum.md +8 -1
- package/docs/reference/functions/symbolicEqual.md +62 -0
- package/docs/reference/functions/tan.md +6 -0
- package/docs/reference/functions/tanh.md +6 -0
- package/docs/reference/functions/to.md +6 -0
- package/docs/reference/functions/trace.md +6 -0
- package/docs/reference/functions/transpose.md +6 -0
- package/docs/reference/functions/typeOf.md +6 -0
- package/docs/reference/functions/unaryMinus.md +6 -0
- package/docs/reference/functions/unaryPlus.md +6 -0
- package/docs/reference/functions/unequal.md +6 -0
- package/docs/reference/functions/usolve.md +6 -0
- package/docs/reference/functions/usolveAll.md +6 -0
- package/docs/reference/functions/variance.md +6 -0
- package/docs/reference/functions/xgcd.md +6 -0
- package/docs/reference/functions/xor.md +6 -0
- package/docs/reference/functions/zeros.md +6 -0
- package/docs/reference/functions.md +6 -1
- package/lib/browser/math.js +6 -6
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/core/create.js +4 -4
- package/lib/cjs/core/function/import.js +3 -3
- package/lib/cjs/core/function/typed.js +2 -2
- package/lib/cjs/defaultInstance.js +3 -3
- package/lib/cjs/entry/allFactoriesAny.js +1 -1
- package/lib/cjs/entry/allFactoriesNumber.js +1 -1
- package/lib/cjs/entry/configReadonly.js +1 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesCumSum.generated.js +26 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesCumSumTransform.generated.js +26 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesLeafCount.generated.js +23 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesRationalize.generated.js +3 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesResolve.generated.js +32 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSimplify.generated.js +6 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSimplifyCore.generated.js +65 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSymbolicEqual.generated.js +29 -0
- package/lib/cjs/entry/dependenciesAny.generated.js +48 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesCumSum.generated.js +26 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesCumSumTransform.generated.js +26 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesRationalize.generated.js +3 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesResolve.generated.js +32 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesSimplify.generated.js +6 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesSimplifyCore.generated.js +65 -0
- package/lib/cjs/entry/dependenciesNumber.generated.js +32 -0
- package/lib/cjs/entry/impureFunctionsAny.generated.js +85 -33
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +102 -64
- package/lib/cjs/entry/pureFunctionsAny.generated.js +68 -64
- package/lib/cjs/entry/pureFunctionsNumber.generated.js +51 -47
- package/lib/cjs/expression/Help.js +4 -0
- package/lib/cjs/expression/Parser.js +1 -1
- package/lib/cjs/expression/embeddedDocs/construction/fraction.js +3 -3
- package/lib/cjs/expression/embeddedDocs/core/typed.js +1 -1
- package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +250 -235
- package/lib/cjs/expression/embeddedDocs/function/algebra/leafCount.js +15 -0
- package/lib/cjs/expression/embeddedDocs/function/algebra/resolve.js +16 -0
- package/lib/cjs/expression/embeddedDocs/function/algebra/simplify.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/algebra/simplifyCore.js +15 -0
- package/lib/cjs/expression/embeddedDocs/function/algebra/symbolicEqual.js +15 -0
- package/lib/cjs/expression/embeddedDocs/function/matrix/subset.js +2 -2
- package/lib/cjs/expression/embeddedDocs/function/statistics/cumsum.js +15 -0
- package/lib/cjs/expression/node/FunctionNode.js +80 -61
- package/lib/cjs/expression/node/IndexNode.js +1 -1
- package/lib/cjs/expression/node/Node.js +3 -3
- package/lib/cjs/expression/node/ObjectNode.js +1 -1
- package/lib/cjs/expression/node/utils/access.js +1 -1
- package/lib/cjs/expression/node/utils/assign.js +1 -1
- package/lib/cjs/expression/parse.js +13 -13
- package/lib/cjs/expression/transform/cumsum.transform.js +57 -0
- package/lib/cjs/expression/transform/sum.transform.js +1 -1
- package/lib/cjs/factoriesAny.js +48 -0
- package/lib/cjs/factoriesNumber.js +33 -1
- package/lib/cjs/function/algebra/decomposition/qr.js +1 -1
- package/lib/cjs/function/algebra/leafCount.js +66 -0
- package/lib/cjs/function/algebra/rationalize.js +24 -41
- package/lib/cjs/function/algebra/resolve.js +106 -0
- package/lib/cjs/function/algebra/simplify/simplifyConstant.js +5 -5
- package/lib/cjs/function/algebra/simplify/util.js +171 -33
- package/lib/cjs/function/algebra/simplify.js +562 -207
- package/lib/cjs/function/algebra/{simplify/simplifyCore.js → simplifyCore.js} +68 -44
- 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 +88 -0
- package/lib/cjs/function/arithmetic/ceil.js +3 -3
- package/lib/cjs/function/arithmetic/floor.js +3 -3
- package/lib/cjs/function/arithmetic/invmod.js +1 -1
- package/lib/cjs/function/arithmetic/norm.js +1 -1
- package/lib/cjs/function/arithmetic/round.js +1 -1
- package/lib/cjs/function/matrix/eigs/complexEigs.js +13 -11
- package/lib/cjs/function/matrix/map.js +53 -15
- package/lib/cjs/function/matrix/matrixFromColumns.js +1 -1
- package/lib/cjs/function/matrix/matrixFromRows.js +1 -1
- package/lib/cjs/function/matrix/subset.js +15 -5
- package/lib/cjs/function/probability/util/seededRNG.js +2 -2
- package/lib/cjs/function/relational/compareNatural.js +6 -6
- package/lib/cjs/function/statistics/cumsum.js +151 -0
- package/lib/cjs/function/statistics/sum.js +1 -1
- package/lib/cjs/function/string/format.js +1 -1
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/plain/bignumber/index.js +1 -1
- package/lib/cjs/plain/number/combinations.js +18 -6
- package/lib/cjs/type/bignumber/BigNumber.js +2 -2
- package/lib/cjs/type/bignumber/function/bignumber.js +1 -1
- package/lib/cjs/type/boolean.js +2 -2
- package/lib/cjs/type/complex/Complex.js +14 -14
- package/lib/cjs/type/complex/function/complex.js +1 -1
- package/lib/cjs/type/fraction/Fraction.js +6 -6
- package/lib/cjs/type/fraction/function/fraction.js +21 -9
- package/lib/cjs/type/matrix/DenseMatrix.js +5 -5
- package/lib/cjs/type/matrix/SparseMatrix.js +2 -2
- package/lib/cjs/type/number.js +1 -1
- package/lib/cjs/type/string.js +2 -2
- package/lib/cjs/type/unit/Unit.js +8 -8
- package/lib/cjs/utils/collection.js +3 -27
- package/lib/cjs/utils/customs.js +2 -2
- package/lib/cjs/utils/emitter.js +1 -1
- package/lib/cjs/utils/function.js +2 -2
- package/lib/cjs/utils/is.js +6 -6
- package/lib/cjs/utils/latex.js +3 -3
- package/lib/cjs/utils/lruQueue.js +1 -1
- package/lib/cjs/utils/map.js +3 -3
- package/lib/cjs/utils/object.js +2 -2
- package/lib/cjs/utils/snapshot.js +7 -7
- package/lib/cjs/utils/string.js +2 -2
- package/lib/cjs/utils/switch.js +31 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/entry/dependenciesAny/dependenciesCumSum.generated.js +14 -0
- package/lib/esm/entry/dependenciesAny/dependenciesCumSumTransform.generated.js +14 -0
- package/lib/esm/entry/dependenciesAny/dependenciesLeafCount.generated.js +12 -0
- package/lib/esm/entry/dependenciesAny/dependenciesRationalize.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesResolve.generated.js +18 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSimplify.generated.js +4 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSimplifyCore.generated.js +40 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSymbolicEqual.generated.js +16 -0
- package/lib/esm/entry/dependenciesAny.generated.js +6 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesCumSum.generated.js +14 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesCumSumTransform.generated.js +14 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesRationalize.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesResolve.generated.js +18 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesSimplify.generated.js +4 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesSimplifyCore.generated.js +40 -0
- package/lib/esm/entry/dependenciesNumber.generated.js +4 -0
- package/lib/esm/entry/impureFunctionsAny.generated.js +74 -26
- package/lib/esm/entry/impureFunctionsNumber.generated.js +89 -53
- package/lib/esm/entry/pureFunctionsAny.generated.js +54 -49
- package/lib/esm/entry/pureFunctionsNumber.generated.js +36 -31
- package/lib/esm/expression/Help.js +4 -0
- package/lib/esm/expression/embeddedDocs/construction/fraction.js +3 -3
- package/lib/esm/expression/embeddedDocs/core/typed.js +1 -1
- package/lib/esm/expression/embeddedDocs/embeddedDocs.js +222 -212
- package/lib/esm/expression/embeddedDocs/function/algebra/leafCount.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/algebra/resolve.js +9 -0
- package/lib/esm/expression/embeddedDocs/function/algebra/simplify.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/algebra/simplifyCore.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/algebra/symbolicEqual.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/matrix/subset.js +2 -2
- package/lib/esm/expression/embeddedDocs/function/statistics/cumsum.js +8 -0
- package/lib/esm/expression/node/FunctionNode.js +70 -53
- package/lib/esm/expression/transform/cumsum.transform.js +48 -0
- package/lib/esm/expression/transform/sum.transform.js +1 -1
- package/lib/esm/factoriesAny.js +6 -0
- package/lib/esm/factoriesNumber.js +4 -0
- package/lib/esm/function/algebra/leafCount.js +59 -0
- package/lib/esm/function/algebra/rationalize.js +24 -40
- package/lib/esm/function/algebra/resolve.js +95 -0
- package/lib/esm/function/algebra/simplify/simplifyConstant.js +3 -3
- package/lib/esm/function/algebra/simplify/util.js +170 -34
- package/lib/esm/function/algebra/simplify.js +557 -202
- package/lib/esm/function/algebra/{simplify/simplifyCore.js → simplifyCore.js} +61 -45
- package/lib/esm/function/algebra/symbolicEqual.js +80 -0
- package/lib/esm/function/matrix/eigs/complexEigs.js +8 -6
- package/lib/esm/function/matrix/map.js +53 -15
- package/lib/esm/function/matrix/subset.js +15 -5
- package/lib/esm/function/statistics/cumsum.js +139 -0
- package/lib/esm/function/statistics/sum.js +1 -1
- package/lib/esm/function/string/format.js +1 -1
- package/lib/esm/plain/number/combinations.js +18 -6
- package/lib/esm/type/fraction/function/fraction.js +20 -8
- package/lib/esm/utils/collection.js +1 -26
- package/lib/esm/utils/switch.js +24 -0
- package/lib/esm/version.js +1 -1
- package/package.json +15 -10
- package/types/index.d.ts +155 -13
- package/lib/cjs/function/algebra/simplify/resolve.js +0 -76
- package/lib/esm/function/algebra/simplify/resolve.js +0 -67
@@ -9,27 +9,39 @@ export var createFraction = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
9
9
|
} = _ref;
|
10
10
|
|
11
11
|
/**
|
12
|
-
* Create a fraction convert a value to a fraction.
|
12
|
+
* Create a fraction or convert a value to a fraction.
|
13
|
+
*
|
14
|
+
* With one numeric argument, produces the closest rational approximation to the
|
15
|
+
* input.
|
16
|
+
* With two arguments, the first is the numerator and the second is the denominator,
|
17
|
+
* and creates the corresponding fraction. Both numerator and denominator must be
|
18
|
+
* integers.
|
19
|
+
* With one object argument, looks for the integer numerator as the value of property
|
20
|
+
* 'n' and the integer denominator as the value of property 'd'.
|
21
|
+
* With a matrix argument, creates a matrix of the same shape with entries
|
22
|
+
* converted into fractions.
|
13
23
|
*
|
14
24
|
* Syntax:
|
25
|
+
* math.fraction(value)
|
15
26
|
* math.fraction(numerator, denominator)
|
16
27
|
* math.fraction({n: numerator, d: denominator})
|
17
|
-
* math.fraction(matrix: Array | Matrix)
|
18
|
-
* into fractions
|
28
|
+
* math.fraction(matrix: Array | Matrix)
|
19
29
|
*
|
20
30
|
* Examples:
|
21
31
|
*
|
22
|
-
* math.fraction(
|
23
|
-
* math.fraction(
|
24
|
-
* math.fraction(
|
25
|
-
* math.fraction(
|
32
|
+
* math.fraction(6.283) // returns Fraction 6283/1000
|
33
|
+
* math.fraction(1, 3) // returns Fraction 1/3
|
34
|
+
* math.fraction('2/3') // returns Fraction 2/3
|
35
|
+
* math.fraction({n: 2, d: 3}) // returns Fraction 2/3
|
36
|
+
* math.fraction([0.2, 0.25, 1.25]) // returns Array [1/5, 1/4, 5/4]
|
37
|
+
* math.fraction(4, 5.1) // throws Error: Parameters must be integer
|
26
38
|
*
|
27
39
|
* See also:
|
28
40
|
*
|
29
41
|
* bignumber, number, string, unit
|
30
42
|
*
|
31
43
|
* @param {number | string | Fraction | BigNumber | Array | Matrix} [args]
|
32
|
-
* Arguments specifying the numerator and denominator of
|
44
|
+
* Arguments specifying the value, or numerator and denominator of
|
33
45
|
* the fraction
|
34
46
|
* @return {Fraction | Array | Matrix} Returns a fraction
|
35
47
|
*/
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { isCollection, isMatrix } from './is.js';
|
2
2
|
import { IndexError } from '../error/IndexError.js';
|
3
3
|
import { arraySize } from './array.js';
|
4
|
+
import { _switch } from './switch.js';
|
4
5
|
/**
|
5
6
|
* Test whether an array contains collections
|
6
7
|
* @param {Array} array
|
@@ -127,32 +128,6 @@ function _reduce(mat, dim, callback) {
|
|
127
128
|
|
128
129
|
return ret;
|
129
130
|
}
|
130
|
-
}
|
131
|
-
/**
|
132
|
-
* Transpose a matrix
|
133
|
-
* @param {Array} mat
|
134
|
-
* @returns {Array} ret
|
135
|
-
* @private
|
136
|
-
*/
|
137
|
-
|
138
|
-
|
139
|
-
function _switch(mat) {
|
140
|
-
var I = mat.length;
|
141
|
-
var J = mat[0].length;
|
142
|
-
var i, j;
|
143
|
-
var ret = [];
|
144
|
-
|
145
|
-
for (j = 0; j < J; j++) {
|
146
|
-
var tmp = [];
|
147
|
-
|
148
|
-
for (i = 0; i < I; i++) {
|
149
|
-
tmp.push(mat[i][j]);
|
150
|
-
}
|
151
|
-
|
152
|
-
ret.push(tmp);
|
153
|
-
}
|
154
|
-
|
155
|
-
return ret;
|
156
131
|
} // TODO: document function scatter
|
157
132
|
|
158
133
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/**
|
2
|
+
* Transpose a matrix
|
3
|
+
* @param {Array} mat
|
4
|
+
* @returns {Array} ret
|
5
|
+
* @private
|
6
|
+
*/
|
7
|
+
export function _switch(mat) {
|
8
|
+
var I = mat.length;
|
9
|
+
var J = mat[0].length;
|
10
|
+
var i, j;
|
11
|
+
var ret = [];
|
12
|
+
|
13
|
+
for (j = 0; j < J; j++) {
|
14
|
+
var tmp = [];
|
15
|
+
|
16
|
+
for (i = 0; i < I; i++) {
|
17
|
+
tmp.push(mat[i][j]);
|
18
|
+
}
|
19
|
+
|
20
|
+
ret.push(tmp);
|
21
|
+
}
|
22
|
+
|
23
|
+
return ret;
|
24
|
+
}
|
package/lib/esm/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export var version = '10.
|
1
|
+
export var version = '10.4.0'; // Note: This file is automatically generated when building math.js.
|
2
2
|
// Changes made in this file will be overwritten.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "mathjs",
|
3
|
-
"version": "10.
|
3
|
+
"version": "10.4.0",
|
4
4
|
"description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
|
5
5
|
"author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
|
6
6
|
"homepage": "https://mathjs.org",
|
@@ -25,26 +25,27 @@
|
|
25
25
|
"unit"
|
26
26
|
],
|
27
27
|
"dependencies": {
|
28
|
-
"@babel/runtime": "^7.
|
28
|
+
"@babel/runtime": "^7.17.2",
|
29
29
|
"complex.js": "^2.0.15",
|
30
30
|
"decimal.js": "^10.3.1",
|
31
31
|
"escape-latex": "^1.2.0",
|
32
|
-
"fraction.js": "^4.
|
32
|
+
"fraction.js": "^4.2.0",
|
33
33
|
"javascript-natural-sort": "^0.7.1",
|
34
34
|
"seedrandom": "^3.0.5",
|
35
35
|
"tiny-emitter": "^2.1.0",
|
36
36
|
"typed-function": "^2.0.0"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
|
-
"@babel/core": "7.
|
39
|
+
"@babel/core": "7.17.5",
|
40
40
|
"@babel/plugin-transform-object-assign": "7.16.7",
|
41
|
-
"@babel/plugin-transform-runtime": "7.
|
41
|
+
"@babel/plugin-transform-runtime": "7.17.0",
|
42
42
|
"@babel/preset-env": "7.16.11",
|
43
|
-
"@babel/register": "7.
|
43
|
+
"@babel/register": "7.17.0",
|
44
|
+
"assert": "2.0.0",
|
44
45
|
"babel-loader": "8.2.3",
|
45
46
|
"benchmark": "2.1.4",
|
46
47
|
"codecov": "3.8.3",
|
47
|
-
"core-js": "3.21.
|
48
|
+
"core-js": "3.21.1",
|
48
49
|
"del": "6.0.0",
|
49
50
|
"dtslint": "4.2.1",
|
50
51
|
"expr-eval": "2.0.2",
|
@@ -54,8 +55,8 @@
|
|
54
55
|
"gulp-babel": "8.0.0",
|
55
56
|
"handlebars": "4.7.7",
|
56
57
|
"istanbul": "0.4.5",
|
57
|
-
"jsep": "1.
|
58
|
-
"karma": "6.3.
|
58
|
+
"jsep": "1.3.0",
|
59
|
+
"karma": "6.3.16",
|
59
60
|
"karma-browserstack-launcher": "1.6.0",
|
60
61
|
"karma-firefox-launcher": "2.1.2",
|
61
62
|
"karma-mocha": "2.0.1",
|
@@ -72,6 +73,7 @@
|
|
72
73
|
"numericjs": "1.2.6",
|
73
74
|
"nyc": "15.1.0",
|
74
75
|
"pad-right": "0.2.2",
|
76
|
+
"process": "0.11.10",
|
75
77
|
"standard": "16.0.4",
|
76
78
|
"sylvester": "0.0.21",
|
77
79
|
"typescript": "4.5.5",
|
@@ -124,7 +126,7 @@
|
|
124
126
|
"CONTRIBUTING.md"
|
125
127
|
],
|
126
128
|
"scripts": {
|
127
|
-
"build": "gulp --gulpfile gulpfile.cjs",
|
129
|
+
"build": "gulp --gulpfile gulpfile.cjs && npm run update-authors",
|
128
130
|
"build-and-test": "npm run build && npm run test:all && npm run lint",
|
129
131
|
"build:clean": "gulp --gulpfile gulpfile.cjs clean",
|
130
132
|
"build:docs": "gulp --gulpfile gulpfile.cjs docs",
|
@@ -161,5 +163,8 @@
|
|
161
163
|
"src": "./src",
|
162
164
|
"test": "./test"
|
163
165
|
},
|
166
|
+
"browserslist": [
|
167
|
+
"IE 11"
|
168
|
+
],
|
164
169
|
"sideEffects": false
|
165
170
|
}
|
package/types/index.d.ts
CHANGED
@@ -575,7 +575,7 @@ declare namespace math {
|
|
575
575
|
* @param unit The unit to be created
|
576
576
|
* @returns The created unit
|
577
577
|
*/
|
578
|
-
unit(value: number | MathArray | Matrix, unit: string): Unit;
|
578
|
+
unit(value: number | MathArray | Matrix | BigNumber, unit: string): Unit;
|
579
579
|
|
580
580
|
/*************************************************************************
|
581
581
|
* Expression functions
|
@@ -1674,6 +1674,19 @@ declare namespace math {
|
|
1674
1674
|
column: number
|
1675
1675
|
): T;
|
1676
1676
|
|
1677
|
+
/**
|
1678
|
+
* Return a rotated matrix.
|
1679
|
+
* @param {Array | Matrix} w Vector to rotate
|
1680
|
+
* @param {number | BigNumber | Complex | Unit} theta Rotation angle
|
1681
|
+
* @param {Array | Matrix} [v] Rotation axis
|
1682
|
+
* @return {Array | Matrix} Multiplication of the rotation matrix and w
|
1683
|
+
*/
|
1684
|
+
rotate<T extends MathArray | Matrix>(
|
1685
|
+
w: T,
|
1686
|
+
theta: number | BigNumber | Complex | Unit,
|
1687
|
+
v?: T
|
1688
|
+
): T;
|
1689
|
+
|
1677
1690
|
/**
|
1678
1691
|
* Calculate the size of a matrix or scalar.
|
1679
1692
|
* @param A matrix
|
@@ -1710,7 +1723,7 @@ declare namespace math {
|
|
1710
1723
|
/**
|
1711
1724
|
* Get or set a subset of a matrix or string.
|
1712
1725
|
* @param value An array, matrix, or string
|
1713
|
-
* @param index
|
1726
|
+
* @param index For each dimension, an index or list of indices to get or set.
|
1714
1727
|
* @param replacement An array, matrix, or scalar. If provided, the
|
1715
1728
|
* subset is replaced with replacement. If not provided, the subset is
|
1716
1729
|
* returned
|
@@ -1783,7 +1796,7 @@ declare namespace math {
|
|
1783
1796
|
* @param n A real or complex number
|
1784
1797
|
* @returns The gamma of n
|
1785
1798
|
*/
|
1786
|
-
gamma
|
1799
|
+
gamma<T extends number | BigNumber | Complex | MathArray | Matrix>(n: T): NoLiteralType<T>;
|
1787
1800
|
|
1788
1801
|
/**
|
1789
1802
|
* Calculate the Kullback-Leibler (KL) divergence between two
|
@@ -2210,6 +2223,38 @@ declare namespace math {
|
|
2210
2223
|
*/
|
2211
2224
|
quantileSeq(A: MathArray | Matrix, prob: number | BigNumber | MathArray, sorted?: boolean): number | BigNumber | Unit | MathArray;
|
2212
2225
|
|
2226
|
+
/**
|
2227
|
+
* Compute the standard deviation of a matrix or a list with values. The
|
2228
|
+
* standard deviations is defined as the square root of the variance:
|
2229
|
+
* std(A) = sqrt(variance(A)). In case of a (multi dimensional) array or
|
2230
|
+
* matrix, the standard deviation over all elements will be calculated.
|
2231
|
+
* Optionally, the type of normalization can be specified as second
|
2232
|
+
* parameter. The parameter normalization can be one of the following
|
2233
|
+
* values: 'unbiased' (default) The sum of squared errors is divided by
|
2234
|
+
* (n - 1) 'uncorrected' The sum of squared errors is divided by n
|
2235
|
+
* 'biased' The sum of squared errors is divided by (n + 1)
|
2236
|
+
* @param a variadic argument of number to calculate standard deviation
|
2237
|
+
* @returns The standard deviation array
|
2238
|
+
*/
|
2239
|
+
std(...values: number[]): number
|
2240
|
+
/**
|
2241
|
+
* Compute the standard deviation of a matrix or a list with values. The
|
2242
|
+
* standard deviations is defined as the square root of the variance:
|
2243
|
+
* std(A) = sqrt(variance(A)). In case of a (multi dimensional) array or
|
2244
|
+
* matrix, the standard deviation over all elements will be calculated.
|
2245
|
+
* Optionally, the type of normalization can be specified as second
|
2246
|
+
* parameter. The parameter normalization can be one of the following
|
2247
|
+
* values: 'unbiased' (default) The sum of squared errors is divided by
|
2248
|
+
* (n - 1) 'uncorrected' The sum of squared errors is divided by n
|
2249
|
+
* 'biased' The sum of squared errors is divided by (n + 1)
|
2250
|
+
* @param array A single matrix to compute standard deviation.
|
2251
|
+
* @param dimension A dimension to calculate standard deviation
|
2252
|
+
* @param normalization Determines how to normalize the variance. Choose
|
2253
|
+
* ‘unbiased’ (default), ‘uncorrected’, or ‘biased’. Default value:
|
2254
|
+
* ‘unbiased’.
|
2255
|
+
* @returns The standard deviation array
|
2256
|
+
*/
|
2257
|
+
std(array: MathArray | Matrix, dimension: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): number[]
|
2213
2258
|
/**
|
2214
2259
|
* Compute the standard deviation of a matrix or a list with values. The
|
2215
2260
|
* standard deviations is defined as the square root of the variance:
|
@@ -2226,7 +2271,7 @@ declare namespace math {
|
|
2226
2271
|
* ‘unbiased’.
|
2227
2272
|
* @returns The standard deviation
|
2228
2273
|
*/
|
2229
|
-
std(array: MathArray | Matrix, normalization
|
2274
|
+
std(array: MathArray | Matrix, normalization: 'unbiased' | 'uncorrected' | 'biased'): number
|
2230
2275
|
|
2231
2276
|
/**
|
2232
2277
|
* Compute the sum of a matrix or a list with values. In case of a
|
@@ -2242,6 +2287,21 @@ declare namespace math {
|
|
2242
2287
|
*/
|
2243
2288
|
sum(array: MathArray | Matrix): any;
|
2244
2289
|
|
2290
|
+
/**
|
2291
|
+
* Compute the cumulative sum of a matrix or a list with values.
|
2292
|
+
* In case of a (multi dimensional) array or matrix, the cumulative sums
|
2293
|
+
* along a specified dimension (defaulting to the first) will be calculated.
|
2294
|
+
* @param args A single matrix or multiple scalar values
|
2295
|
+
* @returns The cumulative sums of the the values.
|
2296
|
+
*/
|
2297
|
+
cumsum(...args: MathType[]): MathType[];
|
2298
|
+
/**
|
2299
|
+
* @param array A single matrix
|
2300
|
+
* @param dim The dimension along which to sum (defaults to 0)
|
2301
|
+
* @returns The cumulative sums along the given dimension
|
2302
|
+
*/
|
2303
|
+
cumsum(array: MathArray | Matrix, dim?: number): MathArray | Matrix;
|
2304
|
+
|
2245
2305
|
/**
|
2246
2306
|
* Compute the variance of a matrix or a list with values. In case of a
|
2247
2307
|
* (multi dimensional) array or matrix, the variance over all elements
|
@@ -2256,7 +2316,26 @@ declare namespace math {
|
|
2256
2316
|
* @param args A single matrix or multiple scalar values
|
2257
2317
|
* @returns The variance
|
2258
2318
|
*/
|
2259
|
-
variance(...args: Array<number | BigNumber | Fraction>):
|
2319
|
+
variance(...args: Array<number | BigNumber | Fraction>): number;
|
2320
|
+
/**
|
2321
|
+
* Compute the variance of a matrix or a list with values. In case of a
|
2322
|
+
* (multi dimensional) array or matrix, the variance over all elements
|
2323
|
+
* will be calculated. Optionally, the type of normalization can be
|
2324
|
+
* specified as second parameter. The parameter normalization can be one
|
2325
|
+
* of the following values: 'unbiased' (default) The sum of squared
|
2326
|
+
* errors is divided by (n - 1) 'uncorrected' The sum of squared errors
|
2327
|
+
* is divided by n 'biased' The sum of squared errors is divided by (n +
|
2328
|
+
* 1) Note that older browser may not like the variable name var. In
|
2329
|
+
* that case, the function can be called as math['var'](...) instead of
|
2330
|
+
* math.variance(...).
|
2331
|
+
* @param array A matrix to compute variance.
|
2332
|
+
* @param dimension A dimension to compute variance on
|
2333
|
+
* @param normalization normalization Determines how to normalize the
|
2334
|
+
* variance. Choose ‘unbiased’ (default), ‘uncorrected’, or ‘biased’.
|
2335
|
+
* Default value: ‘unbiased’.
|
2336
|
+
* @returns variance matrix.
|
2337
|
+
*/
|
2338
|
+
variance(array: MathArray | Matrix, dimension: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): number[];
|
2260
2339
|
/**
|
2261
2340
|
* @param array A single matrix
|
2262
2341
|
* @param normalization normalization Determines how to normalize the
|
@@ -2264,7 +2343,7 @@ declare namespace math {
|
|
2264
2343
|
* Default value: ‘unbiased’.
|
2265
2344
|
* @returns The variance
|
2266
2345
|
*/
|
2267
|
-
variance(array: MathArray | Matrix, normalization?: 'unbiased' | 'uncorrected' | 'biased'
|
2346
|
+
variance(array: MathArray | Matrix, normalization?: 'unbiased' | 'uncorrected' | 'biased'): number;
|
2268
2347
|
|
2269
2348
|
/*************************************************************************
|
2270
2349
|
* String functions
|
@@ -3121,6 +3200,28 @@ declare namespace math {
|
|
3121
3200
|
fixPrefix?: boolean;
|
3122
3201
|
}
|
3123
3202
|
|
3203
|
+
interface UnitComponent {
|
3204
|
+
power: number;
|
3205
|
+
prefix: string;
|
3206
|
+
unit: {
|
3207
|
+
name: string;
|
3208
|
+
base: {
|
3209
|
+
dimensions: number[];
|
3210
|
+
key: string;
|
3211
|
+
};
|
3212
|
+
prefixes: Record<string, UnitPrefix>;
|
3213
|
+
value: number;
|
3214
|
+
offset: number;
|
3215
|
+
dimensions: number[];
|
3216
|
+
};
|
3217
|
+
}
|
3218
|
+
|
3219
|
+
interface UnitPrefix {
|
3220
|
+
name: string;
|
3221
|
+
value: number;
|
3222
|
+
scientific: boolean;
|
3223
|
+
}
|
3224
|
+
|
3124
3225
|
interface Unit {
|
3125
3226
|
valueOf(): string;
|
3126
3227
|
clone(): Unit;
|
@@ -3139,7 +3240,14 @@ declare namespace math {
|
|
3139
3240
|
toJSON(): MathJSON;
|
3140
3241
|
formatUnits(): string;
|
3141
3242
|
format(options: FormatOptions): string;
|
3243
|
+
simplify(): Unit;
|
3142
3244
|
splitUnit(parts: ReadonlyArray<string | Unit>): Unit[];
|
3245
|
+
|
3246
|
+
units: UnitComponent[];
|
3247
|
+
dimensions: number[];
|
3248
|
+
value: number;
|
3249
|
+
fixPrefix: boolean;
|
3250
|
+
skipAutomaticSimplification: true;
|
3143
3251
|
}
|
3144
3252
|
|
3145
3253
|
interface CreateUnitOptions {
|
@@ -3176,8 +3284,6 @@ declare namespace math {
|
|
3176
3284
|
): MathNode;
|
3177
3285
|
|
3178
3286
|
rules: SimplifyRule[];
|
3179
|
-
|
3180
|
-
simplifyCore(expr: MathNode): MathNode;
|
3181
3287
|
}
|
3182
3288
|
|
3183
3289
|
interface UnitDefinition {
|
@@ -3640,6 +3746,8 @@ declare namespace math {
|
|
3640
3746
|
*/
|
3641
3747
|
simplify(rules?: SimplifyRule[], scope?: object): MathJsChain;
|
3642
3748
|
|
3749
|
+
simplifyCore(expr: MathNode): MathNode;
|
3750
|
+
|
3643
3751
|
/**
|
3644
3752
|
* Calculate the Sparse Matrix LU decomposition with full pivoting.
|
3645
3753
|
* Sparse Matrix A is decomposed in two matrices (L, U) and two
|
@@ -4277,7 +4385,7 @@ declare namespace math {
|
|
4277
4385
|
|
4278
4386
|
/**
|
4279
4387
|
* Get or set a subset of a matrix or string.
|
4280
|
-
* @param index
|
4388
|
+
* @param index For each dimension, an index or list of indices to get or set
|
4281
4389
|
* @param replacement An array, matrix, or scalar. If provided, the
|
4282
4390
|
* subset is replaced with replacement. If not provided, the subset is
|
4283
4391
|
* returned
|
@@ -4664,7 +4772,24 @@ declare namespace math {
|
|
4664
4772
|
* @param sorted =false is data sorted in ascending order
|
4665
4773
|
*/
|
4666
4774
|
quantileSeq(prob: number | BigNumber | MathArray, sorted?: boolean): MathJsChain;
|
4667
|
-
|
4775
|
+
/**
|
4776
|
+
* Compute the standard deviation of a matrix or a list with values. The
|
4777
|
+
* standard deviations is defined as the square root of the variance:
|
4778
|
+
* std(A) = sqrt(variance(A)). In case of a (multi dimensional) array or
|
4779
|
+
* matrix, the standard deviation over all elements will be calculated.
|
4780
|
+
* Optionally, the type of normalization can be specified as second
|
4781
|
+
* parameter. The parameter normalization can be one of the following
|
4782
|
+
* values: 'unbiased' (default) The sum of squared errors is divided by
|
4783
|
+
* (n - 1) 'uncorrected' The sum of squared errors is divided by n
|
4784
|
+
* 'biased' The sum of squared errors is divided by (n + 1)
|
4785
|
+
* @param array A single matrix or multiple scalar values
|
4786
|
+
* @param dim A dimension to compute standard deviation.
|
4787
|
+
* @param normalization Determines how to normalize the variance. Choose
|
4788
|
+
* ‘unbiased’ (default), ‘uncorrected’, or ‘biased’. Default value:
|
4789
|
+
* ‘unbiased’.
|
4790
|
+
* @returns The standard deviation
|
4791
|
+
*/
|
4792
|
+
std(dim: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
|
4668
4793
|
/**
|
4669
4794
|
* Compute the standard deviation of a matrix or a list with values. The
|
4670
4795
|
* standard deviations is defined as the square root of the variance:
|
@@ -4681,7 +4806,7 @@ declare namespace math {
|
|
4681
4806
|
* ‘unbiased’.
|
4682
4807
|
* @returns The standard deviation
|
4683
4808
|
*/
|
4684
|
-
std(normalization?: 'unbiased' | 'uncorrected' | 'biased'
|
4809
|
+
std(normalization?: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
|
4685
4810
|
|
4686
4811
|
/**
|
4687
4812
|
* Compute the sum of a matrix or a list with values. In case of a
|
@@ -4689,7 +4814,24 @@ declare namespace math {
|
|
4689
4814
|
* calculated.
|
4690
4815
|
*/
|
4691
4816
|
sum(): MathJsChain;
|
4692
|
-
|
4817
|
+
/**
|
4818
|
+
* Compute the variance of a matrix or a list with values. In case of a
|
4819
|
+
* (multi dimensional) array or matrix, the variance over all elements
|
4820
|
+
* will be calculated. Optionally, the type of normalization can be
|
4821
|
+
* specified as second parameter. The parameter normalization can be one
|
4822
|
+
* of the following values: 'unbiased' (default) The sum of squared
|
4823
|
+
* errors is divided by (n - 1) 'uncorrected' The sum of squared errors
|
4824
|
+
* is divided by n 'biased' The sum of squared errors is divided by (n +
|
4825
|
+
* 1) Note that older browser may not like the variable name var. In
|
4826
|
+
* that case, the function can be called as math['var'](...) instead of
|
4827
|
+
* math.variance(...).
|
4828
|
+
* @param dim a dimension to compute variance.
|
4829
|
+
* @param normalization normalization Determines how to normalize the
|
4830
|
+
* variance. Choose ‘unbiased’ (default), ‘uncorrected’, or ‘biased’.
|
4831
|
+
* Default value: ‘unbiased’.
|
4832
|
+
* @returns The variance
|
4833
|
+
*/
|
4834
|
+
variance(dim: number, normalization?: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
|
4693
4835
|
/**
|
4694
4836
|
* Compute the variance of a matrix or a list with values. In case of a
|
4695
4837
|
* (multi dimensional) array or matrix, the variance over all elements
|
@@ -4706,7 +4848,7 @@ declare namespace math {
|
|
4706
4848
|
* Default value: ‘unbiased’.
|
4707
4849
|
* @returns The variance
|
4708
4850
|
*/
|
4709
|
-
variance(normalization?: 'unbiased' | 'uncorrected' | 'biased'
|
4851
|
+
variance(normalization?: 'unbiased' | 'uncorrected' | 'biased'): MathJsChain;
|
4710
4852
|
|
4711
4853
|
/*************************************************************************
|
4712
4854
|
* String functions
|
@@ -1,76 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.createResolve = void 0;
|
7
|
-
|
8
|
-
var _map = require("../../../utils/map.js");
|
9
|
-
|
10
|
-
var _is = require("../../../utils/is.js");
|
11
|
-
|
12
|
-
var _factory = require("../../../utils/factory.js");
|
13
|
-
|
14
|
-
var name = 'resolve';
|
15
|
-
var dependencies = ['parse', 'FunctionNode', 'OperatorNode', 'ParenthesisNode'];
|
16
|
-
var createResolve = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
|
17
|
-
var parse = _ref.parse,
|
18
|
-
FunctionNode = _ref.FunctionNode,
|
19
|
-
OperatorNode = _ref.OperatorNode,
|
20
|
-
ParenthesisNode = _ref.ParenthesisNode;
|
21
|
-
|
22
|
-
/**
|
23
|
-
* resolve(expr, scope) replaces variable nodes with their scoped values
|
24
|
-
*
|
25
|
-
* Syntax:
|
26
|
-
*
|
27
|
-
* simplify.resolve(expr, scope)
|
28
|
-
*
|
29
|
-
* Examples:
|
30
|
-
*
|
31
|
-
* math.simplify.resolve('x + y', {x:1, y:2}) // Node {1 + 2}
|
32
|
-
* math.simplify.resolve(math.parse('x+y'), {x:1, y:2}) // Node {1 + 2}
|
33
|
-
* math.simplify('x+y', {x:2, y:'x+x'}).toString() // "6"
|
34
|
-
*
|
35
|
-
* @param {Node} node
|
36
|
-
* The expression tree to be simplified
|
37
|
-
* @param {Object} scope with variables to be resolved
|
38
|
-
*/
|
39
|
-
function resolve(node, scope) {
|
40
|
-
if (!scope) {
|
41
|
-
return node;
|
42
|
-
}
|
43
|
-
|
44
|
-
if (!(0, _map.isMap)(scope)) {
|
45
|
-
scope = (0, _map.createMap)(scope);
|
46
|
-
}
|
47
|
-
|
48
|
-
if ((0, _is.isSymbolNode)(node)) {
|
49
|
-
var value = scope.get(node.name);
|
50
|
-
|
51
|
-
if ((0, _is.isNode)(value)) {
|
52
|
-
return resolve(value, scope);
|
53
|
-
} else if (typeof value === 'number') {
|
54
|
-
return parse(String(value));
|
55
|
-
}
|
56
|
-
} else if ((0, _is.isOperatorNode)(node)) {
|
57
|
-
var args = node.args.map(function (arg) {
|
58
|
-
return resolve(arg, scope);
|
59
|
-
});
|
60
|
-
return new OperatorNode(node.op, node.fn, args, node.implicit);
|
61
|
-
} else if ((0, _is.isParenthesisNode)(node)) {
|
62
|
-
return new ParenthesisNode(resolve(node.content, scope));
|
63
|
-
} else if ((0, _is.isFunctionNode)(node)) {
|
64
|
-
var _args = node.args.map(function (arg) {
|
65
|
-
return resolve(arg, scope);
|
66
|
-
});
|
67
|
-
|
68
|
-
return new FunctionNode(node.name, _args);
|
69
|
-
}
|
70
|
-
|
71
|
-
return node;
|
72
|
-
}
|
73
|
-
|
74
|
-
return resolve;
|
75
|
-
});
|
76
|
-
exports.createResolve = createResolve;
|
@@ -1,67 +0,0 @@
|
|
1
|
-
import { createMap, isMap } from '../../../utils/map.js';
|
2
|
-
import { isFunctionNode, isNode, isOperatorNode, isParenthesisNode, isSymbolNode } from '../../../utils/is.js';
|
3
|
-
import { factory } from '../../../utils/factory.js';
|
4
|
-
var name = 'resolve';
|
5
|
-
var dependencies = ['parse', 'FunctionNode', 'OperatorNode', 'ParenthesisNode'];
|
6
|
-
export var createResolve = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
|
-
var {
|
8
|
-
parse,
|
9
|
-
FunctionNode,
|
10
|
-
OperatorNode,
|
11
|
-
ParenthesisNode
|
12
|
-
} = _ref;
|
13
|
-
|
14
|
-
/**
|
15
|
-
* resolve(expr, scope) replaces variable nodes with their scoped values
|
16
|
-
*
|
17
|
-
* Syntax:
|
18
|
-
*
|
19
|
-
* simplify.resolve(expr, scope)
|
20
|
-
*
|
21
|
-
* Examples:
|
22
|
-
*
|
23
|
-
* math.simplify.resolve('x + y', {x:1, y:2}) // Node {1 + 2}
|
24
|
-
* math.simplify.resolve(math.parse('x+y'), {x:1, y:2}) // Node {1 + 2}
|
25
|
-
* math.simplify('x+y', {x:2, y:'x+x'}).toString() // "6"
|
26
|
-
*
|
27
|
-
* @param {Node} node
|
28
|
-
* The expression tree to be simplified
|
29
|
-
* @param {Object} scope with variables to be resolved
|
30
|
-
*/
|
31
|
-
function resolve(node, scope) {
|
32
|
-
if (!scope) {
|
33
|
-
return node;
|
34
|
-
}
|
35
|
-
|
36
|
-
if (!isMap(scope)) {
|
37
|
-
scope = createMap(scope);
|
38
|
-
}
|
39
|
-
|
40
|
-
if (isSymbolNode(node)) {
|
41
|
-
var value = scope.get(node.name);
|
42
|
-
|
43
|
-
if (isNode(value)) {
|
44
|
-
return resolve(value, scope);
|
45
|
-
} else if (typeof value === 'number') {
|
46
|
-
return parse(String(value));
|
47
|
-
}
|
48
|
-
} else if (isOperatorNode(node)) {
|
49
|
-
var args = node.args.map(function (arg) {
|
50
|
-
return resolve(arg, scope);
|
51
|
-
});
|
52
|
-
return new OperatorNode(node.op, node.fn, args, node.implicit);
|
53
|
-
} else if (isParenthesisNode(node)) {
|
54
|
-
return new ParenthesisNode(resolve(node.content, scope));
|
55
|
-
} else if (isFunctionNode(node)) {
|
56
|
-
var _args = node.args.map(function (arg) {
|
57
|
-
return resolve(arg, scope);
|
58
|
-
});
|
59
|
-
|
60
|
-
return new FunctionNode(node.name, _args);
|
61
|
-
}
|
62
|
-
|
63
|
-
return node;
|
64
|
-
}
|
65
|
-
|
66
|
-
return resolve;
|
67
|
-
});
|