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
@@ -4,7 +4,7 @@
|
|
4
4
|
*/
|
5
5
|
import { config } from './configReadonly.js';
|
6
6
|
import { createResultSet, createComplexClass, createRangeClass, createFalse, createNull, createTrue, createBigNumberClass, createMatrixClass, createReplacer, createI, createLN10, createLOG10E, createNaN, createPi, createSQRT1_2 // eslint-disable-line camelcase
|
7
|
-
, createTau, createEfimovFactor, createFineStructure, createSackurTetrode, createWeakMixingAngle, createFractionClass, createE, createInfinity, createLOG2E, createVersion, createDenseMatrixClass, createPhi, createTyped, createIsInteger, createIsNumeric, createIsPositive, createIsNaN, createEqualScalar, createNumber, createBoolean, createComplex, createSplitUnit, createUnaryPlus, createApply, createCube, createExpm1, createLog10, createMultiplyScalar, createSign, createSquare, createBitNot, createArg, createIm, createNot, createFilter, createForEach, createMap, createErf, createFormat, createOct, createPrint, createIsPrime, createAcos, createAcot, createAcsc, createAsec, createAsin, createAtan, createAtanh, createCosh, createCoth, createCsch, createSech, createSinh, createTanh, createCombinations, createPickRandom, createRandomInt, createLN2, createClone, createHasNumericValue, createTypeOf, createString, createFraction, createUnaryMinus, createAddScalar, createExp, createLog2, createSqrt, createConj, createGetMatrixDataType, createMode, createBin, createAcosh, createAcsch, createAsinh, createCos, createCsc, createSin, createCombinationsWithRep, createRandom, createSQRT2, createIsNegative, createSparseMatrixClass, createMatrix,
|
7
|
+
, createTau, createEfimovFactor, createFineStructure, createSackurTetrode, createWeakMixingAngle, createFractionClass, createE, createInfinity, createLOG2E, createVersion, createDenseMatrixClass, createPhi, createTyped, createIsInteger, createIsNumeric, createIsPositive, createIsNaN, createEqualScalar, createNumber, createBoolean, createComplex, createSplitUnit, createUnaryPlus, createApply, createCube, createExpm1, createLog10, createMultiplyScalar, createSign, createSquare, createBitNot, createArg, createIm, createNot, createFilter, createForEach, createMap, createErf, createFormat, createOct, createPrint, createIsPrime, createAcos, createAcot, createAcsc, createAsec, createAsin, createAtan, createAtanh, createCosh, createCoth, createCsch, createSech, createSinh, createTanh, createCombinations, createPickRandom, createRandomInt, createLN2, createClone, createHasNumericValue, createTypeOf, createString, createFraction, createUnaryMinus, createAddScalar, createExp, createLog2, createSqrt, createConj, createGetMatrixDataType, createMode, createBin, createAcosh, createAcsch, createAsinh, createCos, createCsc, createSin, createCombinationsWithRep, createRandom, createSQRT2, createIsNegative, createSparseMatrixClass, createMatrix, createAbs, createGcd, createMod, createNthRoot, createXgcd, createBitAnd, createBitXor, createOr, createConcat, createDiag, createIdentity, createOnes, createReshape, createSize, createSubset, createZeros, createHex, createRound, createLeftShift, createRightLogShift, createCompare, createCompareText, createSmaller, createLarger, createUnequal, createImmutableDenseMatrixClass, createFibonacciHeapClass, createSparse, createAcoth, createAtan2, createSec, createAdd, createDot, createComposition, createIsZero, createMatrixFromFunction, createCbrt, createFloor, createMultiply, createDotMultiply, createRe, createFlatten, createResize, createSqueeze, createTo, createPow, createDotPow, createRightArithShift, createCompareNatural, createEqualText, createLargerEq, createPartitionSelect, createIndexClass, createAsech, createTan, createSetDifference, createSetIntersect, createSetMultiplicity, createSetSize, createTrace, createQuantileSeq, createGamma, createBignumber, createMatrixFromColumns, createLcm, createBitOr, createKron, createTranspose, createNumeric, createAnd, createSmallerEq, createSort, createMin, createCot, createSetDistinct, createSetPowerset, createIndex, createSum, createFactorial, createPermutations, createMatrixFromRows, createSubtract, createCross, createRange, createRow, createProd, createEqual, createMax, createSetCartesian, createSetSymDifference, createCeil, createXor, createCount, createCtranspose, createDeepEqual, createSetIsSubset, createFix, createDiff, createDivideScalar, createNthRoots, createLsolve, createLsolveAll, createSpaClass, createSetUnion, createLup, createSlu, createDet, createDistance, createStirlingS2, createCatalan, createColumn, createLog, createDotDivide, createUsolveAll, createHypot, createQr, createInv, createExpm, createDivide, createMean, createVariance, createKldivergence, createBellNumbers, createLog1p, createUnitClass, createCreateUnit, createEigs, createIntersect, createStd, createAtomicMass, createBohrMagneton, createBoltzmann, createConductanceQuantum, createDeuteronMass, createElectronMass, createFaraday, createFirstRadiation, createGravitationConstant, createHartreeEnergy, createKlitzing, createMagneticConstant, createMolarMass, createMolarPlanckConstant, createNeutronMass, createPlanckCharge, createPlanckLength, createPlanckTemperature, createProtonMass, createReducedPlanckConstant, createSecondRadiation, createStefanBoltzmann, createVacuumImpedance, createUsolve, createNorm, createLusolve, createSqrtm, createMultinomial, createAvogadro, createClassicalElectronRadius, createElectricConstant, createFermiCoupling, createGravity, createLoschmidt, createMolarMassC12, createNuclearMagneton, createPlanckMass, createQuantumOfCirculation, createSpeedOfLight, createWienDisplacement, createRotationMatrix, createMedian, createBohrRadius, createElementaryCharge, createInverseConductanceQuantum, createMolarVolume, createPlanckTime, createThomsonCrossSection, createRotate, createMad, createCoulomb, createMagneticFluxQuantum, createRydberg, createUnitFunction, createGasConstant, createPlanckConstant } from '../factoriesAny.js';
|
8
8
|
export var ResultSet = /* #__PURE__ */createResultSet({});
|
9
9
|
export var Complex = /* #__PURE__ */createComplexClass({});
|
10
10
|
export var Range = /* #__PURE__ */createRangeClass({});
|
@@ -353,15 +353,8 @@ export var matrix = /* #__PURE__ */createMatrix({
|
|
353
353
|
SparseMatrix,
|
354
354
|
typed
|
355
355
|
});
|
356
|
-
export var
|
357
|
-
|
358
|
-
Complex,
|
359
|
-
Fraction,
|
360
|
-
config,
|
361
|
-
isNegative,
|
362
|
-
matrix,
|
363
|
-
typed,
|
364
|
-
unaryMinus
|
356
|
+
export var abs = /* #__PURE__ */createAbs({
|
357
|
+
typed
|
365
358
|
});
|
366
359
|
export var gcd = /* #__PURE__ */createGcd({
|
367
360
|
BigNumber,
|
@@ -563,9 +556,21 @@ export var composition = /* #__PURE__ */createComposition({
|
|
563
556
|
export var isZero = /* #__PURE__ */createIsZero({
|
564
557
|
typed
|
565
558
|
});
|
566
|
-
export var
|
559
|
+
export var matrixFromFunction = /* #__PURE__ */createMatrixFromFunction({
|
560
|
+
isZero,
|
561
|
+
matrix,
|
567
562
|
typed
|
568
563
|
});
|
564
|
+
export var cbrt = /* #__PURE__ */createCbrt({
|
565
|
+
BigNumber,
|
566
|
+
Complex,
|
567
|
+
Fraction,
|
568
|
+
config,
|
569
|
+
isNegative,
|
570
|
+
matrix,
|
571
|
+
typed,
|
572
|
+
unaryMinus
|
573
|
+
});
|
569
574
|
export var floor = /* #__PURE__ */createFloor({
|
570
575
|
config,
|
571
576
|
equalScalar,
|
@@ -714,6 +719,12 @@ export var bignumber = /* #__PURE__ */createBignumber({
|
|
714
719
|
BigNumber,
|
715
720
|
typed
|
716
721
|
});
|
722
|
+
export var matrixFromColumns = /* #__PURE__ */createMatrixFromColumns({
|
723
|
+
flatten,
|
724
|
+
matrix,
|
725
|
+
size,
|
726
|
+
typed
|
727
|
+
});
|
717
728
|
export var lcm = /* #__PURE__ */createLcm({
|
718
729
|
equalScalar,
|
719
730
|
matrix,
|
@@ -801,11 +812,10 @@ export var permutations = /* #__PURE__ */createPermutations({
|
|
801
812
|
factorial,
|
802
813
|
typed
|
803
814
|
});
|
804
|
-
export var
|
805
|
-
|
806
|
-
equalScalar,
|
815
|
+
export var matrixFromRows = /* #__PURE__ */createMatrixFromRows({
|
816
|
+
flatten,
|
807
817
|
matrix,
|
808
|
-
|
818
|
+
size,
|
809
819
|
typed
|
810
820
|
});
|
811
821
|
export var subtract = /* #__PURE__ */createSubtract({
|
@@ -872,23 +882,21 @@ export var setSymDifference = /* #__PURE__ */createSetSymDifference({
|
|
872
882
|
subset,
|
873
883
|
typed
|
874
884
|
});
|
875
|
-
export var
|
876
|
-
|
877
|
-
|
878
|
-
floor,
|
885
|
+
export var ceil = /* #__PURE__ */createCeil({
|
886
|
+
config,
|
887
|
+
equalScalar,
|
879
888
|
matrix,
|
889
|
+
round,
|
880
890
|
typed
|
881
891
|
});
|
882
|
-
export var
|
883
|
-
|
892
|
+
export var xor = /* #__PURE__ */createXor({
|
893
|
+
DenseMatrix,
|
884
894
|
matrix,
|
885
|
-
range,
|
886
895
|
typed
|
887
896
|
});
|
888
|
-
export var
|
889
|
-
|
890
|
-
|
891
|
-
subtract,
|
897
|
+
export var count = /* #__PURE__ */createCount({
|
898
|
+
prod,
|
899
|
+
size,
|
892
900
|
typed
|
893
901
|
});
|
894
902
|
export var ctranspose = /* #__PURE__ */createCtranspose({
|
@@ -907,11 +915,19 @@ export var setIsSubset = /* #__PURE__ */createSetIsSubset({
|
|
907
915
|
subset,
|
908
916
|
typed
|
909
917
|
});
|
910
|
-
export var
|
911
|
-
|
918
|
+
export var fix = /* #__PURE__ */createFix({
|
919
|
+
Complex,
|
920
|
+
ceil,
|
921
|
+
floor,
|
912
922
|
matrix,
|
913
923
|
typed
|
914
924
|
});
|
925
|
+
export var diff = /* #__PURE__ */createDiff({
|
926
|
+
matrix,
|
927
|
+
number,
|
928
|
+
subtract,
|
929
|
+
typed
|
930
|
+
});
|
915
931
|
export var divideScalar = /* #__PURE__ */createDivideScalar({
|
916
932
|
numeric,
|
917
933
|
typed
|
@@ -1021,9 +1037,10 @@ export var catalan = /* #__PURE__ */createCatalan({
|
|
1021
1037
|
multiplyScalar,
|
1022
1038
|
typed
|
1023
1039
|
});
|
1024
|
-
export var
|
1025
|
-
|
1026
|
-
|
1040
|
+
export var column = /* #__PURE__ */createColumn({
|
1041
|
+
Index,
|
1042
|
+
matrix,
|
1043
|
+
range,
|
1027
1044
|
typed
|
1028
1045
|
});
|
1029
1046
|
export var log = /* #__PURE__ */createLog({
|
@@ -1168,16 +1185,33 @@ export var eigs = /* #__PURE__ */createEigs({
|
|
1168
1185
|
addScalar,
|
1169
1186
|
atan,
|
1170
1187
|
bignumber,
|
1188
|
+
column,
|
1189
|
+
complex,
|
1171
1190
|
config,
|
1172
1191
|
cos,
|
1192
|
+
diag,
|
1193
|
+
divideScalar,
|
1173
1194
|
equal,
|
1195
|
+
flatten,
|
1196
|
+
im,
|
1174
1197
|
inv,
|
1198
|
+
larger,
|
1199
|
+
log10,
|
1175
1200
|
matrix,
|
1201
|
+
matrixFromColumns,
|
1176
1202
|
multiply,
|
1177
1203
|
multiplyScalar,
|
1204
|
+
number,
|
1205
|
+
qr,
|
1206
|
+
re,
|
1207
|
+
round,
|
1178
1208
|
sin,
|
1209
|
+
smaller,
|
1210
|
+
sqrt,
|
1179
1211
|
subtract,
|
1180
|
-
|
1212
|
+
transpose,
|
1213
|
+
typed,
|
1214
|
+
usolveAll
|
1181
1215
|
});
|
1182
1216
|
export var intersect = /* #__PURE__ */createIntersect({
|
1183
1217
|
abs,
|
@@ -4,7 +4,7 @@ import { format } from '../utils/string.js';
|
|
4
4
|
import { factory } from '../utils/factory.js';
|
5
5
|
var name = 'Help';
|
6
6
|
var dependencies = ['parse'];
|
7
|
-
export var createHelpClass = /* #__PURE__ */factory(name, dependencies,
|
7
|
+
export var createHelpClass = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
8
|
var {
|
9
9
|
parse
|
10
10
|
} = _ref;
|
@@ -1,9 +1,8 @@
|
|
1
1
|
import { factory } from '../utils/factory.js';
|
2
|
-
import {
|
3
|
-
import { getSafeProperty, setSafeProperty } from '../utils/customs.js';
|
2
|
+
import { createEmptyMap, toObject } from '../utils/map.js';
|
4
3
|
var name = 'Parser';
|
5
4
|
var dependencies = ['parse'];
|
6
|
-
export var createParserClass = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createParserClass = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
6
|
var {
|
8
7
|
parse
|
9
8
|
} = _ref;
|
@@ -61,7 +60,10 @@ export var createParserClass = /* #__PURE__ */factory(name, dependencies, (_ref)
|
|
61
60
|
throw new SyntaxError('Constructor must be called with the new operator');
|
62
61
|
}
|
63
62
|
|
64
|
-
this
|
63
|
+
Object.defineProperty(this, 'scope', {
|
64
|
+
value: createEmptyMap(),
|
65
|
+
writable: false
|
66
|
+
});
|
65
67
|
}
|
66
68
|
/**
|
67
69
|
* Attach type information
|
@@ -91,7 +93,9 @@ export var createParserClass = /* #__PURE__ */factory(name, dependencies, (_ref)
|
|
91
93
|
|
92
94
|
Parser.prototype.get = function (name) {
|
93
95
|
// TODO: validate arguments
|
94
|
-
|
96
|
+
if (this.scope.has(name)) {
|
97
|
+
return this.scope.get(name);
|
98
|
+
}
|
95
99
|
};
|
96
100
|
/**
|
97
101
|
* Get a map with all defined variables
|
@@ -100,7 +104,16 @@ export var createParserClass = /* #__PURE__ */factory(name, dependencies, (_ref)
|
|
100
104
|
|
101
105
|
|
102
106
|
Parser.prototype.getAll = function () {
|
103
|
-
return
|
107
|
+
return toObject(this.scope);
|
108
|
+
};
|
109
|
+
/**
|
110
|
+
* Get a map with all defined variables
|
111
|
+
* @return {Map} values
|
112
|
+
*/
|
113
|
+
|
114
|
+
|
115
|
+
Parser.prototype.getAllAsMap = function () {
|
116
|
+
return this.scope;
|
104
117
|
};
|
105
118
|
/**
|
106
119
|
* Set a symbol (a function or variable) by name from the parsers scope.
|
@@ -110,8 +123,8 @@ export var createParserClass = /* #__PURE__ */factory(name, dependencies, (_ref)
|
|
110
123
|
|
111
124
|
|
112
125
|
Parser.prototype.set = function (name, value) {
|
113
|
-
|
114
|
-
return
|
126
|
+
this.scope.set(name, value);
|
127
|
+
return value;
|
115
128
|
};
|
116
129
|
/**
|
117
130
|
* Remove a variable from the parsers scope
|
@@ -120,8 +133,7 @@ export var createParserClass = /* #__PURE__ */factory(name, dependencies, (_ref)
|
|
120
133
|
|
121
134
|
|
122
135
|
Parser.prototype.remove = function (name) {
|
123
|
-
|
124
|
-
delete this.scope[name];
|
136
|
+
this.scope.delete(name);
|
125
137
|
};
|
126
138
|
/**
|
127
139
|
* Clear the scope with variables and functions
|
@@ -129,11 +141,7 @@ export var createParserClass = /* #__PURE__ */factory(name, dependencies, (_ref)
|
|
129
141
|
|
130
142
|
|
131
143
|
Parser.prototype.clear = function () {
|
132
|
-
|
133
|
-
if (hasOwnProperty(this.scope, _name)) {
|
134
|
-
delete this.scope[_name];
|
135
|
-
}
|
136
|
-
}
|
144
|
+
this.scope.clear();
|
137
145
|
};
|
138
146
|
|
139
147
|
return Parser;
|
@@ -202,6 +202,9 @@ import { splitUnitDocs } from './construction/splitUnit.js';
|
|
202
202
|
import { sparseDocs } from './construction/sparse.js';
|
203
203
|
import { numberDocs } from './construction/number.js';
|
204
204
|
import { matrixDocs } from './construction/matrix.js';
|
205
|
+
import { matrixFromFunctionDocs } from './function/matrix/matrixFromFunction.js';
|
206
|
+
import { matrixFromRowsDocs } from './function/matrix/matrixFromRows.js';
|
207
|
+
import { matrixFromColumnsDocs } from './function/matrix/matrixFromColumns.js';
|
205
208
|
import { indexDocs } from './construction/index.js';
|
206
209
|
import { fractionDocs } from './construction/fraction.js';
|
207
210
|
import { createUnitDocs } from './construction/createUnit.js';
|
@@ -555,6 +558,9 @@ export var embeddedDocs = {
|
|
555
558
|
inv: invDocs,
|
556
559
|
eigs: eigsDocs,
|
557
560
|
kron: kronDocs,
|
561
|
+
matrixFromFunction: matrixFromFunctionDocs,
|
562
|
+
matrixFromRows: matrixFromRowsDocs,
|
563
|
+
matrixFromColumns: matrixFromColumnsDocs,
|
558
564
|
map: mapDocs,
|
559
565
|
ones: onesDocs,
|
560
566
|
partitionSelect: partitionSelectDocs,
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export var matrixFromColumnsDocs = {
|
2
|
+
name: 'matrixFromColumns',
|
3
|
+
category: 'Matrix',
|
4
|
+
syntax: ['math.matrixFromColumns(...arr)', 'math.matrixFromColumns(row1, row2)', 'math.matrixFromColumns(row1, row2, row3)'],
|
5
|
+
description: 'Create a dense matrix from vectors as individual columns.',
|
6
|
+
examples: ['matrixFromColumns([1, 2, 3], [[4],[5],[6]])'],
|
7
|
+
seealso: ['matrix', 'matrixFromRows', 'matrixFromFunction', 'zeros']
|
8
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export var matrixFromFunctionDocs = {
|
2
|
+
name: 'matrixFromFunction',
|
3
|
+
category: 'Matrix',
|
4
|
+
syntax: ['math.matrixFromFunction(size, fn)', 'math.matrixFromFunction(size, fn, format)', 'math.matrixFromFunction(size, fn, format, datatype)', 'math.matrixFromFunction(size, format, fn)', 'math.matrixFromFunction(size, format, datatype, fn)'],
|
5
|
+
description: 'Create a matrix by evaluating a generating function at each index.',
|
6
|
+
examples: ['f(I) = I[1] - I[2]', 'matrixFromFunction([3,3], f)', 'g(I) = I[1] - I[2] == 1 ? 4 : 0', 'matrixFromFunction([100, 100], "sparse", g)', 'matrixFromFunction([5], random)'],
|
7
|
+
seealso: ['matrix', 'matrixFromRows', 'matrixFromColumns', 'zeros']
|
8
|
+
};
|
@@ -0,0 +1,8 @@
|
|
1
|
+
export var matrixFromRowsDocs = {
|
2
|
+
name: 'matrixFromRows',
|
3
|
+
category: 'Matrix',
|
4
|
+
syntax: ['math.matrixFromRows(...arr)', 'math.matrixFromRows(row1, row2)', 'math.matrixFromRows(row1, row2, row3)'],
|
5
|
+
description: 'Create a dense matrix from vectors as individual rows.',
|
6
|
+
examples: ['matrixFromRows([1, 2, 3], [[4],[5],[6]])'],
|
7
|
+
seealso: ['matrix', 'matrixFromColumns', 'matrixFromFunction', 'zeros']
|
8
|
+
};
|
@@ -2,7 +2,7 @@ import { deepMap } from '../../utils/collection.js';
|
|
2
2
|
import { factory } from '../../utils/factory.js';
|
3
3
|
var name = 'compile';
|
4
4
|
var dependencies = ['typed', 'parse'];
|
5
|
-
export var createCompile = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createCompile = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed,
|
8
8
|
parse
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import { deepMap } from '../../utils/collection.js';
|
2
2
|
import { factory } from '../../utils/factory.js';
|
3
|
+
import { createEmptyMap } from '../../utils/map.js';
|
3
4
|
var name = 'evaluate';
|
4
5
|
var dependencies = ['typed', 'parse'];
|
5
|
-
export var createEvaluate = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createEvaluate = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
7
|
var {
|
7
8
|
typed,
|
8
9
|
parse
|
@@ -42,19 +43,19 @@ export var createEvaluate = /* #__PURE__ */factory(name, dependencies, (_ref) =>
|
|
42
43
|
*/
|
43
44
|
return typed(name, {
|
44
45
|
string: function string(expr) {
|
45
|
-
var scope =
|
46
|
+
var scope = createEmptyMap();
|
46
47
|
return parse(expr).compile().evaluate(scope);
|
47
48
|
},
|
48
|
-
'string, Object': function
|
49
|
+
'string, Map | Object': function stringMapObject(expr, scope) {
|
49
50
|
return parse(expr).compile().evaluate(scope);
|
50
51
|
},
|
51
52
|
'Array | Matrix': function ArrayMatrix(expr) {
|
52
|
-
var scope =
|
53
|
+
var scope = createEmptyMap();
|
53
54
|
return deepMap(expr, function (entry) {
|
54
55
|
return parse(entry).compile().evaluate(scope);
|
55
56
|
});
|
56
57
|
},
|
57
|
-
'Array | Matrix, Object': function
|
58
|
+
'Array | Matrix, Map | Object': function ArrayMatrixMapObject(expr, scope) {
|
58
59
|
return deepMap(expr, function (entry) {
|
59
60
|
return parse(entry).compile().evaluate(scope);
|
60
61
|
});
|
@@ -4,7 +4,7 @@ import { embeddedDocs } from '../embeddedDocs/embeddedDocs.js';
|
|
4
4
|
import { hasOwnProperty } from '../../utils/object.js';
|
5
5
|
var name = 'help';
|
6
6
|
var dependencies = ['typed', 'mathWithTransform', 'Help'];
|
7
|
-
export var createHelp = /* #__PURE__ */factory(name, dependencies,
|
7
|
+
export var createHelp = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
8
|
var {
|
9
9
|
typed,
|
10
10
|
mathWithTransform,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { factory } from '../../utils/factory.js';
|
2
2
|
var name = 'parser';
|
3
3
|
var dependencies = ['typed', 'Parser'];
|
4
|
-
export var createParser = /* #__PURE__ */factory(name, dependencies,
|
4
|
+
export var createParser = /* #__PURE__ */factory(name, dependencies, _ref => {
|
5
5
|
var {
|
6
6
|
typed,
|
7
7
|
Parser
|
@@ -4,7 +4,7 @@ import { factory } from '../../utils/factory.js';
|
|
4
4
|
import { accessFactory } from './utils/access.js';
|
5
5
|
var name = 'AccessorNode';
|
6
6
|
var dependencies = ['subset', 'Node'];
|
7
|
-
export var createAccessorNode = /* #__PURE__ */factory(name, dependencies,
|
7
|
+
export var createAccessorNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
8
|
var {
|
9
9
|
subset,
|
10
10
|
Node
|
@@ -77,6 +77,7 @@ export var createAccessorNode = /* #__PURE__ */factory(name, dependencies, (_ref
|
|
77
77
|
if (this.index.isObjectProperty()) {
|
78
78
|
var prop = this.index.getObjectProperty();
|
79
79
|
return function evalAccessorNode(scope, args, context) {
|
80
|
+
// get a property from an object evaluated using the scope.
|
80
81
|
return getSafeProperty(evalObject(scope, args, context), prop);
|
81
82
|
};
|
82
83
|
} else {
|
@@ -3,7 +3,7 @@ import { map } from '../../utils/array.js';
|
|
3
3
|
import { factory } from '../../utils/factory.js';
|
4
4
|
var name = 'ArrayNode';
|
5
5
|
var dependencies = ['Node'];
|
6
|
-
export var createArrayNode = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createArrayNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
Node
|
9
9
|
} = _ref;
|
@@ -7,7 +7,7 @@ import { getPrecedence } from '../operators.js';
|
|
7
7
|
var name = 'AssignmentNode';
|
8
8
|
var dependencies = ['subset', '?matrix', // FIXME: should not be needed at all, should be handled by subset
|
9
9
|
'Node'];
|
10
|
-
export var createAssignmentNode = /* #__PURE__ */factory(name, dependencies,
|
10
|
+
export var createAssignmentNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
11
11
|
var {
|
12
12
|
subset,
|
13
13
|
matrix,
|
@@ -121,7 +121,9 @@ export var createAssignmentNode = /* #__PURE__ */factory(name, dependencies, (_r
|
|
121
121
|
}
|
122
122
|
|
123
123
|
return function evalAssignmentNode(scope, args, context) {
|
124
|
-
|
124
|
+
var value = evalValue(scope, args, context);
|
125
|
+
scope.set(name, value);
|
126
|
+
return value;
|
125
127
|
};
|
126
128
|
} else if (this.index.isObjectProperty()) {
|
127
129
|
// apply an object property for example `a.b=2`
|
@@ -129,7 +131,8 @@ export var createAssignmentNode = /* #__PURE__ */factory(name, dependencies, (_r
|
|
129
131
|
return function evalAssignmentNode(scope, args, context) {
|
130
132
|
var object = evalObject(scope, args, context);
|
131
133
|
var value = evalValue(scope, args, context);
|
132
|
-
|
134
|
+
setSafeProperty(object, prop, value);
|
135
|
+
return value;
|
133
136
|
};
|
134
137
|
} else if (isSymbolNode(this.object)) {
|
135
138
|
// update a matrix subset, for example `a[2]=3`
|
@@ -138,7 +141,7 @@ export var createAssignmentNode = /* #__PURE__ */factory(name, dependencies, (_r
|
|
138
141
|
var value = evalValue(scope, args, context);
|
139
142
|
var index = evalIndex(scope, args, childObject); // Important: we pass childObject instead of context
|
140
143
|
|
141
|
-
|
144
|
+
scope.set(name, assign(childObject, index, value));
|
142
145
|
return value;
|
143
146
|
};
|
144
147
|
} else {
|
@@ -3,7 +3,7 @@ import { forEach, map } from '../../utils/array.js';
|
|
3
3
|
import { factory } from '../../utils/factory.js';
|
4
4
|
var name = 'BlockNode';
|
5
5
|
var dependencies = ['ResultSet', 'Node'];
|
6
|
-
export var createBlockNode = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createBlockNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
ResultSet,
|
9
9
|
Node
|
@@ -3,7 +3,7 @@ import { factory } from '../../utils/factory.js';
|
|
3
3
|
import { getPrecedence } from '../operators.js';
|
4
4
|
var name = 'ConditionalNode';
|
5
5
|
var dependencies = ['Node'];
|
6
|
-
export var createConditionalNode = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createConditionalNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
Node
|
9
9
|
} = _ref;
|
@@ -4,7 +4,7 @@ import { escapeLatex } from '../../utils/latex.js';
|
|
4
4
|
import { factory } from '../../utils/factory.js';
|
5
5
|
var name = 'ConstantNode';
|
6
6
|
var dependencies = ['Node'];
|
7
|
-
export var createConstantNode = /* #__PURE__ */factory(name, dependencies,
|
7
|
+
export var createConstantNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
8
|
var {
|
9
9
|
Node
|
10
10
|
} = _ref;
|
@@ -4,11 +4,10 @@ import { escape } from '../../utils/string.js';
|
|
4
4
|
import { forEach, join } from '../../utils/array.js';
|
5
5
|
import { toSymbol } from '../../utils/latex.js';
|
6
6
|
import { getPrecedence } from '../operators.js';
|
7
|
-
import { setSafeProperty } from '../../utils/customs.js';
|
8
7
|
import { factory } from '../../utils/factory.js';
|
9
8
|
var name = 'FunctionAssignmentNode';
|
10
9
|
var dependencies = ['typed', 'Node'];
|
11
|
-
export var createFunctionAssignmentNode = /* #__PURE__ */factory(name, dependencies,
|
10
|
+
export var createFunctionAssignmentNode = /* #__PURE__ */factory(name, dependencies, _ref => {
|
12
11
|
var {
|
13
12
|
typed,
|
14
13
|
Node
|
@@ -35,7 +34,7 @@ export var createFunctionAssignmentNode = /* #__PURE__ */factory(name, dependenc
|
|
35
34
|
if (typeof name !== 'string') throw new TypeError('String expected for parameter "name"');
|
36
35
|
if (!Array.isArray(params)) throw new TypeError('Array containing strings or objects expected for parameter "params"');
|
37
36
|
if (!isNode(expr)) throw new TypeError('Node expected for parameter "expr"');
|
38
|
-
if (name
|
37
|
+
if (keywords.has(name)) throw new Error('Illegal function name, "' + name + '" is a reserved keyword');
|
39
38
|
this.name = name;
|
40
39
|
this.params = params.map(function (param) {
|
41
40
|
return param && param.name || param;
|
@@ -90,7 +89,7 @@ export var createFunctionAssignmentNode = /* #__PURE__ */factory(name, dependenc
|
|
90
89
|
|
91
90
|
var fn = typed(name, signatures);
|
92
91
|
fn.syntax = syntax;
|
93
|
-
|
92
|
+
scope.set(name, fn);
|
94
93
|
return fn;
|
95
94
|
};
|
96
95
|
};
|