@cortex-js/compute-engine 0.35.4 → 0.35.6
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 +248 -56
- package/dist/compute-engine.min.esm.js +111 -42
- package/dist/compute-engine.min.umd.js +111 -42
- package/dist/compute-engine.umd.js +248 -56
- 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/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/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/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/polynomials.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/terms.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/trigonometry.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 +1 -1
- package/dist/types/compute-engine/compilation/glsl-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 +3 -1
- package/dist/types/compute-engine/compilation/javascript-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/types.d.ts +1 -1
- package/dist/types/compute-engine/cost-function.d.ts +1 -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 +1 -1
- 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 +5 -3
- package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -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.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-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 +1 -1
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -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/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/invisible-operator.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-utils.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/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/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 +1 -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/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/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-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-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.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 +3 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Compute Engine 0.35.
|
|
1
|
+
/** Compute Engine 0.35.6 */
|
|
2
2
|
(function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ComputeEngine = {}));})(this, (function (exports) { 'use strict';
|
|
3
3
|
var ComputeEngine = (() => {
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -15099,22 +15099,22 @@ var ComputeEngine = (() => {
|
|
|
15099
15099
|
if (dividendDeg < divisorDeg) {
|
|
15100
15100
|
return [ce.Zero, dividend];
|
|
15101
15101
|
}
|
|
15102
|
-
const
|
|
15102
|
+
const remainder2 = dividendCoeffs.map((c) => c);
|
|
15103
15103
|
const quotientCoeffs = new Array(
|
|
15104
15104
|
dividendDeg - divisorDeg + 1
|
|
15105
15105
|
).fill(ce.Zero);
|
|
15106
15106
|
const leadingDivisor = divisorCoeffs[divisorDeg];
|
|
15107
15107
|
for (let i = dividendDeg; i >= divisorDeg; i--) {
|
|
15108
|
-
if (
|
|
15109
|
-
const quotientCoef =
|
|
15108
|
+
if (remainder2[i].is(0)) continue;
|
|
15109
|
+
const quotientCoef = remainder2[i].div(leadingDivisor);
|
|
15110
15110
|
quotientCoeffs[i - divisorDeg] = quotientCoef;
|
|
15111
15111
|
for (let j = 0; j <= divisorDeg; j++) {
|
|
15112
15112
|
const product = quotientCoef.mul(divisorCoeffs[j]);
|
|
15113
|
-
|
|
15113
|
+
remainder2[i - divisorDeg + j] = remainder2[i - divisorDeg + j].sub(product);
|
|
15114
15114
|
}
|
|
15115
15115
|
}
|
|
15116
15116
|
const quotient = fromCoefficients(quotientCoeffs, variable);
|
|
15117
|
-
const remainderPoly = fromCoefficients(
|
|
15117
|
+
const remainderPoly = fromCoefficients(remainder2, variable);
|
|
15118
15118
|
return [quotient, remainderPoly];
|
|
15119
15119
|
}
|
|
15120
15120
|
function polynomialGCD(a, b, variable) {
|
|
@@ -15141,9 +15141,9 @@ var ComputeEngine = (() => {
|
|
|
15141
15141
|
if (!divResult) {
|
|
15142
15142
|
return ce.One;
|
|
15143
15143
|
}
|
|
15144
|
-
const [,
|
|
15144
|
+
const [, remainder2] = divResult;
|
|
15145
15145
|
p = q;
|
|
15146
|
-
q =
|
|
15146
|
+
q = remainder2;
|
|
15147
15147
|
}
|
|
15148
15148
|
return makeMonic(p, variable);
|
|
15149
15149
|
}
|
|
@@ -20814,6 +20814,7 @@ var ComputeEngine = (() => {
|
|
|
20814
20814
|
});
|
|
20815
20815
|
} catch (e) {
|
|
20816
20816
|
if (options?.fallback ?? true) {
|
|
20817
|
+
console.warn(`Compilation fallback for "${this.operator}": ${e.message}`);
|
|
20817
20818
|
const { applicableN1: applicableN12 } = (init_function_utils(), __toCommonJS(function_utils_exports));
|
|
20818
20819
|
return applicableN12(this);
|
|
20819
20820
|
}
|
|
@@ -23826,7 +23827,8 @@ ${e.message}`);
|
|
|
23826
23827
|
}
|
|
23827
23828
|
if (type2.kind === "list" || type2.kind === "set" || type2.kind === "tuple")
|
|
23828
23829
|
return true;
|
|
23829
|
-
if (type2.kind === "union")
|
|
23830
|
+
if (type2.kind === "union")
|
|
23831
|
+
return type2.types.some((t) => typeCouldBeCollection(t));
|
|
23830
23832
|
return false;
|
|
23831
23833
|
}
|
|
23832
23834
|
function typeCouldBeNumericCollection(type2) {
|
|
@@ -24634,6 +24636,16 @@ ${lines.join("\n")}`;
|
|
|
24634
24636
|
return engine.function("Power", [engine.E, ...args]);
|
|
24635
24637
|
}
|
|
24636
24638
|
},
|
|
24639
|
+
Exp2: {
|
|
24640
|
+
description: "Base-2 exponential: 2^x",
|
|
24641
|
+
complexity: 3500,
|
|
24642
|
+
broadcastable: true,
|
|
24643
|
+
signature: "(number) -> number",
|
|
24644
|
+
canonical: (args, { engine }) => {
|
|
24645
|
+
args = checkNumericArgs(engine, args, 1);
|
|
24646
|
+
return engine.function("Power", [engine.number(2), ...args]);
|
|
24647
|
+
}
|
|
24648
|
+
},
|
|
24637
24649
|
Factorial: {
|
|
24638
24650
|
description: "Factorial function: the product of all positive integers less than or equal to n",
|
|
24639
24651
|
wikidata: "Q120976",
|
|
@@ -24723,6 +24735,22 @@ ${lines.join("\n")}`;
|
|
|
24723
24735
|
(z) => z.floor(0)
|
|
24724
24736
|
)
|
|
24725
24737
|
},
|
|
24738
|
+
Fract: {
|
|
24739
|
+
description: "Fractional part of a number: x - floor(x)",
|
|
24740
|
+
complexity: 1250,
|
|
24741
|
+
broadcastable: true,
|
|
24742
|
+
signature: "(number) -> number",
|
|
24743
|
+
sgn: ([x]) => {
|
|
24744
|
+
if (x.isNonNegative) return "non-negative";
|
|
24745
|
+
return void 0;
|
|
24746
|
+
},
|
|
24747
|
+
evaluate: ([x]) => apply(
|
|
24748
|
+
x,
|
|
24749
|
+
(x2) => x2 - Math.floor(x2),
|
|
24750
|
+
(x2) => x2.sub(x2.floor()),
|
|
24751
|
+
(z) => z.sub(z.floor(0))
|
|
24752
|
+
)
|
|
24753
|
+
},
|
|
24726
24754
|
Gamma: {
|
|
24727
24755
|
wikidata: "Q190573",
|
|
24728
24756
|
complexity: 8e3,
|
|
@@ -24938,6 +24966,22 @@ ${lines.join("\n")}`;
|
|
|
24938
24966
|
sgn: ([x]) => lnSign(x),
|
|
24939
24967
|
canonical: ([x], { engine }) => engine._fn("Log", [x])
|
|
24940
24968
|
},
|
|
24969
|
+
Log10: {
|
|
24970
|
+
description: "Base-10 Logarithm",
|
|
24971
|
+
complexity: 4100,
|
|
24972
|
+
broadcastable: true,
|
|
24973
|
+
signature: "(number) -> number",
|
|
24974
|
+
sgn: ([x]) => lnSign(x),
|
|
24975
|
+
canonical: ([x], { engine }) => engine._fn("Log", [x])
|
|
24976
|
+
},
|
|
24977
|
+
Log2: {
|
|
24978
|
+
description: "Base-2 Logarithm",
|
|
24979
|
+
complexity: 4100,
|
|
24980
|
+
broadcastable: true,
|
|
24981
|
+
signature: "(number) -> number",
|
|
24982
|
+
sgn: ([x]) => lnSign(x),
|
|
24983
|
+
canonical: ([x], { engine }) => engine._fn("Log", [x, engine.number(2)])
|
|
24984
|
+
},
|
|
24941
24985
|
Mod: {
|
|
24942
24986
|
description: "Modulo",
|
|
24943
24987
|
wikidata: "Q1799665",
|
|
@@ -25180,6 +25224,18 @@ ${lines.join("\n")}`;
|
|
|
25180
25224
|
},
|
|
25181
25225
|
evaluate: ([x, n], { numericApproximation }) => root(x, n, { numericApproximation })
|
|
25182
25226
|
},
|
|
25227
|
+
Remainder: {
|
|
25228
|
+
description: "IEEE remainder: the signed remainder after dividing x by y, with the quotient rounded to the nearest integer",
|
|
25229
|
+
complexity: 2500,
|
|
25230
|
+
broadcastable: true,
|
|
25231
|
+
signature: "(number, number) -> number",
|
|
25232
|
+
evaluate: ([a, b]) => apply2(
|
|
25233
|
+
a,
|
|
25234
|
+
b,
|
|
25235
|
+
(a2, b2) => a2 - b2 * Math.round(a2 / b2),
|
|
25236
|
+
(a2, b2) => a2.sub(b2.mul(a2.div(b2).round()))
|
|
25237
|
+
)
|
|
25238
|
+
},
|
|
25183
25239
|
Round: {
|
|
25184
25240
|
complexity: 1250,
|
|
25185
25241
|
broadcastable: true,
|
|
@@ -25311,6 +25367,19 @@ ${lines.join("\n")}`;
|
|
|
25311
25367
|
const rest = args.slice(1);
|
|
25312
25368
|
return canonicalAdd(engine, [first, ...rest.map((x) => x.neg())]);
|
|
25313
25369
|
}
|
|
25370
|
+
},
|
|
25371
|
+
Truncate: {
|
|
25372
|
+
description: "Rounds a number towards zero (removes the fractional part)",
|
|
25373
|
+
complexity: 1250,
|
|
25374
|
+
broadcastable: true,
|
|
25375
|
+
signature: "(number) -> integer",
|
|
25376
|
+
sgn: ([x]) => x.sgn,
|
|
25377
|
+
evaluate: ([x]) => apply(
|
|
25378
|
+
x,
|
|
25379
|
+
Math.trunc,
|
|
25380
|
+
(x2) => x2.trunc(),
|
|
25381
|
+
(z) => z.trunc(0)
|
|
25382
|
+
)
|
|
25314
25383
|
}
|
|
25315
25384
|
},
|
|
25316
25385
|
{
|
|
@@ -32482,26 +32551,23 @@ ${lines.join("\n")}`;
|
|
|
32482
32551
|
for (let i = 0; i < n; i++) {
|
|
32483
32552
|
const u = Math.random();
|
|
32484
32553
|
const x = Math.tan(Math.PI * (u - 0.5));
|
|
32485
|
-
const
|
|
32486
|
-
const val = f(x) / jacobian;
|
|
32554
|
+
const val = f(x) * Math.PI * (1 + x * x);
|
|
32487
32555
|
sum2 += val;
|
|
32488
32556
|
sumSq += val * val;
|
|
32489
32557
|
}
|
|
32490
32558
|
} else if (a === -Infinity) {
|
|
32491
32559
|
for (let i = 0; i < n; i++) {
|
|
32492
32560
|
const u = Math.random();
|
|
32493
|
-
const x = b
|
|
32494
|
-
const
|
|
32495
|
-
const val = f(x) / jacobian;
|
|
32561
|
+
const x = b + Math.log(u);
|
|
32562
|
+
const val = f(x) / u;
|
|
32496
32563
|
sum2 += val;
|
|
32497
32564
|
sumSq += val * val;
|
|
32498
32565
|
}
|
|
32499
32566
|
} else if (b === Infinity) {
|
|
32500
32567
|
for (let i = 0; i < n; i++) {
|
|
32501
32568
|
const u = Math.random();
|
|
32502
|
-
const x = a
|
|
32503
|
-
const
|
|
32504
|
-
const val = f(x) / jacobian;
|
|
32569
|
+
const x = a - Math.log(u);
|
|
32570
|
+
const val = f(x) / u;
|
|
32505
32571
|
sum2 += val;
|
|
32506
32572
|
sumSq += val * val;
|
|
32507
32573
|
}
|
|
@@ -32515,7 +32581,7 @@ ${lines.join("\n")}`;
|
|
|
32515
32581
|
const mean2 = sum2 / n;
|
|
32516
32582
|
const variance2 = (sumSq - n * mean2 * mean2) / (n - 1);
|
|
32517
32583
|
const stdError = Math.sqrt(variance2 / n);
|
|
32518
|
-
const scale = b - a;
|
|
32584
|
+
const scale = isFinite(a) && isFinite(b) ? b - a : 1;
|
|
32519
32585
|
const estimate = mean2 * scale;
|
|
32520
32586
|
const error = stdError * scale;
|
|
32521
32587
|
const rounded = roundEstimateToError(estimate, error);
|
|
@@ -32617,7 +32683,7 @@ ${lines.join("\n")}`;
|
|
|
32617
32683
|
]
|
|
32618
32684
|
],
|
|
32619
32685
|
// d/dx ln(Γ(x)) = ψ(x) (digamma function)
|
|
32620
|
-
|
|
32686
|
+
GammaLn: ["Digamma", "_"],
|
|
32621
32687
|
// d/dx ψ(x) = ψ₁(x) (trigamma function)
|
|
32622
32688
|
// https://en.wikipedia.org/wiki/Trigamma_function
|
|
32623
32689
|
Digamma: ["Trigamma", "_"],
|
|
@@ -34095,10 +34161,10 @@ ${lines.join("\n")}`;
|
|
|
34095
34161
|
if (numDeg >= 0 && denDeg >= 0 && numDeg >= denDeg) {
|
|
34096
34162
|
const divResult = polynomialDivide(fn.op1, fn.op2, index);
|
|
34097
34163
|
if (divResult) {
|
|
34098
|
-
const [quotient,
|
|
34164
|
+
const [quotient, remainder2] = divResult;
|
|
34099
34165
|
const quotientIntegral = antiderivative(quotient, index);
|
|
34100
|
-
if (!
|
|
34101
|
-
const remainderFraction =
|
|
34166
|
+
if (!remainder2.is(0)) {
|
|
34167
|
+
const remainderFraction = remainder2.div(fn.op2);
|
|
34102
34168
|
const remainderIntegral = antiderivative(remainderFraction, index);
|
|
34103
34169
|
return add3(quotientIntegral, remainderIntegral);
|
|
34104
34170
|
}
|
|
@@ -34353,8 +34419,8 @@ ${lines.join("\n")}`;
|
|
|
34353
34419
|
const linearFactor = ce.symbol(index).sub(r);
|
|
34354
34420
|
const quotient = polynomialDivide(denominator, linearFactor, index);
|
|
34355
34421
|
if (quotient) {
|
|
34356
|
-
const [quad,
|
|
34357
|
-
if (
|
|
34422
|
+
const [quad, remainder2] = quotient;
|
|
34423
|
+
if (remainder2.is(0)) {
|
|
34358
34424
|
const quadCoeffs = getQuadraticCoefficients(quad, index);
|
|
34359
34425
|
if (quadCoeffs) {
|
|
34360
34426
|
const { a: qa, b: qb, c: qc } = quadCoeffs;
|
|
@@ -35609,8 +35675,7 @@ ${lines.join("\n")}`;
|
|
|
35609
35675
|
function multiplyForm(expr) {
|
|
35610
35676
|
if (!expr.ops) return expr;
|
|
35611
35677
|
const ops = expr.ops.map(multiplyForm);
|
|
35612
|
-
if (expr.operator === "Multiply")
|
|
35613
|
-
return canonicalMultiply(expr.engine, ops);
|
|
35678
|
+
if (expr.operator === "Multiply") return canonicalMultiply(expr.engine, ops);
|
|
35614
35679
|
if (expr.operator === "Negate")
|
|
35615
35680
|
return canonicalMultiply(expr.engine, [ops[0], expr.engine.NegativeOne]);
|
|
35616
35681
|
return expr;
|
|
@@ -45983,7 +46048,8 @@ Error in definition of "${name}"`,
|
|
|
45983
46048
|
return this.numeratorDenominator[1];
|
|
45984
46049
|
}
|
|
45985
46050
|
get numeratorDenominator() {
|
|
45986
|
-
if (!(this.isCanonical || this.isStructural))
|
|
46051
|
+
if (!(this.isCanonical || this.isStructural))
|
|
46052
|
+
return [this, this.engine.One];
|
|
45987
46053
|
if (this.isNumber !== true)
|
|
45988
46054
|
return [this.engine.Nothing, this.engine.Nothing];
|
|
45989
46055
|
const operator2 = this.operator;
|
|
@@ -46021,11 +46087,13 @@ Error in definition of "${name}"`,
|
|
|
46021
46087
|
// ALGEBRAIC OPERATIONS
|
|
46022
46088
|
//
|
|
46023
46089
|
neg() {
|
|
46024
|
-
if (!(this.isCanonical || this.isStructural))
|
|
46090
|
+
if (!(this.isCanonical || this.isStructural))
|
|
46091
|
+
throw new Error("Not canonical");
|
|
46025
46092
|
return negate(this);
|
|
46026
46093
|
}
|
|
46027
46094
|
inv() {
|
|
46028
|
-
if (!(this.isCanonical || this.isStructural))
|
|
46095
|
+
if (!(this.isCanonical || this.isStructural))
|
|
46096
|
+
throw new Error("Not canonical");
|
|
46029
46097
|
if (this.isOne) return this;
|
|
46030
46098
|
if (this.isNegativeOne) return this;
|
|
46031
46099
|
if (this.operator === "Sqrt") return this.op1.inv().sqrt();
|
|
@@ -46046,7 +46114,8 @@ Error in definition of "${name}"`,
|
|
|
46046
46114
|
return this.engine._fn("Divide", [this.engine.One, this]);
|
|
46047
46115
|
}
|
|
46048
46116
|
abs() {
|
|
46049
|
-
if (!(this.isCanonical || this.isStructural))
|
|
46117
|
+
if (!(this.isCanonical || this.isStructural))
|
|
46118
|
+
throw new Error("Not canonical");
|
|
46050
46119
|
if (this.operator === "Abs" || this.operator === "Negate") return this;
|
|
46051
46120
|
if (this.isNonNegative) return this;
|
|
46052
46121
|
if (this.isNonPositive) return this.neg();
|
|
@@ -46054,11 +46123,13 @@ Error in definition of "${name}"`,
|
|
|
46054
46123
|
}
|
|
46055
46124
|
add(rhs) {
|
|
46056
46125
|
if (rhs === 0) return this;
|
|
46057
|
-
if (!(this.isCanonical || this.isStructural))
|
|
46126
|
+
if (!(this.isCanonical || this.isStructural))
|
|
46127
|
+
throw new Error("Not canonical");
|
|
46058
46128
|
return add3(this, this.engine.box(rhs));
|
|
46059
46129
|
}
|
|
46060
46130
|
mul(rhs) {
|
|
46061
|
-
if (!(this.isCanonical || this.isStructural))
|
|
46131
|
+
if (!(this.isCanonical || this.isStructural))
|
|
46132
|
+
throw new Error("Not canonical");
|
|
46062
46133
|
if (rhs === 0) return this.engine.Zero;
|
|
46063
46134
|
if (rhs === 1) return this;
|
|
46064
46135
|
if (rhs === -1) return this.neg();
|
|
@@ -46070,7 +46141,8 @@ Error in definition of "${name}"`,
|
|
|
46070
46141
|
return mul3(this, this.engine.box(rhs));
|
|
46071
46142
|
}
|
|
46072
46143
|
div(rhs) {
|
|
46073
|
-
if (!(this.isCanonical || this.isStructural))
|
|
46144
|
+
if (!(this.isCanonical || this.isStructural))
|
|
46145
|
+
throw new Error("Not canonical");
|
|
46074
46146
|
return div2(this, rhs);
|
|
46075
46147
|
}
|
|
46076
46148
|
pow(exp3) {
|
|
@@ -46136,7 +46208,8 @@ Error in definition of "${name}"`,
|
|
|
46136
46208
|
}
|
|
46137
46209
|
ln(semiBase) {
|
|
46138
46210
|
const base = semiBase ? this.engine.box(semiBase) : void 0;
|
|
46139
|
-
if (!(this.isCanonical || this.isStructural))
|
|
46211
|
+
if (!(this.isCanonical || this.isStructural))
|
|
46212
|
+
throw new Error("Not canonical");
|
|
46140
46213
|
if (this.is(0)) return this.engine.NegativeInfinity;
|
|
46141
46214
|
if (this.operator === "Exp") {
|
|
46142
46215
|
if (!base) return this.op1;
|
|
@@ -51471,7 +51544,7 @@ Error in definition of "${name}"`,
|
|
|
51471
51544
|
Arsinh: "Math.asinh",
|
|
51472
51545
|
Arctan: "Math.atan",
|
|
51473
51546
|
Artanh: "Math.atanh",
|
|
51474
|
-
|
|
51547
|
+
Ceil: "Math.ceil",
|
|
51475
51548
|
Chop: "_SYS.chop",
|
|
51476
51549
|
Cos: "Math.cos",
|
|
51477
51550
|
Cosh: "Math.cosh",
|
|
@@ -51501,10 +51574,7 @@ Error in definition of "${name}"`,
|
|
|
51501
51574
|
Floor: "Math.floor",
|
|
51502
51575
|
Fract: ([x], compile) => {
|
|
51503
51576
|
if (x === null) throw new Error("Fract: no argument");
|
|
51504
|
-
return BaseCompiler.inlineExpression(
|
|
51505
|
-
"${x} - Math.floor(${x})",
|
|
51506
|
-
compile(x)
|
|
51507
|
-
);
|
|
51577
|
+
return BaseCompiler.inlineExpression("${x} - Math.floor(${x})", compile(x));
|
|
51508
51578
|
},
|
|
51509
51579
|
Gamma: "_SYS.gamma",
|
|
51510
51580
|
GCD: "_SYS.gcd",
|
|
@@ -51517,7 +51587,7 @@ Error in definition of "${name}"`,
|
|
|
51517
51587
|
if (args.length === 1) return `Math.log10(${compile(args[0])})`;
|
|
51518
51588
|
return `(Math.log(${compile(args[0])}) / Math.log(${compile(args[1])}))`;
|
|
51519
51589
|
},
|
|
51520
|
-
|
|
51590
|
+
GammaLn: "_SYS.lngamma",
|
|
51521
51591
|
Lb: "Math.log2",
|
|
51522
51592
|
Max: "Math.max",
|
|
51523
51593
|
Mean: (args, compile) => {
|
|
@@ -51646,12 +51716,23 @@ Error in definition of "${name}"`,
|
|
|
51646
51716
|
if (arg === null) throw new Error("Sech: no argument");
|
|
51647
51717
|
return `1 / Math.cosh(${compile(arg)})`;
|
|
51648
51718
|
},
|
|
51649
|
-
|
|
51719
|
+
Sign: "Math.sign",
|
|
51650
51720
|
Sin: "Math.sin",
|
|
51651
51721
|
Sinh: "Math.sinh",
|
|
51652
51722
|
Sqrt: "Math.sqrt",
|
|
51653
51723
|
Tan: "Math.tan",
|
|
51654
|
-
Tanh: "Math.tanh"
|
|
51724
|
+
Tanh: "Math.tanh",
|
|
51725
|
+
Mod: ([a, b], compile) => {
|
|
51726
|
+
if (a === null || b === null) throw new Error("Mod: missing argument");
|
|
51727
|
+
const ca = compile(a);
|
|
51728
|
+
const cb = compile(b);
|
|
51729
|
+
return `((${ca} % ${cb}) + ${cb}) % ${cb}`;
|
|
51730
|
+
},
|
|
51731
|
+
Truncate: "Math.trunc",
|
|
51732
|
+
Remainder: ([a, b], compile) => {
|
|
51733
|
+
if (a === null || b === null) throw new Error("Remainder: missing argument");
|
|
51734
|
+
return `(${compile(a)} - ${compile(b)} * Math.round(${compile(a)} / ${compile(b)}))`;
|
|
51735
|
+
}
|
|
51655
51736
|
};
|
|
51656
51737
|
var ComputeEngineFunction = class extends Function {
|
|
51657
51738
|
SYS = {
|
|
@@ -51914,7 +51995,7 @@ Error in definition of "${name}"`,
|
|
|
51914
51995
|
Arccos: "acos",
|
|
51915
51996
|
Arcsin: "asin",
|
|
51916
51997
|
Arctan: "atan",
|
|
51917
|
-
|
|
51998
|
+
Ceil: "ceil",
|
|
51918
51999
|
Clamp: "clamp",
|
|
51919
52000
|
Cos: "cos",
|
|
51920
52001
|
Degrees: "degrees",
|
|
@@ -51939,6 +52020,11 @@ Error in definition of "${name}"`,
|
|
|
51939
52020
|
Sqrt: "sqrt",
|
|
51940
52021
|
Step: "step",
|
|
51941
52022
|
Tan: "tan",
|
|
52023
|
+
Truncate: "trunc",
|
|
52024
|
+
Remainder: ([a, b], compile) => {
|
|
52025
|
+
if (a === null || b === null) throw new Error("Remainder: missing argument");
|
|
52026
|
+
return `(${compile(a)} - ${compile(b)} * round(${compile(a)} / ${compile(b)}))`;
|
|
52027
|
+
},
|
|
51942
52028
|
// Reciprocal trigonometric functions (no GLSL built-ins)
|
|
51943
52029
|
Cot: ([x], compile) => {
|
|
51944
52030
|
if (x === null) throw new Error("Cot: no argument");
|
|
@@ -52002,7 +52088,7 @@ Error in definition of "${name}"`,
|
|
|
52002
52088
|
return `acosh(1.0 / (${compile(x)}))`;
|
|
52003
52089
|
},
|
|
52004
52090
|
// Additional math functions
|
|
52005
|
-
|
|
52091
|
+
// Sign is already registered in the standard functions above
|
|
52006
52092
|
Lb: "log2",
|
|
52007
52093
|
Log: (args, compile) => {
|
|
52008
52094
|
if (args.length === 0) throw new Error("Log: no argument");
|
|
@@ -52600,6 +52686,22 @@ Error in definition of "${name}"`,
|
|
|
52600
52686
|
}
|
|
52601
52687
|
return { kind: "singular", at: flo + 1, continuity: "right" };
|
|
52602
52688
|
}
|
|
52689
|
+
function trunc2(x) {
|
|
52690
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52691
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52692
|
+
const [xVal] = unwrapped;
|
|
52693
|
+
const tlo = Math.trunc(xVal.lo);
|
|
52694
|
+
const thi = Math.trunc(xVal.hi);
|
|
52695
|
+
if (tlo === thi) return ok({ lo: tlo, hi: thi });
|
|
52696
|
+
if (xVal.lo >= 0) {
|
|
52697
|
+
return { kind: "singular", at: tlo + 1, continuity: "right" };
|
|
52698
|
+
}
|
|
52699
|
+
const firstInt = Math.ceil(xVal.lo);
|
|
52700
|
+
if (firstInt !== 0) {
|
|
52701
|
+
return { kind: "singular", at: firstInt, continuity: "left" };
|
|
52702
|
+
}
|
|
52703
|
+
return { kind: "singular", at: 1, continuity: "right" };
|
|
52704
|
+
}
|
|
52603
52705
|
function min2(a, b) {
|
|
52604
52706
|
const unwrapped = unwrapOrPropagate(a, b);
|
|
52605
52707
|
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
@@ -52625,7 +52727,9 @@ Error in definition of "${name}"`,
|
|
|
52625
52727
|
if (containsZero(bVal)) {
|
|
52626
52728
|
return { kind: "singular" };
|
|
52627
52729
|
}
|
|
52628
|
-
const period = Math.abs(
|
|
52730
|
+
const period = Math.abs(
|
|
52731
|
+
bVal.lo === bVal.hi ? bVal.lo : Math.max(Math.abs(bVal.lo), Math.abs(bVal.hi))
|
|
52732
|
+
);
|
|
52629
52733
|
const flo = Math.floor(aVal.lo / period);
|
|
52630
52734
|
const fhi = Math.floor(aVal.hi / period);
|
|
52631
52735
|
if (flo !== fhi) {
|
|
@@ -52635,6 +52739,9 @@ Error in definition of "${name}"`,
|
|
|
52635
52739
|
const modHi = aVal.hi - period * flo;
|
|
52636
52740
|
return ok({ lo: Math.min(modLo, modHi), hi: Math.max(modLo, modHi) });
|
|
52637
52741
|
}
|
|
52742
|
+
function remainder(a, b) {
|
|
52743
|
+
return sub2(a, mul4(b, round2(div3(a, b))));
|
|
52744
|
+
}
|
|
52638
52745
|
function sign2(x) {
|
|
52639
52746
|
const unwrapped = unwrapOrPropagate(x);
|
|
52640
52747
|
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
@@ -53125,9 +53232,11 @@ Error in definition of "${name}"`,
|
|
|
53125
53232
|
ceil: ceil2,
|
|
53126
53233
|
round: round2,
|
|
53127
53234
|
fract,
|
|
53235
|
+
trunc: trunc2,
|
|
53128
53236
|
min: min2,
|
|
53129
53237
|
max: max2,
|
|
53130
53238
|
mod: mod2,
|
|
53239
|
+
remainder,
|
|
53131
53240
|
sign: sign2,
|
|
53132
53241
|
// Trigonometric
|
|
53133
53242
|
sin: sin2,
|
|
@@ -53233,7 +53342,7 @@ Error in definition of "${name}"`,
|
|
|
53233
53342
|
Negate: (args, compile) => `_IA.negate(${compile(args[0])})`,
|
|
53234
53343
|
// Elementary functions
|
|
53235
53344
|
Abs: (args, compile) => `_IA.abs(${compile(args[0])})`,
|
|
53236
|
-
|
|
53345
|
+
Ceil: (args, compile) => `_IA.ceil(${compile(args[0])})`,
|
|
53237
53346
|
Exp: (args, compile) => `_IA.exp(${compile(args[0])})`,
|
|
53238
53347
|
Floor: (args, compile) => `_IA.floor(${compile(args[0])})`,
|
|
53239
53348
|
Ln: (args, compile) => `_IA.ln(${compile(args[0])})`,
|
|
@@ -53286,7 +53395,7 @@ Error in definition of "${name}"`,
|
|
|
53286
53395
|
return `_IA.powInterval(${compile(arg)}, _IA.div(_IA.point(1), ${compile(exp3)}))`;
|
|
53287
53396
|
},
|
|
53288
53397
|
Round: (args, compile) => `_IA.round(${compile(args[0])})`,
|
|
53289
|
-
|
|
53398
|
+
Sign: (args, compile) => `_IA.sign(${compile(args[0])})`,
|
|
53290
53399
|
Sqrt: (args, compile) => `_IA.sqrt(${compile(args[0])})`,
|
|
53291
53400
|
Square: (args, compile) => `_IA.square(${compile(args[0])})`,
|
|
53292
53401
|
// Trigonometric functions
|
|
@@ -53315,14 +53424,12 @@ Error in definition of "${name}"`,
|
|
|
53315
53424
|
Arcoth: (args, compile) => `_IA.acoth(${compile(args[0])})`,
|
|
53316
53425
|
Arcsch: (args, compile) => `_IA.acsch(${compile(args[0])})`,
|
|
53317
53426
|
Arsech: (args, compile) => `_IA.asech(${compile(args[0])})`,
|
|
53318
|
-
// Inverse trig (alternative names)
|
|
53319
|
-
Asin: (args, compile) => `_IA.asin(${compile(args[0])})`,
|
|
53320
|
-
Acos: (args, compile) => `_IA.acos(${compile(args[0])})`,
|
|
53321
|
-
Atan: (args, compile) => `_IA.atan(${compile(args[0])})`,
|
|
53322
53427
|
// Elementary
|
|
53323
53428
|
Fract: (args, compile) => `_IA.fract(${compile(args[0])})`,
|
|
53324
|
-
|
|
53429
|
+
Truncate: (args, compile) => `_IA.trunc(${compile(args[0])})`,
|
|
53430
|
+
// Mod / Remainder
|
|
53325
53431
|
Mod: (args, compile) => `_IA.mod(${compile(args[0])}, ${compile(args[1])})`,
|
|
53432
|
+
Remainder: (args, compile) => `_IA.remainder(${compile(args[0])}, ${compile(args[1])})`,
|
|
53326
53433
|
// Conditionals
|
|
53327
53434
|
If: (args, compile) => {
|
|
53328
53435
|
if (args.length !== 3) throw new Error("If: wrong number of arguments");
|
|
@@ -53642,6 +53749,22 @@ IntervalResult ia_ln(vec2 x) {
|
|
|
53642
53749
|
return ia_partial(vec2(-IA_HUGE, log(x.y) + IA_EPS), IA_PARTIAL_LO);
|
|
53643
53750
|
}
|
|
53644
53751
|
|
|
53752
|
+
// Log base 2
|
|
53753
|
+
IntervalResult ia_log2(vec2 x) {
|
|
53754
|
+
const float INV_LN2 = 1.44269504089;
|
|
53755
|
+
if (x.y <= 0.0) return ia_empty();
|
|
53756
|
+
if (x.x > 0.0) return ia_ok(vec2(log2(x.x) - IA_EPS, log2(x.y) + IA_EPS));
|
|
53757
|
+
return ia_partial(vec2(-IA_HUGE, log2(x.y) + IA_EPS), IA_PARTIAL_LO);
|
|
53758
|
+
}
|
|
53759
|
+
|
|
53760
|
+
// Log base 10
|
|
53761
|
+
IntervalResult ia_log10(vec2 x) {
|
|
53762
|
+
const float INV_LN10 = 0.43429448190;
|
|
53763
|
+
if (x.y <= 0.0) return ia_empty();
|
|
53764
|
+
if (x.x > 0.0) return ia_ok(vec2(log(x.x) * INV_LN10 - IA_EPS, log(x.y) * INV_LN10 + IA_EPS));
|
|
53765
|
+
return ia_partial(vec2(-IA_HUGE, log(x.y) * INV_LN10 + IA_EPS), IA_PARTIAL_LO);
|
|
53766
|
+
}
|
|
53767
|
+
|
|
53645
53768
|
// Absolute value
|
|
53646
53769
|
IntervalResult ia_abs(vec2 x) {
|
|
53647
53770
|
if (x.x >= 0.0) {
|
|
@@ -53715,6 +53838,18 @@ IntervalResult ia_fract(vec2 x) {
|
|
|
53715
53838
|
return ia_singular_right(flo + 1.0);
|
|
53716
53839
|
}
|
|
53717
53840
|
|
|
53841
|
+
// Truncate toward zero - floor for positive, ceil for negative
|
|
53842
|
+
// Discontinuous at every non-zero integer, continuous at zero
|
|
53843
|
+
IntervalResult ia_trunc(vec2 x) {
|
|
53844
|
+
float tlo = trunc(x.x);
|
|
53845
|
+
float thi = trunc(x.y);
|
|
53846
|
+
if (tlo == thi) return ia_ok(vec2(tlo, thi));
|
|
53847
|
+
if (x.x >= 0.0) return ia_singular_right(tlo + 1.0); // like floor
|
|
53848
|
+
float firstInt = ceil(x.x);
|
|
53849
|
+
if (firstInt != 0.0) return ia_singular_left(firstInt); // like ceil
|
|
53850
|
+
return ia_singular_right(1.0); // spans zero, first discontinuity at +1
|
|
53851
|
+
}
|
|
53852
|
+
|
|
53718
53853
|
// Mod - periodic discontinuities at multiples of the modulus
|
|
53719
53854
|
// mod(x, y) = x - y * floor(x / y)
|
|
53720
53855
|
IntervalResult ia_mod(vec2 x, vec2 y) {
|
|
@@ -53748,6 +53883,16 @@ IntervalResult ia_mod(vec2 x, vec2 y) {
|
|
|
53748
53883
|
return ia_sub(x, ia_mul_raw(y, fq.value));
|
|
53749
53884
|
}
|
|
53750
53885
|
|
|
53886
|
+
// IEEE remainder: a - b * round(a / b)
|
|
53887
|
+
// Discontinuities arise from round when a/b spans a half-integer
|
|
53888
|
+
IntervalResult ia_remainder(vec2 a, vec2 b) {
|
|
53889
|
+
IntervalResult q = ia_div(a, b);
|
|
53890
|
+
if (ia_is_error(q.status)) return q;
|
|
53891
|
+
IntervalResult rq = ia_round(q.value);
|
|
53892
|
+
if (ia_is_error(rq.status)) return rq;
|
|
53893
|
+
return ia_sub(a, ia_mul_raw(b, rq.value));
|
|
53894
|
+
}
|
|
53895
|
+
|
|
53751
53896
|
// Min of two intervals
|
|
53752
53897
|
IntervalResult ia_min(vec2 a, vec2 b) {
|
|
53753
53898
|
return ia_ok(vec2(min(a.x, b.x), min(a.y, b.y)));
|
|
@@ -54014,6 +54159,16 @@ IntervalResult ia_ln(IntervalResult x) {
|
|
|
54014
54159
|
return ia_ln(x.value);
|
|
54015
54160
|
}
|
|
54016
54161
|
|
|
54162
|
+
IntervalResult ia_log2(IntervalResult x) {
|
|
54163
|
+
if (ia_is_error(x.status)) return x;
|
|
54164
|
+
return ia_log2(x.value);
|
|
54165
|
+
}
|
|
54166
|
+
|
|
54167
|
+
IntervalResult ia_log10(IntervalResult x) {
|
|
54168
|
+
if (ia_is_error(x.status)) return x;
|
|
54169
|
+
return ia_log10(x.value);
|
|
54170
|
+
}
|
|
54171
|
+
|
|
54017
54172
|
IntervalResult ia_abs(IntervalResult x) {
|
|
54018
54173
|
if (ia_is_error(x.status)) return x;
|
|
54019
54174
|
return ia_abs(x.value);
|
|
@@ -54044,6 +54199,11 @@ IntervalResult ia_fract(IntervalResult x) {
|
|
|
54044
54199
|
return ia_fract(x.value);
|
|
54045
54200
|
}
|
|
54046
54201
|
|
|
54202
|
+
IntervalResult ia_trunc(IntervalResult x) {
|
|
54203
|
+
if (ia_is_error(x.status)) return x;
|
|
54204
|
+
return ia_trunc(x.value);
|
|
54205
|
+
}
|
|
54206
|
+
|
|
54047
54207
|
IntervalResult ia_mod(IntervalResult a, IntervalResult b) {
|
|
54048
54208
|
if (ia_is_error(a.status)) return a;
|
|
54049
54209
|
if (ia_is_error(b.status)) return b;
|
|
@@ -54060,6 +54220,22 @@ IntervalResult ia_mod(vec2 a, IntervalResult b) {
|
|
|
54060
54220
|
return ia_mod(a, b.value);
|
|
54061
54221
|
}
|
|
54062
54222
|
|
|
54223
|
+
IntervalResult ia_remainder(IntervalResult a, IntervalResult b) {
|
|
54224
|
+
if (ia_is_error(a.status)) return a;
|
|
54225
|
+
if (ia_is_error(b.status)) return b;
|
|
54226
|
+
return ia_remainder(a.value, b.value);
|
|
54227
|
+
}
|
|
54228
|
+
|
|
54229
|
+
IntervalResult ia_remainder(IntervalResult a, vec2 b) {
|
|
54230
|
+
if (ia_is_error(a.status)) return a;
|
|
54231
|
+
return ia_remainder(a.value, b);
|
|
54232
|
+
}
|
|
54233
|
+
|
|
54234
|
+
IntervalResult ia_remainder(vec2 a, IntervalResult b) {
|
|
54235
|
+
if (ia_is_error(b.status)) return b;
|
|
54236
|
+
return ia_remainder(a, b.value);
|
|
54237
|
+
}
|
|
54238
|
+
|
|
54063
54239
|
IntervalResult ia_min(IntervalResult a, IntervalResult b) {
|
|
54064
54240
|
if (ia_is_error(a.status)) return a;
|
|
54065
54241
|
if (ia_is_error(b.status)) return b;
|
|
@@ -54446,12 +54622,19 @@ float ia_notEqual(IntervalResult a, IntervalResult b) {
|
|
|
54446
54622
|
Negate: (args, compile) => `ia_negate(${compile(args[0])})`,
|
|
54447
54623
|
// Elementary functions
|
|
54448
54624
|
Abs: (args, compile) => `ia_abs(${compile(args[0])})`,
|
|
54449
|
-
|
|
54625
|
+
Ceil: (args, compile) => `ia_ceil(${compile(args[0])})`,
|
|
54450
54626
|
Exp: (args, compile) => `ia_exp(${compile(args[0])})`,
|
|
54451
54627
|
Floor: (args, compile) => `ia_floor(${compile(args[0])})`,
|
|
54452
54628
|
Fract: (args, compile) => `ia_fract(${compile(args[0])})`,
|
|
54629
|
+
Truncate: (args, compile) => `ia_trunc(${compile(args[0])})`,
|
|
54630
|
+
Lb: (args, compile) => `ia_log2(${compile(args[0])})`,
|
|
54453
54631
|
Ln: (args, compile) => `ia_ln(${compile(args[0])})`,
|
|
54632
|
+
Log: (args, compile) => {
|
|
54633
|
+
if (args.length === 1) return `ia_log10(${compile(args[0])})`;
|
|
54634
|
+
return `ia_div(ia_ln(${compile(args[0])}), ia_ln(${compile(args[1])}))`;
|
|
54635
|
+
},
|
|
54454
54636
|
Mod: (args, compile) => `ia_mod(${compile(args[0])}, ${compile(args[1])})`,
|
|
54637
|
+
Remainder: (args, compile) => `ia_remainder(${compile(args[0])}, ${compile(args[1])})`,
|
|
54455
54638
|
Max: (args, compile) => {
|
|
54456
54639
|
if (args.length === 0) return "ia_point(-1e38)";
|
|
54457
54640
|
if (args.length === 1) return compile(args[0]);
|
|
@@ -54484,8 +54667,17 @@ float ia_notEqual(IntervalResult a, IntervalResult b) {
|
|
|
54484
54667
|
}
|
|
54485
54668
|
throw new Error("Interval GLSL does not support variable exponents");
|
|
54486
54669
|
},
|
|
54670
|
+
Root: (args, compile) => {
|
|
54671
|
+
const [arg, exp3] = args;
|
|
54672
|
+
if (arg === null) throw new Error("Root: no argument");
|
|
54673
|
+
if (exp3 === null || exp3?.re === 2) return `ia_sqrt(${compile(arg)})`;
|
|
54674
|
+
if (exp3?.isNumberLiteral && exp3.im === 0) {
|
|
54675
|
+
return `ia_pow(${compile(arg)}, ${1 / exp3.re})`;
|
|
54676
|
+
}
|
|
54677
|
+
throw new Error("Interval GLSL does not support variable root indices");
|
|
54678
|
+
},
|
|
54487
54679
|
Round: (args, compile) => `ia_round(${compile(args[0])})`,
|
|
54488
|
-
|
|
54680
|
+
Sign: (args, compile) => `ia_sign(${compile(args[0])})`,
|
|
54489
54681
|
Sqrt: (args, compile) => `ia_sqrt(${compile(args[0])})`,
|
|
54490
54682
|
Square: (args, compile) => `ia_square(${compile(args[0])})`,
|
|
54491
54683
|
// Trigonometric functions
|
|
@@ -56426,10 +56618,10 @@ IntervalResult ${functionName}(${params}) {
|
|
|
56426
56618
|
// src/compute-engine.ts
|
|
56427
56619
|
init_types6();
|
|
56428
56620
|
init_base_compiler();
|
|
56429
|
-
var version = "0.35.
|
|
56621
|
+
var version = "0.35.6";
|
|
56430
56622
|
globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
|
|
56431
56623
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
56432
|
-
version: "0.35.
|
|
56624
|
+
version: "0.35.6"
|
|
56433
56625
|
};
|
|
56434
56626
|
return __toCommonJS(compute_engine_exports);
|
|
56435
56627
|
})();
|
package/dist/math-json.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Compute Engine 0.35.
|
|
1
|
+
/** Compute Engine 0.35.6 */
|
|
2
2
|
|
|
3
3
|
// src/math-json/utils.ts
|
|
4
4
|
function isNumberObject(expr) {
|
|
@@ -115,7 +115,7 @@ function expressionToDictionaryValue(expr) {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// src/math-json.ts
|
|
118
|
-
var version = "0.35.
|
|
118
|
+
var version = "0.35.6";
|
|
119
119
|
export {
|
|
120
120
|
dictionaryFromExpression,
|
|
121
121
|
isFunctionObject,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** Compute Engine 0.35.
|
|
2
|
-
function d(n){return n!==null&&typeof n=="object"&&"num"in n}function s(n){return n!==null&&typeof n=="object"&&"sym"in n}function a(n){return n!==null&&typeof n=="object"&&"str"in n}function m(n){return n!==null&&typeof n=="object"&&"dict"in n&&typeof n.dict=="object"&&!Array.isArray(n.dict)&&n.dict!==null}function u(n){return n!==null&&typeof n=="object"&&"fn"in n&&Array.isArray(n.fn)&&n.fn.length>0&&typeof n.fn[0]=="string"}function c(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"?null:n.length>=2&&n.at(0)==="'"&&n.at(-1)==="'"?n.substring(1,n.length-1):M(n)||b(n)?null:n}function l(n){return Array.isArray(n)?n[0]:n==null?"":u(n)?n.fn[0]:""}function y(n){return Array.isArray(n)?n.slice(1):n!==void 0&&u(n)?n.fn.slice(1):[]}function E(n,t){return Array.isArray(n)?n[t]??null:n===null||!u(n)?null:n.fn[t]??null}function h(n){return n==null?0:Array.isArray(n)?Math.max(0,n.length-1):u(n)?Math.max(0,n.fn.length-1):0}function g(n){return typeof n=="string"&&b(n)?n.length>=2&&n.at(0)==="`"&&n.at(-1)==="`"?n.slice(1,-1):n:n==null?null:s(n)?n.sym:null}function f(n){let t=l(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let[i,r]=y(n),e=c(i);return e?[e,r??"Nothing"]:null}return null}function j(n){if(n===null)return null;if(m(n))return n;let t=f(n);if(t)return{[t[0]]:t[1]};if(l(n)==="Dictionary"){let i={},r=y(n);for(let e=1;e<h(n);e++){let o=f(r[e]);o&&(i[o[0]]=A(o[1])??"Nothing")}return{dict:i}}return null}function O(n,t){let i=null;if(Array.isArray(n)&&(i=n),u(n)&&(i=n.fn),i===null)return[];let r=1,e=[];for(;r<i.length;)e.push(t(i[r])),r+=1;return e}function M(n){return/^(nan|oo|\+oo|-oo|infinity|\+infinity|-infinity)$/i.test(n)||/^[+-]?(0|[1-9][0-9]*)(\.[0-9]+)?(\([0-9]+\))?([eE][+-]?[0-9]+)?$/.test(n)}function b(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||n.length>=2&&n[0]==="`"&&n[n.length-1]==="`"}function A(n){return n==null?null:a(n)?n.str:d(n)?parseFloat(n.num):s(n)?n.sym:typeof n=="string"||typeof n=="number"?n:Array.isArray(n)?{fn:n}:n}var S="0.35.
|
|
1
|
+
/** Compute Engine 0.35.6 */
|
|
2
|
+
function d(n){return n!==null&&typeof n=="object"&&"num"in n}function s(n){return n!==null&&typeof n=="object"&&"sym"in n}function a(n){return n!==null&&typeof n=="object"&&"str"in n}function m(n){return n!==null&&typeof n=="object"&&"dict"in n&&typeof n.dict=="object"&&!Array.isArray(n.dict)&&n.dict!==null}function u(n){return n!==null&&typeof n=="object"&&"fn"in n&&Array.isArray(n.fn)&&n.fn.length>0&&typeof n.fn[0]=="string"}function c(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"?null:n.length>=2&&n.at(0)==="'"&&n.at(-1)==="'"?n.substring(1,n.length-1):M(n)||b(n)?null:n}function l(n){return Array.isArray(n)?n[0]:n==null?"":u(n)?n.fn[0]:""}function y(n){return Array.isArray(n)?n.slice(1):n!==void 0&&u(n)?n.fn.slice(1):[]}function E(n,t){return Array.isArray(n)?n[t]??null:n===null||!u(n)?null:n.fn[t]??null}function h(n){return n==null?0:Array.isArray(n)?Math.max(0,n.length-1):u(n)?Math.max(0,n.fn.length-1):0}function g(n){return typeof n=="string"&&b(n)?n.length>=2&&n.at(0)==="`"&&n.at(-1)==="`"?n.slice(1,-1):n:n==null?null:s(n)?n.sym:null}function f(n){let t=l(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let[i,r]=y(n),e=c(i);return e?[e,r??"Nothing"]:null}return null}function j(n){if(n===null)return null;if(m(n))return n;let t=f(n);if(t)return{[t[0]]:t[1]};if(l(n)==="Dictionary"){let i={},r=y(n);for(let e=1;e<h(n);e++){let o=f(r[e]);o&&(i[o[0]]=A(o[1])??"Nothing")}return{dict:i}}return null}function O(n,t){let i=null;if(Array.isArray(n)&&(i=n),u(n)&&(i=n.fn),i===null)return[];let r=1,e=[];for(;r<i.length;)e.push(t(i[r])),r+=1;return e}function M(n){return/^(nan|oo|\+oo|-oo|infinity|\+infinity|-infinity)$/i.test(n)||/^[+-]?(0|[1-9][0-9]*)(\.[0-9]+)?(\([0-9]+\))?([eE][+-]?[0-9]+)?$/.test(n)}function b(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||n.length>=2&&n[0]==="`"&&n[n.length-1]==="`"}function A(n){return n==null?null:a(n)?n.str:d(n)?parseFloat(n.num):s(n)?n.sym:typeof n=="string"||typeof n=="number"?n:Array.isArray(n)?{fn:n}:n}var S="0.35.6";export{j as dictionaryFromExpression,u as isFunctionObject,a as isStringObject,s as isSymbolObject,O as mapArgs,E as operand,l as operator,c as stringValue,g as symbol,S as version};
|