mathjs 9.3.2 → 9.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HISTORY.md +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,28 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.createFunctionNode = void 0;
|
|
7
9
|
|
|
10
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
+
|
|
12
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
13
|
+
|
|
8
14
|
var _is = require("../../utils/is.js");
|
|
9
15
|
|
|
10
16
|
var _string = require("../../utils/string.js");
|
|
11
17
|
|
|
12
18
|
var _object = require("../../utils/object.js");
|
|
13
19
|
|
|
14
|
-
var _array = require("../../utils/array.js");
|
|
15
|
-
|
|
16
20
|
var _customs = require("../../utils/customs.js");
|
|
17
21
|
|
|
22
|
+
var _scope = require("../../utils/scope.js");
|
|
23
|
+
|
|
18
24
|
var _factory = require("../../utils/factory.js");
|
|
19
25
|
|
|
20
26
|
var _latex = require("../../utils/latex.js");
|
|
21
27
|
|
|
22
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
23
|
-
|
|
24
|
-
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); }
|
|
25
|
-
|
|
26
28
|
var name = 'FunctionNode';
|
|
27
29
|
var dependencies = ['math', 'Node', 'SymbolNode'];
|
|
28
30
|
var createFunctionNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
|
|
@@ -90,50 +92,68 @@ var createFunctionNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies
|
|
|
90
92
|
} // compile arguments
|
|
91
93
|
|
|
92
94
|
|
|
93
|
-
var evalArgs =
|
|
95
|
+
var evalArgs = this.args.map(function (arg) {
|
|
94
96
|
return arg._compile(math, argNames);
|
|
95
97
|
});
|
|
96
98
|
|
|
97
99
|
if ((0, _is.isSymbolNode)(this.fn)) {
|
|
98
|
-
var resolveFn = function resolveFn(scope) {
|
|
99
|
-
return _name in scope ? (0, _customs.getSafeProperty)(scope, _name) : _name in math ? (0, _customs.getSafeProperty)(math, _name) : FunctionNode.onUndefinedFunction(_name);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
100
|
// we can statically determine whether the function has an rawArgs property
|
|
103
101
|
var _name = this.fn.name;
|
|
104
102
|
var fn = _name in math ? (0, _customs.getSafeProperty)(math, _name) : undefined;
|
|
105
103
|
var isRaw = typeof fn === 'function' && fn.rawArgs === true;
|
|
106
104
|
|
|
105
|
+
var resolveFn = function resolveFn(scope) {
|
|
106
|
+
if (scope.has(_name)) {
|
|
107
|
+
return scope.get(_name);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (_name in math) {
|
|
111
|
+
return (0, _customs.getSafeProperty)(math, _name);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return FunctionNode.onUndefinedFunction(_name);
|
|
115
|
+
};
|
|
116
|
+
|
|
107
117
|
if (isRaw) {
|
|
108
118
|
// pass unevaluated parameters (nodes) to the function
|
|
109
119
|
// "raw" evaluation
|
|
110
120
|
var rawArgs = this.args;
|
|
111
121
|
return function evalFunctionNode(scope, args, context) {
|
|
112
122
|
var fn = resolveFn(scope);
|
|
113
|
-
return fn(rawArgs, math,
|
|
123
|
+
return fn(rawArgs, math, (0, _scope.createSubScope)(scope, args), scope);
|
|
114
124
|
};
|
|
115
125
|
} else {
|
|
116
126
|
// "regular" evaluation
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
127
|
+
switch (evalArgs.length) {
|
|
128
|
+
case 0:
|
|
129
|
+
return function evalFunctionNode(scope, args, context) {
|
|
130
|
+
var fn = resolveFn(scope);
|
|
131
|
+
return fn();
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
case 1:
|
|
135
|
+
return function evalFunctionNode(scope, args, context) {
|
|
136
|
+
var fn = resolveFn(scope);
|
|
137
|
+
var evalArg0 = evalArgs[0];
|
|
138
|
+
return fn(evalArg0(scope, args, context));
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
case 2:
|
|
142
|
+
return function evalFunctionNode(scope, args, context) {
|
|
143
|
+
var fn = resolveFn(scope);
|
|
144
|
+
var evalArg0 = evalArgs[0];
|
|
145
|
+
var evalArg1 = evalArgs[1];
|
|
146
|
+
return fn(evalArg0(scope, args, context), evalArg1(scope, args, context));
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
default:
|
|
150
|
+
return function evalFunctionNode(scope, args, context) {
|
|
151
|
+
var fn = resolveFn(scope);
|
|
152
|
+
var values = evalArgs.map(function (evalArg) {
|
|
153
|
+
return evalArg(scope, args, context);
|
|
154
|
+
});
|
|
155
|
+
return fn.apply(void 0, (0, _toConsumableArray2["default"])(values));
|
|
156
|
+
};
|
|
137
157
|
}
|
|
138
158
|
}
|
|
139
159
|
} else if ((0, _is.isAccessorNode)(this.fn) && (0, _is.isIndexNode)(this.fn.index) && this.fn.index.isObjectProperty()) {
|
|
@@ -146,11 +166,16 @@ var createFunctionNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies
|
|
|
146
166
|
var object = evalObject(scope, args, context);
|
|
147
167
|
(0, _customs.validateSafeMethod)(object, prop);
|
|
148
168
|
var isRaw = object[prop] && object[prop].rawArgs;
|
|
149
|
-
|
|
150
|
-
|
|
169
|
+
|
|
170
|
+
if (isRaw) {
|
|
171
|
+
return object[prop](_rawArgs, math, (0, _scope.createSubScope)(scope, args), scope); // "raw" evaluation
|
|
172
|
+
} else {
|
|
151
173
|
// "regular" evaluation
|
|
152
|
-
|
|
153
|
-
|
|
174
|
+
var values = evalArgs.map(function (evalArg) {
|
|
175
|
+
return evalArg(scope, args, context);
|
|
176
|
+
});
|
|
177
|
+
return object[prop].apply(object, values);
|
|
178
|
+
}
|
|
154
179
|
};
|
|
155
180
|
} else {
|
|
156
181
|
// node.fn.isAccessorNode && !node.fn.index.isObjectProperty()
|
|
@@ -161,11 +186,16 @@ var createFunctionNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies
|
|
|
161
186
|
return function evalFunctionNode(scope, args, context) {
|
|
162
187
|
var fn = evalFn(scope, args, context);
|
|
163
188
|
var isRaw = fn && fn.rawArgs;
|
|
164
|
-
|
|
165
|
-
|
|
189
|
+
|
|
190
|
+
if (isRaw) {
|
|
191
|
+
return fn(_rawArgs2, math, (0, _scope.createSubScope)(scope, args), scope); // "raw" evaluation
|
|
192
|
+
} else {
|
|
166
193
|
// "regular" evaluation
|
|
167
|
-
|
|
168
|
-
|
|
194
|
+
var values = evalArgs.map(function (evalArg) {
|
|
195
|
+
return evalArg(scope, args, context);
|
|
196
|
+
});
|
|
197
|
+
return fn.apply(fn, values);
|
|
198
|
+
}
|
|
169
199
|
};
|
|
170
200
|
}
|
|
171
201
|
};
|
|
@@ -240,7 +270,7 @@ var createFunctionNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies
|
|
|
240
270
|
var customString;
|
|
241
271
|
var name = this.fn.toString(options);
|
|
242
272
|
|
|
243
|
-
if (options &&
|
|
273
|
+
if (options && (0, _typeof2["default"])(options.handler) === 'object' && (0, _object.hasOwnProperty)(options.handler, name)) {
|
|
244
274
|
// callback is a map of callback functions
|
|
245
275
|
customString = options.handler[name](this, options);
|
|
246
276
|
}
|
|
@@ -346,7 +376,7 @@ var createFunctionNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies
|
|
|
346
376
|
|
|
347
377
|
if (match[2] === undefined) {
|
|
348
378
|
// no square brackets
|
|
349
|
-
switch (
|
|
379
|
+
switch ((0, _typeof2["default"])(property)) {
|
|
350
380
|
case 'string':
|
|
351
381
|
latex += property;
|
|
352
382
|
break;
|
|
@@ -406,7 +436,7 @@ var createFunctionNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies
|
|
|
406
436
|
FunctionNode.prototype.toTex = function (options) {
|
|
407
437
|
var customTex;
|
|
408
438
|
|
|
409
|
-
if (options &&
|
|
439
|
+
if (options && (0, _typeof2["default"])(options.handler) === 'object' && (0, _object.hasOwnProperty)(options.handler, this.name)) {
|
|
410
440
|
// callback is a map of callback functions
|
|
411
441
|
customTex = options.handler[this.name](this, options);
|
|
412
442
|
}
|
|
@@ -437,14 +467,14 @@ var createFunctionNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies
|
|
|
437
467
|
} // toTex property on the function itself
|
|
438
468
|
|
|
439
469
|
|
|
440
|
-
if (math[this.name] && (typeof math[this.name].toTex === 'function' ||
|
|
470
|
+
if (math[this.name] && (typeof math[this.name].toTex === 'function' || (0, _typeof2["default"])(math[this.name].toTex) === 'object' || typeof math[this.name].toTex === 'string')) {
|
|
441
471
|
// .toTex is a callback function
|
|
442
472
|
latexConverter = math[this.name].toTex;
|
|
443
473
|
}
|
|
444
474
|
|
|
445
475
|
var customToTex;
|
|
446
476
|
|
|
447
|
-
switch (
|
|
477
|
+
switch ((0, _typeof2["default"])(latexConverter)) {
|
|
448
478
|
case 'function':
|
|
449
479
|
// a callback function
|
|
450
480
|
customToTex = latexConverter(this, options);
|
|
@@ -457,7 +487,7 @@ var createFunctionNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies
|
|
|
457
487
|
|
|
458
488
|
case 'object':
|
|
459
489
|
// an object with different "converters" for different numbers of arguments
|
|
460
|
-
switch (
|
|
490
|
+
switch ((0, _typeof2["default"])(latexConverter[args.length])) {
|
|
461
491
|
case 'function':
|
|
462
492
|
customToTex = latexConverter[args.length](this, options);
|
|
463
493
|
break;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.createIndexNode = void 0;
|
|
7
9
|
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
8
12
|
var _is = require("../../utils/is.js");
|
|
9
13
|
|
|
10
14
|
var _array = require("../../utils/array.js");
|
|
@@ -15,18 +19,6 @@ var _factory = require("../../utils/factory.js");
|
|
|
15
19
|
|
|
16
20
|
var _customs = require("../../utils/customs.js");
|
|
17
21
|
|
|
18
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
19
|
-
|
|
20
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
|
-
|
|
22
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
23
|
-
|
|
24
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
|
|
25
|
-
|
|
26
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
27
|
-
|
|
28
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
29
|
-
|
|
30
22
|
var name = 'IndexNode';
|
|
31
23
|
var dependencies = ['Range', 'Node', 'size'];
|
|
32
24
|
var createIndexNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
|
|
@@ -151,7 +143,7 @@ var createIndexNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies, f
|
|
|
151
143
|
var dimensions = (0, _array.map)(evalDimensions, function (evalDimension) {
|
|
152
144
|
return evalDimension(scope, args, context);
|
|
153
145
|
});
|
|
154
|
-
return index.apply(void 0,
|
|
146
|
+
return index.apply(void 0, (0, _toConsumableArray2["default"])(dimensions));
|
|
155
147
|
};
|
|
156
148
|
};
|
|
157
149
|
/**
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.createNode = void 0;
|
|
7
9
|
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
+
|
|
8
14
|
var _is = require("../../utils/is.js");
|
|
9
15
|
|
|
10
16
|
var _keywords = require("../keywords.js");
|
|
@@ -13,7 +19,7 @@ var _object = require("../../utils/object.js");
|
|
|
13
19
|
|
|
14
20
|
var _factory = require("../../utils/factory.js");
|
|
15
21
|
|
|
16
|
-
|
|
22
|
+
var _map = require("../../utils/map.js");
|
|
17
23
|
|
|
18
24
|
var name = 'Node';
|
|
19
25
|
var dependencies = ['mathWithTransform'];
|
|
@@ -58,7 +64,7 @@ var createNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functi
|
|
|
58
64
|
var context = null;
|
|
59
65
|
|
|
60
66
|
function evaluate(scope) {
|
|
61
|
-
var s = scope
|
|
67
|
+
var s = (0, _map.createMap)(scope);
|
|
62
68
|
|
|
63
69
|
_validateScope(s);
|
|
64
70
|
|
|
@@ -361,8 +367,8 @@ var createNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functi
|
|
|
361
367
|
|
|
362
368
|
|
|
363
369
|
Node.prototype._getCustomString = function (options) {
|
|
364
|
-
if (options &&
|
|
365
|
-
switch (
|
|
370
|
+
if (options && (0, _typeof2["default"])(options) === 'object') {
|
|
371
|
+
switch ((0, _typeof2["default"])(options.handler)) {
|
|
366
372
|
case 'object':
|
|
367
373
|
case 'undefined':
|
|
368
374
|
return;
|
|
@@ -401,11 +407,11 @@ var createNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies, functi
|
|
|
401
407
|
|
|
402
408
|
|
|
403
409
|
function _validateScope(scope) {
|
|
404
|
-
for (var
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
410
|
+
for (var _i = 0, _arr = (0, _toConsumableArray2["default"])(_keywords.keywords); _i < _arr.length; _i++) {
|
|
411
|
+
var symbol = _arr[_i];
|
|
412
|
+
|
|
413
|
+
if (scope.has(symbol)) {
|
|
414
|
+
throw new Error('Scope contains an illegal symbol, "' + symbol + '" is a reserved keyword');
|
|
409
415
|
}
|
|
410
416
|
}
|
|
411
417
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.createObjectNode = void 0;
|
|
7
9
|
|
|
10
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
+
|
|
8
12
|
var _is = require("../../utils/is.js");
|
|
9
13
|
|
|
10
14
|
var _string = require("../../utils/string.js");
|
|
@@ -15,8 +19,6 @@ var _object = require("../../utils/object.js");
|
|
|
15
19
|
|
|
16
20
|
var _factory = require("../../utils/factory.js");
|
|
17
21
|
|
|
18
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
19
|
-
|
|
20
22
|
var name = 'ObjectNode';
|
|
21
23
|
var dependencies = ['Node'];
|
|
22
24
|
var createObjectNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
|
|
@@ -36,7 +38,7 @@ var createObjectNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies,
|
|
|
36
38
|
this.properties = properties || {}; // validate input
|
|
37
39
|
|
|
38
40
|
if (properties) {
|
|
39
|
-
if (!(
|
|
41
|
+
if (!((0, _typeof2["default"])(properties) === 'object') || !Object.keys(properties).every(function (key) {
|
|
40
42
|
return (0, _is.isNode)(properties[key]);
|
|
41
43
|
})) {
|
|
42
44
|
throw new TypeError('Object containing Nodes expected');
|
|
@@ -75,12 +75,12 @@ var createSymbolNode = /* #__PURE__ */(0, _factory.factory)(name, dependencies,
|
|
|
75
75
|
};
|
|
76
76
|
} else if (name in math) {
|
|
77
77
|
return function (scope, args, context) {
|
|
78
|
-
return name
|
|
78
|
+
return scope.has(name) ? scope.get(name) : (0, _customs.getSafeProperty)(math, name);
|
|
79
79
|
};
|
|
80
80
|
} else {
|
|
81
81
|
var isUnit = isValuelessUnit(name);
|
|
82
82
|
return function (scope, args, context) {
|
|
83
|
-
return name
|
|
83
|
+
return scope.has(name) ? scope.get(name) : isUnit ? new Unit(null, name) : SymbolNode.onUndefinedSymbol(name);
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
};
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.accessFactory = accessFactory;
|
|
7
9
|
|
|
10
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
+
|
|
8
12
|
var _errorTransform = require("../../transform/utils/errorTransform.js");
|
|
9
13
|
|
|
10
14
|
var _customs = require("../../../utils/customs.js");
|
|
11
15
|
|
|
12
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
13
|
-
|
|
14
16
|
function accessFactory(_ref) {
|
|
15
17
|
var subset = _ref.subset;
|
|
16
18
|
|
|
@@ -35,7 +37,7 @@ function accessFactory(_ref) {
|
|
|
35
37
|
} else if (typeof object === 'string') {
|
|
36
38
|
// TODO: move getStringSubset into a separate util file, use that
|
|
37
39
|
return subset(object, index);
|
|
38
|
-
} else if (
|
|
40
|
+
} else if ((0, _typeof2["default"])(object) === 'object') {
|
|
39
41
|
if (!index.isObjectProperty()) {
|
|
40
42
|
throw new TypeError('Cannot apply a numeric index as object property');
|
|
41
43
|
}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.assignFactory = assignFactory;
|
|
7
9
|
|
|
10
|
+
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
11
|
+
|
|
8
12
|
var _errorTransform = require("../../transform/utils/errorTransform.js");
|
|
9
13
|
|
|
10
14
|
var _customs = require("../../../utils/customs.js");
|
|
11
15
|
|
|
12
|
-
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
13
|
-
|
|
14
16
|
function assignFactory(_ref) {
|
|
15
17
|
var subset = _ref.subset,
|
|
16
18
|
matrix = _ref.matrix;
|
|
@@ -40,7 +42,7 @@ function assignFactory(_ref) {
|
|
|
40
42
|
} else if (typeof object === 'string') {
|
|
41
43
|
// TODO: move setStringSubset into a separate util file, use that
|
|
42
44
|
return subset(object, index, value);
|
|
43
|
-
} else if (
|
|
45
|
+
} else if ((0, _typeof2["default"])(object) === 'object') {
|
|
44
46
|
if (!index.isObjectProperty()) {
|
|
45
47
|
throw TypeError('Cannot apply a numeric index as object property');
|
|
46
48
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.createParse = void 0;
|
|
7
9
|
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
8
12
|
var _factory = require("../utils/factory.js");
|
|
9
13
|
|
|
10
14
|
var _is = require("../utils/is.js");
|
|
@@ -13,8 +17,6 @@ var _collection = require("../utils/collection.js");
|
|
|
13
17
|
|
|
14
18
|
var _object = require("../utils/object.js");
|
|
15
19
|
|
|
16
|
-
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); }
|
|
17
|
-
|
|
18
20
|
var name = 'parse';
|
|
19
21
|
var dependencies = ['typed', 'numeric', 'config', 'AccessorNode', 'ArrayNode', 'AssignmentNode', 'BlockNode', 'ConditionalNode', 'ConstantNode', 'FunctionAssignmentNode', 'FunctionNode', 'IndexNode', 'ObjectNode', 'OperatorNode', 'ParenthesisNode', 'RangeNode', 'RelationalNode', 'SymbolNode'];
|
|
20
22
|
var createParse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {
|
|
@@ -581,12 +583,10 @@ var createParse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
|
581
583
|
|
|
582
584
|
function parseStart(expression, extraNodes) {
|
|
583
585
|
var state = initialState();
|
|
584
|
-
|
|
585
|
-
_extends(state, {
|
|
586
|
+
(0, _extends2["default"])(state, {
|
|
586
587
|
expression: expression,
|
|
587
588
|
extraNodes: extraNodes
|
|
588
589
|
});
|
|
589
|
-
|
|
590
590
|
getToken(state);
|
|
591
591
|
var node = parseBlock(state); // check for garbage at the end of the expression
|
|
592
592
|
// an expression ends with a empty character '' and tokenType DELIMITER
|
|
@@ -1106,34 +1106,30 @@ var createParse = /* #__PURE__ */(0, _factory.factory)(name, dependencies, funct
|
|
|
1106
1106
|
// Match the "number /" part of the pattern "number / number symbol"
|
|
1107
1107
|
if (state.token === '/' && (0, _is.isConstantNode)(last)) {
|
|
1108
1108
|
// Look ahead to see if the next token is a number
|
|
1109
|
-
tokenStates.push(
|
|
1109
|
+
tokenStates.push((0, _extends2["default"])({}, state));
|
|
1110
1110
|
getTokenSkipNewline(state); // Match the "number / number" part of the pattern
|
|
1111
1111
|
|
|
1112
1112
|
if (state.tokenType === TOKENTYPE.NUMBER) {
|
|
1113
1113
|
// Look ahead again
|
|
1114
|
-
tokenStates.push(
|
|
1114
|
+
tokenStates.push((0, _extends2["default"])({}, state));
|
|
1115
1115
|
getTokenSkipNewline(state); // Match the "symbol" part of the pattern, or a left parenthesis
|
|
1116
1116
|
|
|
1117
1117
|
if (state.tokenType === TOKENTYPE.SYMBOL || state.token === '(') {
|
|
1118
1118
|
// We've matched the pattern "number / number symbol".
|
|
1119
1119
|
// Rewind once and build the "number / number" node; the symbol will be consumed later
|
|
1120
|
-
|
|
1121
|
-
|
|
1120
|
+
(0, _extends2["default"])(state, tokenStates.pop());
|
|
1122
1121
|
tokenStates.pop();
|
|
1123
1122
|
last = parseUnary(state);
|
|
1124
1123
|
node = new OperatorNode('/', 'divide', [node, last]);
|
|
1125
1124
|
} else {
|
|
1126
1125
|
// Not a match, so rewind
|
|
1127
1126
|
tokenStates.pop();
|
|
1128
|
-
|
|
1129
|
-
_extends(state, tokenStates.pop());
|
|
1130
|
-
|
|
1127
|
+
(0, _extends2["default"])(state, tokenStates.pop());
|
|
1131
1128
|
break;
|
|
1132
1129
|
}
|
|
1133
1130
|
} else {
|
|
1134
1131
|
// Not a match, so rewind
|
|
1135
|
-
|
|
1136
|
-
|
|
1132
|
+
(0, _extends2["default"])(state, tokenStates.pop());
|
|
1137
1133
|
break;
|
|
1138
1134
|
}
|
|
1139
1135
|
} else {
|
|
@@ -7,6 +7,8 @@ exports.compileInlineExpression = compileInlineExpression;
|
|
|
7
7
|
|
|
8
8
|
var _is = require("../../../utils/is.js");
|
|
9
9
|
|
|
10
|
+
var _scope = require("../../../utils/scope.js");
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* Compile an inline expression like "x > 0"
|
|
12
14
|
* @param {Node} expression
|
|
@@ -18,7 +20,7 @@ var _is = require("../../../utils/is.js");
|
|
|
18
20
|
function compileInlineExpression(expression, math, scope) {
|
|
19
21
|
// find an undefined symbol
|
|
20
22
|
var symbol = expression.filter(function (node) {
|
|
21
|
-
return (0, _is.isSymbolNode)(node) && !(node.name in math) && !(node.name
|
|
23
|
+
return (0, _is.isSymbolNode)(node) && !(node.name in math) && !scope.has(node.name);
|
|
22
24
|
})[0];
|
|
23
25
|
|
|
24
26
|
if (!symbol) {
|
|
@@ -28,10 +30,10 @@ function compileInlineExpression(expression, math, scope) {
|
|
|
28
30
|
|
|
29
31
|
var name = symbol.name; // variable name
|
|
30
32
|
|
|
31
|
-
var subScope =
|
|
33
|
+
var subScope = (0, _scope.createSubScope)(scope);
|
|
32
34
|
var eq = expression.compile();
|
|
33
35
|
return function inlineExpression(x) {
|
|
34
|
-
subScope
|
|
36
|
+
subScope.set(name, x);
|
|
35
37
|
return eq.evaluate(subScope);
|
|
36
38
|
};
|
|
37
39
|
}
|
package/lib/cjs/factoriesAny.js
CHANGED
|
@@ -159,6 +159,24 @@ Object.defineProperty(exports, "createMatrix", {
|
|
|
159
159
|
return _matrix.createMatrix;
|
|
160
160
|
}
|
|
161
161
|
});
|
|
162
|
+
Object.defineProperty(exports, "createMatrixFromFunction", {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function get() {
|
|
165
|
+
return _matrixFromFunction.createMatrixFromFunction;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(exports, "createMatrixFromRows", {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function get() {
|
|
171
|
+
return _matrixFromRows.createMatrixFromRows;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
Object.defineProperty(exports, "createMatrixFromColumns", {
|
|
175
|
+
enumerable: true,
|
|
176
|
+
get: function get() {
|
|
177
|
+
return _matrixFromColumns.createMatrixFromColumns;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
162
180
|
Object.defineProperty(exports, "createSplitUnit", {
|
|
163
181
|
enumerable: true,
|
|
164
182
|
get: function get() {
|
|
@@ -2036,6 +2054,12 @@ var _fraction = require("./type/fraction/function/fraction.js");
|
|
|
2036
2054
|
|
|
2037
2055
|
var _matrix = require("./type/matrix/function/matrix.js");
|
|
2038
2056
|
|
|
2057
|
+
var _matrixFromFunction = require("./function/matrix/matrixFromFunction.js");
|
|
2058
|
+
|
|
2059
|
+
var _matrixFromRows = require("./function/matrix/matrixFromRows.js");
|
|
2060
|
+
|
|
2061
|
+
var _matrixFromColumns = require("./function/matrix/matrixFromColumns.js");
|
|
2062
|
+
|
|
2039
2063
|
var _splitUnit = require("./type/unit/function/splitUnit.js");
|
|
2040
2064
|
|
|
2041
2065
|
var _unaryMinus = require("./function/arithmetic/unaryMinus.js");
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.createQr = void 0;
|
|
7
9
|
|
|
8
|
-
var
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
var _factory = require("../../../utils/factory.js");
|
|
11
13
|
|
|
12
14
|
var name = 'qr';
|
|
13
15
|
var dependencies = ['typed', 'matrix', 'zeros', 'identity', 'isZero', 'equal', 'sign', 'sqrt', 'conj', 'unaryMinus', 'addScalar', 'divideScalar', 'multiplyScalar', 'subtract', 'complex'];
|
|
@@ -71,7 +73,7 @@ var createQr = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function
|
|
|
71
73
|
* @return {{Q: Array | Matrix, R: Array | Matrix}} Q: the orthogonal
|
|
72
74
|
* matrix and R: the upper triangular matrix
|
|
73
75
|
*/
|
|
74
|
-
return
|
|
76
|
+
return (0, _extends2["default"])(typed(name, {
|
|
75
77
|
DenseMatrix: function DenseMatrix(m) {
|
|
76
78
|
return _denseQR(m);
|
|
77
79
|
},
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createResolve = void 0;
|
|
7
7
|
|
|
8
|
+
var _map = require("../../../utils/map.js");
|
|
9
|
+
|
|
8
10
|
var _is = require("../../../utils/is.js");
|
|
9
11
|
|
|
10
12
|
var _factory = require("../../../utils/factory.js");
|
|
@@ -39,8 +41,12 @@ var createResolve = /* #__PURE__ */(0, _factory.factory)(name, dependencies, fun
|
|
|
39
41
|
return node;
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
if (!(0, _map.isMap)(scope)) {
|
|
45
|
+
scope = (0, _map.createMap)(scope);
|
|
46
|
+
}
|
|
47
|
+
|
|
42
48
|
if ((0, _is.isSymbolNode)(node)) {
|
|
43
|
-
var value = scope
|
|
49
|
+
var value = scope.get(node.name);
|
|
44
50
|
|
|
45
51
|
if ((0, _is.isNode)(value)) {
|
|
46
52
|
return resolve(value, scope);
|