@cortex-js/compute-engine 0.51.0 → 0.51.1
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/dist/compute-engine.esm.js +1447 -250
- package/dist/compute-engine.min.esm.js +66 -58
- package/dist/compute-engine.min.umd.js +66 -58
- package/dist/compute-engine.umd.js +1447 -250
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.umd.js +2 -2
- package/dist/math-json.umd.js +2 -2
- package/dist/types/color/categorical.d.ts +10 -3
- package/dist/types/color/contrast.d.ts +1 -1
- package/dist/types/color/conversion.d.ts +1 -1
- package/dist/types/color/diverging-palettes.d.ts +1 -1
- package/dist/types/color/index.d.ts +1 -1
- package/dist/types/color/manipulation.d.ts +3 -3
- package/dist/types/color/palette.d.ts +47 -17
- package/dist/types/color/sequential.d.ts +1 -1
- package/dist/types/color/types.d.ts +1 -1
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/configuration-change.d.ts +1 -1
- package/dist/types/common/fuzzy-string-match.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/interruptible.d.ts +1 -1
- package/dist/types/common/one-of.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/type/ast-nodes.d.ts +1 -1
- package/dist/types/common/type/boxed-type.d.ts +1 -1
- package/dist/types/common/type/lexer.d.ts +1 -1
- package/dist/types/common/type/parse.d.ts +1 -1
- package/dist/types/common/type/parser.d.ts +1 -1
- package/dist/types/common/type/primitive.d.ts +1 -1
- package/dist/types/common/type/reduce.d.ts +1 -1
- package/dist/types/common/type/serialize.d.ts +1 -1
- package/dist/types/common/type/subtype.d.ts +1 -1
- package/dist/types/common/type/type-builder.d.ts +1 -1
- package/dist/types/common/type/types.d.ts +1 -1
- package/dist/types/common/type/utils.d.ts +1 -1
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/constants.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/predicates.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/product.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/type-guards.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
- package/dist/types/compute-engine/collection-utils.d.ts +1 -1
- package/dist/types/compute-engine/compilation/base-compiler.d.ts +26 -1
- package/dist/types/compute-engine/compilation/compile-expression.d.ts +1 -1
- package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/gpu-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/interval-glsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +7 -1
- package/dist/types/compute-engine/compilation/interval-wgsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/javascript-target.d.ts +10 -2
- package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/types.d.ts +24 -6
- package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
- package/dist/types/compute-engine/engine-cache.d.ts +1 -1
- package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
- package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
- package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
- package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
- package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
- package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
- package/dist/types/compute-engine/engine-latex-dictionary-state.d.ts +1 -1
- package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
- package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
- package/dist/types/compute-engine/engine-parse-entrypoint.d.ts +1 -1
- package/dist/types/compute-engine/engine-runtime-state.d.ts +1 -1
- package/dist/types/compute-engine/engine-scope.d.ts +1 -1
- package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
- package/dist/types/compute-engine/engine-simplification-rules.d.ts +1 -1
- package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
- package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
- package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
- package/dist/types/compute-engine/free-functions.d.ts +2 -1
- package/dist/types/compute-engine/function-utils.d.ts +1 -1
- package/dist/types/compute-engine/global-types.d.ts +1 -1
- package/dist/types/compute-engine/index.d.ts +2 -2
- package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
- package/dist/types/compute-engine/interval/elementary.d.ts +18 -1
- package/dist/types/compute-engine/interval/index.d.ts +11 -5
- package/dist/types/compute-engine/interval/trigonometric.d.ts +16 -1
- package/dist/types/compute-engine/interval/types.d.ts +1 -1
- package/dist/types/compute-engine/interval/util.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-units.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +22 -0
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/types.d.ts +58 -1
- package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/colors.d.ts +1 -1
- package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
- package/dist/types/compute-engine/library/complex.d.ts +1 -1
- package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +1 -1
- package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/library/logic-analysis.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/quantity-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/statistics.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/library/type-handlers.d.ts +1 -1
- package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
- package/dist/types/compute-engine/library/units.d.ts +1 -1
- package/dist/types/compute-engine/library/utils.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
- package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
- package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
- package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
- package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/numerics/special-functions.d.ts +15 -1
- package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
- package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
- package/dist/types/compute-engine/numerics/types.d.ts +1 -1
- package/dist/types/compute-engine/numerics/unit-data.d.ts +1 -1
- package/dist/types/compute-engine/oeis.d.ts +1 -1
- package/dist/types/compute-engine/sequence.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
- package/dist/types/compute-engine/types-definitions.d.ts +1 -1
- package/dist/types/compute-engine/types-engine.d.ts +1 -1
- package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
- package/dist/types/compute-engine/types-expression.d.ts +1 -1
- package/dist/types/compute-engine/types-kernel-evaluation.d.ts +1 -1
- package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
- package/dist/types/compute-engine/types-serialization.d.ts +1 -1
- package/dist/types/compute-engine/types.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +1 -1
- package/dist/types/math-json/symbols.d.ts +1 -1
- package/dist/types/math-json/types.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +1 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Compute Engine 0.51.
|
|
1
|
+
/** Compute Engine 0.51.1 */
|
|
2
2
|
|
|
3
3
|
// node_modules/complex-esm/dist/src/complex.js
|
|
4
4
|
var cosh = Math.cosh || function(x) {
|
|
@@ -9798,13 +9798,175 @@ var DEFINITIONS_CORE = [
|
|
|
9798
9798
|
parse: (parser, lhs, terminator) => {
|
|
9799
9799
|
const seq = parseSequence(parser, terminator, lhs, 19, ";");
|
|
9800
9800
|
if (seq === null) return null;
|
|
9801
|
+
if (seq.some((e) => operator(e) === "Assign"))
|
|
9802
|
+
return buildBlockFromSequence(seq);
|
|
9801
9803
|
return ["Delimiter", ["Sequence", ...seq], "';'"];
|
|
9802
9804
|
}
|
|
9803
9805
|
},
|
|
9806
|
+
// \text{where} — variable binding infix
|
|
9807
|
+
{
|
|
9808
|
+
latexTrigger: ["\\text"],
|
|
9809
|
+
kind: "infix",
|
|
9810
|
+
associativity: "none",
|
|
9811
|
+
precedence: 21,
|
|
9812
|
+
// Above ; (19) and , (20), very low binding
|
|
9813
|
+
parse: (parser, lhs, until) => {
|
|
9814
|
+
const start = parser.index;
|
|
9815
|
+
if (!matchTextKeyword(parser, "where")) {
|
|
9816
|
+
parser.index = start;
|
|
9817
|
+
return null;
|
|
9818
|
+
}
|
|
9819
|
+
return parseWhereExpression(parser, lhs, until);
|
|
9820
|
+
}
|
|
9821
|
+
},
|
|
9822
|
+
// \operatorname{where}
|
|
9823
|
+
{
|
|
9824
|
+
symbolTrigger: "where",
|
|
9825
|
+
kind: "infix",
|
|
9826
|
+
associativity: "none",
|
|
9827
|
+
precedence: 21,
|
|
9828
|
+
parse: (parser, lhs, until) => parseWhereExpression(parser, lhs, until)
|
|
9829
|
+
},
|
|
9830
|
+
// Block serializer — used by both `where` and semicolon blocks
|
|
9831
|
+
{
|
|
9832
|
+
name: "Block",
|
|
9833
|
+
serialize: (serializer, expr) => {
|
|
9834
|
+
const args = operands(expr);
|
|
9835
|
+
if (!args || args.length === 0) return "";
|
|
9836
|
+
const parts = args.filter((a) => operator(a) !== "Declare").map((a) => serializer.serialize(a));
|
|
9837
|
+
return parts.join(";\\; ");
|
|
9838
|
+
}
|
|
9839
|
+
},
|
|
9840
|
+
// Serializer for If expressions (separate from the parser entry
|
|
9841
|
+
// because name-based entries affect kind-based indexing)
|
|
9842
|
+
{
|
|
9843
|
+
name: "If",
|
|
9844
|
+
serialize: (serializer, expr) => {
|
|
9845
|
+
const args = operands(expr);
|
|
9846
|
+
if (!args || args.length < 3) return "";
|
|
9847
|
+
return joinLatex([
|
|
9848
|
+
"\\text{if }",
|
|
9849
|
+
serializer.serialize(args[0]),
|
|
9850
|
+
"\\text{ then }",
|
|
9851
|
+
serializer.serialize(args[1]),
|
|
9852
|
+
"\\text{ else }",
|
|
9853
|
+
serializer.serialize(args[2])
|
|
9854
|
+
]);
|
|
9855
|
+
}
|
|
9856
|
+
},
|
|
9857
|
+
// Serializer for Loop expressions
|
|
9858
|
+
{
|
|
9859
|
+
name: "Loop",
|
|
9860
|
+
serialize: (serializer, expr) => {
|
|
9861
|
+
const args = operands(expr);
|
|
9862
|
+
if (!args || args.length < 2) return "";
|
|
9863
|
+
const body = args[0];
|
|
9864
|
+
const indexing = args[1];
|
|
9865
|
+
if (operator(indexing) === "Element") {
|
|
9866
|
+
const index = operand(indexing, 1);
|
|
9867
|
+
const range2 = operand(indexing, 2);
|
|
9868
|
+
if (operator(range2) === "Range") {
|
|
9869
|
+
const lo = operand(range2, 1);
|
|
9870
|
+
const hi = operand(range2, 2);
|
|
9871
|
+
return joinLatex([
|
|
9872
|
+
"\\text{for }",
|
|
9873
|
+
serializer.serialize(index),
|
|
9874
|
+
"\\text{ from }",
|
|
9875
|
+
serializer.serialize(lo),
|
|
9876
|
+
"\\text{ to }",
|
|
9877
|
+
serializer.serialize(hi),
|
|
9878
|
+
"\\text{ do }",
|
|
9879
|
+
serializer.serialize(body)
|
|
9880
|
+
]);
|
|
9881
|
+
}
|
|
9882
|
+
}
|
|
9883
|
+
return joinLatex([
|
|
9884
|
+
"\\operatorname{Loop}(",
|
|
9885
|
+
serializer.serialize(body),
|
|
9886
|
+
", ",
|
|
9887
|
+
serializer.serialize(indexing),
|
|
9888
|
+
")"
|
|
9889
|
+
]);
|
|
9890
|
+
}
|
|
9891
|
+
},
|
|
9892
|
+
// Serializer for Break
|
|
9893
|
+
{ name: "Break", serialize: () => "\\text{break}" },
|
|
9894
|
+
// Serializer for Continue
|
|
9895
|
+
{ name: "Continue", serialize: () => "\\text{continue}" },
|
|
9896
|
+
// Serializer for Return
|
|
9897
|
+
{
|
|
9898
|
+
name: "Return",
|
|
9899
|
+
serialize: (serializer, expr) => {
|
|
9900
|
+
const arg = operand(expr, 1);
|
|
9901
|
+
if (!arg || symbol(arg) === "Nothing") return "\\text{return}";
|
|
9902
|
+
return joinLatex(["\\text{return }", serializer.serialize(arg)]);
|
|
9903
|
+
}
|
|
9904
|
+
},
|
|
9905
|
+
// Also match `\operatorname{if}` / `\mathrm{if}`
|
|
9906
|
+
{
|
|
9907
|
+
symbolTrigger: "if",
|
|
9908
|
+
kind: "prefix",
|
|
9909
|
+
precedence: 245,
|
|
9910
|
+
parse: (parser, until) => {
|
|
9911
|
+
return parseIfExpression(parser, until);
|
|
9912
|
+
}
|
|
9913
|
+
},
|
|
9914
|
+
// \operatorname{for}
|
|
9915
|
+
{
|
|
9916
|
+
symbolTrigger: "for",
|
|
9917
|
+
kind: "prefix",
|
|
9918
|
+
precedence: 245,
|
|
9919
|
+
parse: (parser, until) => parseForExpression(parser, until)
|
|
9920
|
+
},
|
|
9921
|
+
// \operatorname{break}
|
|
9922
|
+
{
|
|
9923
|
+
symbolTrigger: "break",
|
|
9924
|
+
kind: "prefix",
|
|
9925
|
+
precedence: 245,
|
|
9926
|
+
parse: () => ["Break"]
|
|
9927
|
+
},
|
|
9928
|
+
// \operatorname{continue}
|
|
9929
|
+
{
|
|
9930
|
+
symbolTrigger: "continue",
|
|
9931
|
+
kind: "prefix",
|
|
9932
|
+
precedence: 245,
|
|
9933
|
+
parse: () => ["Continue"]
|
|
9934
|
+
},
|
|
9935
|
+
// \operatorname{return}
|
|
9936
|
+
{
|
|
9937
|
+
symbolTrigger: "return",
|
|
9938
|
+
kind: "prefix",
|
|
9939
|
+
precedence: 245,
|
|
9940
|
+
parse: (parser, until) => [
|
|
9941
|
+
"Return",
|
|
9942
|
+
parser.parseExpression(until) ?? "Nothing"
|
|
9943
|
+
]
|
|
9944
|
+
},
|
|
9804
9945
|
{
|
|
9805
9946
|
name: "String",
|
|
9806
9947
|
latexTrigger: ["\\text"],
|
|
9807
|
-
parse: (
|
|
9948
|
+
parse: (parser, until) => {
|
|
9949
|
+
const start = parser.index;
|
|
9950
|
+
if (matchTextKeyword(parser, "if"))
|
|
9951
|
+
return parseIfExpression(parser, until);
|
|
9952
|
+
parser.index = start;
|
|
9953
|
+
if (matchTextKeyword(parser, "for"))
|
|
9954
|
+
return parseForExpression(parser, until);
|
|
9955
|
+
parser.index = start;
|
|
9956
|
+
if (matchTextKeyword(parser, "break"))
|
|
9957
|
+
return ["Break"];
|
|
9958
|
+
parser.index = start;
|
|
9959
|
+
if (matchTextKeyword(parser, "continue"))
|
|
9960
|
+
return ["Continue"];
|
|
9961
|
+
parser.index = start;
|
|
9962
|
+
if (matchTextKeyword(parser, "return"))
|
|
9963
|
+
return [
|
|
9964
|
+
"Return",
|
|
9965
|
+
parser.parseExpression(until) ?? "Nothing"
|
|
9966
|
+
];
|
|
9967
|
+
parser.index = start;
|
|
9968
|
+
return parseTextRun(parser);
|
|
9969
|
+
},
|
|
9808
9970
|
serialize: (serializer, expr) => {
|
|
9809
9971
|
const args = operands(expr);
|
|
9810
9972
|
if (args.length === 0) return "\\text{}";
|
|
@@ -10458,7 +10620,7 @@ var DELIMITERS_SHORTHAND = {
|
|
|
10458
10620
|
// '⎾': '', // U+23BE RIGHT PARENTHESIS UPPER HOOK
|
|
10459
10621
|
// '⎿': '', // U+23BF RIGHT PARENTHESIS LOWER HOOK
|
|
10460
10622
|
};
|
|
10461
|
-
function parseAssign(parser, lhs) {
|
|
10623
|
+
function parseAssign(parser, lhs, until) {
|
|
10462
10624
|
const lhsSymbol = symbol(lhs);
|
|
10463
10625
|
if (lhsSymbol && lhsSymbol.includes("_")) {
|
|
10464
10626
|
const underscoreIndex = lhsSymbol.indexOf("_");
|
|
@@ -10471,7 +10633,7 @@ function parseAssign(parser, lhs) {
|
|
|
10471
10633
|
if (operator(lhs) === "InvisibleOperator" && nops(lhs) === 2 && operator(operand(lhs, 2)) === "Delimiter") {
|
|
10472
10634
|
const fn2 = symbol(operand(lhs, 1));
|
|
10473
10635
|
if (!fn2) return null;
|
|
10474
|
-
const rhs2 = parser.parseExpression({ minPrec:
|
|
10636
|
+
const rhs2 = parser.parseExpression({ ...until ?? {}, minPrec: 20 });
|
|
10475
10637
|
if (rhs2 === null) return null;
|
|
10476
10638
|
const delimBody = operand(operand(lhs, 2), 1);
|
|
10477
10639
|
let args = [];
|
|
@@ -10482,7 +10644,7 @@ function parseAssign(parser, lhs) {
|
|
|
10482
10644
|
if (operator(lhs) === "Subscript" && symbol(operand(lhs, 1))) {
|
|
10483
10645
|
const fn2 = symbol(operand(lhs, 1));
|
|
10484
10646
|
if (!fn2) return null;
|
|
10485
|
-
const rhs2 = parser.parseExpression({ minPrec:
|
|
10647
|
+
const rhs2 = parser.parseExpression({ ...until ?? {}, minPrec: 20 });
|
|
10486
10648
|
if (rhs2 === null) return null;
|
|
10487
10649
|
const sub3 = operand(lhs, 2);
|
|
10488
10650
|
if (stringValue(sub3) !== null) {
|
|
@@ -10498,12 +10660,12 @@ function parseAssign(parser, lhs) {
|
|
|
10498
10660
|
if (fn === "Subscript" || fn === "Superscript") {
|
|
10499
10661
|
}
|
|
10500
10662
|
const args = operands(lhs);
|
|
10501
|
-
const rhs2 = parser.parseExpression({ minPrec:
|
|
10663
|
+
const rhs2 = parser.parseExpression({ ...until ?? {}, minPrec: 20 });
|
|
10502
10664
|
if (rhs2 === null) return null;
|
|
10503
10665
|
return ["Assign", fn, ["Function", rhs2, ...args]];
|
|
10504
10666
|
}
|
|
10505
10667
|
if (!symbol(lhs)) return null;
|
|
10506
|
-
const rhs = parser.parseExpression({ minPrec:
|
|
10668
|
+
const rhs = parser.parseExpression({ ...until ?? {}, minPrec: 20 });
|
|
10507
10669
|
if (rhs === null) return null;
|
|
10508
10670
|
return ["Assign", lhs, rhs];
|
|
10509
10671
|
}
|
|
@@ -10530,6 +10692,141 @@ function parseCasesEnvironment(parser) {
|
|
|
10530
10692
|
}
|
|
10531
10693
|
return ["Which", ...result];
|
|
10532
10694
|
}
|
|
10695
|
+
function matchTextKeyword(parser, keyword) {
|
|
10696
|
+
const start = parser.index;
|
|
10697
|
+
if (!parser.match("<{>")) {
|
|
10698
|
+
parser.index = start;
|
|
10699
|
+
return false;
|
|
10700
|
+
}
|
|
10701
|
+
while (parser.match("<space>")) {
|
|
10702
|
+
}
|
|
10703
|
+
let text = "";
|
|
10704
|
+
while (!parser.atEnd && parser.peek !== "<}>" && parser.peek !== "<space>") {
|
|
10705
|
+
const tok = parser.peek;
|
|
10706
|
+
if (/^[a-zA-Z]$/.test(tok)) {
|
|
10707
|
+
text += tok;
|
|
10708
|
+
parser.nextToken();
|
|
10709
|
+
} else {
|
|
10710
|
+
break;
|
|
10711
|
+
}
|
|
10712
|
+
}
|
|
10713
|
+
while (parser.match("<space>")) {
|
|
10714
|
+
}
|
|
10715
|
+
if (!parser.match("<}>")) {
|
|
10716
|
+
parser.index = start;
|
|
10717
|
+
return false;
|
|
10718
|
+
}
|
|
10719
|
+
if (text !== keyword) {
|
|
10720
|
+
parser.index = start;
|
|
10721
|
+
return false;
|
|
10722
|
+
}
|
|
10723
|
+
return true;
|
|
10724
|
+
}
|
|
10725
|
+
function matchKeyword(parser, keyword) {
|
|
10726
|
+
const start = parser.index;
|
|
10727
|
+
if (parser.match("\\text")) {
|
|
10728
|
+
if (matchTextKeyword(parser, keyword)) return true;
|
|
10729
|
+
parser.index = start;
|
|
10730
|
+
}
|
|
10731
|
+
const saved = parser.index;
|
|
10732
|
+
const sym2 = parser.parseSymbol();
|
|
10733
|
+
if (sym2 !== null && symbol(sym2) === keyword) return true;
|
|
10734
|
+
parser.index = saved;
|
|
10735
|
+
return false;
|
|
10736
|
+
}
|
|
10737
|
+
function peekKeyword(parser, keyword) {
|
|
10738
|
+
const start = parser.index;
|
|
10739
|
+
const result = matchKeyword(parser, keyword);
|
|
10740
|
+
parser.index = start;
|
|
10741
|
+
return result;
|
|
10742
|
+
}
|
|
10743
|
+
function parseIfExpression(parser, until) {
|
|
10744
|
+
const condition = parser.parseExpression({
|
|
10745
|
+
minPrec: 0,
|
|
10746
|
+
condition: (p) => peekKeyword(p, "then")
|
|
10747
|
+
});
|
|
10748
|
+
if (condition === null) return null;
|
|
10749
|
+
if (!matchKeyword(parser, "then")) return null;
|
|
10750
|
+
const trueBranch = parser.parseExpression({
|
|
10751
|
+
minPrec: 0,
|
|
10752
|
+
condition: (p) => peekKeyword(p, "else")
|
|
10753
|
+
});
|
|
10754
|
+
if (trueBranch === null) return null;
|
|
10755
|
+
if (!matchKeyword(parser, "else")) return null;
|
|
10756
|
+
const falseBranch = parser.parseExpression(until) ?? "Nothing";
|
|
10757
|
+
return ["If", condition, trueBranch, falseBranch];
|
|
10758
|
+
}
|
|
10759
|
+
function parseForExpression(parser, until) {
|
|
10760
|
+
const indexExpr = parser.parseExpression({
|
|
10761
|
+
minPrec: 0,
|
|
10762
|
+
condition: (p) => peekKeyword(p, "from")
|
|
10763
|
+
});
|
|
10764
|
+
const index = indexExpr ? symbol(indexExpr) : null;
|
|
10765
|
+
if (!index) return null;
|
|
10766
|
+
if (!matchKeyword(parser, "from")) return null;
|
|
10767
|
+
const lower = parser.parseExpression({
|
|
10768
|
+
minPrec: 0,
|
|
10769
|
+
condition: (p) => peekKeyword(p, "to")
|
|
10770
|
+
});
|
|
10771
|
+
if (lower === null) return null;
|
|
10772
|
+
if (!matchKeyword(parser, "to")) return null;
|
|
10773
|
+
const upper = parser.parseExpression({
|
|
10774
|
+
minPrec: 0,
|
|
10775
|
+
condition: (p) => peekKeyword(p, "do")
|
|
10776
|
+
});
|
|
10777
|
+
if (upper === null) return null;
|
|
10778
|
+
if (!matchKeyword(parser, "do")) return null;
|
|
10779
|
+
const body = parser.parseExpression(until) ?? "Nothing";
|
|
10780
|
+
return [
|
|
10781
|
+
"Loop",
|
|
10782
|
+
body,
|
|
10783
|
+
["Element", index, ["Range", lower, upper]]
|
|
10784
|
+
];
|
|
10785
|
+
}
|
|
10786
|
+
function parseWhereExpression(parser, lhs, until) {
|
|
10787
|
+
const bindingTerminator = {
|
|
10788
|
+
minPrec: 21,
|
|
10789
|
+
// Above comma (20) and ; (19)
|
|
10790
|
+
condition: (p) => {
|
|
10791
|
+
if (until?.condition?.(p)) return true;
|
|
10792
|
+
const saved = p.index;
|
|
10793
|
+
p.skipSpace();
|
|
10794
|
+
const isComma = p.peek === ",";
|
|
10795
|
+
p.index = saved;
|
|
10796
|
+
return isComma;
|
|
10797
|
+
}
|
|
10798
|
+
};
|
|
10799
|
+
const bindings = [];
|
|
10800
|
+
do {
|
|
10801
|
+
parser.skipSpace();
|
|
10802
|
+
const binding = parser.parseExpression(bindingTerminator);
|
|
10803
|
+
if (!binding) break;
|
|
10804
|
+
bindings.push(binding);
|
|
10805
|
+
parser.skipSpace();
|
|
10806
|
+
} while (parser.match(","));
|
|
10807
|
+
if (bindings.length === 0) return null;
|
|
10808
|
+
const block = [];
|
|
10809
|
+
for (const b of bindings) {
|
|
10810
|
+
if (operator(b) === "Assign") {
|
|
10811
|
+
block.push(["Declare", operand(b, 1)]);
|
|
10812
|
+
block.push(b);
|
|
10813
|
+
} else {
|
|
10814
|
+
block.push(b);
|
|
10815
|
+
}
|
|
10816
|
+
}
|
|
10817
|
+
block.push(lhs);
|
|
10818
|
+
return ["Block", ...block];
|
|
10819
|
+
}
|
|
10820
|
+
function buildBlockFromSequence(seq) {
|
|
10821
|
+
const block = [];
|
|
10822
|
+
for (const s of seq) {
|
|
10823
|
+
if (operator(s) === "Assign") {
|
|
10824
|
+
block.push(["Declare", operand(s, 1)]);
|
|
10825
|
+
}
|
|
10826
|
+
block.push(s);
|
|
10827
|
+
}
|
|
10828
|
+
return ["Block", ...block];
|
|
10829
|
+
}
|
|
10533
10830
|
function parseAt(...close) {
|
|
10534
10831
|
return (parser, lhs) => {
|
|
10535
10832
|
if (!symbol(lhs) && operator(lhs) !== "List") return null;
|
|
@@ -10664,7 +10961,11 @@ var Serializer2 = class {
|
|
|
10664
10961
|
level = -1;
|
|
10665
10962
|
constructor(dictionary, options) {
|
|
10666
10963
|
this.dictionary = dictionary;
|
|
10667
|
-
this.options =
|
|
10964
|
+
this.options = {
|
|
10965
|
+
dmsFormat: false,
|
|
10966
|
+
angleNormalization: "none",
|
|
10967
|
+
...options
|
|
10968
|
+
};
|
|
10668
10969
|
}
|
|
10669
10970
|
/**
|
|
10670
10971
|
* Serialize the expression, and if the expression is an operator
|
|
@@ -11786,6 +12087,8 @@ var _BoxedExpression = class {
|
|
|
11786
12087
|
// invisibleApply: '',
|
|
11787
12088
|
multiply: "\\times",
|
|
11788
12089
|
missingSymbol: "\\blacksquare",
|
|
12090
|
+
dmsFormat: false,
|
|
12091
|
+
angleNormalization: "none",
|
|
11789
12092
|
// openGroup: '(',
|
|
11790
12093
|
// closeGroup: ')',
|
|
11791
12094
|
// divide: '\\frac{#1}{#2}',
|
|
@@ -16841,6 +17144,150 @@ function airyBiNegAsymptotic(absX, xi) {
|
|
|
16841
17144
|
const x14 = Math.pow(absX, 0.25);
|
|
16842
17145
|
return Math.cos(xi + Math.PI / 4) / (Math.sqrt(Math.PI) * x14);
|
|
16843
17146
|
}
|
|
17147
|
+
var SN = [
|
|
17148
|
+
-2991.8191940101983,
|
|
17149
|
+
708840.0452577386,
|
|
17150
|
+
-6297414862058625e-8,
|
|
17151
|
+
25489088057337637e-7,
|
|
17152
|
+
-4429795180596978e-5,
|
|
17153
|
+
3180162978765678e-4
|
|
17154
|
+
];
|
|
17155
|
+
var SD = [
|
|
17156
|
+
1,
|
|
17157
|
+
281.3762688899943,
|
|
17158
|
+
45584.78108065326,
|
|
17159
|
+
5173438887700964e-9,
|
|
17160
|
+
4193202458981112e-7,
|
|
17161
|
+
22441179564534092e-6,
|
|
17162
|
+
607366389490085e-3
|
|
17163
|
+
];
|
|
17164
|
+
var CN = [
|
|
17165
|
+
-49884311457357354e-24,
|
|
17166
|
+
9504280628298596e-21,
|
|
17167
|
+
-6451914356839651e-19,
|
|
17168
|
+
0.018884331939670384,
|
|
17169
|
+
-0.20552590095501388,
|
|
17170
|
+
1
|
|
17171
|
+
];
|
|
17172
|
+
var CD = [
|
|
17173
|
+
399982968972496e-26,
|
|
17174
|
+
9154392157746574e-25,
|
|
17175
|
+
12500186247959882e-23,
|
|
17176
|
+
12226278902417902e-21,
|
|
17177
|
+
8680295429417843e-19,
|
|
17178
|
+
0.04121420907221998,
|
|
17179
|
+
1
|
|
17180
|
+
];
|
|
17181
|
+
var FN = [
|
|
17182
|
+
0.4215435550436775,
|
|
17183
|
+
0.1434079197807589,
|
|
17184
|
+
0.011522095507358577,
|
|
17185
|
+
345017939782574e-18,
|
|
17186
|
+
46361374928786735e-22,
|
|
17187
|
+
3055689837902576e-23,
|
|
17188
|
+
10230451416490724e-26,
|
|
17189
|
+
17201074326816183e-29,
|
|
17190
|
+
13428327623306275e-32,
|
|
17191
|
+
3763297112699879e-35
|
|
17192
|
+
];
|
|
17193
|
+
var FD = [
|
|
17194
|
+
1,
|
|
17195
|
+
0.7515863983533789,
|
|
17196
|
+
0.11688892585919138,
|
|
17197
|
+
0.0064405152650885865,
|
|
17198
|
+
15593440916415301e-20,
|
|
17199
|
+
18462756734893055e-22,
|
|
17200
|
+
11269922476399903e-24,
|
|
17201
|
+
36014002958937136e-27,
|
|
17202
|
+
5887545336215784e-29,
|
|
17203
|
+
45200143407412973e-33,
|
|
17204
|
+
12544323709001127e-36
|
|
17205
|
+
];
|
|
17206
|
+
var GN = [
|
|
17207
|
+
0.5044420736433832,
|
|
17208
|
+
0.1971028335255234,
|
|
17209
|
+
0.018764858409257526,
|
|
17210
|
+
6840793809153931e-19,
|
|
17211
|
+
11513882611188428e-21,
|
|
17212
|
+
9828524436884223e-23,
|
|
17213
|
+
44534441586175015e-26,
|
|
17214
|
+
10826804113902088e-28,
|
|
17215
|
+
1375554606332618e-30,
|
|
17216
|
+
8363544356306774e-34,
|
|
17217
|
+
18695871016278324e-38
|
|
17218
|
+
];
|
|
17219
|
+
var GD = [
|
|
17220
|
+
1,
|
|
17221
|
+
1.4749575992512833,
|
|
17222
|
+
0.33774898912002,
|
|
17223
|
+
0.02536037414203388,
|
|
17224
|
+
8146791071843061e-19,
|
|
17225
|
+
12754507566772912e-21,
|
|
17226
|
+
10431458965757199e-23,
|
|
17227
|
+
46068072851523205e-26,
|
|
17228
|
+
11027321506624028e-28,
|
|
17229
|
+
13879653125957886e-31,
|
|
17230
|
+
8391588162831187e-34,
|
|
17231
|
+
18695871016278324e-38
|
|
17232
|
+
];
|
|
17233
|
+
function polevl(x, coef) {
|
|
17234
|
+
let ans = coef[0];
|
|
17235
|
+
for (let i = 1; i < coef.length; i++) ans = ans * x + coef[i];
|
|
17236
|
+
return ans;
|
|
17237
|
+
}
|
|
17238
|
+
function fresnelS(x) {
|
|
17239
|
+
if (!isFinite(x)) {
|
|
17240
|
+
if (x !== x) return NaN;
|
|
17241
|
+
return x > 0 ? 0.5 : -0.5;
|
|
17242
|
+
}
|
|
17243
|
+
const sign3 = x < 0 ? -1 : 1;
|
|
17244
|
+
x = Math.abs(x);
|
|
17245
|
+
if (x < 1.6) {
|
|
17246
|
+
const x2 = x * x;
|
|
17247
|
+
const t = x2 * x2;
|
|
17248
|
+
return sign3 * x * x2 * polevl(t, SN) / polevl(t, SD);
|
|
17249
|
+
}
|
|
17250
|
+
if (x < 36) {
|
|
17251
|
+
const x2 = x * x;
|
|
17252
|
+
const t = Math.PI * x2;
|
|
17253
|
+
const u = 1 / (t * t);
|
|
17254
|
+
const f = 1 - u * polevl(u, FN) / polevl(u, FD);
|
|
17255
|
+
const g = 1 / t * polevl(u, GN) / polevl(u, GD);
|
|
17256
|
+
const z = Math.PI / 2 * x2;
|
|
17257
|
+
const c = Math.cos(z);
|
|
17258
|
+
const s = Math.sin(z);
|
|
17259
|
+
return sign3 * (0.5 - (f * c + g * s) / (Math.PI * x));
|
|
17260
|
+
}
|
|
17261
|
+
return sign3 * 0.5;
|
|
17262
|
+
}
|
|
17263
|
+
function fresnelC(x) {
|
|
17264
|
+
if (!isFinite(x)) {
|
|
17265
|
+
if (x !== x) return NaN;
|
|
17266
|
+
return x > 0 ? 0.5 : -0.5;
|
|
17267
|
+
}
|
|
17268
|
+
const sign3 = x < 0 ? -1 : 1;
|
|
17269
|
+
x = Math.abs(x);
|
|
17270
|
+
if (x < 1.6) {
|
|
17271
|
+
const x2 = x * x;
|
|
17272
|
+
const t = x2 * x2;
|
|
17273
|
+
return sign3 * x * polevl(t, CN) / polevl(t, CD);
|
|
17274
|
+
}
|
|
17275
|
+
if (x < 36) {
|
|
17276
|
+
const x2 = x * x;
|
|
17277
|
+
const t = Math.PI * x2;
|
|
17278
|
+
const u = 1 / (t * t);
|
|
17279
|
+
const f = 1 - u * polevl(u, FN) / polevl(u, FD);
|
|
17280
|
+
const g = 1 / t * polevl(u, GN) / polevl(u, GD);
|
|
17281
|
+
const z = Math.PI / 2 * x2;
|
|
17282
|
+
const c = Math.cos(z);
|
|
17283
|
+
const s = Math.sin(z);
|
|
17284
|
+
return sign3 * (0.5 + (f * s - g * c) / (Math.PI * x));
|
|
17285
|
+
}
|
|
17286
|
+
return sign3 * 0.5;
|
|
17287
|
+
}
|
|
17288
|
+
function sinc(x) {
|
|
17289
|
+
return x === 0 ? 1 : Math.sin(x) / x;
|
|
17290
|
+
}
|
|
16844
17291
|
|
|
16845
17292
|
// src/compute-engine/boxed-expression/predicates.ts
|
|
16846
17293
|
function isPrime2(expr) {
|
|
@@ -23492,7 +23939,7 @@ var ARITHMETIC_LIBRARY = [
|
|
|
23492
23939
|
wikidata: "Q715358",
|
|
23493
23940
|
complexity: 2e3,
|
|
23494
23941
|
broadcastable: true,
|
|
23495
|
-
signature: "(
|
|
23942
|
+
signature: "(value) -> value",
|
|
23496
23943
|
type: ([x]) => x.type,
|
|
23497
23944
|
sgn: ([x]) => oppositeSgn(x.sgn),
|
|
23498
23945
|
canonical: (args, { engine }) => {
|
|
@@ -23705,6 +24152,20 @@ var ARITHMETIC_LIBRARY = [
|
|
|
23705
24152
|
(x2) => x2.round(0)
|
|
23706
24153
|
)
|
|
23707
24154
|
},
|
|
24155
|
+
/** Heaviside step function: H(x) = 0 for x < 0, 1/2 for x = 0, 1 for x > 0 */
|
|
24156
|
+
Heaviside: {
|
|
24157
|
+
complexity: 1200,
|
|
24158
|
+
broadcastable: true,
|
|
24159
|
+
signature: "(number) -> real",
|
|
24160
|
+
type: () => "finite_real",
|
|
24161
|
+
sgn: () => "non-negative",
|
|
24162
|
+
evaluate: ([x], { engine }) => {
|
|
24163
|
+
if (x.is(0)) return engine.Half;
|
|
24164
|
+
if (x.isPositive) return engine.One;
|
|
24165
|
+
if (x.isNegative) return engine.Zero;
|
|
24166
|
+
return void 0;
|
|
24167
|
+
}
|
|
24168
|
+
},
|
|
23708
24169
|
Sign: {
|
|
23709
24170
|
complexity: 1200,
|
|
23710
24171
|
broadcastable: true,
|
|
@@ -28775,7 +29236,7 @@ var CALCULUS_LIBRARY = [
|
|
|
28775
29236
|
];
|
|
28776
29237
|
|
|
28777
29238
|
// src/color/palette.ts
|
|
28778
|
-
var
|
|
29239
|
+
var NAMED_COLORS = {
|
|
28779
29240
|
"red": "#d7170b",
|
|
28780
29241
|
//<- 700, 500 ->'#f21c0d'
|
|
28781
29242
|
"orange": "#fe8a2b",
|
|
@@ -28789,11 +29250,31 @@ var FOREGROUND_COLORS = {
|
|
|
28789
29250
|
"indigo": "#63c",
|
|
28790
29251
|
"purple": "#a219e6",
|
|
28791
29252
|
"magenta": "#eb4799",
|
|
29253
|
+
"brown": "#8c564b",
|
|
29254
|
+
"olive": "#8a8f2a",
|
|
29255
|
+
"midnight": "#2c4670",
|
|
29256
|
+
"sky": "#d2dce9",
|
|
28792
29257
|
"black": "#000",
|
|
29258
|
+
"white": "#ffffff",
|
|
29259
|
+
"carbon": "#111111",
|
|
29260
|
+
// near-black, high-contrast text
|
|
29261
|
+
"charcoal": "#333333",
|
|
29262
|
+
// primary axis / label color
|
|
29263
|
+
"slate": "#555555",
|
|
29264
|
+
// secondary text, major gridlines
|
|
28793
29265
|
"dark-grey": "#666",
|
|
29266
|
+
"graphite": "#777777",
|
|
29267
|
+
// minor gridlines
|
|
29268
|
+
"stone": "#999999",
|
|
29269
|
+
// de-emphasized strokes
|
|
28794
29270
|
"grey": "#A6A6A6",
|
|
28795
29271
|
"light-grey": "#d4d5d2",
|
|
28796
|
-
"
|
|
29272
|
+
"ash": "#E6E6E6",
|
|
29273
|
+
// subtle fills, light strokes
|
|
29274
|
+
"mist": "#F3F3F3",
|
|
29275
|
+
// light background tint
|
|
29276
|
+
"snow": "#FFFFFF"
|
|
29277
|
+
// pure white
|
|
28797
29278
|
};
|
|
28798
29279
|
|
|
28799
29280
|
// src/color/manipulation.ts
|
|
@@ -29003,9 +29484,9 @@ function parseColor(s) {
|
|
|
29003
29484
|
}
|
|
29004
29485
|
const lms = lmsFromLab(l, labA, labB);
|
|
29005
29486
|
const lin = linSRGBFromLMS(lms);
|
|
29006
|
-
|
|
29007
|
-
|
|
29008
|
-
|
|
29487
|
+
const r = Math.max(0, Math.min(1, gammaCorrect(lin.r)));
|
|
29488
|
+
const g = Math.max(0, Math.min(1, gammaCorrect(lin.g)));
|
|
29489
|
+
const b = Math.max(0, Math.min(1, gammaCorrect(lin.b)));
|
|
29009
29490
|
const rByte = Math.round(r * 255);
|
|
29010
29491
|
const gByte = Math.round(g * 255);
|
|
29011
29492
|
const bByte = Math.round(b * 255);
|
|
@@ -29041,8 +29522,8 @@ function parseColor(s) {
|
|
|
29041
29522
|
return (r << 24 | g << 16 | b << 8 | a) >>> 0;
|
|
29042
29523
|
}
|
|
29043
29524
|
if (str === "transparent") return 0;
|
|
29044
|
-
if (str in
|
|
29045
|
-
return parseColor(
|
|
29525
|
+
if (str in NAMED_COLORS)
|
|
29526
|
+
return parseColor(NAMED_COLORS[str]);
|
|
29046
29527
|
console.warn(`parseColor: unrecognized color "${s}"`);
|
|
29047
29528
|
return 0;
|
|
29048
29529
|
}
|
|
@@ -31362,50 +31843,188 @@ var SEQUENTIAL_PALETTES = {
|
|
|
31362
31843
|
|
|
31363
31844
|
// src/color/categorical.ts
|
|
31364
31845
|
var TYCHO_11 = [
|
|
31365
|
-
"#0d80f2",
|
|
31366
|
-
// blue
|
|
31367
|
-
"#d7170b",
|
|
31368
|
-
// red
|
|
31369
|
-
"#21ba3a",
|
|
31370
|
-
// green
|
|
31371
|
-
"#eb4799",
|
|
31372
|
-
// magenta
|
|
31373
|
-
"#13a7ec",
|
|
31374
|
-
// cyan
|
|
31375
|
-
"#fe8a2b",
|
|
31376
|
-
// orange
|
|
31377
|
-
"#17cfcf",
|
|
31378
|
-
// teal
|
|
31379
|
-
"#a219e6",
|
|
31380
|
-
// purple
|
|
31381
|
-
"#ffc02b",
|
|
31382
|
-
// yellow
|
|
31383
|
-
"#63b215",
|
|
31384
|
-
// lime
|
|
31385
|
-
"#663399"
|
|
31386
|
-
// indigo
|
|
31387
|
-
];
|
|
31388
|
-
var TABLEAU_10 = [
|
|
31389
31846
|
"#4e79a7",
|
|
31390
31847
|
// Blue
|
|
31391
31848
|
"#f28e2b",
|
|
31392
31849
|
// Orange
|
|
31850
|
+
"#59a14f",
|
|
31851
|
+
// Green
|
|
31393
31852
|
"#e15759",
|
|
31394
31853
|
// Red
|
|
31854
|
+
"#b07aa1",
|
|
31855
|
+
// Purple
|
|
31856
|
+
"#9c755f",
|
|
31857
|
+
// Brown
|
|
31858
|
+
"#ff9da7",
|
|
31859
|
+
// Pink
|
|
31860
|
+
"#edc948",
|
|
31861
|
+
// Yellow
|
|
31395
31862
|
"#76b7b2",
|
|
31396
31863
|
// Teal
|
|
31397
|
-
"#
|
|
31864
|
+
"#6b8fd6",
|
|
31865
|
+
// Steel Blue
|
|
31866
|
+
"#c07bc4"
|
|
31867
|
+
// Magenta
|
|
31868
|
+
];
|
|
31869
|
+
var TYCHO_DARK_11 = [
|
|
31870
|
+
"#78a6d9",
|
|
31871
|
+
// Blue
|
|
31872
|
+
"#ffae54",
|
|
31873
|
+
// Orange
|
|
31874
|
+
"#7ddc7a",
|
|
31398
31875
|
// Green
|
|
31399
|
-
"#
|
|
31876
|
+
"#ff7a7a",
|
|
31877
|
+
// Red
|
|
31878
|
+
"#d29be0",
|
|
31879
|
+
// Purple
|
|
31880
|
+
"#c49a84",
|
|
31881
|
+
// Brown
|
|
31882
|
+
"#ffb3bf",
|
|
31883
|
+
// Pink
|
|
31884
|
+
"#ffe066",
|
|
31400
31885
|
// Yellow
|
|
31886
|
+
"#7fd6d0",
|
|
31887
|
+
// Teal
|
|
31888
|
+
"#8fb4ff",
|
|
31889
|
+
// Steel Blue
|
|
31890
|
+
"#e199eb"
|
|
31891
|
+
// Magenta
|
|
31892
|
+
];
|
|
31893
|
+
var TYCHO_ROBUST_11 = [
|
|
31894
|
+
"#4e79a7",
|
|
31895
|
+
// Blue
|
|
31896
|
+
"#f28e2b",
|
|
31897
|
+
// Orange
|
|
31898
|
+
"#2ca58d",
|
|
31899
|
+
// Teal-shifted green (more CB-safe)
|
|
31900
|
+
"#d13a3c",
|
|
31901
|
+
// Stronger red
|
|
31401
31902
|
"#b07aa1",
|
|
31402
31903
|
// Purple
|
|
31904
|
+
"#9c755f",
|
|
31905
|
+
// Brown
|
|
31403
31906
|
"#ff9da7",
|
|
31404
31907
|
// Pink
|
|
31405
|
-
"#
|
|
31908
|
+
"#e3c13b",
|
|
31909
|
+
// Darker yellow for contrast
|
|
31910
|
+
"#5fb8b2",
|
|
31911
|
+
// Teal
|
|
31912
|
+
"#6b8fd6",
|
|
31913
|
+
// Steel Blue
|
|
31914
|
+
"#c07bc4"
|
|
31915
|
+
// Magenta
|
|
31916
|
+
];
|
|
31917
|
+
var TYCHO_SOFT_11 = [
|
|
31918
|
+
"#8fb1d4",
|
|
31919
|
+
"#f6b878",
|
|
31920
|
+
"#8ecf86",
|
|
31921
|
+
"#f08a8b",
|
|
31922
|
+
"#d3a9cc",
|
|
31923
|
+
"#c3a492",
|
|
31924
|
+
"#ffc6cc",
|
|
31925
|
+
"#f3e08a",
|
|
31926
|
+
"#a8d8d4",
|
|
31927
|
+
"#a9c0ea",
|
|
31928
|
+
"#e0b4e4"
|
|
31929
|
+
];
|
|
31930
|
+
var TYCHO_SOFT_DARK_11 = [
|
|
31931
|
+
"#78a6d9",
|
|
31932
|
+
"#ffae54",
|
|
31933
|
+
"#7ddc7a",
|
|
31934
|
+
"#ff7a7a",
|
|
31935
|
+
"#d29be0",
|
|
31936
|
+
"#c49a84",
|
|
31937
|
+
"#ffb3bf",
|
|
31938
|
+
"#ffe066",
|
|
31939
|
+
"#7fd6d0",
|
|
31940
|
+
"#8fb4ff",
|
|
31941
|
+
"#e199eb"
|
|
31942
|
+
];
|
|
31943
|
+
var TYCHO_BOLD_11 = [
|
|
31944
|
+
"#2f6fb0",
|
|
31945
|
+
"#ff7a00",
|
|
31946
|
+
"#2fa23a",
|
|
31947
|
+
"#e02f2f",
|
|
31948
|
+
"#9b4db5",
|
|
31949
|
+
"#7f4f38",
|
|
31950
|
+
"#ff6f86",
|
|
31951
|
+
"#f2c200",
|
|
31952
|
+
"#2daaa3",
|
|
31953
|
+
"#4c79e0",
|
|
31954
|
+
"#b84ac6"
|
|
31955
|
+
];
|
|
31956
|
+
var TYCHO_BOLD_DARK_11 = [
|
|
31957
|
+
"#4f93ff",
|
|
31958
|
+
"#ff8c1a",
|
|
31959
|
+
"#33c94a",
|
|
31960
|
+
"#ff4f4f",
|
|
31961
|
+
"#b86bff",
|
|
31962
|
+
"#a86a4a",
|
|
31963
|
+
"#ff7f9e",
|
|
31964
|
+
"#ffd400",
|
|
31965
|
+
"#2ec9c1",
|
|
31966
|
+
"#6f9bff",
|
|
31967
|
+
"#cc5bd9"
|
|
31968
|
+
];
|
|
31969
|
+
var MATHEMATICA_10 = [
|
|
31970
|
+
"#5E81B5",
|
|
31971
|
+
"#E19C24",
|
|
31972
|
+
"#8FB131",
|
|
31973
|
+
"#EB6235",
|
|
31974
|
+
"#8778B3",
|
|
31975
|
+
"#C56E1A",
|
|
31976
|
+
"#5E9EC9",
|
|
31977
|
+
"#B23A3A",
|
|
31978
|
+
"#4C9F70",
|
|
31979
|
+
"#C979B7"
|
|
31980
|
+
];
|
|
31981
|
+
var TABLEAU_10 = [
|
|
31982
|
+
"#1f77b4",
|
|
31983
|
+
// Blue
|
|
31984
|
+
"#ff7f0e",
|
|
31985
|
+
// Orange
|
|
31986
|
+
"#2ca02c",
|
|
31987
|
+
// Green
|
|
31988
|
+
"#d62728",
|
|
31989
|
+
// Red
|
|
31990
|
+
"#9467bd",
|
|
31991
|
+
// Purple
|
|
31992
|
+
"#8c564b",
|
|
31406
31993
|
// Brown
|
|
31407
|
-
"#
|
|
31994
|
+
"#e377c2",
|
|
31995
|
+
// Pink
|
|
31996
|
+
"#7f7f7f",
|
|
31408
31997
|
// Gray
|
|
31998
|
+
"#bcbd22",
|
|
31999
|
+
// Olive
|
|
32000
|
+
"#17becf"
|
|
32001
|
+
// Cyan
|
|
32002
|
+
];
|
|
32003
|
+
var CUPERTINO_10 = [
|
|
32004
|
+
"#007AFF",
|
|
32005
|
+
"#FF9500",
|
|
32006
|
+
"#34C759",
|
|
32007
|
+
"#FF3B30",
|
|
32008
|
+
"#AF52DE",
|
|
32009
|
+
"#FF2D55",
|
|
32010
|
+
"#30B0C7",
|
|
32011
|
+
"#5856D6",
|
|
32012
|
+
"#A2845E",
|
|
32013
|
+
"#32ADE6",
|
|
32014
|
+
"#00C7BE"
|
|
32015
|
+
];
|
|
32016
|
+
var CUPERTINO_DARK_10 = [
|
|
32017
|
+
"#0A84FF",
|
|
32018
|
+
"#FF9F0A",
|
|
32019
|
+
"#30D158",
|
|
32020
|
+
"#FF453A",
|
|
32021
|
+
"#BF5AF2",
|
|
32022
|
+
"#FF375F",
|
|
32023
|
+
"#40C8E0",
|
|
32024
|
+
"#5E5CE6",
|
|
32025
|
+
"#AC8E68",
|
|
32026
|
+
"#64D2FF",
|
|
32027
|
+
"#00D1C1"
|
|
31409
32028
|
];
|
|
31410
32029
|
var KELLY_22 = [
|
|
31411
32030
|
"#fdfdfd",
|
|
@@ -31453,28 +32072,6 @@ var KELLY_22 = [
|
|
|
31453
32072
|
"#2b3514"
|
|
31454
32073
|
// Olive green
|
|
31455
32074
|
];
|
|
31456
|
-
var GRAPH_6 = [
|
|
31457
|
-
"#2d6fb4",
|
|
31458
|
-
// Blue
|
|
31459
|
-
"#c84442",
|
|
31460
|
-
// Red
|
|
31461
|
-
"#398c46",
|
|
31462
|
-
// Green
|
|
31463
|
-
"#fa7d19",
|
|
31464
|
-
// Orange
|
|
31465
|
-
"#00beff",
|
|
31466
|
-
// Light Blue
|
|
31467
|
-
"#6042a6"
|
|
31468
|
-
// Purple
|
|
31469
|
-
];
|
|
31470
|
-
var SPECTRUM_6 = [
|
|
31471
|
-
"#4148cc",
|
|
31472
|
-
"#db3c80",
|
|
31473
|
-
"#12b5b0",
|
|
31474
|
-
"#ff8c14",
|
|
31475
|
-
"#848aff",
|
|
31476
|
-
"#78e16e"
|
|
31477
|
-
];
|
|
31478
32075
|
var SPECTRUM_12 = [
|
|
31479
32076
|
"#4148cc",
|
|
31480
32077
|
"#db3c80",
|
|
@@ -31490,12 +32087,19 @@ var SPECTRUM_12 = [
|
|
|
31490
32087
|
"#00915f"
|
|
31491
32088
|
];
|
|
31492
32089
|
var CATEGORICAL_PALETTES = {
|
|
31493
|
-
tycho11: TYCHO_11,
|
|
31494
|
-
|
|
31495
|
-
|
|
31496
|
-
|
|
31497
|
-
|
|
31498
|
-
|
|
32090
|
+
"tycho11": TYCHO_11,
|
|
32091
|
+
"tycho-dark11": TYCHO_DARK_11,
|
|
32092
|
+
"tycho-robust11": TYCHO_ROBUST_11,
|
|
32093
|
+
"tycho-soft11": TYCHO_SOFT_11,
|
|
32094
|
+
"tycho-soft-dark11": TYCHO_SOFT_DARK_11,
|
|
32095
|
+
"tycho-bold11": TYCHO_BOLD_11,
|
|
32096
|
+
"tycho-bold-dark11": TYCHO_BOLD_DARK_11,
|
|
32097
|
+
"tableau10": TABLEAU_10,
|
|
32098
|
+
"kelly22": KELLY_22,
|
|
32099
|
+
"mathematica10": MATHEMATICA_10,
|
|
32100
|
+
"cupertino10": CUPERTINO_10,
|
|
32101
|
+
"cupertino-dark10": CUPERTINO_DARK_10,
|
|
32102
|
+
"spectrum12": SPECTRUM_12
|
|
31499
32103
|
};
|
|
31500
32104
|
|
|
31501
32105
|
// src/color/diverging-palettes.ts
|
|
@@ -39792,6 +40396,29 @@ var TRIGONOMETRY_LIBRARY = [
|
|
|
39792
40396
|
return ops[0].mul(options.engine.Pi.div(180)).evaluate(options);
|
|
39793
40397
|
}
|
|
39794
40398
|
},
|
|
40399
|
+
// DMS(degrees, minutes?, seconds?) — programmatic angle construction
|
|
40400
|
+
DMS: {
|
|
40401
|
+
signature: "(real, real?, real?) -> real",
|
|
40402
|
+
type: () => "finite_real",
|
|
40403
|
+
canonical: (ops, { engine: ce }) => {
|
|
40404
|
+
const deg = ops[0]?.re ?? NaN;
|
|
40405
|
+
const min3 = ops[1]?.re ?? 0;
|
|
40406
|
+
const sec2 = ops[2]?.re ?? 0;
|
|
40407
|
+
if (Number.isNaN(deg)) return ce._fn("DMS", ops);
|
|
40408
|
+
const total = deg + min3 / 60 + sec2 / 3600;
|
|
40409
|
+
return ce.function("Degrees", [ce.number(total)]);
|
|
40410
|
+
},
|
|
40411
|
+
evaluate: (ops, options) => {
|
|
40412
|
+
const ce = options.engine;
|
|
40413
|
+
const deg = ops[0]?.re ?? NaN;
|
|
40414
|
+
const min3 = ops[1]?.re ?? 0;
|
|
40415
|
+
const sec2 = ops[2]?.re ?? 0;
|
|
40416
|
+
if (Number.isNaN(deg)) return ce._fn("DMS", ops);
|
|
40417
|
+
const total = deg + min3 / 60 + sec2 / 3600;
|
|
40418
|
+
if (ce.angularUnit === "deg") return ce.number(total);
|
|
40419
|
+
return ce.number(total).div(180).mul(ce.Pi).evaluate(options);
|
|
40420
|
+
}
|
|
40421
|
+
},
|
|
39795
40422
|
// Hypot: sqrt(x*x + y*y)
|
|
39796
40423
|
Hypot: {
|
|
39797
40424
|
broadcastable: true,
|
|
@@ -39893,6 +40520,39 @@ var TRIGONOMETRY_LIBRARY = [
|
|
|
39893
40520
|
Arsech: trigFunction("Arsech", 6250),
|
|
39894
40521
|
Arccsc: trigFunction("Arccsc", 5650),
|
|
39895
40522
|
Coth: trigFunction("Coth", 6300),
|
|
40523
|
+
/** sinc(x) = sin(x)/x with sinc(0) = 1 (unnormalized cardinal sine) */
|
|
40524
|
+
Sinc: {
|
|
40525
|
+
complexity: 5100,
|
|
40526
|
+
broadcastable: true,
|
|
40527
|
+
signature: "(number) -> real",
|
|
40528
|
+
type: () => "finite_real",
|
|
40529
|
+
evaluate: ([x], { engine: ce }) => {
|
|
40530
|
+
if (!x || !isNumber(x)) return void 0;
|
|
40531
|
+
return ce.number(sinc(x.re));
|
|
40532
|
+
}
|
|
40533
|
+
},
|
|
40534
|
+
/** FresnelS(x) = ∫₀ˣ sin(πt²/2) dt — odd function, S(∞) = 1/2 */
|
|
40535
|
+
FresnelS: {
|
|
40536
|
+
complexity: 5200,
|
|
40537
|
+
broadcastable: true,
|
|
40538
|
+
signature: "(number) -> real",
|
|
40539
|
+
type: () => "finite_real",
|
|
40540
|
+
evaluate: ([x], { engine: ce }) => {
|
|
40541
|
+
if (!x || !isNumber(x)) return void 0;
|
|
40542
|
+
return ce.number(fresnelS(x.re));
|
|
40543
|
+
}
|
|
40544
|
+
},
|
|
40545
|
+
/** FresnelC(x) = ∫₀ˣ cos(πt²/2) dt — odd function, C(∞) = 1/2 */
|
|
40546
|
+
FresnelC: {
|
|
40547
|
+
complexity: 5200,
|
|
40548
|
+
broadcastable: true,
|
|
40549
|
+
signature: "(number) -> real",
|
|
40550
|
+
type: () => "finite_real",
|
|
40551
|
+
evaluate: ([x], { engine: ce }) => {
|
|
40552
|
+
if (!x || !isNumber(x)) return void 0;
|
|
40553
|
+
return ce.number(fresnelC(x.re));
|
|
40554
|
+
}
|
|
40555
|
+
},
|
|
39896
40556
|
/* converts (radius, angle) -> (x, y) */
|
|
39897
40557
|
// FromPolarCoordinates: {
|
|
39898
40558
|
// domain: 'Function',
|
|
@@ -39976,6 +40636,61 @@ var DEFINITIONS_ALGEBRA = [
|
|
|
39976
40636
|
}
|
|
39977
40637
|
];
|
|
39978
40638
|
|
|
40639
|
+
// src/compute-engine/latex-syntax/serialize-dms.ts
|
|
40640
|
+
function normalizeAngle(degrees, mode2) {
|
|
40641
|
+
if (mode2 === "none") return degrees;
|
|
40642
|
+
if (mode2 === "0...360") {
|
|
40643
|
+
const normalized = degrees % 360;
|
|
40644
|
+
return (normalized < 0 ? normalized + 360 : normalized) || 0;
|
|
40645
|
+
}
|
|
40646
|
+
if (mode2 === "-180...180") {
|
|
40647
|
+
let normalized = degrees % 360;
|
|
40648
|
+
if (normalized > 180) normalized -= 360;
|
|
40649
|
+
if (normalized < -180) normalized += 360;
|
|
40650
|
+
return normalized || 0;
|
|
40651
|
+
}
|
|
40652
|
+
return degrees;
|
|
40653
|
+
}
|
|
40654
|
+
function degreesToDMS(totalDegrees) {
|
|
40655
|
+
const sign3 = totalDegrees < 0 ? -1 : 1;
|
|
40656
|
+
const absDegrees = Math.abs(totalDegrees);
|
|
40657
|
+
const deg = Math.floor(absDegrees);
|
|
40658
|
+
const minDecimal = (absDegrees - deg) * 60;
|
|
40659
|
+
const min3 = Math.floor(minDecimal);
|
|
40660
|
+
const secDecimal = (minDecimal - min3) * 60;
|
|
40661
|
+
let sec2 = Math.round(secDecimal * 1e3) / 1e3;
|
|
40662
|
+
let finalMin = min3;
|
|
40663
|
+
let finalDeg = deg;
|
|
40664
|
+
if (sec2 >= 60) {
|
|
40665
|
+
sec2 = 0;
|
|
40666
|
+
finalMin++;
|
|
40667
|
+
}
|
|
40668
|
+
if (finalMin >= 60) {
|
|
40669
|
+
finalMin = 0;
|
|
40670
|
+
finalDeg++;
|
|
40671
|
+
}
|
|
40672
|
+
return {
|
|
40673
|
+
deg: sign3 * finalDeg || 0,
|
|
40674
|
+
// Avoid -0
|
|
40675
|
+
min: sign3 * finalMin || 0,
|
|
40676
|
+
// Avoid -0
|
|
40677
|
+
sec: sec2 === 0 ? 0 : sign3 * sec2
|
|
40678
|
+
};
|
|
40679
|
+
}
|
|
40680
|
+
function formatDMS(degrees) {
|
|
40681
|
+
const { deg, min: min3, sec: sec2 } = degreesToDMS(degrees);
|
|
40682
|
+
let result = `${deg}\xB0`;
|
|
40683
|
+
if (Math.abs(sec2) > 1e-3) {
|
|
40684
|
+
const secStr = sec2 % 1 === 0 ? sec2.toString() : sec2.toFixed(2);
|
|
40685
|
+
result += `${Math.abs(min3)}'${Math.abs(Number(secStr))}"`;
|
|
40686
|
+
} else if (Math.abs(min3) > 0) {
|
|
40687
|
+
result += `${Math.abs(min3)}'`;
|
|
40688
|
+
} else {
|
|
40689
|
+
result += `0'0"`;
|
|
40690
|
+
}
|
|
40691
|
+
return result;
|
|
40692
|
+
}
|
|
40693
|
+
|
|
39979
40694
|
// src/compute-engine/latex-syntax/dictionary/definitions-units.ts
|
|
39980
40695
|
function readBracedText(parser) {
|
|
39981
40696
|
if (!parser.match("<{>")) return null;
|
|
@@ -40143,6 +40858,29 @@ var DEFINITIONS_UNITS = [
|
|
|
40143
40858
|
const magnitude = operand(expr, 1);
|
|
40144
40859
|
const unit = operand(expr, 2);
|
|
40145
40860
|
if (magnitude === null || unit === null) return "";
|
|
40861
|
+
const unitSymbol2 = symbol(unit);
|
|
40862
|
+
const isAngleUnit = unitSymbol2 === "deg" || unitSymbol2 === "rad" || unitSymbol2 === "arcmin" || unitSymbol2 === "arcsec";
|
|
40863
|
+
const options = serializer.options;
|
|
40864
|
+
if (isAngleUnit && (options.dmsFormat || options.angleNormalization && options.angleNormalization !== "none")) {
|
|
40865
|
+
const magnitudeValue = machineValue(magnitude);
|
|
40866
|
+
if (magnitudeValue === null) {
|
|
40867
|
+
const magLatex2 = serializer.serialize(magnitude);
|
|
40868
|
+
const unitStr2 = unitToMathrm(unit);
|
|
40869
|
+
return joinLatex([magLatex2, "\\,", `\\mathrm{${unitStr2}}`]);
|
|
40870
|
+
}
|
|
40871
|
+
let degrees = magnitudeValue;
|
|
40872
|
+
if (unitSymbol2 === "rad") {
|
|
40873
|
+
degrees = degrees * 180 / Math.PI;
|
|
40874
|
+
} else if (unitSymbol2 === "arcmin") {
|
|
40875
|
+
degrees = degrees / 60;
|
|
40876
|
+
} else if (unitSymbol2 === "arcsec") {
|
|
40877
|
+
degrees = degrees / 3600;
|
|
40878
|
+
}
|
|
40879
|
+
if (options.angleNormalization && options.angleNormalization !== "none")
|
|
40880
|
+
degrees = normalizeAngle(degrees, options.angleNormalization);
|
|
40881
|
+
if (options.dmsFormat) return formatDMS(degrees);
|
|
40882
|
+
return `${degrees}\xB0`;
|
|
40883
|
+
}
|
|
40146
40884
|
const magLatex = serializer.serialize(magnitude);
|
|
40147
40885
|
const unitStr = unitToMathrm(unit);
|
|
40148
40886
|
return joinLatex([magLatex, "\\,", `\\mathrm{${unitStr}}`]);
|
|
@@ -40548,6 +41286,37 @@ function serializePower(serializer, expr) {
|
|
|
40548
41286
|
serializer.serialize(exp3)
|
|
40549
41287
|
);
|
|
40550
41288
|
}
|
|
41289
|
+
function parseDMS(parser, lhs) {
|
|
41290
|
+
parser.skipSpace();
|
|
41291
|
+
const savepoint = parser.index;
|
|
41292
|
+
const minExpr = parser.parseNumber();
|
|
41293
|
+
let minNum = null;
|
|
41294
|
+
let secNum = null;
|
|
41295
|
+
if (minExpr !== null && (parser.match("'") || parser.match("\\prime"))) {
|
|
41296
|
+
minNum = machineValue(minExpr);
|
|
41297
|
+
parser.skipSpace();
|
|
41298
|
+
const secSavepoint = parser.index;
|
|
41299
|
+
const secExpr = parser.parseNumber();
|
|
41300
|
+
if (secExpr !== null && (parser.match('"') || parser.match("\\doubleprime"))) {
|
|
41301
|
+
secNum = machineValue(secExpr);
|
|
41302
|
+
} else {
|
|
41303
|
+
parser.index = secSavepoint;
|
|
41304
|
+
}
|
|
41305
|
+
} else {
|
|
41306
|
+
parser.index = savepoint;
|
|
41307
|
+
return ["Degrees", lhs];
|
|
41308
|
+
}
|
|
41309
|
+
const degNum = machineValue(lhs);
|
|
41310
|
+
if (degNum !== null && minNum !== null) {
|
|
41311
|
+
let total = degNum + minNum / 60;
|
|
41312
|
+
if (secNum !== null) total += secNum / 3600;
|
|
41313
|
+
return ["Degrees", total];
|
|
41314
|
+
}
|
|
41315
|
+
const parts = [["Quantity", lhs, "deg"]];
|
|
41316
|
+
parts.push(["Quantity", minExpr, "arcmin"]);
|
|
41317
|
+
if (secNum !== null) parts.push(["Quantity", secNum, "arcsec"]);
|
|
41318
|
+
return ["Add", ...parts];
|
|
41319
|
+
}
|
|
40551
41320
|
var DEFINITIONS_ARITHMETIC = [
|
|
40552
41321
|
// Constants
|
|
40553
41322
|
{ name: "CatalanConstant", symbolTrigger: "G" },
|
|
@@ -40558,32 +41327,48 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
40558
41327
|
latexTrigger: ["\\degree"],
|
|
40559
41328
|
kind: "postfix",
|
|
40560
41329
|
precedence: 880,
|
|
40561
|
-
parse: (
|
|
41330
|
+
parse: (parser, lhs) => parseDMS(parser, lhs),
|
|
40562
41331
|
serialize: (serializer, expr) => {
|
|
40563
|
-
|
|
41332
|
+
const options = serializer.options;
|
|
41333
|
+
const arg = operand(expr, 1);
|
|
41334
|
+
if (options.dmsFormat || options.angleNormalization && options.angleNormalization !== "none") {
|
|
41335
|
+
const argValue = machineValue(arg);
|
|
41336
|
+
if (argValue !== null) {
|
|
41337
|
+
let degrees = argValue;
|
|
41338
|
+
if (options.angleNormalization && options.angleNormalization !== "none")
|
|
41339
|
+
degrees = normalizeAngle(degrees, options.angleNormalization);
|
|
41340
|
+
if (options.dmsFormat) return formatDMS(degrees);
|
|
41341
|
+
return `${degrees}\xB0`;
|
|
41342
|
+
}
|
|
41343
|
+
}
|
|
41344
|
+
return joinLatex([serializer.serialize(arg), "\\degree"]);
|
|
40564
41345
|
}
|
|
40565
41346
|
},
|
|
40566
41347
|
{
|
|
40567
41348
|
latexTrigger: ["\\degree"],
|
|
40568
41349
|
kind: "postfix",
|
|
40569
41350
|
precedence: 880,
|
|
40570
|
-
parse: (
|
|
41351
|
+
parse: (parser, lhs) => parseDMS(parser, lhs)
|
|
40571
41352
|
},
|
|
41353
|
+
// No `precedence` on these entries: the dictionary validator
|
|
41354
|
+
// (definitions.ts:947-968) rejects `precedence` on entries whose
|
|
41355
|
+
// `latexTrigger` starts with `^` or `_`, since their binding is
|
|
41356
|
+
// governed by LaTeX grouping rules, not operator precedence.
|
|
40572
41357
|
{
|
|
40573
41358
|
latexTrigger: ["^", "<{>", "\\circ", "<}>"],
|
|
40574
41359
|
kind: "postfix",
|
|
40575
|
-
parse: (
|
|
41360
|
+
parse: (parser, lhs) => parseDMS(parser, lhs)
|
|
40576
41361
|
},
|
|
40577
41362
|
{
|
|
40578
41363
|
latexTrigger: ["^", "\\circ"],
|
|
40579
41364
|
kind: "postfix",
|
|
40580
|
-
parse: (
|
|
41365
|
+
parse: (parser, lhs) => parseDMS(parser, lhs)
|
|
40581
41366
|
},
|
|
40582
41367
|
{
|
|
40583
41368
|
latexTrigger: ["\xB0"],
|
|
40584
41369
|
kind: "postfix",
|
|
40585
41370
|
precedence: 880,
|
|
40586
|
-
parse: (
|
|
41371
|
+
parse: (parser, lhs) => parseDMS(parser, lhs)
|
|
40587
41372
|
},
|
|
40588
41373
|
{
|
|
40589
41374
|
latexTrigger: ["\\ang"],
|
|
@@ -40592,6 +41377,28 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
40592
41377
|
return arg === null ? ["Degrees"] : ["Degrees", arg];
|
|
40593
41378
|
}
|
|
40594
41379
|
},
|
|
41380
|
+
{
|
|
41381
|
+
name: "DMS",
|
|
41382
|
+
serialize: (serializer, expr) => {
|
|
41383
|
+
const deg = machineValue(operand(expr, 1));
|
|
41384
|
+
const min3 = machineValue(operand(expr, 2));
|
|
41385
|
+
const sec2 = machineValue(operand(expr, 3));
|
|
41386
|
+
if (deg !== null) {
|
|
41387
|
+
const m = min3 ?? 0;
|
|
41388
|
+
const s = sec2 ?? 0;
|
|
41389
|
+
let result = `${deg}\xB0`;
|
|
41390
|
+
if (m !== 0 || s !== 0) result += `${m}'`;
|
|
41391
|
+
if (s !== 0) result += `${s}"`;
|
|
41392
|
+
return result;
|
|
41393
|
+
}
|
|
41394
|
+
const args = [];
|
|
41395
|
+
for (const i of [1, 2, 3]) {
|
|
41396
|
+
const op = operand(expr, i);
|
|
41397
|
+
if (op !== void 0) args.push(serializer.serialize(op));
|
|
41398
|
+
}
|
|
41399
|
+
return `\\operatorname{DMS}(${args.join(", ")})`;
|
|
41400
|
+
}
|
|
41401
|
+
},
|
|
40595
41402
|
{
|
|
40596
41403
|
latexTrigger: ["\\infty"],
|
|
40597
41404
|
parse: "PositiveInfinity"
|
|
@@ -41327,6 +42134,11 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
41327
42134
|
parse: parseBigOp("Sum", "Add", MULTIPLICATION_PRECEDENCE),
|
|
41328
42135
|
serialize: serializeBigOp("\\sum")
|
|
41329
42136
|
},
|
|
42137
|
+
{
|
|
42138
|
+
name: "Heaviside",
|
|
42139
|
+
symbolTrigger: "Heaviside",
|
|
42140
|
+
kind: "function"
|
|
42141
|
+
},
|
|
41330
42142
|
{
|
|
41331
42143
|
name: "Sign",
|
|
41332
42144
|
// As per ISO 80000-2, "signum" is 'sgn'
|
|
@@ -44212,6 +45024,21 @@ var DEFINITIONS_TRIGONOMETRY = [
|
|
|
44212
45024
|
name: "Sin",
|
|
44213
45025
|
latexTrigger: ["\\sin"],
|
|
44214
45026
|
parse: parseTrig("Sin")
|
|
45027
|
+
},
|
|
45028
|
+
{
|
|
45029
|
+
name: "Sinc",
|
|
45030
|
+
symbolTrigger: "sinc",
|
|
45031
|
+
kind: "function"
|
|
45032
|
+
},
|
|
45033
|
+
{
|
|
45034
|
+
name: "FresnelS",
|
|
45035
|
+
symbolTrigger: "FresnelS",
|
|
45036
|
+
kind: "function"
|
|
45037
|
+
},
|
|
45038
|
+
{
|
|
45039
|
+
name: "FresnelC",
|
|
45040
|
+
symbolTrigger: "FresnelC",
|
|
45041
|
+
kind: "function"
|
|
44215
45042
|
}
|
|
44216
45043
|
];
|
|
44217
45044
|
|
|
@@ -54096,6 +54923,17 @@ var BaseCompiler = class _BaseCompiler {
|
|
|
54096
54923
|
return `(${args.map((arg) => _BaseCompiler.compile(arg, target, prec)).join(", ")})`;
|
|
54097
54924
|
}
|
|
54098
54925
|
if (h === "Sum" || h === "Product") {
|
|
54926
|
+
const sumProdFn = target.functions?.(h);
|
|
54927
|
+
if (typeof sumProdFn === "function") {
|
|
54928
|
+
return sumProdFn(
|
|
54929
|
+
args,
|
|
54930
|
+
(expr) => _BaseCompiler.compile(expr, target),
|
|
54931
|
+
target
|
|
54932
|
+
);
|
|
54933
|
+
}
|
|
54934
|
+
if (typeof sumProdFn === "string") {
|
|
54935
|
+
return `${sumProdFn}(${args.map((x) => _BaseCompiler.compile(x, target)).join(", ")})`;
|
|
54936
|
+
}
|
|
54099
54937
|
return _BaseCompiler.compileLoop(h, args, target);
|
|
54100
54938
|
}
|
|
54101
54939
|
const op = target.operators?.(h);
|
|
@@ -54104,7 +54942,6 @@ var BaseCompiler = class _BaseCompiler {
|
|
|
54104
54942
|
if (!hasComplex) {
|
|
54105
54943
|
const isFunction4 = /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(op[0]);
|
|
54106
54944
|
if (isFunction4) {
|
|
54107
|
-
if (args === null) return `${op[0]}()`;
|
|
54108
54945
|
return `${op[0]}(${args.map((arg) => _BaseCompiler.compile(arg, target)).join(", ")})`;
|
|
54109
54946
|
} else {
|
|
54110
54947
|
if (args.every((x) => !x.isCollection)) {
|
|
@@ -54123,7 +54960,6 @@ var BaseCompiler = class _BaseCompiler {
|
|
|
54123
54960
|
}
|
|
54124
54961
|
return `(${result.join(") && (")})`;
|
|
54125
54962
|
}
|
|
54126
|
-
if (args === null) return "";
|
|
54127
54963
|
let resultStr;
|
|
54128
54964
|
if (args.length === 1) {
|
|
54129
54965
|
resultStr = `${op[0]}${_BaseCompiler.compile(args[0], target, op[1])}`;
|
|
@@ -54151,6 +54987,9 @@ var BaseCompiler = class _BaseCompiler {
|
|
|
54151
54987
|
return `${isSymbol2(args[0]) ? args[0].symbol : "_"} = ${_BaseCompiler.compile(args[1], target)}`;
|
|
54152
54988
|
if (h === "Return")
|
|
54153
54989
|
return `return ${_BaseCompiler.compile(args[0], target)}`;
|
|
54990
|
+
if (h === "Break") return "break";
|
|
54991
|
+
if (h === "Continue") return "continue";
|
|
54992
|
+
if (h === "Loop") return _BaseCompiler.compileForLoop(args, target);
|
|
54154
54993
|
if (h === "If") {
|
|
54155
54994
|
if (args.length !== 3) throw new Error("If: wrong number of arguments");
|
|
54156
54995
|
const fn2 = target.functions?.(h);
|
|
@@ -54158,7 +54997,6 @@ var BaseCompiler = class _BaseCompiler {
|
|
|
54158
54997
|
if (typeof fn2 === "function") {
|
|
54159
54998
|
return fn2(args, (expr) => _BaseCompiler.compile(expr, target), target);
|
|
54160
54999
|
}
|
|
54161
|
-
if (args === null) return `${fn2}()`;
|
|
54162
55000
|
return `${fn2}(${args.map((x) => _BaseCompiler.compile(x, target)).join(", ")})`;
|
|
54163
55001
|
}
|
|
54164
55002
|
return `((${_BaseCompiler.compile(args[0], target)}) ? (${_BaseCompiler.compile(
|
|
@@ -54166,6 +55004,29 @@ var BaseCompiler = class _BaseCompiler {
|
|
|
54166
55004
|
target
|
|
54167
55005
|
)}) : (${_BaseCompiler.compile(args[2], target)}))`;
|
|
54168
55006
|
}
|
|
55007
|
+
if (h === "Which") {
|
|
55008
|
+
if (args.length < 2 || args.length % 2 !== 0)
|
|
55009
|
+
throw new Error(
|
|
55010
|
+
"Which: expected even number of arguments (condition/value pairs)"
|
|
55011
|
+
);
|
|
55012
|
+
const fn2 = target.functions?.(h);
|
|
55013
|
+
if (fn2) {
|
|
55014
|
+
if (typeof fn2 === "function") {
|
|
55015
|
+
return fn2(args, (expr) => _BaseCompiler.compile(expr, target), target);
|
|
55016
|
+
}
|
|
55017
|
+
return `${fn2}(${args.map((x) => _BaseCompiler.compile(x, target)).join(", ")})`;
|
|
55018
|
+
}
|
|
55019
|
+
const compilePair = (i) => {
|
|
55020
|
+
if (i >= args.length) return "NaN";
|
|
55021
|
+
const cond = args[i];
|
|
55022
|
+
const val = args[i + 1];
|
|
55023
|
+
if (isSymbol2(cond) && cond.symbol === "True") {
|
|
55024
|
+
return `(${_BaseCompiler.compile(val, target)})`;
|
|
55025
|
+
}
|
|
55026
|
+
return `((${_BaseCompiler.compile(cond, target)}) ? (${_BaseCompiler.compile(val, target)}) : ${compilePair(i + 2)})`;
|
|
55027
|
+
};
|
|
55028
|
+
return compilePair(0);
|
|
55029
|
+
}
|
|
54169
55030
|
if (h === "Block") {
|
|
54170
55031
|
return _BaseCompiler.compileBlock(args, target);
|
|
54171
55032
|
}
|
|
@@ -54183,7 +55044,6 @@ var BaseCompiler = class _BaseCompiler {
|
|
|
54183
55044
|
}
|
|
54184
55045
|
return fn(args, (expr) => _BaseCompiler.compile(expr, target), target);
|
|
54185
55046
|
}
|
|
54186
|
-
if (args === null) return `${fn}()`;
|
|
54187
55047
|
return `${fn}(${args.map((x) => _BaseCompiler.compile(x, target)).join(", ")})`;
|
|
54188
55048
|
}
|
|
54189
55049
|
/**
|
|
@@ -54214,11 +55074,109 @@ var BaseCompiler = class _BaseCompiler {
|
|
|
54214
55074
|
`;${target.ws("\n")}`
|
|
54215
55075
|
)}${target.ws("\n")}})()`;
|
|
54216
55076
|
}
|
|
55077
|
+
/**
|
|
55078
|
+
* Compile a Loop expression with Element(index, Range(lo, hi)) indexing.
|
|
55079
|
+
* Generates: (() => { for (let i = lo; i <= hi; i++) { body } })()
|
|
55080
|
+
*
|
|
55081
|
+
* The loop counter is always a raw number. For targets that wrap numeric
|
|
55082
|
+
* values (e.g. interval-js wraps with `_IA.point()`), references to the
|
|
55083
|
+
* loop index inside the body are wrapped via `target.number`.
|
|
55084
|
+
*/
|
|
55085
|
+
static compileForLoop(args, target) {
|
|
55086
|
+
if (!args[0]) throw new Error("Loop: no body");
|
|
55087
|
+
if (!args[1]) throw new Error("Loop: no indexing set");
|
|
55088
|
+
const indexing = args[1];
|
|
55089
|
+
if (indexing.operator !== "Element" || !isFunction2(indexing))
|
|
55090
|
+
throw new Error("Loop: expected Element(index, Range(lo, hi))");
|
|
55091
|
+
const indexExpr = indexing.ops[0];
|
|
55092
|
+
const rangeExpr = indexing.ops[1];
|
|
55093
|
+
if (!isSymbol2(indexExpr)) throw new Error("Loop: index must be a symbol");
|
|
55094
|
+
if (rangeExpr.operator !== "Range" || !isFunction2(rangeExpr))
|
|
55095
|
+
throw new Error("Loop: expected Range(lo, hi)");
|
|
55096
|
+
const index = indexExpr.symbol;
|
|
55097
|
+
const lower = Math.floor(rangeExpr.ops[0].re);
|
|
55098
|
+
const upper = Math.floor(rangeExpr.ops[1].re);
|
|
55099
|
+
if (!Number.isFinite(lower) || !Number.isFinite(upper))
|
|
55100
|
+
throw new Error("Loop: bounds must be finite numbers");
|
|
55101
|
+
const needsWrap = target.number(0) !== "0";
|
|
55102
|
+
const bodyTarget = {
|
|
55103
|
+
...target,
|
|
55104
|
+
var: (id) => id === index ? needsWrap ? target.number(0).replace("0", index) : index : target.var(id)
|
|
55105
|
+
};
|
|
55106
|
+
const bodyStmts = _BaseCompiler.compileLoopBody(args[0], bodyTarget);
|
|
55107
|
+
return `(() => {${target.ws("\n")}for (let ${index} = ${lower}; ${index} <= ${upper}; ${index}++) {${target.ws("\n")}${bodyStmts}${target.ws("\n")}}${target.ws("\n")}})()`;
|
|
55108
|
+
}
|
|
55109
|
+
/**
|
|
55110
|
+
* Compile a loop body expression as statements (not wrapped in IIFE).
|
|
55111
|
+
* Handles Break, Continue, Return as statements, and If as if-else when
|
|
55112
|
+
* branches contain control flow.
|
|
55113
|
+
*/
|
|
55114
|
+
static compileLoopBody(expr, target) {
|
|
55115
|
+
if (isSymbol2(expr) && expr.symbol === "Nothing") return "";
|
|
55116
|
+
if (!isFunction2(expr)) return _BaseCompiler.compile(expr, target);
|
|
55117
|
+
const h = expr.operator;
|
|
55118
|
+
if (h === "Break") return "break";
|
|
55119
|
+
if (h === "Continue") return "continue";
|
|
55120
|
+
if (h === "Return")
|
|
55121
|
+
return `return ${_BaseCompiler.compile(expr.ops[0], target)}`;
|
|
55122
|
+
if (h === "If") {
|
|
55123
|
+
const condTarget = _BaseCompiler.scalarConditionTarget(target);
|
|
55124
|
+
const cond = _BaseCompiler.compile(expr.ops[0], condTarget);
|
|
55125
|
+
const thenBranch = _BaseCompiler.compileLoopBody(expr.ops[1], target);
|
|
55126
|
+
if (expr.ops.length > 2) {
|
|
55127
|
+
const elseBranch = _BaseCompiler.compileLoopBody(expr.ops[2], target);
|
|
55128
|
+
if (elseBranch)
|
|
55129
|
+
return `if (${cond}) { ${thenBranch} } else { ${elseBranch} }`;
|
|
55130
|
+
}
|
|
55131
|
+
return `if (${cond}) { ${thenBranch} }`;
|
|
55132
|
+
}
|
|
55133
|
+
if (h === "Block") {
|
|
55134
|
+
return expr.ops.map((s) => _BaseCompiler.compileLoopBody(s, target)).join("; ");
|
|
55135
|
+
}
|
|
55136
|
+
return _BaseCompiler.compile(expr, target);
|
|
55137
|
+
}
|
|
55138
|
+
/**
|
|
55139
|
+
* Create a target that compiles conditions as plain JS booleans.
|
|
55140
|
+
* Used inside `compileLoopBody` so that `if (cond)` gets a real boolean,
|
|
55141
|
+
* not an interval result object (which would always be truthy).
|
|
55142
|
+
*
|
|
55143
|
+
* Overrides comparison and logical operators to use plain JS, and
|
|
55144
|
+
* numeric values/variables to use raw numbers (the loop counter is
|
|
55145
|
+
* already a plain number).
|
|
55146
|
+
*/
|
|
55147
|
+
static scalarConditionTarget(target) {
|
|
55148
|
+
const SCALAR_OPS = {
|
|
55149
|
+
Less: ["<", 20],
|
|
55150
|
+
Greater: [">", 20],
|
|
55151
|
+
LessEqual: ["<=", 20],
|
|
55152
|
+
GreaterEqual: [">=", 20],
|
|
55153
|
+
Equal: ["===", 20],
|
|
55154
|
+
NotEqual: ["!==", 20],
|
|
55155
|
+
And: ["&&", 6],
|
|
55156
|
+
Or: ["||", 5],
|
|
55157
|
+
Not: ["!", 16]
|
|
55158
|
+
};
|
|
55159
|
+
if (target.number(0) === "0") return target;
|
|
55160
|
+
return {
|
|
55161
|
+
...target,
|
|
55162
|
+
number: (n) => String(n),
|
|
55163
|
+
var: (id) => {
|
|
55164
|
+
const resolved = target.var(id);
|
|
55165
|
+
if (!resolved) return void 0;
|
|
55166
|
+
const match2 = resolved.match(/^_IA\.point\((.+)\)$/);
|
|
55167
|
+
return match2 ? match2[1] : resolved;
|
|
55168
|
+
},
|
|
55169
|
+
operators: (op) => SCALAR_OPS[op] ?? target.operators?.(op),
|
|
55170
|
+
functions: (id) => {
|
|
55171
|
+
if (id in SCALAR_OPS) return void 0;
|
|
55172
|
+
return target.functions?.(id);
|
|
55173
|
+
}
|
|
55174
|
+
};
|
|
55175
|
+
}
|
|
54217
55176
|
/**
|
|
54218
55177
|
* Compile loop constructs (Sum/Product)
|
|
54219
55178
|
*/
|
|
54220
55179
|
static compileLoop(h, args, target) {
|
|
54221
|
-
if (args === null) throw new Error("Sum/Product: no arguments");
|
|
54222
55180
|
if (!args[0]) throw new Error("Sum/Product: no body");
|
|
54223
55181
|
const {
|
|
54224
55182
|
index,
|
|
@@ -54470,6 +55428,8 @@ var JAVASCRIPT_FUNCTIONS = {
|
|
|
54470
55428
|
GCD: "_SYS.gcd",
|
|
54471
55429
|
Integrate: (args, compile3, target) => compileIntegrate(args, compile3, target),
|
|
54472
55430
|
LCM: "_SYS.lcm",
|
|
55431
|
+
Product: (args, compile3, target) => compileSumProduct("Product", args, compile3, target),
|
|
55432
|
+
Sum: (args, compile3, target) => compileSumProduct("Sum", args, compile3, target),
|
|
54473
55433
|
Limit: (args, compile3) => `_SYS.limit(${compile3(args[0])}, ${compile3(args[1])})`,
|
|
54474
55434
|
Ln: (args, compile3) => {
|
|
54475
55435
|
if (BaseCompiler.isComplexValued(args[0]))
|
|
@@ -54621,7 +55581,11 @@ var JAVASCRIPT_FUNCTIONS = {
|
|
|
54621
55581
|
if (BaseCompiler.isComplexValued(arg)) return `_SYS.csech(${compile3(arg)})`;
|
|
54622
55582
|
return `1 / Math.cosh(${compile3(arg)})`;
|
|
54623
55583
|
},
|
|
55584
|
+
Heaviside: "_SYS.heaviside",
|
|
54624
55585
|
Sign: "Math.sign",
|
|
55586
|
+
Sinc: "_SYS.sinc",
|
|
55587
|
+
FresnelS: "_SYS.fresnelS",
|
|
55588
|
+
FresnelC: "_SYS.fresnelC",
|
|
54625
55589
|
Sin: (args, compile3) => {
|
|
54626
55590
|
if (BaseCompiler.isComplexValued(args[0]))
|
|
54627
55591
|
return `_SYS.csin(${compile3(args[0])})`;
|
|
@@ -55023,9 +55987,18 @@ var colorHelpers = {
|
|
|
55023
55987
|
const pos = t * (colors.length - 1);
|
|
55024
55988
|
const i = Math.floor(pos);
|
|
55025
55989
|
const frac = pos - i;
|
|
55026
|
-
if (frac === 0 || i >= colors.length - 1)
|
|
55027
|
-
|
|
55028
|
-
const
|
|
55990
|
+
if (frac === 0 || i >= colors.length - 1)
|
|
55991
|
+
return [...colors[Math.min(i, colors.length - 1)]];
|
|
55992
|
+
const rgb1 = {
|
|
55993
|
+
r: colors[i][0] * 255,
|
|
55994
|
+
g: colors[i][1] * 255,
|
|
55995
|
+
b: colors[i][2] * 255
|
|
55996
|
+
};
|
|
55997
|
+
const rgb2 = {
|
|
55998
|
+
r: colors[i + 1][0] * 255,
|
|
55999
|
+
g: colors[i + 1][1] * 255,
|
|
56000
|
+
b: colors[i + 1][2] * 255
|
|
56001
|
+
};
|
|
55029
56002
|
const c1 = rgbToOklch(rgb1);
|
|
55030
56003
|
const c2 = rgbToOklch(rgb2);
|
|
55031
56004
|
let dh = c2.H - c1.H;
|
|
@@ -55074,82 +56047,87 @@ var colorHelpers = {
|
|
|
55074
56047
|
return result;
|
|
55075
56048
|
}
|
|
55076
56049
|
};
|
|
56050
|
+
var SYS_HELPERS = {
|
|
56051
|
+
chop,
|
|
56052
|
+
factorial: factorial2,
|
|
56053
|
+
factorial2: factorial22,
|
|
56054
|
+
gamma: gamma2,
|
|
56055
|
+
gcd,
|
|
56056
|
+
heaviside: (x) => x < 0 ? 0 : x === 0 ? 0.5 : 1,
|
|
56057
|
+
integrate: (f, a, b) => monteCarloEstimate(f, a, b, 1e7).estimate,
|
|
56058
|
+
lcm,
|
|
56059
|
+
lngamma: gammaln2,
|
|
56060
|
+
limit,
|
|
56061
|
+
mean,
|
|
56062
|
+
median,
|
|
56063
|
+
variance,
|
|
56064
|
+
populationVariance,
|
|
56065
|
+
standardDeviation,
|
|
56066
|
+
populationStandardDeviation,
|
|
56067
|
+
kurtosis,
|
|
56068
|
+
skewness,
|
|
56069
|
+
mode,
|
|
56070
|
+
quartiles,
|
|
56071
|
+
interquartileRange,
|
|
56072
|
+
erf,
|
|
56073
|
+
erfc,
|
|
56074
|
+
erfInv,
|
|
56075
|
+
beta,
|
|
56076
|
+
digamma,
|
|
56077
|
+
trigamma,
|
|
56078
|
+
polygamma,
|
|
56079
|
+
zeta,
|
|
56080
|
+
lambertW,
|
|
56081
|
+
besselJ,
|
|
56082
|
+
besselY,
|
|
56083
|
+
besselI,
|
|
56084
|
+
besselK,
|
|
56085
|
+
airyAi,
|
|
56086
|
+
airyBi,
|
|
56087
|
+
sinc,
|
|
56088
|
+
fresnelS,
|
|
56089
|
+
fresnelC,
|
|
56090
|
+
binomial: choose,
|
|
56091
|
+
fibonacci,
|
|
56092
|
+
// Complex helpers
|
|
56093
|
+
csin: (z) => toRI(new Complex(z.re, z.im).sin()),
|
|
56094
|
+
ccos: (z) => toRI(new Complex(z.re, z.im).cos()),
|
|
56095
|
+
ctan: (z) => toRI(new Complex(z.re, z.im).tan()),
|
|
56096
|
+
casin: (z) => toRI(new Complex(z.re, z.im).asin()),
|
|
56097
|
+
cacos: (z) => toRI(new Complex(z.re, z.im).acos()),
|
|
56098
|
+
catan: (z) => toRI(new Complex(z.re, z.im).atan()),
|
|
56099
|
+
csinh: (z) => toRI(new Complex(z.re, z.im).sinh()),
|
|
56100
|
+
ccosh: (z) => toRI(new Complex(z.re, z.im).cosh()),
|
|
56101
|
+
ctanh: (z) => toRI(new Complex(z.re, z.im).tanh()),
|
|
56102
|
+
csqrt: (z) => toRI(new Complex(z.re, z.im).sqrt()),
|
|
56103
|
+
cexp: (z) => toRI(new Complex(z.re, z.im).exp()),
|
|
56104
|
+
cln: (z) => toRI(new Complex(z.re, z.im).log()),
|
|
56105
|
+
cpow: (z, w) => {
|
|
56106
|
+
const zz = typeof z === "number" ? new Complex(z, 0) : new Complex(z.re, z.im);
|
|
56107
|
+
const ww = typeof w === "number" ? new Complex(w, 0) : new Complex(w.re, w.im);
|
|
56108
|
+
return toRI(zz.pow(ww));
|
|
56109
|
+
},
|
|
56110
|
+
ccot: (z) => toRI(new Complex(z.re, z.im).cot()),
|
|
56111
|
+
csec: (z) => toRI(new Complex(z.re, z.im).sec()),
|
|
56112
|
+
ccsc: (z) => toRI(new Complex(z.re, z.im).csc()),
|
|
56113
|
+
ccoth: (z) => toRI(new Complex(z.re, z.im).coth()),
|
|
56114
|
+
csech: (z) => toRI(new Complex(z.re, z.im).sech()),
|
|
56115
|
+
ccsch: (z) => toRI(new Complex(z.re, z.im).csch()),
|
|
56116
|
+
cacot: (z) => toRI(new Complex(z.re, z.im).acot()),
|
|
56117
|
+
casec: (z) => toRI(new Complex(z.re, z.im).asec()),
|
|
56118
|
+
cacsc: (z) => toRI(new Complex(z.re, z.im).acsc()),
|
|
56119
|
+
cacoth: (z) => toRI(new Complex(z.re, z.im).acoth()),
|
|
56120
|
+
casech: (z) => toRI(new Complex(z.re, z.im).asech()),
|
|
56121
|
+
cacsch: (z) => toRI(new Complex(z.re, z.im).acsch()),
|
|
56122
|
+
cabs: (z) => new Complex(z.re, z.im).abs(),
|
|
56123
|
+
carg: (z) => new Complex(z.re, z.im).arg(),
|
|
56124
|
+
cconj: (z) => toRI(new Complex(z.re, z.im).conjugate()),
|
|
56125
|
+
cneg: (z) => ({ re: -z.re, im: -z.im }),
|
|
56126
|
+
// Color helpers
|
|
56127
|
+
...colorHelpers
|
|
56128
|
+
};
|
|
55077
56129
|
var ComputeEngineFunction = class extends Function {
|
|
55078
|
-
SYS =
|
|
55079
|
-
chop,
|
|
55080
|
-
factorial: factorial2,
|
|
55081
|
-
factorial2: factorial22,
|
|
55082
|
-
gamma: gamma2,
|
|
55083
|
-
gcd,
|
|
55084
|
-
integrate: (f, a, b) => monteCarloEstimate(f, a, b, 1e7).estimate,
|
|
55085
|
-
lcm,
|
|
55086
|
-
lngamma: gammaln2,
|
|
55087
|
-
limit,
|
|
55088
|
-
mean,
|
|
55089
|
-
median,
|
|
55090
|
-
variance,
|
|
55091
|
-
populationVariance,
|
|
55092
|
-
standardDeviation,
|
|
55093
|
-
populationStandardDeviation,
|
|
55094
|
-
kurtosis,
|
|
55095
|
-
skewness,
|
|
55096
|
-
mode,
|
|
55097
|
-
quartiles,
|
|
55098
|
-
interquartileRange,
|
|
55099
|
-
erf,
|
|
55100
|
-
erfc,
|
|
55101
|
-
erfInv,
|
|
55102
|
-
beta,
|
|
55103
|
-
digamma,
|
|
55104
|
-
trigamma,
|
|
55105
|
-
polygamma,
|
|
55106
|
-
zeta,
|
|
55107
|
-
lambertW,
|
|
55108
|
-
besselJ,
|
|
55109
|
-
besselY,
|
|
55110
|
-
besselI,
|
|
55111
|
-
besselK,
|
|
55112
|
-
airyAi,
|
|
55113
|
-
airyBi,
|
|
55114
|
-
binomial: choose,
|
|
55115
|
-
fibonacci,
|
|
55116
|
-
// Complex helpers
|
|
55117
|
-
csin: (z) => toRI(new Complex(z.re, z.im).sin()),
|
|
55118
|
-
ccos: (z) => toRI(new Complex(z.re, z.im).cos()),
|
|
55119
|
-
ctan: (z) => toRI(new Complex(z.re, z.im).tan()),
|
|
55120
|
-
casin: (z) => toRI(new Complex(z.re, z.im).asin()),
|
|
55121
|
-
cacos: (z) => toRI(new Complex(z.re, z.im).acos()),
|
|
55122
|
-
catan: (z) => toRI(new Complex(z.re, z.im).atan()),
|
|
55123
|
-
csinh: (z) => toRI(new Complex(z.re, z.im).sinh()),
|
|
55124
|
-
ccosh: (z) => toRI(new Complex(z.re, z.im).cosh()),
|
|
55125
|
-
ctanh: (z) => toRI(new Complex(z.re, z.im).tanh()),
|
|
55126
|
-
csqrt: (z) => toRI(new Complex(z.re, z.im).sqrt()),
|
|
55127
|
-
cexp: (z) => toRI(new Complex(z.re, z.im).exp()),
|
|
55128
|
-
cln: (z) => toRI(new Complex(z.re, z.im).log()),
|
|
55129
|
-
cpow: (z, w) => {
|
|
55130
|
-
const zz = typeof z === "number" ? new Complex(z, 0) : new Complex(z.re, z.im);
|
|
55131
|
-
const ww = typeof w === "number" ? new Complex(w, 0) : new Complex(w.re, w.im);
|
|
55132
|
-
return toRI(zz.pow(ww));
|
|
55133
|
-
},
|
|
55134
|
-
ccot: (z) => toRI(new Complex(z.re, z.im).cot()),
|
|
55135
|
-
csec: (z) => toRI(new Complex(z.re, z.im).sec()),
|
|
55136
|
-
ccsc: (z) => toRI(new Complex(z.re, z.im).csc()),
|
|
55137
|
-
ccoth: (z) => toRI(new Complex(z.re, z.im).coth()),
|
|
55138
|
-
csech: (z) => toRI(new Complex(z.re, z.im).sech()),
|
|
55139
|
-
ccsch: (z) => toRI(new Complex(z.re, z.im).csch()),
|
|
55140
|
-
cacot: (z) => toRI(new Complex(z.re, z.im).acot()),
|
|
55141
|
-
casec: (z) => toRI(new Complex(z.re, z.im).asec()),
|
|
55142
|
-
cacsc: (z) => toRI(new Complex(z.re, z.im).acsc()),
|
|
55143
|
-
cacoth: (z) => toRI(new Complex(z.re, z.im).acoth()),
|
|
55144
|
-
casech: (z) => toRI(new Complex(z.re, z.im).asech()),
|
|
55145
|
-
cacsch: (z) => toRI(new Complex(z.re, z.im).acsch()),
|
|
55146
|
-
cabs: (z) => new Complex(z.re, z.im).abs(),
|
|
55147
|
-
carg: (z) => new Complex(z.re, z.im).arg(),
|
|
55148
|
-
cconj: (z) => toRI(new Complex(z.re, z.im).conjugate()),
|
|
55149
|
-
cneg: (z) => ({ re: -z.re, im: -z.im }),
|
|
55150
|
-
// Color helpers
|
|
55151
|
-
...colorHelpers
|
|
55152
|
-
};
|
|
56130
|
+
SYS = SYS_HELPERS;
|
|
55153
56131
|
constructor(body, preamble = "") {
|
|
55154
56132
|
super(
|
|
55155
56133
|
"_SYS",
|
|
@@ -55167,81 +56145,7 @@ var ComputeEngineFunction = class extends Function {
|
|
|
55167
56145
|
}
|
|
55168
56146
|
};
|
|
55169
56147
|
var ComputeEngineFunctionLiteral = class extends Function {
|
|
55170
|
-
SYS =
|
|
55171
|
-
chop,
|
|
55172
|
-
factorial: factorial2,
|
|
55173
|
-
factorial2: factorial22,
|
|
55174
|
-
gamma: gamma2,
|
|
55175
|
-
gcd,
|
|
55176
|
-
integrate: (f, a, b) => monteCarloEstimate(f, a, b, 1e7).estimate,
|
|
55177
|
-
lcm,
|
|
55178
|
-
lngamma: gammaln2,
|
|
55179
|
-
limit,
|
|
55180
|
-
mean,
|
|
55181
|
-
median,
|
|
55182
|
-
variance,
|
|
55183
|
-
populationVariance,
|
|
55184
|
-
standardDeviation,
|
|
55185
|
-
populationStandardDeviation,
|
|
55186
|
-
kurtosis,
|
|
55187
|
-
skewness,
|
|
55188
|
-
mode,
|
|
55189
|
-
quartiles,
|
|
55190
|
-
interquartileRange,
|
|
55191
|
-
erf,
|
|
55192
|
-
erfc,
|
|
55193
|
-
erfInv,
|
|
55194
|
-
beta,
|
|
55195
|
-
digamma,
|
|
55196
|
-
trigamma,
|
|
55197
|
-
polygamma,
|
|
55198
|
-
zeta,
|
|
55199
|
-
lambertW,
|
|
55200
|
-
besselJ,
|
|
55201
|
-
besselY,
|
|
55202
|
-
besselI,
|
|
55203
|
-
besselK,
|
|
55204
|
-
airyAi,
|
|
55205
|
-
airyBi,
|
|
55206
|
-
binomial: choose,
|
|
55207
|
-
fibonacci,
|
|
55208
|
-
// Complex helpers
|
|
55209
|
-
csin: (z) => toRI(new Complex(z.re, z.im).sin()),
|
|
55210
|
-
ccos: (z) => toRI(new Complex(z.re, z.im).cos()),
|
|
55211
|
-
ctan: (z) => toRI(new Complex(z.re, z.im).tan()),
|
|
55212
|
-
casin: (z) => toRI(new Complex(z.re, z.im).asin()),
|
|
55213
|
-
cacos: (z) => toRI(new Complex(z.re, z.im).acos()),
|
|
55214
|
-
catan: (z) => toRI(new Complex(z.re, z.im).atan()),
|
|
55215
|
-
csinh: (z) => toRI(new Complex(z.re, z.im).sinh()),
|
|
55216
|
-
ccosh: (z) => toRI(new Complex(z.re, z.im).cosh()),
|
|
55217
|
-
ctanh: (z) => toRI(new Complex(z.re, z.im).tanh()),
|
|
55218
|
-
csqrt: (z) => toRI(new Complex(z.re, z.im).sqrt()),
|
|
55219
|
-
cexp: (z) => toRI(new Complex(z.re, z.im).exp()),
|
|
55220
|
-
cln: (z) => toRI(new Complex(z.re, z.im).log()),
|
|
55221
|
-
cpow: (z, w) => {
|
|
55222
|
-
const zz = typeof z === "number" ? new Complex(z, 0) : new Complex(z.re, z.im);
|
|
55223
|
-
const ww = typeof w === "number" ? new Complex(w, 0) : new Complex(w.re, w.im);
|
|
55224
|
-
return toRI(zz.pow(ww));
|
|
55225
|
-
},
|
|
55226
|
-
ccot: (z) => toRI(new Complex(z.re, z.im).cot()),
|
|
55227
|
-
csec: (z) => toRI(new Complex(z.re, z.im).sec()),
|
|
55228
|
-
ccsc: (z) => toRI(new Complex(z.re, z.im).csc()),
|
|
55229
|
-
ccoth: (z) => toRI(new Complex(z.re, z.im).coth()),
|
|
55230
|
-
csech: (z) => toRI(new Complex(z.re, z.im).sech()),
|
|
55231
|
-
ccsch: (z) => toRI(new Complex(z.re, z.im).csch()),
|
|
55232
|
-
cacot: (z) => toRI(new Complex(z.re, z.im).acot()),
|
|
55233
|
-
casec: (z) => toRI(new Complex(z.re, z.im).asec()),
|
|
55234
|
-
cacsc: (z) => toRI(new Complex(z.re, z.im).acsc()),
|
|
55235
|
-
cacoth: (z) => toRI(new Complex(z.re, z.im).acoth()),
|
|
55236
|
-
casech: (z) => toRI(new Complex(z.re, z.im).asech()),
|
|
55237
|
-
cacsch: (z) => toRI(new Complex(z.re, z.im).acsch()),
|
|
55238
|
-
cabs: (z) => new Complex(z.re, z.im).abs(),
|
|
55239
|
-
carg: (z) => new Complex(z.re, z.im).arg(),
|
|
55240
|
-
cconj: (z) => toRI(new Complex(z.re, z.im).conjugate()),
|
|
55241
|
-
cneg: (z) => ({ re: -z.re, im: -z.im }),
|
|
55242
|
-
// Color helpers
|
|
55243
|
-
...colorHelpers
|
|
55244
|
-
};
|
|
56148
|
+
SYS = SYS_HELPERS;
|
|
55245
56149
|
constructor(body, args) {
|
|
55246
56150
|
super("_SYS", ...args, `return ${body}`);
|
|
55247
56151
|
return new Proxy(this, {
|
|
@@ -55291,7 +56195,14 @@ var JavaScriptTarget = class {
|
|
|
55291
56195
|
};
|
|
55292
56196
|
}
|
|
55293
56197
|
compile(expr, options = {}) {
|
|
55294
|
-
const {
|
|
56198
|
+
const {
|
|
56199
|
+
operators,
|
|
56200
|
+
functions,
|
|
56201
|
+
vars,
|
|
56202
|
+
imports = [],
|
|
56203
|
+
preamble,
|
|
56204
|
+
realOnly
|
|
56205
|
+
} = options;
|
|
55295
56206
|
const unknowns = expr.unknowns;
|
|
55296
56207
|
let preambleImports = imports.map((x) => {
|
|
55297
56208
|
if (typeof x === "function") return x.toString();
|
|
@@ -55344,10 +56255,21 @@ var JavaScriptTarget = class {
|
|
|
55344
56255
|
},
|
|
55345
56256
|
preamble: (preamble ?? "") + preambleImports
|
|
55346
56257
|
});
|
|
55347
|
-
return compileToTarget(expr, target);
|
|
56258
|
+
return compileToTarget(expr, target, realOnly);
|
|
55348
56259
|
}
|
|
55349
56260
|
};
|
|
55350
|
-
function
|
|
56261
|
+
function wrapRealOnly(result) {
|
|
56262
|
+
if (!result.run) return result;
|
|
56263
|
+
const origRun = result.run;
|
|
56264
|
+
result.run = ((...args) => {
|
|
56265
|
+
const r = origRun(...args);
|
|
56266
|
+
if (typeof r === "object" && r !== null && "im" in r)
|
|
56267
|
+
return r.im === 0 ? r.re : NaN;
|
|
56268
|
+
return r;
|
|
56269
|
+
});
|
|
56270
|
+
return result;
|
|
56271
|
+
}
|
|
56272
|
+
function compileToTarget(expr, target, realOnly) {
|
|
55351
56273
|
if (expr.operator === "Function" && isFunction2(expr)) {
|
|
55352
56274
|
const args = expr.ops;
|
|
55353
56275
|
const params = args.slice(1).map((x) => isSymbol2(x) ? x.symbol : "_");
|
|
@@ -55377,12 +56299,68 @@ function compileToTarget(expr, target) {
|
|
|
55377
56299
|
}
|
|
55378
56300
|
const js = BaseCompiler.compile(expr, target);
|
|
55379
56301
|
const fn = new ComputeEngineFunction(js, target.preamble);
|
|
55380
|
-
|
|
56302
|
+
const result = {
|
|
55381
56303
|
target: "javascript",
|
|
55382
56304
|
success: true,
|
|
55383
56305
|
code: js,
|
|
55384
56306
|
run: fn
|
|
55385
56307
|
};
|
|
56308
|
+
return realOnly ? wrapRealOnly(result) : result;
|
|
56309
|
+
}
|
|
56310
|
+
var UNROLL_LIMIT = 100;
|
|
56311
|
+
function compileSumProduct(kind, args, _compile, target) {
|
|
56312
|
+
if (!args[0]) throw new Error(`${kind}: no body`);
|
|
56313
|
+
if (!args[1]) throw new Error(`${kind}: no indexing set`);
|
|
56314
|
+
const { index, lower, upper } = normalizeIndexingSet(args[1]);
|
|
56315
|
+
const isSum = kind === "Sum";
|
|
56316
|
+
const op = isSum ? "+" : "*";
|
|
56317
|
+
const identity = isSum ? "0" : "1";
|
|
56318
|
+
if (lower > upper) return identity;
|
|
56319
|
+
const termCount = upper - lower + 1;
|
|
56320
|
+
const bodyIsComplex = BaseCompiler.isComplexValued(args[0]);
|
|
56321
|
+
if (termCount <= UNROLL_LIMIT) {
|
|
56322
|
+
const terms = [];
|
|
56323
|
+
for (let k = lower; k <= upper; k++) {
|
|
56324
|
+
const innerTarget = {
|
|
56325
|
+
...target,
|
|
56326
|
+
var: (id) => id === index ? String(k) : target.var(id)
|
|
56327
|
+
};
|
|
56328
|
+
terms.push(`(${BaseCompiler.compile(args[0], innerTarget)})`);
|
|
56329
|
+
}
|
|
56330
|
+
if (!bodyIsComplex) {
|
|
56331
|
+
return `(${terms.join(` ${op} `)})`;
|
|
56332
|
+
}
|
|
56333
|
+
const temps = terms.map((_, i) => `_t${i}`);
|
|
56334
|
+
const assignments = terms.map((t, i) => `const ${temps[i]} = ${t}`).join("; ");
|
|
56335
|
+
if (isSum) {
|
|
56336
|
+
const reSum = temps.map((t) => `${t}.re`).join(" + ");
|
|
56337
|
+
const imSum = temps.map((t) => `${t}.im`).join(" + ");
|
|
56338
|
+
return `(() => { ${assignments}; return { re: ${reSum}, im: ${imSum} }; })()`;
|
|
56339
|
+
}
|
|
56340
|
+
let acc2 = temps[0];
|
|
56341
|
+
const parts = [assignments];
|
|
56342
|
+
for (let i = 1; i < temps.length; i++) {
|
|
56343
|
+
const prev = acc2;
|
|
56344
|
+
acc2 = `_p${i}`;
|
|
56345
|
+
parts.push(
|
|
56346
|
+
`const ${acc2} = { re: ${prev}.re * ${temps[i]}.re - ${prev}.im * ${temps[i]}.im, im: ${prev}.re * ${temps[i]}.im + ${prev}.im * ${temps[i]}.re }`
|
|
56347
|
+
);
|
|
56348
|
+
}
|
|
56349
|
+
return `(() => { ${parts.join("; ")}; return ${acc2}; })()`;
|
|
56350
|
+
}
|
|
56351
|
+
const bodyCode = BaseCompiler.compile(args[0], {
|
|
56352
|
+
...target,
|
|
56353
|
+
var: (id) => id === index ? index : target.var(id)
|
|
56354
|
+
});
|
|
56355
|
+
const acc = BaseCompiler.tempVar();
|
|
56356
|
+
if (bodyIsComplex) {
|
|
56357
|
+
const val = BaseCompiler.tempVar();
|
|
56358
|
+
if (isSum) {
|
|
56359
|
+
return `(() => { let ${acc} = { re: 0, im: 0 }; let ${index} = ${lower}; while (${index} <= ${upper}) { const ${val} = ${bodyCode}; ${acc} = { re: ${acc}.re + ${val}.re, im: ${acc}.im + ${val}.im }; ${index}++; } return ${acc}; })()`;
|
|
56360
|
+
}
|
|
56361
|
+
return `(() => { let ${acc} = { re: 1, im: 0 }; let ${index} = ${lower}; while (${index} <= ${upper}) { const ${val} = ${bodyCode}; ${acc} = { re: ${acc}.re * ${val}.re - ${acc}.im * ${val}.im, im: ${acc}.re * ${val}.im + ${acc}.im * ${val}.re }; ${index}++; } return ${acc}; })()`;
|
|
56362
|
+
}
|
|
56363
|
+
return `(() => { let ${acc} = ${identity}; let ${index} = ${lower}; while (${index} <= ${upper}) { ${acc} ${op}= ${bodyCode}; ${index}++; } return ${acc}; })()`;
|
|
55386
56364
|
}
|
|
55387
56365
|
function compileIntegrate(args, _, target) {
|
|
55388
56366
|
const { index, lower, upper } = normalizeIndexingSet(args[1]);
|
|
@@ -55598,13 +56576,11 @@ var GPU_FUNCTIONS = {
|
|
|
55598
56576
|
Truncate: "trunc",
|
|
55599
56577
|
// Complex-specific functions
|
|
55600
56578
|
Re: (args, compile3) => {
|
|
55601
|
-
if (BaseCompiler.isComplexValued(args[0]))
|
|
55602
|
-
return `(${compile3(args[0])}).x`;
|
|
56579
|
+
if (BaseCompiler.isComplexValued(args[0])) return `(${compile3(args[0])}).x`;
|
|
55603
56580
|
return compile3(args[0]);
|
|
55604
56581
|
},
|
|
55605
56582
|
Im: (args, compile3) => {
|
|
55606
|
-
if (BaseCompiler.isComplexValued(args[0]))
|
|
55607
|
-
return `(${compile3(args[0])}).y`;
|
|
56583
|
+
if (BaseCompiler.isComplexValued(args[0])) return `(${compile3(args[0])}).y`;
|
|
55608
56584
|
return "0.0";
|
|
55609
56585
|
},
|
|
55610
56586
|
Arg: (args, compile3) => {
|
|
@@ -57057,6 +58033,15 @@ function mod2(a, b) {
|
|
|
57057
58033
|
function remainder(a, b) {
|
|
57058
58034
|
return sub2(a, mul4(b, round2(div3(a, b))));
|
|
57059
58035
|
}
|
|
58036
|
+
function heaviside(x) {
|
|
58037
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
58038
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
58039
|
+
const [xVal] = unwrapped;
|
|
58040
|
+
if (xVal.lo > 0) return ok({ lo: 1, hi: 1 });
|
|
58041
|
+
if (xVal.hi < 0) return ok({ lo: 0, hi: 0 });
|
|
58042
|
+
if (xVal.lo === 0 && xVal.hi === 0) return ok({ lo: 0.5, hi: 0.5 });
|
|
58043
|
+
return { kind: "singular", at: 0 };
|
|
58044
|
+
}
|
|
57060
58045
|
function sign2(x) {
|
|
57061
58046
|
const unwrapped = unwrapOrPropagate(x);
|
|
57062
58047
|
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
@@ -57066,6 +58051,61 @@ function sign2(x) {
|
|
|
57066
58051
|
if (xVal.lo === 0 && xVal.hi === 0) return ok({ lo: 0, hi: 0 });
|
|
57067
58052
|
return { kind: "singular", at: 0 };
|
|
57068
58053
|
}
|
|
58054
|
+
var GAMMA_MIN_X = 1.4616321449683622;
|
|
58055
|
+
var GAMMA_MIN_Y = 0.8856031944108887;
|
|
58056
|
+
function gamma3(x) {
|
|
58057
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
58058
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
58059
|
+
const [xVal] = unwrapped;
|
|
58060
|
+
return _gamma(xVal);
|
|
58061
|
+
}
|
|
58062
|
+
function _gamma(x) {
|
|
58063
|
+
if (x.hi >= 0 && x.lo <= 0) {
|
|
58064
|
+
return { kind: "singular", at: 0 };
|
|
58065
|
+
}
|
|
58066
|
+
if (x.lo < 0) {
|
|
58067
|
+
const ceilLo = Math.ceil(x.lo);
|
|
58068
|
+
const floorHi = Math.floor(x.hi);
|
|
58069
|
+
if (ceilLo <= floorHi) {
|
|
58070
|
+
return { kind: "singular", at: ceilLo };
|
|
58071
|
+
}
|
|
58072
|
+
const gLo = gamma2(x.lo);
|
|
58073
|
+
const gHi = gamma2(x.hi);
|
|
58074
|
+
return ok({ lo: Math.min(gLo, gHi), hi: Math.max(gLo, gHi) });
|
|
58075
|
+
}
|
|
58076
|
+
if (x.lo >= GAMMA_MIN_X) {
|
|
58077
|
+
return ok({ lo: gamma2(x.lo), hi: gamma2(x.hi) });
|
|
58078
|
+
}
|
|
58079
|
+
if (x.hi <= GAMMA_MIN_X) {
|
|
58080
|
+
return ok({ lo: gamma2(x.hi), hi: gamma2(x.lo) });
|
|
58081
|
+
}
|
|
58082
|
+
return ok({
|
|
58083
|
+
lo: GAMMA_MIN_Y,
|
|
58084
|
+
hi: Math.max(gamma2(x.lo), gamma2(x.hi))
|
|
58085
|
+
});
|
|
58086
|
+
}
|
|
58087
|
+
function gammaln3(x) {
|
|
58088
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
58089
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
58090
|
+
const [xVal] = unwrapped;
|
|
58091
|
+
return _gammaln(xVal);
|
|
58092
|
+
}
|
|
58093
|
+
function _gammaln(x) {
|
|
58094
|
+
if (x.hi >= 0 && x.lo <= 0) {
|
|
58095
|
+
return { kind: "singular", at: 0 };
|
|
58096
|
+
}
|
|
58097
|
+
if (x.lo < 0) {
|
|
58098
|
+
const ceilLo = Math.ceil(x.lo);
|
|
58099
|
+
const floorHi = Math.floor(x.hi);
|
|
58100
|
+
if (ceilLo <= floorHi) {
|
|
58101
|
+
return { kind: "singular", at: ceilLo };
|
|
58102
|
+
}
|
|
58103
|
+
const gLo = gammaln2(x.lo);
|
|
58104
|
+
const gHi = gammaln2(x.hi);
|
|
58105
|
+
return ok({ lo: Math.min(gLo, gHi), hi: Math.max(gLo, gHi) });
|
|
58106
|
+
}
|
|
58107
|
+
return ok({ lo: gammaln2(x.lo), hi: gammaln2(x.hi) });
|
|
58108
|
+
}
|
|
57069
58109
|
|
|
57070
58110
|
// src/compute-engine/interval/trigonometric.ts
|
|
57071
58111
|
var TWO_PI = 2 * Math.PI;
|
|
@@ -57399,6 +58439,86 @@ function asech(x) {
|
|
|
57399
58439
|
}
|
|
57400
58440
|
return acosh2(div3(ok({ lo: 1, hi: 1 }), ok(xVal)));
|
|
57401
58441
|
}
|
|
58442
|
+
var SINC_EXTREMA = [
|
|
58443
|
+
4.49341,
|
|
58444
|
+
7.72525,
|
|
58445
|
+
10.90412,
|
|
58446
|
+
14.06619,
|
|
58447
|
+
17.22076,
|
|
58448
|
+
20.3713,
|
|
58449
|
+
23.51945,
|
|
58450
|
+
26.66605,
|
|
58451
|
+
29.8116,
|
|
58452
|
+
32.95639
|
|
58453
|
+
];
|
|
58454
|
+
var SINC_GLOBAL_LO = -0.21724;
|
|
58455
|
+
function sinc2(x) {
|
|
58456
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
58457
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
58458
|
+
const [xVal] = unwrapped;
|
|
58459
|
+
const sincVal = (t) => t === 0 ? 1 : Math.sin(t) / t;
|
|
58460
|
+
let lo = sincVal(xVal.lo);
|
|
58461
|
+
let hi = lo;
|
|
58462
|
+
const update = (v) => {
|
|
58463
|
+
if (v < lo) lo = v;
|
|
58464
|
+
if (v > hi) hi = v;
|
|
58465
|
+
};
|
|
58466
|
+
update(sincVal(xVal.hi));
|
|
58467
|
+
if (xVal.lo <= 0 && xVal.hi >= 0) {
|
|
58468
|
+
update(1);
|
|
58469
|
+
}
|
|
58470
|
+
const lastExtremum = SINC_EXTREMA[SINC_EXTREMA.length - 1];
|
|
58471
|
+
for (const e of SINC_EXTREMA) {
|
|
58472
|
+
if (e >= xVal.lo && e <= xVal.hi) update(sincVal(e));
|
|
58473
|
+
if (-e >= xVal.lo && -e <= xVal.hi) update(sincVal(-e));
|
|
58474
|
+
}
|
|
58475
|
+
if (Math.abs(xVal.lo) > lastExtremum || Math.abs(xVal.hi) > lastExtremum) {
|
|
58476
|
+
update(SINC_GLOBAL_LO);
|
|
58477
|
+
}
|
|
58478
|
+
return ok({ lo, hi });
|
|
58479
|
+
}
|
|
58480
|
+
var FRESNEL_S_EXTREMA = [];
|
|
58481
|
+
var FRESNEL_C_EXTREMA = [];
|
|
58482
|
+
for (let n = 1; n <= 20; n++) {
|
|
58483
|
+
FRESNEL_S_EXTREMA.push(Math.sqrt(2 * n));
|
|
58484
|
+
FRESNEL_C_EXTREMA.push(Math.sqrt(2 * n - 1));
|
|
58485
|
+
}
|
|
58486
|
+
function fresnelS2(x) {
|
|
58487
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
58488
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
58489
|
+
const [xVal] = unwrapped;
|
|
58490
|
+
let lo = fresnelS(xVal.lo);
|
|
58491
|
+
let hi = lo;
|
|
58492
|
+
const update = (v) => {
|
|
58493
|
+
if (v < lo) lo = v;
|
|
58494
|
+
if (v > hi) hi = v;
|
|
58495
|
+
};
|
|
58496
|
+
update(fresnelS(xVal.hi));
|
|
58497
|
+
if (xVal.lo <= 0 && xVal.hi >= 0) update(0);
|
|
58498
|
+
for (const e of FRESNEL_S_EXTREMA) {
|
|
58499
|
+
if (e >= xVal.lo && e <= xVal.hi) update(fresnelS(e));
|
|
58500
|
+
if (-e >= xVal.lo && -e <= xVal.hi) update(fresnelS(-e));
|
|
58501
|
+
}
|
|
58502
|
+
return ok({ lo, hi });
|
|
58503
|
+
}
|
|
58504
|
+
function fresnelC2(x) {
|
|
58505
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
58506
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
58507
|
+
const [xVal] = unwrapped;
|
|
58508
|
+
let lo = fresnelC(xVal.lo);
|
|
58509
|
+
let hi = lo;
|
|
58510
|
+
const update = (v) => {
|
|
58511
|
+
if (v < lo) lo = v;
|
|
58512
|
+
if (v > hi) hi = v;
|
|
58513
|
+
};
|
|
58514
|
+
update(fresnelC(xVal.hi));
|
|
58515
|
+
if (xVal.lo <= 0 && xVal.hi >= 0) update(0);
|
|
58516
|
+
for (const e of FRESNEL_C_EXTREMA) {
|
|
58517
|
+
if (e >= xVal.lo && e <= xVal.hi) update(fresnelC(e));
|
|
58518
|
+
if (-e >= xVal.lo && -e <= xVal.hi) update(fresnelC(-e));
|
|
58519
|
+
}
|
|
58520
|
+
return ok({ lo, hi });
|
|
58521
|
+
}
|
|
57402
58522
|
|
|
57403
58523
|
// src/compute-engine/interval/comparison.ts
|
|
57404
58524
|
function less(a, b) {
|
|
@@ -57552,7 +58672,10 @@ var IntervalArithmetic = {
|
|
|
57552
58672
|
max: max2,
|
|
57553
58673
|
mod: mod2,
|
|
57554
58674
|
remainder,
|
|
58675
|
+
heaviside,
|
|
57555
58676
|
sign: sign2,
|
|
58677
|
+
gamma: gamma3,
|
|
58678
|
+
gammaln: gammaln3,
|
|
57556
58679
|
// Trigonometric
|
|
57557
58680
|
sin: sin2,
|
|
57558
58681
|
cos: cos2,
|
|
@@ -57579,6 +58702,9 @@ var IntervalArithmetic = {
|
|
|
57579
58702
|
acoth,
|
|
57580
58703
|
acsch,
|
|
57581
58704
|
asech,
|
|
58705
|
+
sinc: sinc2,
|
|
58706
|
+
fresnelS: fresnelS2,
|
|
58707
|
+
fresnelC: fresnelC2,
|
|
57582
58708
|
// Comparison
|
|
57583
58709
|
less,
|
|
57584
58710
|
lessEqual,
|
|
@@ -57710,6 +58836,7 @@ var INTERVAL_JAVASCRIPT_FUNCTIONS = {
|
|
|
57710
58836
|
return `_IA.powInterval(${compile3(arg)}, _IA.div(_IA.point(1), ${compile3(exp3)}))`;
|
|
57711
58837
|
},
|
|
57712
58838
|
Round: (args, compile3) => `_IA.round(${compile3(args[0])})`,
|
|
58839
|
+
Heaviside: (args, compile3) => `_IA.heaviside(${compile3(args[0])})`,
|
|
57713
58840
|
Sign: (args, compile3) => `_IA.sign(${compile3(args[0])})`,
|
|
57714
58841
|
Sqrt: (args, compile3) => `_IA.sqrt(${compile3(args[0])})`,
|
|
57715
58842
|
Square: (args, compile3) => `_IA.square(${compile3(args[0])})`,
|
|
@@ -57739,6 +58866,11 @@ var INTERVAL_JAVASCRIPT_FUNCTIONS = {
|
|
|
57739
58866
|
Arcoth: (args, compile3) => `_IA.acoth(${compile3(args[0])})`,
|
|
57740
58867
|
Arcsch: (args, compile3) => `_IA.acsch(${compile3(args[0])})`,
|
|
57741
58868
|
Arsech: (args, compile3) => `_IA.asech(${compile3(args[0])})`,
|
|
58869
|
+
// Cardinal sine
|
|
58870
|
+
Sinc: (args, compile3) => `_IA.sinc(${compile3(args[0])})`,
|
|
58871
|
+
// Fresnel integrals
|
|
58872
|
+
FresnelS: (args, compile3) => `_IA.fresnelS(${compile3(args[0])})`,
|
|
58873
|
+
FresnelC: (args, compile3) => `_IA.fresnelC(${compile3(args[0])})`,
|
|
57742
58874
|
// Special functions
|
|
57743
58875
|
Gamma: (args, compile3) => `_IA.gamma(${compile3(args[0])})`,
|
|
57744
58876
|
GammaLn: (args, compile3) => `_IA.gammaln(${compile3(args[0])})`,
|
|
@@ -57748,6 +58880,9 @@ var INTERVAL_JAVASCRIPT_FUNCTIONS = {
|
|
|
57748
58880
|
// Mod / Remainder
|
|
57749
58881
|
Mod: (args, compile3) => `_IA.mod(${compile3(args[0])}, ${compile3(args[1])})`,
|
|
57750
58882
|
Remainder: (args, compile3) => `_IA.remainder(${compile3(args[0])}, ${compile3(args[1])})`,
|
|
58883
|
+
// Sum / Product
|
|
58884
|
+
Sum: (args, compile3, target) => compileIntervalSumProduct("Sum", args, compile3, target),
|
|
58885
|
+
Product: (args, compile3, target) => compileIntervalSumProduct("Product", args, compile3, target),
|
|
57751
58886
|
// Conditionals
|
|
57752
58887
|
If: (args, compile3) => {
|
|
57753
58888
|
if (args.length !== 3) throw new Error("If: wrong number of arguments");
|
|
@@ -57757,6 +58892,26 @@ var INTERVAL_JAVASCRIPT_FUNCTIONS = {
|
|
|
57757
58892
|
() => ${compile3(args[2])}
|
|
57758
58893
|
)`;
|
|
57759
58894
|
},
|
|
58895
|
+
Which: (args, compile3) => {
|
|
58896
|
+
if (args.length < 2 || args.length % 2 !== 0)
|
|
58897
|
+
throw new Error(
|
|
58898
|
+
"Which: expected even number of arguments (condition/value pairs)"
|
|
58899
|
+
);
|
|
58900
|
+
const buildPiecewise = (i) => {
|
|
58901
|
+
if (i >= args.length) return `{ kind: 'empty' }`;
|
|
58902
|
+
const cond = args[i];
|
|
58903
|
+
const val = args[i + 1];
|
|
58904
|
+
if (isSymbol2(cond) && cond.symbol === "True") {
|
|
58905
|
+
return compile3(val);
|
|
58906
|
+
}
|
|
58907
|
+
return `_IA.piecewise(
|
|
58908
|
+
${compile3(cond)},
|
|
58909
|
+
() => ${compile3(val)},
|
|
58910
|
+
() => ${buildPiecewise(i + 2)}
|
|
58911
|
+
)`;
|
|
58912
|
+
};
|
|
58913
|
+
return buildPiecewise(0);
|
|
58914
|
+
},
|
|
57760
58915
|
// Comparisons
|
|
57761
58916
|
Equal: (args, compile3) => `_IA.equal(${compile3(args[0])}, ${compile3(args[1])})`,
|
|
57762
58917
|
NotEqual: (args, compile3) => `_IA.notEqual(${compile3(args[0])}, ${compile3(args[1])})`,
|
|
@@ -57768,6 +58923,38 @@ var INTERVAL_JAVASCRIPT_FUNCTIONS = {
|
|
|
57768
58923
|
Or: (args, compile3) => `_IA.or(${compile3(args[0])}, ${compile3(args[1])})`,
|
|
57769
58924
|
Not: (args, compile3) => `_IA.not(${compile3(args[0])})`
|
|
57770
58925
|
};
|
|
58926
|
+
var INTERVAL_UNROLL_LIMIT = 100;
|
|
58927
|
+
function compileIntervalSumProduct(kind, args, _compile, target) {
|
|
58928
|
+
if (!args[0]) throw new Error(`${kind}: no body`);
|
|
58929
|
+
if (!args[1]) throw new Error(`${kind}: no indexing set`);
|
|
58930
|
+
const { index, lower, upper } = normalizeIndexingSet(args[1]);
|
|
58931
|
+
const isSum = kind === "Sum";
|
|
58932
|
+
const iaOp = isSum ? "_IA.add" : "_IA.mul";
|
|
58933
|
+
const identity = isSum ? "_IA.point(0)" : "_IA.point(1)";
|
|
58934
|
+
if (lower > upper) return identity;
|
|
58935
|
+
const termCount = upper - lower + 1;
|
|
58936
|
+
if (termCount <= INTERVAL_UNROLL_LIMIT) {
|
|
58937
|
+
const terms = [];
|
|
58938
|
+
for (let k = lower; k <= upper; k++) {
|
|
58939
|
+
const innerTarget = {
|
|
58940
|
+
...target,
|
|
58941
|
+
var: (id) => id === index ? `_IA.point(${k})` : target.var(id)
|
|
58942
|
+
};
|
|
58943
|
+
terms.push(BaseCompiler.compile(args[0], innerTarget));
|
|
58944
|
+
}
|
|
58945
|
+
let result = terms[terms.length - 1];
|
|
58946
|
+
for (let i = terms.length - 2; i >= 0; i--) {
|
|
58947
|
+
result = `${iaOp}(${terms[i]}, ${result})`;
|
|
58948
|
+
}
|
|
58949
|
+
return result;
|
|
58950
|
+
}
|
|
58951
|
+
const acc = BaseCompiler.tempVar();
|
|
58952
|
+
const bodyCode = BaseCompiler.compile(args[0], {
|
|
58953
|
+
...target,
|
|
58954
|
+
var: (id) => id === index ? `_IA.point(${index})` : target.var(id)
|
|
58955
|
+
});
|
|
58956
|
+
return `(() => { let ${acc} = ${identity}; for (let ${index} = ${lower}; ${index} <= ${upper}; ${index}++) { ${acc} = ${iaOp}(${acc}, ${bodyCode}); } return ${acc}; })()`;
|
|
58957
|
+
}
|
|
57771
58958
|
var ComputeEngineIntervalFunction = class extends Function {
|
|
57772
58959
|
IA = IntervalArithmetic;
|
|
57773
58960
|
constructor(body, preamble = "") {
|
|
@@ -57778,8 +58965,12 @@ var ComputeEngineIntervalFunction = class extends Function {
|
|
|
57778
58965
|
);
|
|
57779
58966
|
return new Proxy(this, {
|
|
57780
58967
|
apply: (target, thisArg, argumentsList) => {
|
|
57781
|
-
|
|
57782
|
-
|
|
58968
|
+
try {
|
|
58969
|
+
const processedArgs = argumentsList.map(processInput);
|
|
58970
|
+
return super.apply(thisArg, [this.IA, ...processedArgs]);
|
|
58971
|
+
} catch {
|
|
58972
|
+
return { kind: "entire" };
|
|
58973
|
+
}
|
|
57783
58974
|
},
|
|
57784
58975
|
get: (target, prop) => {
|
|
57785
58976
|
if (prop === "toString") return () => body;
|
|
@@ -57891,7 +59082,12 @@ var IntervalJavaScriptTarget = class {
|
|
|
57891
59082
|
}
|
|
57892
59083
|
};
|
|
57893
59084
|
function compileToIntervalTarget(expr, target) {
|
|
57894
|
-
|
|
59085
|
+
let js;
|
|
59086
|
+
try {
|
|
59087
|
+
js = BaseCompiler.compile(expr, target);
|
|
59088
|
+
} catch {
|
|
59089
|
+
return { target: "interval-js", success: false, code: "" };
|
|
59090
|
+
}
|
|
57895
59091
|
const fn = new ComputeEngineIntervalFunction(js, target.preamble);
|
|
57896
59092
|
return {
|
|
57897
59093
|
target: "interval-js",
|
|
@@ -64018,7 +65214,8 @@ var _Parser = class __Parser {
|
|
|
64018
65214
|
this.skipSpace();
|
|
64019
65215
|
let result = this.parseInfixOperator(lhs, until);
|
|
64020
65216
|
if (result === null && until.minPrec <= INVISIBLE_OP_PRECEDENCE) {
|
|
64021
|
-
|
|
65217
|
+
const opDefs = this.peekDefinitions("operator");
|
|
65218
|
+
if (opDefs.length === 0 || opDefs.every(([def]) => def.latexTrigger === "\\text")) {
|
|
64022
65219
|
const rhs = this.parseExpression({
|
|
64023
65220
|
...until,
|
|
64024
65221
|
minPrec: INVISIBLE_OP_PRECEDENCE + 1
|
|
@@ -67553,10 +68750,10 @@ var ComputeEngine = class _ComputeEngine {
|
|
|
67553
68750
|
_setComputeEngineClass(ComputeEngine);
|
|
67554
68751
|
|
|
67555
68752
|
// src/compute-engine.ts
|
|
67556
|
-
var version = "0.51.
|
|
68753
|
+
var version = "0.51.1";
|
|
67557
68754
|
globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
|
|
67558
68755
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
67559
|
-
version: "0.51.
|
|
68756
|
+
version: "0.51.1"
|
|
67560
68757
|
};
|
|
67561
68758
|
export {
|
|
67562
68759
|
BaseCompiler,
|