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
@@ -2,7 +2,7 @@ import { factory } from '../../utils/factory.js';
|
|
2
2
|
import { deepMap } from '../../utils/collection.js';
|
3
3
|
var name = 'sin';
|
4
4
|
var dependencies = ['typed'];
|
5
|
-
export var createSin = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createSin = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed
|
8
8
|
} = _ref;
|
@@ -3,7 +3,7 @@ import { deepMap } from '../../utils/collection.js';
|
|
3
3
|
import { sinhNumber } from '../../plain/number/index.js';
|
4
4
|
var name = 'sinh';
|
5
5
|
var dependencies = ['typed'];
|
6
|
-
export var createSinh = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createSinh = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
typed
|
9
9
|
} = _ref;
|
@@ -2,7 +2,7 @@ import { factory } from '../../utils/factory.js';
|
|
2
2
|
import { deepMap } from '../../utils/collection.js';
|
3
3
|
var name = 'tan';
|
4
4
|
var dependencies = ['typed'];
|
5
|
-
export var createTan = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createTan = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed
|
8
8
|
} = _ref;
|
@@ -3,7 +3,7 @@ import { deepMap } from '../../utils/collection.js';
|
|
3
3
|
import { tanh as _tanh } from '../../utils/number.js';
|
4
4
|
var name = 'tanh';
|
5
5
|
var dependencies = ['typed'];
|
6
|
-
export var createTanh = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createTanh = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
typed
|
9
9
|
} = _ref;
|
@@ -3,7 +3,7 @@ import { createAlgorithm13 } from '../../type/matrix/utils/algorithm13.js';
|
|
3
3
|
import { createAlgorithm14 } from '../../type/matrix/utils/algorithm14.js';
|
4
4
|
var name = 'to';
|
5
5
|
var dependencies = ['typed', 'matrix'];
|
6
|
-
export var createTo = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createTo = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
typed,
|
9
9
|
matrix
|
@@ -2,7 +2,7 @@ import { clone as objectClone } from '../../utils/object.js';
|
|
2
2
|
import { factory } from '../../utils/factory.js';
|
3
3
|
var name = 'clone';
|
4
4
|
var dependencies = ['typed'];
|
5
|
-
export var createClone = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createClone = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed
|
8
8
|
} = _ref;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { factory } from '../../utils/factory.js';
|
2
2
|
var name = 'hasNumericValue';
|
3
3
|
var dependencies = ['typed', 'isNumeric'];
|
4
|
-
export var createHasNumericValue = /* #__PURE__ */factory(name, dependencies,
|
4
|
+
export var createHasNumericValue = /* #__PURE__ */factory(name, dependencies, _ref => {
|
5
5
|
var {
|
6
6
|
typed,
|
7
7
|
isNumeric
|
@@ -3,7 +3,7 @@ import { isInteger as isIntegerNumber } from '../../utils/number.js';
|
|
3
3
|
import { factory } from '../../utils/factory.js';
|
4
4
|
var name = 'isInteger';
|
5
5
|
var dependencies = ['typed'];
|
6
|
-
export var createIsInteger = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createIsInteger = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
typed
|
9
9
|
} = _ref;
|
@@ -3,7 +3,7 @@ import { factory } from '../../utils/factory.js';
|
|
3
3
|
import { isNaNNumber } from '../../plain/number/index.js';
|
4
4
|
var name = 'isNaN';
|
5
5
|
var dependencies = ['typed'];
|
6
|
-
export var createIsNaN = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createIsNaN = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
typed
|
9
9
|
} = _ref;
|
@@ -3,7 +3,7 @@ import { factory } from '../../utils/factory.js';
|
|
3
3
|
import { isNegativeNumber } from '../../plain/number/index.js';
|
4
4
|
var name = 'isNegative';
|
5
5
|
var dependencies = ['typed'];
|
6
|
-
export var createIsNegative = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createIsNegative = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
typed
|
9
9
|
} = _ref;
|
@@ -2,7 +2,7 @@ import { deepMap } from '../../utils/collection.js';
|
|
2
2
|
import { factory } from '../../utils/factory.js';
|
3
3
|
var name = 'isNumeric';
|
4
4
|
var dependencies = ['typed'];
|
5
|
-
export var createIsNumeric = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createIsNumeric = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed
|
8
8
|
} = _ref;
|
@@ -3,7 +3,7 @@ import { factory } from '../../utils/factory.js';
|
|
3
3
|
import { isPositiveNumber } from '../../plain/number/index.js';
|
4
4
|
var name = 'isPositive';
|
5
5
|
var dependencies = ['typed'];
|
6
|
-
export var createIsPositive = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createIsPositive = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
typed
|
9
9
|
} = _ref;
|
@@ -2,7 +2,7 @@ import { deepMap } from '../../utils/collection.js';
|
|
2
2
|
import { factory } from '../../utils/factory.js';
|
3
3
|
var name = 'isPrime';
|
4
4
|
var dependencies = ['typed'];
|
5
|
-
export var createIsPrime = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createIsPrime = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed
|
8
8
|
} = _ref;
|
@@ -3,7 +3,7 @@ import { factory } from '../../utils/factory.js';
|
|
3
3
|
import { isZeroNumber } from '../../plain/number/index.js';
|
4
4
|
var name = 'isZero';
|
5
5
|
var dependencies = ['typed'];
|
6
|
-
export var createIsZero = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createIsZero = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
typed
|
9
9
|
} = _ref;
|
@@ -3,7 +3,7 @@ import { factory } from '../../utils/factory.js';
|
|
3
3
|
import { noBignumber, noFraction } from '../../utils/noop.js';
|
4
4
|
var name = 'numeric';
|
5
5
|
var dependencies = ['number', '?bignumber', '?fraction'];
|
6
|
-
export var createNumeric = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createNumeric = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
number: _number,
|
9
9
|
bignumber,
|
@@ -2,7 +2,7 @@ import { factory } from '../../utils/factory.js';
|
|
2
2
|
import { typeOf as _typeOf } from '../../utils/is.js';
|
3
3
|
var name = 'typeOf';
|
4
4
|
var dependencies = ['typed'];
|
5
|
-
export var createTypeOf = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createTypeOf = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed
|
8
8
|
} = _ref;
|
package/lib/esm/json/reviver.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { factory } from '../utils/factory.js';
|
2
2
|
var name = 'reviver';
|
3
3
|
var dependencies = ['classes'];
|
4
|
-
export var createReviver = /* #__PURE__ */factory(name, dependencies,
|
4
|
+
export var createReviver = /* #__PURE__ */factory(name, dependencies, _ref => {
|
5
5
|
var {
|
6
6
|
classes
|
7
7
|
} = _ref;
|
@@ -2,7 +2,7 @@ import Decimal from 'decimal.js';
|
|
2
2
|
import { factory } from '../../utils/factory.js';
|
3
3
|
var name = 'BigNumber';
|
4
4
|
var dependencies = ['?on', 'config'];
|
5
|
-
export var createBigNumberClass = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createBigNumberClass = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
on,
|
8
8
|
config
|
@@ -2,7 +2,7 @@ import { factory } from '../../../utils/factory.js';
|
|
2
2
|
import { deepMap } from '../../../utils/collection.js';
|
3
3
|
var name = 'bignumber';
|
4
4
|
var dependencies = ['typed', 'BigNumber'];
|
5
|
-
export var createBignumber = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createBignumber = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed,
|
8
8
|
BigNumber
|
package/lib/esm/type/boolean.js
CHANGED
@@ -2,7 +2,7 @@ import { factory } from '../utils/factory.js';
|
|
2
2
|
import { deepMap } from '../utils/collection.js';
|
3
3
|
var name = 'boolean';
|
4
4
|
var dependencies = ['typed'];
|
5
|
-
export var createBoolean = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createBoolean = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed
|
8
8
|
} = _ref;
|
@@ -4,7 +4,7 @@ import { hasOwnProperty, lazy } from '../../utils/object.js';
|
|
4
4
|
import { factory } from '../../utils/factory.js';
|
5
5
|
var name = 'Chain';
|
6
6
|
var dependencies = ['?on', 'math'];
|
7
|
-
export var createChainClass = /* #__PURE__ */factory(name, dependencies,
|
7
|
+
export var createChainClass = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
8
|
var {
|
9
9
|
on,
|
10
10
|
math
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { factory } from '../../../utils/factory.js';
|
2
2
|
var name = 'chain';
|
3
3
|
var dependencies = ['typed', 'Chain'];
|
4
|
-
export var createChain = /* #__PURE__ */factory(name, dependencies,
|
4
|
+
export var createChain = /* #__PURE__ */factory(name, dependencies, _ref => {
|
5
5
|
var {
|
6
6
|
typed,
|
7
7
|
Chain
|
@@ -2,7 +2,7 @@ import { factory } from '../../../utils/factory.js';
|
|
2
2
|
import { deepMap } from '../../../utils/collection.js';
|
3
3
|
var name = 'complex';
|
4
4
|
var dependencies = ['typed', 'Complex'];
|
5
|
-
export var createComplex = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createComplex = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed,
|
8
8
|
Complex
|
@@ -2,7 +2,7 @@ import { factory } from '../../../utils/factory.js';
|
|
2
2
|
import { deepMap } from '../../../utils/collection.js';
|
3
3
|
var name = 'fraction';
|
4
4
|
var dependencies = ['typed', 'Fraction'];
|
5
|
-
export var createFraction = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createFraction = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed,
|
8
8
|
Fraction
|
@@ -7,7 +7,7 @@ import { DimensionError } from '../../error/DimensionError.js';
|
|
7
7
|
import { factory } from '../../utils/factory.js';
|
8
8
|
var name = 'DenseMatrix';
|
9
9
|
var dependencies = ['Matrix'];
|
10
|
-
export var createDenseMatrixClass = /* #__PURE__ */factory(name, dependencies,
|
10
|
+
export var createDenseMatrixClass = /* #__PURE__ */factory(name, dependencies, _ref => {
|
11
11
|
var {
|
12
12
|
Matrix
|
13
13
|
} = _ref;
|
@@ -15,6 +15,7 @@ export var createDenseMatrixClass = /* #__PURE__ */factory(name, dependencies, (
|
|
15
15
|
/**
|
16
16
|
* Dense Matrix implementation. A regular, dense matrix, supporting multi-dimensional matrices. This is the default matrix type.
|
17
17
|
* @class DenseMatrix
|
18
|
+
* @enum {{ value, index: number[] }}
|
18
19
|
*/
|
19
20
|
function DenseMatrix(data, datatype) {
|
20
21
|
if (!(this instanceof DenseMatrix)) {
|
@@ -617,6 +618,79 @@ export var createDenseMatrixClass = /* #__PURE__ */factory(name, dependencies, (
|
|
617
618
|
|
618
619
|
recurse(this._data, []);
|
619
620
|
};
|
621
|
+
/**
|
622
|
+
* Iterate over the matrix elements
|
623
|
+
* @return {Iterable<{ value, index: number[] }>}
|
624
|
+
*/
|
625
|
+
|
626
|
+
|
627
|
+
DenseMatrix.prototype[Symbol.iterator] = function* () {
|
628
|
+
var recurse = function* recurse(value, index) {
|
629
|
+
if (isArray(value)) {
|
630
|
+
for (var i = 0; i < value.length; i++) {
|
631
|
+
yield* recurse(value[i], index.concat(i));
|
632
|
+
}
|
633
|
+
} else {
|
634
|
+
yield {
|
635
|
+
value,
|
636
|
+
index
|
637
|
+
};
|
638
|
+
}
|
639
|
+
};
|
640
|
+
|
641
|
+
yield* recurse(this._data, []);
|
642
|
+
};
|
643
|
+
/**
|
644
|
+
* Returns an array containing the rows of a 2D matrix
|
645
|
+
* @returns {Array<Matrix>}
|
646
|
+
*/
|
647
|
+
|
648
|
+
|
649
|
+
DenseMatrix.prototype.rows = function () {
|
650
|
+
var result = [];
|
651
|
+
var s = this.size();
|
652
|
+
|
653
|
+
if (s.length !== 2) {
|
654
|
+
throw new TypeError('Rows can only be returned for a 2D matrix.');
|
655
|
+
}
|
656
|
+
|
657
|
+
var data = this._data;
|
658
|
+
|
659
|
+
for (var row of data) {
|
660
|
+
result.push(new DenseMatrix([row], this._datatype));
|
661
|
+
}
|
662
|
+
|
663
|
+
return result;
|
664
|
+
};
|
665
|
+
/**
|
666
|
+
* Returns an array containing the columns of a 2D matrix
|
667
|
+
* @returns {Array<Matrix>}
|
668
|
+
*/
|
669
|
+
|
670
|
+
|
671
|
+
DenseMatrix.prototype.columns = function () {
|
672
|
+
var _this = this;
|
673
|
+
|
674
|
+
var result = [];
|
675
|
+
var s = this.size();
|
676
|
+
|
677
|
+
if (s.length !== 2) {
|
678
|
+
throw new TypeError('Rows can only be returned for a 2D matrix.');
|
679
|
+
}
|
680
|
+
|
681
|
+
var data = this._data;
|
682
|
+
|
683
|
+
var _loop = function _loop(i) {
|
684
|
+
var col = data.map(row => [row[i]]);
|
685
|
+
result.push(new DenseMatrix(col, _this._datatype));
|
686
|
+
};
|
687
|
+
|
688
|
+
for (var i = 0; i < s[1]; i++) {
|
689
|
+
_loop(i);
|
690
|
+
}
|
691
|
+
|
692
|
+
return result;
|
693
|
+
};
|
620
694
|
/**
|
621
695
|
* Create an Array with a copy of the data of the DenseMatrix
|
622
696
|
* @memberof DenseMatrix
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { factory } from '../../utils/factory.js';
|
2
2
|
var name = 'FibonacciHeap';
|
3
3
|
var dependencies = ['smaller', 'larger'];
|
4
|
-
export var createFibonacciHeapClass = /* #__PURE__ */factory(name, dependencies,
|
4
|
+
export var createFibonacciHeapClass = /* #__PURE__ */factory(name, dependencies, _ref => {
|
5
5
|
var {
|
6
6
|
smaller,
|
7
7
|
larger
|
@@ -3,7 +3,7 @@ import { clone } from '../../utils/object.js';
|
|
3
3
|
import { factory } from '../../utils/factory.js';
|
4
4
|
var name = 'ImmutableDenseMatrix';
|
5
5
|
var dependencies = ['smaller', 'DenseMatrix'];
|
6
|
-
export var createImmutableDenseMatrixClass = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createImmutableDenseMatrixClass = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
smaller,
|
9
9
|
DenseMatrix
|
@@ -199,6 +199,16 @@ export var createMatrixClass = /* #__PURE__ */factory(name, dependencies, () =>
|
|
199
199
|
// must be implemented by each of the Matrix implementations
|
200
200
|
throw new Error('Cannot invoke forEach on a Matrix interface');
|
201
201
|
};
|
202
|
+
/**
|
203
|
+
* Iterate over the matrix elements
|
204
|
+
* @return {Iterable<{ value, index: number[] }>}
|
205
|
+
*/
|
206
|
+
|
207
|
+
|
208
|
+
Matrix.prototype[Symbol.iterator] = function () {
|
209
|
+
// must be implemented by each of the Matrix implementations
|
210
|
+
throw new Error('Cannot iterate a Matrix interface');
|
211
|
+
};
|
202
212
|
/**
|
203
213
|
* Create an Array with a copy of the data of the Matrix
|
204
214
|
* @returns {Array} array
|
@@ -4,7 +4,7 @@ import { isInteger } from '../../utils/number.js';
|
|
4
4
|
import { factory } from '../../utils/factory.js';
|
5
5
|
var name = 'Index';
|
6
6
|
var dependencies = ['ImmutableDenseMatrix'];
|
7
|
-
export var createIndexClass = /* #__PURE__ */factory(name, dependencies,
|
7
|
+
export var createIndexClass = /* #__PURE__ */factory(name, dependencies, _ref => {
|
8
8
|
var {
|
9
9
|
ImmutableDenseMatrix
|
10
10
|
} = _ref;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { factory } from '../../utils/factory.js';
|
2
2
|
var name = 'Spa';
|
3
3
|
var dependencies = ['addScalar', 'equalScalar', 'FibonacciHeap'];
|
4
|
-
export var createSpaClass = /* #__PURE__ */factory(name, dependencies,
|
4
|
+
export var createSpaClass = /* #__PURE__ */factory(name, dependencies, _ref => {
|
5
5
|
var {
|
6
6
|
addScalar,
|
7
7
|
equalScalar,
|
@@ -7,7 +7,7 @@ import { factory } from '../../utils/factory.js';
|
|
7
7
|
import { DimensionError } from '../../error/DimensionError.js';
|
8
8
|
var name = 'SparseMatrix';
|
9
9
|
var dependencies = ['typed', 'equalScalar', 'Matrix'];
|
10
|
-
export var createSparseMatrixClass = /* #__PURE__ */factory(name, dependencies,
|
10
|
+
export var createSparseMatrixClass = /* #__PURE__ */factory(name, dependencies, _ref => {
|
11
11
|
var {
|
12
12
|
typed,
|
13
13
|
equalScalar,
|
@@ -15,8 +15,9 @@ export var createSparseMatrixClass = /* #__PURE__ */factory(name, dependencies,
|
|
15
15
|
} = _ref;
|
16
16
|
|
17
17
|
/**
|
18
|
-
* Sparse Matrix implementation. This type implements
|
19
|
-
*
|
18
|
+
* Sparse Matrix implementation. This type implements
|
19
|
+
* a [Compressed Column Storage](https://en.wikipedia.org/wiki/Sparse_matrix#Compressed_sparse_column_(CSC_or_CCS))
|
20
|
+
* format for two-dimensional sparse matrices.
|
20
21
|
* @class SparseMatrix
|
21
22
|
*/
|
22
23
|
function SparseMatrix(data, datatype) {
|
@@ -598,6 +599,8 @@ export var createSparseMatrixClass = /* #__PURE__ */factory(name, dependencies,
|
|
598
599
|
*
|
599
600
|
* @memberof SparseMatrix
|
600
601
|
* @param {number[] | Matrix} size The new size the matrix should have.
|
602
|
+
* Since sparse matrices are always two-dimensional,
|
603
|
+
* size must be two numbers in either an array or a matrix
|
601
604
|
* @param {*} [defaultValue=0] Default value, filled in on new entries.
|
602
605
|
* If not provided, the matrix elements will
|
603
606
|
* be filled with zeros.
|
@@ -768,6 +771,8 @@ export var createSparseMatrixClass = /* #__PURE__ */factory(name, dependencies,
|
|
768
771
|
*
|
769
772
|
* @memberof SparseMatrix
|
770
773
|
* @param {number[]} sizes The new size the matrix should have.
|
774
|
+
* Since sparse matrices are always two-dimensional,
|
775
|
+
* size must be two numbers in either an array or a matrix
|
771
776
|
* @param {boolean} [copy] Return a reshaped copy of the matrix
|
772
777
|
*
|
773
778
|
* @return {Matrix} The reshaped matrix
|
@@ -1008,6 +1013,8 @@ export var createSparseMatrixClass = /* #__PURE__ */factory(name, dependencies,
|
|
1008
1013
|
* parameters: the value of the element, the index
|
1009
1014
|
* of the element, and the Matrix being traversed.
|
1010
1015
|
* @param {boolean} [skipZeros] Invoke callback function for non-zero values only.
|
1016
|
+
* If false, the indices are guaranteed to be in order,
|
1017
|
+
* if true, the indices can be unordered.
|
1011
1018
|
*/
|
1012
1019
|
|
1013
1020
|
|
@@ -1054,6 +1061,33 @@ export var createSparseMatrixClass = /* #__PURE__ */factory(name, dependencies,
|
|
1054
1061
|
}
|
1055
1062
|
}
|
1056
1063
|
};
|
1064
|
+
/**
|
1065
|
+
* Iterate over the matrix elements, skipping zeros
|
1066
|
+
* @return {Iterable<{ value, index: number[] }>}
|
1067
|
+
*/
|
1068
|
+
|
1069
|
+
|
1070
|
+
SparseMatrix.prototype[Symbol.iterator] = function* () {
|
1071
|
+
if (!this._values) {
|
1072
|
+
throw new Error('Cannot iterate a Pattern only matrix');
|
1073
|
+
}
|
1074
|
+
|
1075
|
+
var columns = this._size[1];
|
1076
|
+
|
1077
|
+
for (var j = 0; j < columns; j++) {
|
1078
|
+
var k0 = this._ptr[j];
|
1079
|
+
var k1 = this._ptr[j + 1];
|
1080
|
+
|
1081
|
+
for (var k = k0; k < k1; k++) {
|
1082
|
+
// row index
|
1083
|
+
var i = this._index[k];
|
1084
|
+
yield {
|
1085
|
+
value: this._values[k],
|
1086
|
+
index: [i, j]
|
1087
|
+
};
|
1088
|
+
}
|
1089
|
+
}
|
1090
|
+
};
|
1057
1091
|
/**
|
1058
1092
|
* Create an Array with a copy of the data of the SparseMatrix
|
1059
1093
|
* @memberof SparseMatrix
|
@@ -2,7 +2,7 @@ import { factory } from '../../../utils/factory.js';
|
|
2
2
|
import { isBigNumber, isMatrix } from '../../../utils/is.js';
|
3
3
|
var name = 'index';
|
4
4
|
var dependencies = ['typed', 'Index'];
|
5
|
-
export var createIndex = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createIndex = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed,
|
8
8
|
Index
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { factory } from '../../../utils/factory.js';
|
2
2
|
var name = 'matrix';
|
3
3
|
var dependencies = ['typed', 'Matrix', 'DenseMatrix', 'SparseMatrix'];
|
4
|
-
export var createMatrix = /* #__PURE__ */factory(name, dependencies,
|
4
|
+
export var createMatrix = /* #__PURE__ */factory(name, dependencies, _ref => {
|
5
5
|
var {
|
6
6
|
typed,
|
7
7
|
Matrix,
|
@@ -37,7 +37,8 @@ export var createMatrix = /* #__PURE__ */factory(name, dependencies, (_ref) => {
|
|
37
37
|
* bignumber, boolean, complex, index, number, string, unit, sparse
|
38
38
|
*
|
39
39
|
* @param {Array | Matrix} [data] A multi dimensional array
|
40
|
-
* @param {string} [format] The Matrix storage format
|
40
|
+
* @param {string} [format] The Matrix storage format, either `'dense'` or `'sparse'`
|
41
|
+
* @param {string} [datatype] Type of the values
|
41
42
|
*
|
42
43
|
* @return {Matrix} The created matrix
|
43
44
|
*/
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { factory } from '../../../utils/factory.js';
|
2
2
|
var name = 'sparse';
|
3
3
|
var dependencies = ['typed', 'SparseMatrix'];
|
4
|
-
export var createSparse = /* #__PURE__ */factory(name, dependencies,
|
4
|
+
export var createSparse = /* #__PURE__ */factory(name, dependencies, _ref => {
|
5
5
|
var {
|
6
6
|
typed,
|
7
7
|
SparseMatrix
|
@@ -2,7 +2,7 @@ import { factory } from '../../../utils/factory.js';
|
|
2
2
|
import { DimensionError } from '../../../error/DimensionError.js';
|
3
3
|
var name = 'algorithm01';
|
4
4
|
var dependencies = ['typed'];
|
5
|
-
export var createAlgorithm01 = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createAlgorithm01 = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed
|
8
8
|
} = _ref;
|
@@ -2,7 +2,7 @@ import { factory } from '../../../utils/factory.js';
|
|
2
2
|
import { DimensionError } from '../../../error/DimensionError.js';
|
3
3
|
var name = 'algorithm02';
|
4
4
|
var dependencies = ['typed', 'equalScalar'];
|
5
|
-
export var createAlgorithm02 = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createAlgorithm02 = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed,
|
8
8
|
equalScalar
|
@@ -2,7 +2,7 @@ import { factory } from '../../../utils/factory.js';
|
|
2
2
|
import { DimensionError } from '../../../error/DimensionError.js';
|
3
3
|
var name = 'algorithm03';
|
4
4
|
var dependencies = ['typed'];
|
5
|
-
export var createAlgorithm03 = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createAlgorithm03 = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed
|
8
8
|
} = _ref;
|
@@ -2,7 +2,7 @@ import { factory } from '../../../utils/factory.js';
|
|
2
2
|
import { DimensionError } from '../../../error/DimensionError.js';
|
3
3
|
var name = 'algorithm04';
|
4
4
|
var dependencies = ['typed', 'equalScalar'];
|
5
|
-
export var createAlgorithm04 = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createAlgorithm04 = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed,
|
8
8
|
equalScalar
|
@@ -2,7 +2,7 @@ import { factory } from '../../../utils/factory.js';
|
|
2
2
|
import { DimensionError } from '../../../error/DimensionError.js';
|
3
3
|
var name = 'algorithm05';
|
4
4
|
var dependencies = ['typed', 'equalScalar'];
|
5
|
-
export var createAlgorithm05 = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createAlgorithm05 = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed,
|
8
8
|
equalScalar
|
@@ -3,7 +3,7 @@ import { DimensionError } from '../../../error/DimensionError.js';
|
|
3
3
|
import { scatter } from '../../../utils/collection.js';
|
4
4
|
var name = 'algorithm06';
|
5
5
|
var dependencies = ['typed', 'equalScalar'];
|
6
|
-
export var createAlgorithm06 = /* #__PURE__ */factory(name, dependencies,
|
6
|
+
export var createAlgorithm06 = /* #__PURE__ */factory(name, dependencies, _ref => {
|
7
7
|
var {
|
8
8
|
typed,
|
9
9
|
equalScalar
|
@@ -2,7 +2,7 @@ import { factory } from '../../../utils/factory.js';
|
|
2
2
|
import { DimensionError } from '../../../error/DimensionError.js';
|
3
3
|
var name = 'algorithm07';
|
4
4
|
var dependencies = ['typed', 'DenseMatrix'];
|
5
|
-
export var createAlgorithm07 = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createAlgorithm07 = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed,
|
8
8
|
DenseMatrix
|
@@ -2,7 +2,7 @@ import { factory } from '../../../utils/factory.js';
|
|
2
2
|
import { DimensionError } from '../../../error/DimensionError.js';
|
3
3
|
var name = 'algorithm08';
|
4
4
|
var dependencies = ['typed', 'equalScalar'];
|
5
|
-
export var createAlgorithm08 = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createAlgorithm08 = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed,
|
8
8
|
equalScalar
|
@@ -2,7 +2,7 @@ import { factory } from '../../../utils/factory.js';
|
|
2
2
|
import { DimensionError } from '../../../error/DimensionError.js';
|
3
3
|
var name = 'algorithm09';
|
4
4
|
var dependencies = ['typed', 'equalScalar'];
|
5
|
-
export var createAlgorithm09 = /* #__PURE__ */factory(name, dependencies,
|
5
|
+
export var createAlgorithm09 = /* #__PURE__ */factory(name, dependencies, _ref => {
|
6
6
|
var {
|
7
7
|
typed,
|
8
8
|
equalScalar
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { factory } from '../../../utils/factory.js';
|
2
2
|
var name = 'algorithm10';
|
3
3
|
var dependencies = ['typed', 'DenseMatrix'];
|
4
|
-
export var createAlgorithm10 = /* #__PURE__ */factory(name, dependencies,
|
4
|
+
export var createAlgorithm10 = /* #__PURE__ */factory(name, dependencies, _ref => {
|
5
5
|
var {
|
6
6
|
typed,
|
7
7
|
DenseMatrix
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { factory } from '../../../utils/factory.js';
|
2
2
|
var name = 'algorithm11';
|
3
3
|
var dependencies = ['typed', 'equalScalar'];
|
4
|
-
export var createAlgorithm11 = /* #__PURE__ */factory(name, dependencies,
|
4
|
+
export var createAlgorithm11 = /* #__PURE__ */factory(name, dependencies, _ref => {
|
5
5
|
var {
|
6
6
|
typed,
|
7
7
|
equalScalar
|