mathjs 9.3.2 → 9.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/HISTORY.md +22 -0
- package/README.md +1 -0
- package/bin/cli.js +11 -11
- package/docs/expressions/parsing.md +21 -4
- package/docs/reference/functions/complex.md +5 -49
- package/docs/reference/functions/eigs.md +12 -12
- package/docs/reference/functions/flatten.md +1 -0
- package/docs/reference/functions/matrixFromColumns.md +1 -1
- package/docs/reference/functions/matrixFromFunction.md +12 -0
- package/docs/reference/functions/matrixFromRows.md +1 -1
- package/docs/reference/functions.md +4 -1
- package/examples/advanced/custom_scope_objects.js +115 -0
- package/lib/browser/math.js +10 -10
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/core/create.js +8 -7
- package/lib/cjs/core/function/import.js +9 -7
- package/lib/cjs/core/function/typed.js +6 -1
- package/lib/cjs/defaultInstance.js +3 -3
- package/lib/cjs/entry/allFactoriesAny.js +3 -3
- package/lib/cjs/entry/allFactoriesNumber.js +3 -3
- package/lib/cjs/entry/configReadonly.js +5 -4
- package/lib/cjs/entry/dependenciesAny/dependenciesEigs.generated.js +51 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesMatrixFromColumns.generated.js +29 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesMatrixFromFunction.generated.js +26 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesMatrixFromRows.generated.js +29 -0
- package/lib/cjs/entry/dependenciesAny.generated.js +24 -0
- package/lib/cjs/entry/impureFunctionsAny.generated.js +22 -17
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +11 -9
- package/lib/cjs/entry/pureFunctionsAny.generated.js +78 -41
- package/lib/cjs/expression/Parser.js +22 -15
- package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +9 -0
- package/lib/cjs/expression/embeddedDocs/function/matrix/column.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/matrix/matrixFromColumns.js +15 -0
- package/lib/cjs/expression/embeddedDocs/function/matrix/matrixFromFunction.js +15 -0
- package/lib/cjs/expression/embeddedDocs/function/matrix/matrixFromRows.js +15 -0
- package/lib/cjs/expression/embeddedDocs/function/matrix/row.js +1 -1
- package/lib/cjs/expression/function/evaluate.js +6 -4
- package/lib/cjs/expression/keywords.js +1 -3
- package/lib/cjs/expression/node/AccessorNode.js +1 -0
- package/lib/cjs/expression/node/AssignmentNode.js +6 -3
- package/lib/cjs/expression/node/FunctionAssignmentNode.js +2 -4
- package/lib/cjs/expression/node/FunctionNode.js +76 -46
- package/lib/cjs/expression/node/IndexNode.js +5 -13
- package/lib/cjs/expression/node/Node.js +15 -9
- package/lib/cjs/expression/node/ObjectNode.js +5 -3
- package/lib/cjs/expression/node/SymbolNode.js +2 -2
- package/lib/cjs/expression/node/utils/access.js +5 -3
- package/lib/cjs/expression/node/utils/assign.js +5 -3
- package/lib/cjs/expression/parse.js +10 -14
- package/lib/cjs/expression/transform/utils/compileInlineExpression.js +5 -3
- package/lib/cjs/factoriesAny.js +24 -0
- package/lib/cjs/function/algebra/decomposition/qr.js +5 -3
- package/lib/cjs/function/algebra/simplify/resolve.js +7 -1
- package/lib/cjs/function/algebra/simplify.js +20 -14
- package/lib/cjs/function/algebra/solver/lsolveAll.js +6 -16
- package/lib/cjs/function/algebra/solver/usolveAll.js +6 -16
- package/lib/cjs/function/arithmetic/ceil.js +6 -16
- package/lib/cjs/function/arithmetic/floor.js +6 -16
- package/lib/cjs/function/arithmetic/norm.js +2 -2
- package/lib/cjs/function/arithmetic/pow.js +9 -7
- package/lib/cjs/function/arithmetic/round.js +7 -5
- package/lib/cjs/function/complex/im.js +3 -0
- package/lib/cjs/function/complex/re.js +3 -0
- package/lib/cjs/function/matrix/eigs/complexEigs.js +631 -0
- package/lib/cjs/function/matrix/eigs/realSymetric.js +341 -0
- package/lib/cjs/function/matrix/eigs.js +188 -334
- package/lib/cjs/function/matrix/flatten.js +1 -0
- package/lib/cjs/function/matrix/matrixFromColumns.js +118 -0
- package/lib/cjs/function/matrix/matrixFromFunction.js +85 -0
- package/lib/cjs/function/matrix/matrixFromRows.js +108 -0
- package/lib/cjs/function/probability/pickRandom.js +1 -1
- package/lib/cjs/function/probability/util/seededRNG.js +2 -2
- package/lib/cjs/function/relational/compareNatural.js +2 -2
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/plain/bignumber/index.js +2 -2
- package/lib/cjs/type/bignumber/BigNumber.js +2 -2
- package/lib/cjs/type/complex/Complex.js +5 -5
- package/lib/cjs/type/fraction/Fraction.js +2 -2
- package/lib/cjs/type/matrix/DenseMatrix.js +138 -0
- package/lib/cjs/type/matrix/Matrix.js +10 -0
- package/lib/cjs/type/matrix/SparseMatrix.js +77 -3
- package/lib/cjs/type/matrix/function/matrix.js +2 -1
- package/lib/cjs/type/unit/Unit.js +15 -13
- package/lib/cjs/utils/array.js +1 -1
- package/lib/cjs/utils/customs.js +18 -4
- package/lib/cjs/utils/emitter.js +2 -2
- package/lib/cjs/utils/function.js +6 -2
- package/lib/cjs/utils/is.js +7 -5
- package/lib/cjs/utils/latex.js +2 -2
- package/lib/cjs/utils/map.js +197 -0
- package/lib/cjs/utils/object.js +6 -5
- package/lib/cjs/utils/scope.js +33 -0
- package/lib/cjs/utils/snapshot.js +17 -16
- package/lib/cjs/utils/string.js +6 -4
- package/lib/cjs/version.js +1 -1
- package/lib/esm/constants.js +15 -15
- package/lib/esm/core/create.js +1 -2
- package/lib/esm/core/function/typed.js +5 -1
- package/lib/esm/entry/configReadonly.js +1 -2
- package/lib/esm/entry/dependenciesAny/dependenciesEigs.generated.js +34 -0
- package/lib/esm/entry/dependenciesAny/dependenciesMatrixFromColumns.generated.js +16 -0
- package/lib/esm/entry/dependenciesAny/dependenciesMatrixFromFunction.generated.js +14 -0
- package/lib/esm/entry/dependenciesAny/dependenciesMatrixFromRows.generated.js +16 -0
- package/lib/esm/entry/dependenciesAny.generated.js +3 -0
- package/lib/esm/entry/impureFunctionsAny.generated.js +13 -10
- package/lib/esm/entry/impureFunctionsNumber.generated.js +1 -1
- package/lib/esm/entry/pureFunctionsAny.generated.js +66 -32
- package/lib/esm/expression/Help.js +1 -1
- package/lib/esm/expression/Parser.js +23 -15
- package/lib/esm/expression/embeddedDocs/embeddedDocs.js +6 -0
- package/lib/esm/expression/embeddedDocs/function/matrix/column.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/matrix/matrixFromColumns.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/matrix/matrixFromFunction.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/matrix/matrixFromRows.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/matrix/row.js +1 -1
- package/lib/esm/expression/function/compile.js +1 -1
- package/lib/esm/expression/function/evaluate.js +6 -5
- package/lib/esm/expression/function/help.js +1 -1
- package/lib/esm/expression/function/parser.js +1 -1
- package/lib/esm/expression/keywords.js +1 -3
- package/lib/esm/expression/node/AccessorNode.js +2 -1
- package/lib/esm/expression/node/ArrayNode.js +1 -1
- package/lib/esm/expression/node/AssignmentNode.js +7 -4
- package/lib/esm/expression/node/BlockNode.js +1 -1
- package/lib/esm/expression/node/ConditionalNode.js +1 -1
- package/lib/esm/expression/node/ConstantNode.js +1 -1
- package/lib/esm/expression/node/FunctionAssignmentNode.js +3 -4
- package/lib/esm/expression/node/FunctionNode.js +57 -39
- package/lib/esm/expression/node/IndexNode.js +1 -1
- package/lib/esm/expression/node/Node.js +7 -8
- package/lib/esm/expression/node/ObjectNode.js +1 -1
- package/lib/esm/expression/node/OperatorNode.js +1 -1
- package/lib/esm/expression/node/ParenthesisNode.js +1 -1
- package/lib/esm/expression/node/RangeNode.js +1 -1
- package/lib/esm/expression/node/RelationalNode.js +1 -1
- package/lib/esm/expression/node/SymbolNode.js +3 -3
- package/lib/esm/expression/parse.js +2 -3
- package/lib/esm/expression/transform/apply.transform.js +1 -1
- package/lib/esm/expression/transform/column.transform.js +1 -1
- package/lib/esm/expression/transform/concat.transform.js +1 -1
- package/lib/esm/expression/transform/diff.transform.js +1 -1
- package/lib/esm/expression/transform/filter.transform.js +1 -1
- package/lib/esm/expression/transform/forEach.transform.js +1 -1
- package/lib/esm/expression/transform/index.transform.js +1 -1
- package/lib/esm/expression/transform/map.transform.js +1 -1
- package/lib/esm/expression/transform/max.transform.js +1 -1
- package/lib/esm/expression/transform/mean.transform.js +1 -1
- package/lib/esm/expression/transform/min.transform.js +1 -1
- package/lib/esm/expression/transform/range.transform.js +1 -1
- package/lib/esm/expression/transform/row.transform.js +1 -1
- package/lib/esm/expression/transform/std.transform.js +1 -1
- package/lib/esm/expression/transform/subset.transform.js +1 -1
- package/lib/esm/expression/transform/sum.transform.js +1 -1
- package/lib/esm/expression/transform/utils/compileInlineExpression.js +4 -3
- package/lib/esm/expression/transform/variance.transform.js +1 -1
- package/lib/esm/factoriesAny.js +3 -0
- package/lib/esm/factoriesNumber.js +1 -1
- package/lib/esm/function/algebra/decomposition/lup.js +1 -1
- package/lib/esm/function/algebra/decomposition/qr.js +2 -3
- package/lib/esm/function/algebra/decomposition/slu.js +1 -1
- package/lib/esm/function/algebra/derivative.js +1 -1
- package/lib/esm/function/algebra/rationalize.js +1 -1
- package/lib/esm/function/algebra/simplify/resolve.js +7 -2
- package/lib/esm/function/algebra/simplify/simplifyConstant.js +1 -1
- package/lib/esm/function/algebra/simplify/simplifyCore.js +1 -1
- package/lib/esm/function/algebra/simplify/util.js +1 -1
- package/lib/esm/function/algebra/simplify.js +16 -12
- package/lib/esm/function/algebra/solver/lsolve.js +1 -1
- package/lib/esm/function/algebra/solver/lsolveAll.js +1 -1
- package/lib/esm/function/algebra/solver/lusolve.js +1 -1
- package/lib/esm/function/algebra/solver/usolve.js +1 -1
- package/lib/esm/function/algebra/solver/usolveAll.js +1 -1
- package/lib/esm/function/algebra/sparse/csAmd.js +1 -1
- package/lib/esm/function/algebra/sparse/csChol.js +1 -1
- package/lib/esm/function/algebra/sparse/csCounts.js +1 -1
- package/lib/esm/function/algebra/sparse/csLu.js +1 -1
- package/lib/esm/function/algebra/sparse/csSpsolve.js +1 -1
- package/lib/esm/function/algebra/sparse/csSqr.js +1 -1
- package/lib/esm/function/algebra/sparse/csSymperm.js +1 -1
- package/lib/esm/function/arithmetic/abs.js +1 -1
- package/lib/esm/function/arithmetic/add.js +1 -1
- package/lib/esm/function/arithmetic/addScalar.js +1 -1
- package/lib/esm/function/arithmetic/cbrt.js +1 -1
- package/lib/esm/function/arithmetic/ceil.js +1 -1
- package/lib/esm/function/arithmetic/cube.js +1 -1
- package/lib/esm/function/arithmetic/divide.js +1 -1
- package/lib/esm/function/arithmetic/divideScalar.js +1 -1
- package/lib/esm/function/arithmetic/dotDivide.js +1 -1
- package/lib/esm/function/arithmetic/dotMultiply.js +1 -1
- package/lib/esm/function/arithmetic/dotPow.js +1 -1
- package/lib/esm/function/arithmetic/exp.js +1 -1
- package/lib/esm/function/arithmetic/expm1.js +1 -1
- package/lib/esm/function/arithmetic/fix.js +1 -1
- package/lib/esm/function/arithmetic/floor.js +1 -1
- package/lib/esm/function/arithmetic/gcd.js +1 -1
- package/lib/esm/function/arithmetic/hypot.js +1 -1
- package/lib/esm/function/arithmetic/lcm.js +1 -1
- package/lib/esm/function/arithmetic/log.js +1 -1
- package/lib/esm/function/arithmetic/log10.js +1 -1
- package/lib/esm/function/arithmetic/log1p.js +1 -1
- package/lib/esm/function/arithmetic/log2.js +1 -1
- package/lib/esm/function/arithmetic/mod.js +1 -1
- package/lib/esm/function/arithmetic/multiply.js +1 -1
- package/lib/esm/function/arithmetic/multiplyScalar.js +1 -1
- package/lib/esm/function/arithmetic/norm.js +3 -3
- package/lib/esm/function/arithmetic/nthRoot.js +2 -2
- package/lib/esm/function/arithmetic/nthRoots.js +1 -1
- package/lib/esm/function/arithmetic/pow.js +10 -8
- package/lib/esm/function/arithmetic/round.js +6 -6
- package/lib/esm/function/arithmetic/sign.js +1 -1
- package/lib/esm/function/arithmetic/sqrt.js +1 -1
- package/lib/esm/function/arithmetic/square.js +1 -1
- package/lib/esm/function/arithmetic/subtract.js +1 -1
- package/lib/esm/function/arithmetic/unaryMinus.js +1 -1
- package/lib/esm/function/arithmetic/unaryPlus.js +1 -1
- package/lib/esm/function/arithmetic/xgcd.js +1 -1
- package/lib/esm/function/bitwise/bitAnd.js +1 -1
- package/lib/esm/function/bitwise/bitNot.js +1 -1
- package/lib/esm/function/bitwise/bitOr.js +1 -1
- package/lib/esm/function/bitwise/bitXor.js +1 -1
- package/lib/esm/function/bitwise/leftShift.js +1 -1
- package/lib/esm/function/bitwise/rightArithShift.js +1 -1
- package/lib/esm/function/bitwise/rightLogShift.js +1 -1
- package/lib/esm/function/combinatorics/bellNumbers.js +1 -1
- package/lib/esm/function/combinatorics/catalan.js +1 -1
- package/lib/esm/function/combinatorics/composition.js +1 -1
- package/lib/esm/function/combinatorics/stirlingS2.js +1 -1
- package/lib/esm/function/complex/arg.js +1 -1
- package/lib/esm/function/complex/conj.js +1 -1
- package/lib/esm/function/complex/im.js +4 -1
- package/lib/esm/function/complex/re.js +4 -1
- package/lib/esm/function/geometry/distance.js +1 -1
- package/lib/esm/function/geometry/intersect.js +1 -1
- package/lib/esm/function/logical/and.js +1 -1
- package/lib/esm/function/logical/not.js +1 -1
- package/lib/esm/function/logical/or.js +1 -1
- package/lib/esm/function/logical/xor.js +1 -1
- package/lib/esm/function/matrix/apply.js +1 -1
- package/lib/esm/function/matrix/column.js +1 -1
- package/lib/esm/function/matrix/concat.js +1 -1
- package/lib/esm/function/matrix/count.js +1 -1
- package/lib/esm/function/matrix/cross.js +1 -1
- package/lib/esm/function/matrix/ctranspose.js +1 -1
- package/lib/esm/function/matrix/det.js +1 -1
- package/lib/esm/function/matrix/diag.js +1 -1
- package/lib/esm/function/matrix/diff.js +1 -1
- package/lib/esm/function/matrix/dot.js +1 -1
- package/lib/esm/function/matrix/eigs/complexEigs.js +586 -0
- package/lib/esm/function/matrix/eigs/realSymetric.js +335 -0
- package/lib/esm/function/matrix/eigs.js +187 -335
- package/lib/esm/function/matrix/expm.js +1 -1
- package/lib/esm/function/matrix/filter.js +1 -1
- package/lib/esm/function/matrix/flatten.js +2 -1
- package/lib/esm/function/matrix/forEach.js +1 -1
- package/lib/esm/function/matrix/getMatrixDataType.js +1 -1
- package/lib/esm/function/matrix/identity.js +1 -1
- package/lib/esm/function/matrix/inv.js +1 -1
- package/lib/esm/function/matrix/kron.js +1 -1
- package/lib/esm/function/matrix/map.js +1 -1
- package/lib/esm/function/matrix/matrixFromColumns.js +93 -0
- package/lib/esm/function/matrix/matrixFromFunction.js +78 -0
- package/lib/esm/function/matrix/matrixFromRows.js +83 -0
- package/lib/esm/function/matrix/ones.js +1 -1
- package/lib/esm/function/matrix/partitionSelect.js +1 -1
- package/lib/esm/function/matrix/range.js +1 -1
- package/lib/esm/function/matrix/reshape.js +1 -1
- package/lib/esm/function/matrix/resize.js +1 -1
- package/lib/esm/function/matrix/rotate.js +1 -1
- package/lib/esm/function/matrix/rotationMatrix.js +1 -1
- package/lib/esm/function/matrix/row.js +1 -1
- package/lib/esm/function/matrix/size.js +1 -1
- package/lib/esm/function/matrix/sort.js +1 -1
- package/lib/esm/function/matrix/sqrtm.js +1 -1
- package/lib/esm/function/matrix/squeeze.js +1 -1
- package/lib/esm/function/matrix/subset.js +1 -1
- package/lib/esm/function/matrix/trace.js +1 -1
- package/lib/esm/function/matrix/transpose.js +1 -1
- package/lib/esm/function/matrix/zeros.js +1 -1
- package/lib/esm/function/probability/combinations.js +1 -1
- package/lib/esm/function/probability/combinationsWithRep.js +1 -1
- package/lib/esm/function/probability/factorial.js +1 -1
- package/lib/esm/function/probability/gamma.js +1 -1
- package/lib/esm/function/probability/kldivergence.js +1 -1
- package/lib/esm/function/probability/multinomial.js +1 -1
- package/lib/esm/function/probability/permutations.js +1 -1
- package/lib/esm/function/probability/pickRandom.js +2 -2
- package/lib/esm/function/probability/random.js +2 -2
- package/lib/esm/function/probability/randomInt.js +1 -1
- package/lib/esm/function/relational/compare.js +2 -2
- package/lib/esm/function/relational/compareNatural.js +1 -1
- package/lib/esm/function/relational/compareText.js +2 -2
- package/lib/esm/function/relational/deepEqual.js +1 -1
- package/lib/esm/function/relational/equal.js +2 -2
- package/lib/esm/function/relational/equalScalar.js +2 -2
- package/lib/esm/function/relational/equalText.js +1 -1
- package/lib/esm/function/relational/larger.js +2 -2
- package/lib/esm/function/relational/largerEq.js +2 -2
- package/lib/esm/function/relational/smaller.js +2 -2
- package/lib/esm/function/relational/smallerEq.js +2 -2
- package/lib/esm/function/relational/unequal.js +2 -2
- package/lib/esm/function/set/setCartesian.js +1 -1
- package/lib/esm/function/set/setDifference.js +1 -1
- package/lib/esm/function/set/setDistinct.js +1 -1
- package/lib/esm/function/set/setIntersect.js +1 -1
- package/lib/esm/function/set/setIsSubset.js +1 -1
- package/lib/esm/function/set/setMultiplicity.js +1 -1
- package/lib/esm/function/set/setPowerset.js +1 -1
- package/lib/esm/function/set/setSize.js +1 -1
- package/lib/esm/function/set/setSymDifference.js +1 -1
- package/lib/esm/function/set/setUnion.js +1 -1
- package/lib/esm/function/special/erf.js +1 -1
- package/lib/esm/function/statistics/mad.js +1 -1
- package/lib/esm/function/statistics/max.js +1 -1
- package/lib/esm/function/statistics/mean.js +1 -1
- package/lib/esm/function/statistics/median.js +1 -1
- package/lib/esm/function/statistics/min.js +1 -1
- package/lib/esm/function/statistics/mode.js +1 -1
- package/lib/esm/function/statistics/prod.js +1 -1
- package/lib/esm/function/statistics/quantileSeq.js +1 -1
- package/lib/esm/function/statistics/std.js +1 -1
- package/lib/esm/function/statistics/sum.js +1 -1
- package/lib/esm/function/statistics/variance.js +1 -1
- package/lib/esm/function/string/bin.js +1 -1
- package/lib/esm/function/string/format.js +1 -1
- package/lib/esm/function/string/hex.js +1 -1
- package/lib/esm/function/string/oct.js +1 -1
- package/lib/esm/function/string/print.js +1 -1
- package/lib/esm/function/trigonometry/acos.js +1 -1
- package/lib/esm/function/trigonometry/acosh.js +1 -1
- package/lib/esm/function/trigonometry/acot.js +1 -1
- package/lib/esm/function/trigonometry/acoth.js +1 -1
- package/lib/esm/function/trigonometry/acsc.js +1 -1
- package/lib/esm/function/trigonometry/acsch.js +1 -1
- package/lib/esm/function/trigonometry/asec.js +1 -1
- package/lib/esm/function/trigonometry/asech.js +1 -1
- package/lib/esm/function/trigonometry/asin.js +1 -1
- package/lib/esm/function/trigonometry/asinh.js +1 -1
- package/lib/esm/function/trigonometry/atan.js +1 -1
- package/lib/esm/function/trigonometry/atan2.js +1 -1
- package/lib/esm/function/trigonometry/atanh.js +1 -1
- package/lib/esm/function/trigonometry/cos.js +1 -1
- package/lib/esm/function/trigonometry/cosh.js +1 -1
- package/lib/esm/function/trigonometry/cot.js +1 -1
- package/lib/esm/function/trigonometry/coth.js +1 -1
- package/lib/esm/function/trigonometry/csc.js +1 -1
- package/lib/esm/function/trigonometry/csch.js +1 -1
- package/lib/esm/function/trigonometry/sec.js +1 -1
- package/lib/esm/function/trigonometry/sech.js +1 -1
- package/lib/esm/function/trigonometry/sin.js +1 -1
- package/lib/esm/function/trigonometry/sinh.js +1 -1
- package/lib/esm/function/trigonometry/tan.js +1 -1
- package/lib/esm/function/trigonometry/tanh.js +1 -1
- package/lib/esm/function/unit/to.js +1 -1
- package/lib/esm/function/utils/clone.js +1 -1
- package/lib/esm/function/utils/hasNumericValue.js +1 -1
- package/lib/esm/function/utils/isInteger.js +1 -1
- package/lib/esm/function/utils/isNaN.js +1 -1
- package/lib/esm/function/utils/isNegative.js +1 -1
- package/lib/esm/function/utils/isNumeric.js +1 -1
- package/lib/esm/function/utils/isPositive.js +1 -1
- package/lib/esm/function/utils/isPrime.js +1 -1
- package/lib/esm/function/utils/isZero.js +1 -1
- package/lib/esm/function/utils/numeric.js +1 -1
- package/lib/esm/function/utils/typeOf.js +1 -1
- package/lib/esm/json/reviver.js +1 -1
- package/lib/esm/type/bignumber/BigNumber.js +1 -1
- package/lib/esm/type/bignumber/function/bignumber.js +1 -1
- package/lib/esm/type/boolean.js +1 -1
- package/lib/esm/type/chain/Chain.js +1 -1
- package/lib/esm/type/chain/function/chain.js +1 -1
- package/lib/esm/type/complex/function/complex.js +1 -1
- package/lib/esm/type/fraction/function/fraction.js +1 -1
- package/lib/esm/type/matrix/DenseMatrix.js +75 -1
- package/lib/esm/type/matrix/FibonacciHeap.js +1 -1
- package/lib/esm/type/matrix/ImmutableDenseMatrix.js +1 -1
- package/lib/esm/type/matrix/Matrix.js +10 -0
- package/lib/esm/type/matrix/MatrixIndex.js +1 -1
- package/lib/esm/type/matrix/Spa.js +1 -1
- package/lib/esm/type/matrix/SparseMatrix.js +37 -3
- package/lib/esm/type/matrix/function/index.js +1 -1
- package/lib/esm/type/matrix/function/matrix.js +3 -2
- package/lib/esm/type/matrix/function/sparse.js +1 -1
- package/lib/esm/type/matrix/utils/algorithm01.js +1 -1
- package/lib/esm/type/matrix/utils/algorithm02.js +1 -1
- package/lib/esm/type/matrix/utils/algorithm03.js +1 -1
- package/lib/esm/type/matrix/utils/algorithm04.js +1 -1
- package/lib/esm/type/matrix/utils/algorithm05.js +1 -1
- package/lib/esm/type/matrix/utils/algorithm06.js +1 -1
- package/lib/esm/type/matrix/utils/algorithm07.js +1 -1
- package/lib/esm/type/matrix/utils/algorithm08.js +1 -1
- package/lib/esm/type/matrix/utils/algorithm09.js +1 -1
- package/lib/esm/type/matrix/utils/algorithm10.js +1 -1
- package/lib/esm/type/matrix/utils/algorithm11.js +1 -1
- package/lib/esm/type/matrix/utils/algorithm12.js +1 -1
- package/lib/esm/type/matrix/utils/algorithm13.js +1 -1
- package/lib/esm/type/matrix/utils/algorithm14.js +1 -1
- package/lib/esm/type/number.js +1 -1
- package/lib/esm/type/string.js +1 -1
- package/lib/esm/type/unit/Unit.js +4 -5
- package/lib/esm/type/unit/function/createUnit.js +1 -1
- package/lib/esm/type/unit/function/splitUnit.js +1 -1
- package/lib/esm/type/unit/function/unit.js +1 -1
- package/lib/esm/type/unit/physicalConstants.js +2 -2
- package/lib/esm/utils/array.js +1 -1
- package/lib/esm/utils/customs.js +10 -0
- package/lib/esm/utils/map.js +135 -0
- package/lib/esm/utils/scope.js +26 -0
- package/lib/esm/utils/snapshot.js +3 -4
- package/lib/esm/version.js +1 -1
- package/package.json +18 -9
@@ -1,15 +1,13 @@
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
-
|
3
1
|
import { isAccessorNode, isFunctionAssignmentNode, isIndexNode, isNode, isSymbolNode } from '../../utils/is.js';
|
4
2
|
import { escape } from '../../utils/string.js';
|
5
3
|
import { hasOwnProperty } from '../../utils/object.js';
|
6
|
-
import { map } from '../../utils/array.js';
|
7
4
|
import { getSafeProperty, validateSafeMethod } from '../../utils/customs.js';
|
5
|
+
import { createSubScope } from '../../utils/scope.js';
|
8
6
|
import { factory } from '../../utils/factory.js';
|
9
7
|
import { defaultTemplate, latexFunctions } from '../../utils/latex.js';
|
10
8
|
var name = 'FunctionNode';
|
11
9
|
var dependencies = ['math', 'Node', 'SymbolNode'];
|
12
|
-
export var createFunctionNode = /* #__PURE__ */factory(name, dependencies,
|
10
|
+
export var createFunctionNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
13
11
|
var {
|
14
12
|
math,
|
15
13
|
Node,
|
@@ -76,9 +74,7 @@ export var createFunctionNode = /* #__PURE__ */factory(name, dependencies, (_ref
|
|
76
74
|
} // compile arguments
|
77
75
|
|
78
76
|
|
79
|
-
var evalArgs =
|
80
|
-
return arg._compile(math, argNames);
|
81
|
-
});
|
77
|
+
var evalArgs = this.args.map(arg => arg._compile(math, argNames));
|
82
78
|
|
83
79
|
if (isSymbolNode(this.fn)) {
|
84
80
|
// we can statically determine whether the function has an rawArgs property
|
@@ -86,9 +82,17 @@ export var createFunctionNode = /* #__PURE__ */factory(name, dependencies, (_ref
|
|
86
82
|
var fn = _name in math ? getSafeProperty(math, _name) : undefined;
|
87
83
|
var isRaw = typeof fn === 'function' && fn.rawArgs === true;
|
88
84
|
|
89
|
-
|
90
|
-
|
91
|
-
|
85
|
+
var resolveFn = scope => {
|
86
|
+
if (scope.has(_name)) {
|
87
|
+
return scope.get(_name);
|
88
|
+
}
|
89
|
+
|
90
|
+
if (_name in math) {
|
91
|
+
return getSafeProperty(math, _name);
|
92
|
+
}
|
93
|
+
|
94
|
+
return FunctionNode.onUndefinedFunction(_name);
|
95
|
+
};
|
92
96
|
|
93
97
|
if (isRaw) {
|
94
98
|
// pass unevaluated parameters (nodes) to the function
|
@@ -96,30 +100,38 @@ export var createFunctionNode = /* #__PURE__ */factory(name, dependencies, (_ref
|
|
96
100
|
var rawArgs = this.args;
|
97
101
|
return function evalFunctionNode(scope, args, context) {
|
98
102
|
var fn = resolveFn(scope);
|
99
|
-
return fn(rawArgs, math,
|
103
|
+
return fn(rawArgs, math, createSubScope(scope, args), scope);
|
100
104
|
};
|
101
105
|
} else {
|
102
106
|
// "regular" evaluation
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
107
|
+
switch (evalArgs.length) {
|
108
|
+
case 0:
|
109
|
+
return function evalFunctionNode(scope, args, context) {
|
110
|
+
var fn = resolveFn(scope);
|
111
|
+
return fn();
|
112
|
+
};
|
113
|
+
|
114
|
+
case 1:
|
115
|
+
return function evalFunctionNode(scope, args, context) {
|
116
|
+
var fn = resolveFn(scope);
|
117
|
+
var evalArg0 = evalArgs[0];
|
118
|
+
return fn(evalArg0(scope, args, context));
|
119
|
+
};
|
120
|
+
|
121
|
+
case 2:
|
122
|
+
return function evalFunctionNode(scope, args, context) {
|
123
|
+
var fn = resolveFn(scope);
|
124
|
+
var evalArg0 = evalArgs[0];
|
125
|
+
var evalArg1 = evalArgs[1];
|
126
|
+
return fn(evalArg0(scope, args, context), evalArg1(scope, args, context));
|
127
|
+
};
|
128
|
+
|
129
|
+
default:
|
130
|
+
return function evalFunctionNode(scope, args, context) {
|
131
|
+
var fn = resolveFn(scope);
|
132
|
+
var values = evalArgs.map(evalArg => evalArg(scope, args, context));
|
133
|
+
return fn(...values);
|
134
|
+
};
|
123
135
|
}
|
124
136
|
}
|
125
137
|
} else if (isAccessorNode(this.fn) && isIndexNode(this.fn.index) && this.fn.index.isObjectProperty()) {
|
@@ -132,11 +144,14 @@ export var createFunctionNode = /* #__PURE__ */factory(name, dependencies, (_ref
|
|
132
144
|
var object = evalObject(scope, args, context);
|
133
145
|
validateSafeMethod(object, prop);
|
134
146
|
var isRaw = object[prop] && object[prop].rawArgs;
|
135
|
-
|
136
|
-
|
147
|
+
|
148
|
+
if (isRaw) {
|
149
|
+
return object[prop](_rawArgs, math, createSubScope(scope, args), scope); // "raw" evaluation
|
150
|
+
} else {
|
137
151
|
// "regular" evaluation
|
138
|
-
|
139
|
-
|
152
|
+
var values = evalArgs.map(evalArg => evalArg(scope, args, context));
|
153
|
+
return object[prop].apply(object, values);
|
154
|
+
}
|
140
155
|
};
|
141
156
|
} else {
|
142
157
|
// node.fn.isAccessorNode && !node.fn.index.isObjectProperty()
|
@@ -147,11 +162,14 @@ export var createFunctionNode = /* #__PURE__ */factory(name, dependencies, (_ref
|
|
147
162
|
return function evalFunctionNode(scope, args, context) {
|
148
163
|
var fn = evalFn(scope, args, context);
|
149
164
|
var isRaw = fn && fn.rawArgs;
|
150
|
-
|
151
|
-
|
165
|
+
|
166
|
+
if (isRaw) {
|
167
|
+
return fn(_rawArgs2, math, createSubScope(scope, args), scope); // "raw" evaluation
|
168
|
+
} else {
|
152
169
|
// "regular" evaluation
|
153
|
-
|
154
|
-
|
170
|
+
var values = evalArgs.map(evalArg => evalArg(scope, args, context));
|
171
|
+
return fn.apply(fn, values);
|
172
|
+
}
|
155
173
|
};
|
156
174
|
}
|
157
175
|
};
|
@@ -5,7 +5,7 @@ import { factory } from '../../utils/factory.js';
|
|
5
5
|
import { getSafeProperty } from '../../utils/customs.js';
|
6
6
|
var name = 'IndexNode';
|
7
7
|
var dependencies = ['Range', 'Node', 'size'];
|
8
|
-
export var createIndexNode = /* #__PURE__ */factory(name, dependencies,
|
8
|
+
export var createIndexNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
9
9
|
var {
|
10
10
|
Range,
|
11
11
|
Node,
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import { isNode } from '../../utils/is.js';
|
2
2
|
import { keywords } from '../keywords.js';
|
3
|
-
import { deepStrictEqual
|
3
|
+
import { deepStrictEqual } from '../../utils/object.js';
|
4
4
|
import { factory } from '../../utils/factory.js';
|
5
|
+
import { createMap } from '../../utils/map.js';
|
5
6
|
var name = 'Node';
|
6
7
|
var dependencies = ['mathWithTransform'];
|
7
|
-
export var createNode = /* #__PURE__ */factory(name, dependencies,
|
8
|
+
export var createNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
9
|
var {
|
9
10
|
mathWithTransform
|
10
11
|
} = _ref;
|
@@ -47,7 +48,7 @@ export var createNode = /* #__PURE__ */factory(name, dependencies, (_ref) => {
|
|
47
48
|
var context = null;
|
48
49
|
|
49
50
|
function evaluate(scope) {
|
50
|
-
var s = scope
|
51
|
+
var s = createMap(scope);
|
51
52
|
|
52
53
|
_validateScope(s);
|
53
54
|
|
@@ -390,11 +391,9 @@ export var createNode = /* #__PURE__ */factory(name, dependencies, (_ref) => {
|
|
390
391
|
|
391
392
|
|
392
393
|
function _validateScope(scope) {
|
393
|
-
for (var symbol
|
394
|
-
if (
|
395
|
-
|
396
|
-
throw new Error('Scope contains an illegal symbol, "' + symbol + '" is a reserved keyword');
|
397
|
-
}
|
394
|
+
for (var symbol of [...keywords]) {
|
395
|
+
if (scope.has(symbol)) {
|
396
|
+
throw new Error('Scope contains an illegal symbol, "' + symbol + '" is a reserved keyword');
|
398
397
|
}
|
399
398
|
}
|
400
399
|
}
|
@@ -5,7 +5,7 @@ import { hasOwnProperty } from '../../utils/object.js';
|
|
5
5
|
import { factory } from '../../utils/factory.js';
|
6
6
|
var name = 'ObjectNode';
|
7
7
|
var dependencies = ['Node'];
|
8
|
-
export var createObjectNode = /* #__PURE__ */factory(name, dependencies,
|
8
|
+
export var createObjectNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
9
9
|
var {
|
10
10
|
Node
|
11
11
|
} = _ref;
|
@@ -7,7 +7,7 @@ import { latexOperators } from '../../utils/latex.js';
|
|
7
7
|
import { factory } from '../../utils/factory.js';
|
8
8
|
var name = 'OperatorNode';
|
9
9
|
var dependencies = ['Node'];
|
10
|
-
export var createOperatorNode = /* #__PURE__ */factory(name, dependencies,
|
10
|
+
export var createOperatorNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
11
11
|
var {
|
12
12
|
Node
|
13
13
|
} = _ref;
|
@@ -2,7 +2,7 @@ import { isNode } from '../../utils/is.js';
|
|
2
2
|
import { factory } from '../../utils/factory.js';
|
3
3
|
var name = 'ParenthesisNode';
|
4
4
|
var dependencies = ['Node'];
|
5
|
-
export var createParenthesisNode = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createParenthesisNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
Node
|
8
8
|
} = _ref;
|
@@ -3,7 +3,7 @@ import { factory } from '../../utils/factory.js';
|
|
3
3
|
import { getPrecedence } from '../operators.js';
|
4
4
|
var name = 'RangeNode';
|
5
5
|
var dependencies = ['Node'];
|
6
|
-
export var createRangeNode = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createRangeNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
Node
|
9
9
|
} = _ref;
|
@@ -5,7 +5,7 @@ import { latexOperators } from '../../utils/latex.js';
|
|
5
5
|
import { factory } from '../../utils/factory.js';
|
6
6
|
var name = 'RelationalNode';
|
7
7
|
var dependencies = ['Node'];
|
8
|
-
export var createRelationalNode = /* #__PURE__ */factory(name, dependencies,
|
8
|
+
export var createRelationalNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
9
9
|
var {
|
10
10
|
Node
|
11
11
|
} = _ref;
|
@@ -4,7 +4,7 @@ import { factory } from '../../utils/factory.js';
|
|
4
4
|
import { toSymbol } from '../../utils/latex.js';
|
5
5
|
var name = 'SymbolNode';
|
6
6
|
var dependencies = ['math', '?Unit', 'Node'];
|
7
|
-
export var createSymbolNode = /* #__PURE__ */factory(name, dependencies,
|
7
|
+
export var createSymbolNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
8
|
var {
|
9
9
|
math,
|
10
10
|
Unit,
|
@@ -66,12 +66,12 @@ export var createSymbolNode = /* #__PURE__ */factory(name, dependencies, (_ref)
|
|
66
66
|
};
|
67
67
|
} else if (name in math) {
|
68
68
|
return function (scope, args, context) {
|
69
|
-
return name
|
69
|
+
return scope.has(name) ? scope.get(name) : getSafeProperty(math, name);
|
70
70
|
};
|
71
71
|
} else {
|
72
72
|
var isUnit = isValuelessUnit(name);
|
73
73
|
return function (scope, args, context) {
|
74
|
-
return name
|
74
|
+
return scope.has(name) ? scope.get(name) : isUnit ? new Unit(null, name) : SymbolNode.onUndefinedSymbol(name);
|
75
75
|
};
|
76
76
|
}
|
77
77
|
};
|
@@ -1,12 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
3
2
|
import { factory } from '../utils/factory.js';
|
4
3
|
import { isAccessorNode, isConstantNode, isFunctionNode, isOperatorNode, isSymbolNode } from '../utils/is.js';
|
5
4
|
import { deepMap } from '../utils/collection.js';
|
6
5
|
import { hasOwnProperty } from '../utils/object.js';
|
7
6
|
var name = 'parse';
|
8
7
|
var dependencies = ['typed', 'numeric', 'config', 'AccessorNode', 'ArrayNode', 'AssignmentNode', 'BlockNode', 'ConditionalNode', 'ConstantNode', 'FunctionAssignmentNode', 'FunctionNode', 'IndexNode', 'ObjectNode', 'OperatorNode', 'ParenthesisNode', 'RangeNode', 'RelationalNode', 'SymbolNode'];
|
9
|
-
export var createParse = /* #__PURE__ */factory(name, dependencies,
|
8
|
+
export var createParse = /* #__PURE__ */factory(name, dependencies, _ref => {
|
10
9
|
var {
|
11
10
|
typed,
|
12
11
|
numeric,
|
@@ -12,7 +12,7 @@ var dependencies = ['typed', 'isInteger'];
|
|
12
12
|
* from one-based to zero based
|
13
13
|
*/
|
14
14
|
|
15
|
-
export var createApplyTransform = /* #__PURE__ */factory(name, dependencies,
|
15
|
+
export var createApplyTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
16
16
|
var {
|
17
17
|
typed,
|
18
18
|
isInteger
|
@@ -12,7 +12,7 @@ var dependencies = ['typed', 'Index', 'matrix', 'range'];
|
|
12
12
|
* from zero-based to one-based
|
13
13
|
*/
|
14
14
|
|
15
|
-
export var createColumnTransform = /* #__PURE__ */factory(name, dependencies,
|
15
|
+
export var createColumnTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
16
16
|
var {
|
17
17
|
typed,
|
18
18
|
Index,
|
@@ -4,7 +4,7 @@ import { factory } from '../../utils/factory.js';
|
|
4
4
|
import { createConcat } from '../../function/matrix/concat.js';
|
5
5
|
var name = 'concat';
|
6
6
|
var dependencies = ['typed', 'matrix', 'isInteger'];
|
7
|
-
export var createConcatTransform = /* #__PURE__ */factory(name, dependencies,
|
7
|
+
export var createConcatTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
8
|
var {
|
9
9
|
typed,
|
10
10
|
matrix,
|
@@ -4,7 +4,7 @@ import { createDiff } from '../../function/matrix/diff.js';
|
|
4
4
|
import { lastDimToZeroBase } from './utils/lastDimToZeroBase.js';
|
5
5
|
var name = 'diff';
|
6
6
|
var dependencies = ['typed', 'matrix', 'subtract', 'number', 'bignumber'];
|
7
|
-
export var createDiffTransform = /* #__PURE__ */factory(name, dependencies,
|
7
|
+
export var createDiffTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
8
|
var {
|
9
9
|
typed,
|
10
10
|
matrix,
|
@@ -5,7 +5,7 @@ import { compileInlineExpression } from './utils/compileInlineExpression.js';
|
|
5
5
|
import { factory } from '../../utils/factory.js';
|
6
6
|
var name = 'filter';
|
7
7
|
var dependencies = ['typed'];
|
8
|
-
export var createFilterTransform = /* #__PURE__ */factory(name, dependencies,
|
8
|
+
export var createFilterTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
9
9
|
var {
|
10
10
|
typed
|
11
11
|
} = _ref;
|
@@ -5,7 +5,7 @@ import { factory } from '../../utils/factory.js';
|
|
5
5
|
import { compileInlineExpression } from './utils/compileInlineExpression.js';
|
6
6
|
var name = 'forEach';
|
7
7
|
var dependencies = ['typed'];
|
8
|
-
export var createForEachTransform = /* #__PURE__ */factory(name, dependencies,
|
8
|
+
export var createForEachTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
9
9
|
var {
|
10
10
|
typed
|
11
11
|
} = _ref;
|
@@ -2,7 +2,7 @@ import { isArray, isBigNumber, isMatrix, isNumber, isRange } from '../../utils/i
|
|
2
2
|
import { factory } from '../../utils/factory.js';
|
3
3
|
var name = 'index';
|
4
4
|
var dependencies = ['Index'];
|
5
|
-
export var createIndexTransform = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createIndexTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
Index
|
8
8
|
} = _ref;
|
@@ -5,7 +5,7 @@ import { factory } from '../../utils/factory.js';
|
|
5
5
|
import { compileInlineExpression } from './utils/compileInlineExpression.js';
|
6
6
|
var name = 'map';
|
7
7
|
var dependencies = ['typed'];
|
8
|
-
export var createMapTransform = /* #__PURE__ */factory(name, dependencies,
|
8
|
+
export var createMapTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
9
9
|
var {
|
10
10
|
typed
|
11
11
|
} = _ref;
|
@@ -4,7 +4,7 @@ import { createMax } from '../../function/statistics/max.js';
|
|
4
4
|
import { lastDimToZeroBase } from './utils/lastDimToZeroBase.js';
|
5
5
|
var name = 'max';
|
6
6
|
var dependencies = ['typed', 'config', 'numeric', 'larger'];
|
7
|
-
export var createMaxTransform = /* #__PURE__ */factory(name, dependencies,
|
7
|
+
export var createMaxTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
8
|
var {
|
9
9
|
typed,
|
10
10
|
config,
|
@@ -4,7 +4,7 @@ import { createMean } from '../../function/statistics/mean.js';
|
|
4
4
|
import { lastDimToZeroBase } from './utils/lastDimToZeroBase.js';
|
5
5
|
var name = 'mean';
|
6
6
|
var dependencies = ['typed', 'add', 'divide'];
|
7
|
-
export var createMeanTransform = /* #__PURE__ */factory(name, dependencies,
|
7
|
+
export var createMeanTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
8
|
var {
|
9
9
|
typed,
|
10
10
|
add,
|
@@ -4,7 +4,7 @@ import { createMin } from '../../function/statistics/min.js';
|
|
4
4
|
import { lastDimToZeroBase } from './utils/lastDimToZeroBase.js';
|
5
5
|
var name = 'min';
|
6
6
|
var dependencies = ['typed', 'config', 'numeric', 'smaller'];
|
7
|
-
export var createMinTransform = /* #__PURE__ */factory(name, dependencies,
|
7
|
+
export var createMinTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
8
|
var {
|
9
9
|
typed,
|
10
10
|
config,
|
@@ -2,7 +2,7 @@ import { factory } from '../../utils/factory.js';
|
|
2
2
|
import { createRange } from '../../function/matrix/range.js';
|
3
3
|
var name = 'range';
|
4
4
|
var dependencies = ['typed', 'config', '?matrix', '?bignumber', 'smaller', 'smallerEq', 'larger', 'largerEq'];
|
5
|
-
export var createRangeTransform = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createRangeTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed,
|
8
8
|
config,
|
@@ -12,7 +12,7 @@ var dependencies = ['typed', 'Index', 'matrix', 'range'];
|
|
12
12
|
* from zero-based to one-based
|
13
13
|
*/
|
14
14
|
|
15
|
-
export var createRowTransform = /* #__PURE__ */factory(name, dependencies,
|
15
|
+
export var createRowTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
16
16
|
var {
|
17
17
|
typed,
|
18
18
|
Index,
|
@@ -12,7 +12,7 @@ var dependencies = ['typed', 'sqrt', 'variance'];
|
|
12
12
|
* from one-based to zero based
|
13
13
|
*/
|
14
14
|
|
15
|
-
export var createStdTransform = /* #__PURE__ */factory(name, dependencies,
|
15
|
+
export var createStdTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
16
16
|
var {
|
17
17
|
typed,
|
18
18
|
sqrt,
|
@@ -3,7 +3,7 @@ import { errorTransform } from './utils/errorTransform.js';
|
|
3
3
|
import { createSubset } from '../../function/matrix/subset.js';
|
4
4
|
var name = 'subset';
|
5
5
|
var dependencies = ['typed', 'matrix'];
|
6
|
-
export var createSubsetTransform = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createSubsetTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
typed,
|
9
9
|
matrix
|
@@ -12,7 +12,7 @@ import { lastDimToZeroBase } from './utils/lastDimToZeroBase.js';
|
|
12
12
|
|
13
13
|
var name = 'sum';
|
14
14
|
var dependencies = ['typed', 'config', 'add', 'numeric'];
|
15
|
-
export var createSumTransform = /* #__PURE__ */factory(name, dependencies,
|
15
|
+
export var createSumTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
16
16
|
var {
|
17
17
|
typed,
|
18
18
|
config,
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { isSymbolNode } from '../../../utils/is.js';
|
2
|
+
import { createSubScope } from '../../../utils/scope.js';
|
2
3
|
/**
|
3
4
|
* Compile an inline expression like "x > 0"
|
4
5
|
* @param {Node} expression
|
@@ -11,7 +12,7 @@ import { isSymbolNode } from '../../../utils/is.js';
|
|
11
12
|
export function compileInlineExpression(expression, math, scope) {
|
12
13
|
// find an undefined symbol
|
13
14
|
var symbol = expression.filter(function (node) {
|
14
|
-
return isSymbolNode(node) && !(node.name in math) && !(node.name
|
15
|
+
return isSymbolNode(node) && !(node.name in math) && !scope.has(node.name);
|
15
16
|
})[0];
|
16
17
|
|
17
18
|
if (!symbol) {
|
@@ -21,10 +22,10 @@ export function compileInlineExpression(expression, math, scope) {
|
|
21
22
|
|
22
23
|
var name = symbol.name; // variable name
|
23
24
|
|
24
|
-
var subScope =
|
25
|
+
var subScope = createSubScope(scope);
|
25
26
|
var eq = expression.compile();
|
26
27
|
return function inlineExpression(x) {
|
27
|
-
subScope
|
28
|
+
subScope.set(name, x);
|
28
29
|
return eq.evaluate(subScope);
|
29
30
|
};
|
30
31
|
}
|
@@ -12,7 +12,7 @@ var dependencies = ['typed', 'add', 'subtract', 'multiply', 'divide', 'apply', '
|
|
12
12
|
* from one-based to zero based
|
13
13
|
*/
|
14
14
|
|
15
|
-
export var createVarianceTransform = /* #__PURE__ */factory(name, dependencies,
|
15
|
+
export var createVarianceTransform = /* #__PURE__ */factory(name, dependencies, _ref => {
|
16
16
|
var {
|
17
17
|
typed,
|
18
18
|
add,
|
package/lib/esm/factoriesAny.js
CHANGED
@@ -24,6 +24,9 @@ export { createBignumber } from './type/bignumber/function/bignumber.js';
|
|
24
24
|
export { createComplex } from './type/complex/function/complex.js';
|
25
25
|
export { createFraction } from './type/fraction/function/fraction.js';
|
26
26
|
export { createMatrix } from './type/matrix/function/matrix.js';
|
27
|
+
export { createMatrixFromFunction } from './function/matrix/matrixFromFunction.js';
|
28
|
+
export { createMatrixFromRows } from './function/matrix/matrixFromRows.js';
|
29
|
+
export { createMatrixFromColumns } from './function/matrix/matrixFromColumns.js';
|
27
30
|
export { createSplitUnit } from './type/unit/function/splitUnit.js';
|
28
31
|
export { createUnaryMinus } from './function/arithmetic/unaryMinus.js';
|
29
32
|
export { createUnaryPlus } from './function/arithmetic/unaryPlus.js';
|
@@ -211,7 +211,7 @@ export { createReviver } from './json/reviver.js';
|
|
211
211
|
export { createReplacer } from './json/replacer.js'; // helper function to create a factory function for a function which only needs typed-function
|
212
212
|
|
213
213
|
function createNumberFactory(name, fn) {
|
214
|
-
return factory(name, ['typed'],
|
214
|
+
return factory(name, ['typed'], _ref => {
|
215
215
|
var {
|
216
216
|
typed
|
217
217
|
} = _ref;
|
@@ -2,7 +2,7 @@ import { clone } from '../../../utils/object.js';
|
|
2
2
|
import { factory } from '../../../utils/factory.js';
|
3
3
|
var name = 'lup';
|
4
4
|
var dependencies = ['typed', 'matrix', 'abs', 'addScalar', 'divideScalar', 'multiplyScalar', 'subtract', 'larger', 'equalScalar', 'unaryMinus', 'DenseMatrix', 'SparseMatrix', 'Spa'];
|
5
|
-
export var createLup = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createLup = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed,
|
8
8
|
matrix,
|
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
3
2
|
import { factory } from '../../../utils/factory.js';
|
4
3
|
var name = 'qr';
|
5
4
|
var dependencies = ['typed', 'matrix', 'zeros', 'identity', 'isZero', 'equal', 'sign', 'sqrt', 'conj', 'unaryMinus', 'addScalar', 'divideScalar', 'multiplyScalar', 'subtract', 'complex'];
|
6
|
-
export var createQr = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createQr = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
6
|
var {
|
8
7
|
typed,
|
9
8
|
matrix,
|
@@ -4,7 +4,7 @@ import { createCsSqr } from '../sparse/csSqr.js';
|
|
4
4
|
import { createCsLu } from '../sparse/csLu.js';
|
5
5
|
var name = 'slu';
|
6
6
|
var dependencies = ['typed', 'abs', 'add', 'multiply', 'transpose', 'divideScalar', 'subtract', 'larger', 'largerEq', 'SparseMatrix'];
|
7
|
-
export var createSlu = /* #__PURE__ */factory(name, dependencies,
|
7
|
+
export var createSlu = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
8
|
var {
|
9
9
|
typed,
|
10
10
|
abs,
|
@@ -2,7 +2,7 @@ import { isConstantNode, typeOf } from '../../utils/is.js';
|
|
2
2
|
import { factory } from '../../utils/factory.js';
|
3
3
|
var name = 'derivative';
|
4
4
|
var dependencies = ['typed', 'config', 'parse', 'simplify', 'equal', 'isZero', 'numeric', 'ConstantNode', 'FunctionNode', 'OperatorNode', 'ParenthesisNode', 'SymbolNode'];
|
5
|
-
export var createDerivative = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createDerivative = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed,
|
8
8
|
config,
|
@@ -4,7 +4,7 @@ import { createSimplifyConstant } from './simplify/simplifyConstant.js';
|
|
4
4
|
import { createSimplifyCore } from './simplify/simplifyCore.js';
|
5
5
|
var name = 'rationalize';
|
6
6
|
var dependencies = ['config', 'typed', 'equal', 'isZero', 'add', 'subtract', 'multiply', 'divide', 'pow', 'parse', 'simplify', '?bignumber', '?fraction', 'mathWithTransform', 'ConstantNode', 'OperatorNode', 'FunctionNode', 'SymbolNode', 'ParenthesisNode'];
|
7
|
-
export var createRationalize = /* #__PURE__ */factory(name, dependencies,
|
7
|
+
export var createRationalize = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
8
|
var {
|
9
9
|
config,
|
10
10
|
typed,
|
@@ -1,8 +1,9 @@
|
|
1
|
+
import { createMap, isMap } from '../../../utils/map.js';
|
1
2
|
import { isFunctionNode, isNode, isOperatorNode, isParenthesisNode, isSymbolNode } from '../../../utils/is.js';
|
2
3
|
import { factory } from '../../../utils/factory.js';
|
3
4
|
var name = 'resolve';
|
4
5
|
var dependencies = ['parse', 'FunctionNode', 'OperatorNode', 'ParenthesisNode'];
|
5
|
-
export var createResolve = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createResolve = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
7
|
var {
|
7
8
|
parse,
|
8
9
|
FunctionNode,
|
@@ -32,8 +33,12 @@ export var createResolve = /* #__PURE__ */factory(name, dependencies, (_ref) =>
|
|
32
33
|
return node;
|
33
34
|
}
|
34
35
|
|
36
|
+
if (!isMap(scope)) {
|
37
|
+
scope = createMap(scope);
|
38
|
+
}
|
39
|
+
|
35
40
|
if (isSymbolNode(node)) {
|
36
|
-
var value = scope
|
41
|
+
var value = scope.get(node.name);
|
37
42
|
|
38
43
|
if (isNode(value)) {
|
39
44
|
return resolve(value, scope);
|
@@ -5,7 +5,7 @@ import { createUtil } from './util.js';
|
|
5
5
|
import { noBignumber, noFraction } from '../../../utils/noop.js';
|
6
6
|
var name = 'simplifyConstant';
|
7
7
|
var dependencies = ['typed', 'config', 'mathWithTransform', '?fraction', '?bignumber', 'ConstantNode', 'OperatorNode', 'FunctionNode', 'SymbolNode'];
|
8
|
-
export var createSimplifyConstant = /* #__PURE__ */factory(name, dependencies,
|
8
|
+
export var createSimplifyConstant = /* #__PURE__ */factory(name, dependencies, _ref => {
|
9
9
|
var {
|
10
10
|
typed,
|
11
11
|
config,
|
@@ -2,7 +2,7 @@ import { isConstantNode, isFunctionNode, isOperatorNode, isParenthesisNode, isSy
|
|
2
2
|
import { factory } from '../../../utils/factory.js';
|
3
3
|
var name = 'simplifyCore';
|
4
4
|
var dependencies = ['equal', 'isZero', 'add', 'subtract', 'multiply', 'divide', 'pow', 'ConstantNode', 'OperatorNode', 'FunctionNode', 'ParenthesisNode'];
|
5
|
-
export var createSimplifyCore = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createSimplifyCore = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
equal,
|
8
8
|
isZero,
|
@@ -3,7 +3,7 @@ import { factory } from '../../../utils/factory.js';
|
|
3
3
|
import { hasOwnProperty } from '../../../utils/object.js';
|
4
4
|
var name = 'simplifyUtil';
|
5
5
|
var dependencies = ['FunctionNode', 'OperatorNode', 'SymbolNode'];
|
6
|
-
export var createUtil = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createUtil = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
FunctionNode,
|
9
9
|
OperatorNode,
|