@cortex-js/compute-engine 0.35.5 → 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 +148 -30
- package/dist/compute-engine.min.esm.js +107 -38
- package/dist/compute-engine.min.umd.js +107 -38
- package/dist/compute-engine.umd.js +148 -30
- 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
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -15097,22 +15097,22 @@ function polynomialDivide(dividend, divisor, variable) {
|
|
|
15097
15097
|
if (dividendDeg < divisorDeg) {
|
|
15098
15098
|
return [ce.Zero, dividend];
|
|
15099
15099
|
}
|
|
15100
|
-
const
|
|
15100
|
+
const remainder2 = dividendCoeffs.map((c) => c);
|
|
15101
15101
|
const quotientCoeffs = new Array(
|
|
15102
15102
|
dividendDeg - divisorDeg + 1
|
|
15103
15103
|
).fill(ce.Zero);
|
|
15104
15104
|
const leadingDivisor = divisorCoeffs[divisorDeg];
|
|
15105
15105
|
for (let i = dividendDeg; i >= divisorDeg; i--) {
|
|
15106
|
-
if (
|
|
15107
|
-
const quotientCoef =
|
|
15106
|
+
if (remainder2[i].is(0)) continue;
|
|
15107
|
+
const quotientCoef = remainder2[i].div(leadingDivisor);
|
|
15108
15108
|
quotientCoeffs[i - divisorDeg] = quotientCoef;
|
|
15109
15109
|
for (let j = 0; j <= divisorDeg; j++) {
|
|
15110
15110
|
const product = quotientCoef.mul(divisorCoeffs[j]);
|
|
15111
|
-
|
|
15111
|
+
remainder2[i - divisorDeg + j] = remainder2[i - divisorDeg + j].sub(product);
|
|
15112
15112
|
}
|
|
15113
15113
|
}
|
|
15114
15114
|
const quotient = fromCoefficients(quotientCoeffs, variable);
|
|
15115
|
-
const remainderPoly = fromCoefficients(
|
|
15115
|
+
const remainderPoly = fromCoefficients(remainder2, variable);
|
|
15116
15116
|
return [quotient, remainderPoly];
|
|
15117
15117
|
}
|
|
15118
15118
|
function polynomialGCD(a, b, variable) {
|
|
@@ -15139,9 +15139,9 @@ function polynomialGCD(a, b, variable) {
|
|
|
15139
15139
|
if (!divResult) {
|
|
15140
15140
|
return ce.One;
|
|
15141
15141
|
}
|
|
15142
|
-
const [,
|
|
15142
|
+
const [, remainder2] = divResult;
|
|
15143
15143
|
p = q;
|
|
15144
|
-
q =
|
|
15144
|
+
q = remainder2;
|
|
15145
15145
|
}
|
|
15146
15146
|
return makeMonic(p, variable);
|
|
15147
15147
|
}
|
|
@@ -20812,6 +20812,7 @@ var init_abstract_boxed_expression = __esm({
|
|
|
20812
20812
|
});
|
|
20813
20813
|
} catch (e) {
|
|
20814
20814
|
if (options?.fallback ?? true) {
|
|
20815
|
+
console.warn(`Compilation fallback for "${this.operator}": ${e.message}`);
|
|
20815
20816
|
const { applicableN1: applicableN12 } = (init_function_utils(), __toCommonJS(function_utils_exports));
|
|
20816
20817
|
return applicableN12(this);
|
|
20817
20818
|
}
|
|
@@ -32536,26 +32537,23 @@ function monteCarloEstimate(f, a, b, n = 1e5) {
|
|
|
32536
32537
|
for (let i = 0; i < n; i++) {
|
|
32537
32538
|
const u = Math.random();
|
|
32538
32539
|
const x = Math.tan(Math.PI * (u - 0.5));
|
|
32539
|
-
const
|
|
32540
|
-
const val = f(x) / jacobian;
|
|
32540
|
+
const val = f(x) * Math.PI * (1 + x * x);
|
|
32541
32541
|
sum2 += val;
|
|
32542
32542
|
sumSq += val * val;
|
|
32543
32543
|
}
|
|
32544
32544
|
} else if (a === -Infinity) {
|
|
32545
32545
|
for (let i = 0; i < n; i++) {
|
|
32546
32546
|
const u = Math.random();
|
|
32547
|
-
const x = b
|
|
32548
|
-
const
|
|
32549
|
-
const val = f(x) / jacobian;
|
|
32547
|
+
const x = b + Math.log(u);
|
|
32548
|
+
const val = f(x) / u;
|
|
32550
32549
|
sum2 += val;
|
|
32551
32550
|
sumSq += val * val;
|
|
32552
32551
|
}
|
|
32553
32552
|
} else if (b === Infinity) {
|
|
32554
32553
|
for (let i = 0; i < n; i++) {
|
|
32555
32554
|
const u = Math.random();
|
|
32556
|
-
const x = a
|
|
32557
|
-
const
|
|
32558
|
-
const val = f(x) / jacobian;
|
|
32555
|
+
const x = a - Math.log(u);
|
|
32556
|
+
const val = f(x) / u;
|
|
32559
32557
|
sum2 += val;
|
|
32560
32558
|
sumSq += val * val;
|
|
32561
32559
|
}
|
|
@@ -32569,7 +32567,7 @@ function monteCarloEstimate(f, a, b, n = 1e5) {
|
|
|
32569
32567
|
const mean2 = sum2 / n;
|
|
32570
32568
|
const variance2 = (sumSq - n * mean2 * mean2) / (n - 1);
|
|
32571
32569
|
const stdError = Math.sqrt(variance2 / n);
|
|
32572
|
-
const scale = b - a;
|
|
32570
|
+
const scale = isFinite(a) && isFinite(b) ? b - a : 1;
|
|
32573
32571
|
const estimate = mean2 * scale;
|
|
32574
32572
|
const error = stdError * scale;
|
|
32575
32573
|
const rounded = roundEstimateToError(estimate, error);
|
|
@@ -34149,10 +34147,10 @@ function antiderivative(fn, index) {
|
|
|
34149
34147
|
if (numDeg >= 0 && denDeg >= 0 && numDeg >= denDeg) {
|
|
34150
34148
|
const divResult = polynomialDivide(fn.op1, fn.op2, index);
|
|
34151
34149
|
if (divResult) {
|
|
34152
|
-
const [quotient,
|
|
34150
|
+
const [quotient, remainder2] = divResult;
|
|
34153
34151
|
const quotientIntegral = antiderivative(quotient, index);
|
|
34154
|
-
if (!
|
|
34155
|
-
const remainderFraction =
|
|
34152
|
+
if (!remainder2.is(0)) {
|
|
34153
|
+
const remainderFraction = remainder2.div(fn.op2);
|
|
34156
34154
|
const remainderIntegral = antiderivative(remainderFraction, index);
|
|
34157
34155
|
return add3(quotientIntegral, remainderIntegral);
|
|
34158
34156
|
}
|
|
@@ -34407,8 +34405,8 @@ function antiderivative(fn, index) {
|
|
|
34407
34405
|
const linearFactor = ce.symbol(index).sub(r);
|
|
34408
34406
|
const quotient = polynomialDivide(denominator, linearFactor, index);
|
|
34409
34407
|
if (quotient) {
|
|
34410
|
-
const [quad,
|
|
34411
|
-
if (
|
|
34408
|
+
const [quad, remainder2] = quotient;
|
|
34409
|
+
if (remainder2.is(0)) {
|
|
34412
34410
|
const quadCoeffs = getQuadraticCoefficients(quad, index);
|
|
34413
34411
|
if (quadCoeffs) {
|
|
34414
34412
|
const { a: qa, b: qb, c: qc } = quadCoeffs;
|
|
@@ -51709,7 +51707,18 @@ var JAVASCRIPT_FUNCTIONS = {
|
|
|
51709
51707
|
Sinh: "Math.sinh",
|
|
51710
51708
|
Sqrt: "Math.sqrt",
|
|
51711
51709
|
Tan: "Math.tan",
|
|
51712
|
-
Tanh: "Math.tanh"
|
|
51710
|
+
Tanh: "Math.tanh",
|
|
51711
|
+
Mod: ([a, b], compile) => {
|
|
51712
|
+
if (a === null || b === null) throw new Error("Mod: missing argument");
|
|
51713
|
+
const ca = compile(a);
|
|
51714
|
+
const cb = compile(b);
|
|
51715
|
+
return `((${ca} % ${cb}) + ${cb}) % ${cb}`;
|
|
51716
|
+
},
|
|
51717
|
+
Truncate: "Math.trunc",
|
|
51718
|
+
Remainder: ([a, b], compile) => {
|
|
51719
|
+
if (a === null || b === null) throw new Error("Remainder: missing argument");
|
|
51720
|
+
return `(${compile(a)} - ${compile(b)} * Math.round(${compile(a)} / ${compile(b)}))`;
|
|
51721
|
+
}
|
|
51713
51722
|
};
|
|
51714
51723
|
var ComputeEngineFunction = class extends Function {
|
|
51715
51724
|
SYS = {
|
|
@@ -51997,6 +52006,11 @@ var GLSL_FUNCTIONS = {
|
|
|
51997
52006
|
Sqrt: "sqrt",
|
|
51998
52007
|
Step: "step",
|
|
51999
52008
|
Tan: "tan",
|
|
52009
|
+
Truncate: "trunc",
|
|
52010
|
+
Remainder: ([a, b], compile) => {
|
|
52011
|
+
if (a === null || b === null) throw new Error("Remainder: missing argument");
|
|
52012
|
+
return `(${compile(a)} - ${compile(b)} * round(${compile(a)} / ${compile(b)}))`;
|
|
52013
|
+
},
|
|
52000
52014
|
// Reciprocal trigonometric functions (no GLSL built-ins)
|
|
52001
52015
|
Cot: ([x], compile) => {
|
|
52002
52016
|
if (x === null) throw new Error("Cot: no argument");
|
|
@@ -52658,6 +52672,22 @@ function fract(x) {
|
|
|
52658
52672
|
}
|
|
52659
52673
|
return { kind: "singular", at: flo + 1, continuity: "right" };
|
|
52660
52674
|
}
|
|
52675
|
+
function trunc2(x) {
|
|
52676
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52677
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52678
|
+
const [xVal] = unwrapped;
|
|
52679
|
+
const tlo = Math.trunc(xVal.lo);
|
|
52680
|
+
const thi = Math.trunc(xVal.hi);
|
|
52681
|
+
if (tlo === thi) return ok({ lo: tlo, hi: thi });
|
|
52682
|
+
if (xVal.lo >= 0) {
|
|
52683
|
+
return { kind: "singular", at: tlo + 1, continuity: "right" };
|
|
52684
|
+
}
|
|
52685
|
+
const firstInt = Math.ceil(xVal.lo);
|
|
52686
|
+
if (firstInt !== 0) {
|
|
52687
|
+
return { kind: "singular", at: firstInt, continuity: "left" };
|
|
52688
|
+
}
|
|
52689
|
+
return { kind: "singular", at: 1, continuity: "right" };
|
|
52690
|
+
}
|
|
52661
52691
|
function min2(a, b) {
|
|
52662
52692
|
const unwrapped = unwrapOrPropagate(a, b);
|
|
52663
52693
|
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
@@ -52695,6 +52725,9 @@ function mod2(a, b) {
|
|
|
52695
52725
|
const modHi = aVal.hi - period * flo;
|
|
52696
52726
|
return ok({ lo: Math.min(modLo, modHi), hi: Math.max(modLo, modHi) });
|
|
52697
52727
|
}
|
|
52728
|
+
function remainder(a, b) {
|
|
52729
|
+
return sub2(a, mul4(b, round2(div3(a, b))));
|
|
52730
|
+
}
|
|
52698
52731
|
function sign2(x) {
|
|
52699
52732
|
const unwrapped = unwrapOrPropagate(x);
|
|
52700
52733
|
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
@@ -53185,9 +53218,11 @@ var IntervalArithmetic = {
|
|
|
53185
53218
|
ceil: ceil2,
|
|
53186
53219
|
round: round2,
|
|
53187
53220
|
fract,
|
|
53221
|
+
trunc: trunc2,
|
|
53188
53222
|
min: min2,
|
|
53189
53223
|
max: max2,
|
|
53190
53224
|
mod: mod2,
|
|
53225
|
+
remainder,
|
|
53191
53226
|
sign: sign2,
|
|
53192
53227
|
// Trigonometric
|
|
53193
53228
|
sin: sin2,
|
|
@@ -53375,14 +53410,12 @@ var INTERVAL_JAVASCRIPT_FUNCTIONS = {
|
|
|
53375
53410
|
Arcoth: (args, compile) => `_IA.acoth(${compile(args[0])})`,
|
|
53376
53411
|
Arcsch: (args, compile) => `_IA.acsch(${compile(args[0])})`,
|
|
53377
53412
|
Arsech: (args, compile) => `_IA.asech(${compile(args[0])})`,
|
|
53378
|
-
// Inverse trig (alternative names)
|
|
53379
|
-
Asin: (args, compile) => `_IA.asin(${compile(args[0])})`,
|
|
53380
|
-
Acos: (args, compile) => `_IA.acos(${compile(args[0])})`,
|
|
53381
|
-
Atan: (args, compile) => `_IA.atan(${compile(args[0])})`,
|
|
53382
53413
|
// Elementary
|
|
53383
53414
|
Fract: (args, compile) => `_IA.fract(${compile(args[0])})`,
|
|
53384
|
-
|
|
53415
|
+
Truncate: (args, compile) => `_IA.trunc(${compile(args[0])})`,
|
|
53416
|
+
// Mod / Remainder
|
|
53385
53417
|
Mod: (args, compile) => `_IA.mod(${compile(args[0])}, ${compile(args[1])})`,
|
|
53418
|
+
Remainder: (args, compile) => `_IA.remainder(${compile(args[0])}, ${compile(args[1])})`,
|
|
53386
53419
|
// Conditionals
|
|
53387
53420
|
If: (args, compile) => {
|
|
53388
53421
|
if (args.length !== 3) throw new Error("If: wrong number of arguments");
|
|
@@ -53702,6 +53735,22 @@ IntervalResult ia_ln(vec2 x) {
|
|
|
53702
53735
|
return ia_partial(vec2(-IA_HUGE, log(x.y) + IA_EPS), IA_PARTIAL_LO);
|
|
53703
53736
|
}
|
|
53704
53737
|
|
|
53738
|
+
// Log base 2
|
|
53739
|
+
IntervalResult ia_log2(vec2 x) {
|
|
53740
|
+
const float INV_LN2 = 1.44269504089;
|
|
53741
|
+
if (x.y <= 0.0) return ia_empty();
|
|
53742
|
+
if (x.x > 0.0) return ia_ok(vec2(log2(x.x) - IA_EPS, log2(x.y) + IA_EPS));
|
|
53743
|
+
return ia_partial(vec2(-IA_HUGE, log2(x.y) + IA_EPS), IA_PARTIAL_LO);
|
|
53744
|
+
}
|
|
53745
|
+
|
|
53746
|
+
// Log base 10
|
|
53747
|
+
IntervalResult ia_log10(vec2 x) {
|
|
53748
|
+
const float INV_LN10 = 0.43429448190;
|
|
53749
|
+
if (x.y <= 0.0) return ia_empty();
|
|
53750
|
+
if (x.x > 0.0) return ia_ok(vec2(log(x.x) * INV_LN10 - IA_EPS, log(x.y) * INV_LN10 + IA_EPS));
|
|
53751
|
+
return ia_partial(vec2(-IA_HUGE, log(x.y) * INV_LN10 + IA_EPS), IA_PARTIAL_LO);
|
|
53752
|
+
}
|
|
53753
|
+
|
|
53705
53754
|
// Absolute value
|
|
53706
53755
|
IntervalResult ia_abs(vec2 x) {
|
|
53707
53756
|
if (x.x >= 0.0) {
|
|
@@ -53775,6 +53824,18 @@ IntervalResult ia_fract(vec2 x) {
|
|
|
53775
53824
|
return ia_singular_right(flo + 1.0);
|
|
53776
53825
|
}
|
|
53777
53826
|
|
|
53827
|
+
// Truncate toward zero - floor for positive, ceil for negative
|
|
53828
|
+
// Discontinuous at every non-zero integer, continuous at zero
|
|
53829
|
+
IntervalResult ia_trunc(vec2 x) {
|
|
53830
|
+
float tlo = trunc(x.x);
|
|
53831
|
+
float thi = trunc(x.y);
|
|
53832
|
+
if (tlo == thi) return ia_ok(vec2(tlo, thi));
|
|
53833
|
+
if (x.x >= 0.0) return ia_singular_right(tlo + 1.0); // like floor
|
|
53834
|
+
float firstInt = ceil(x.x);
|
|
53835
|
+
if (firstInt != 0.0) return ia_singular_left(firstInt); // like ceil
|
|
53836
|
+
return ia_singular_right(1.0); // spans zero, first discontinuity at +1
|
|
53837
|
+
}
|
|
53838
|
+
|
|
53778
53839
|
// Mod - periodic discontinuities at multiples of the modulus
|
|
53779
53840
|
// mod(x, y) = x - y * floor(x / y)
|
|
53780
53841
|
IntervalResult ia_mod(vec2 x, vec2 y) {
|
|
@@ -53808,6 +53869,16 @@ IntervalResult ia_mod(vec2 x, vec2 y) {
|
|
|
53808
53869
|
return ia_sub(x, ia_mul_raw(y, fq.value));
|
|
53809
53870
|
}
|
|
53810
53871
|
|
|
53872
|
+
// IEEE remainder: a - b * round(a / b)
|
|
53873
|
+
// Discontinuities arise from round when a/b spans a half-integer
|
|
53874
|
+
IntervalResult ia_remainder(vec2 a, vec2 b) {
|
|
53875
|
+
IntervalResult q = ia_div(a, b);
|
|
53876
|
+
if (ia_is_error(q.status)) return q;
|
|
53877
|
+
IntervalResult rq = ia_round(q.value);
|
|
53878
|
+
if (ia_is_error(rq.status)) return rq;
|
|
53879
|
+
return ia_sub(a, ia_mul_raw(b, rq.value));
|
|
53880
|
+
}
|
|
53881
|
+
|
|
53811
53882
|
// Min of two intervals
|
|
53812
53883
|
IntervalResult ia_min(vec2 a, vec2 b) {
|
|
53813
53884
|
return ia_ok(vec2(min(a.x, b.x), min(a.y, b.y)));
|
|
@@ -54074,6 +54145,16 @@ IntervalResult ia_ln(IntervalResult x) {
|
|
|
54074
54145
|
return ia_ln(x.value);
|
|
54075
54146
|
}
|
|
54076
54147
|
|
|
54148
|
+
IntervalResult ia_log2(IntervalResult x) {
|
|
54149
|
+
if (ia_is_error(x.status)) return x;
|
|
54150
|
+
return ia_log2(x.value);
|
|
54151
|
+
}
|
|
54152
|
+
|
|
54153
|
+
IntervalResult ia_log10(IntervalResult x) {
|
|
54154
|
+
if (ia_is_error(x.status)) return x;
|
|
54155
|
+
return ia_log10(x.value);
|
|
54156
|
+
}
|
|
54157
|
+
|
|
54077
54158
|
IntervalResult ia_abs(IntervalResult x) {
|
|
54078
54159
|
if (ia_is_error(x.status)) return x;
|
|
54079
54160
|
return ia_abs(x.value);
|
|
@@ -54104,6 +54185,11 @@ IntervalResult ia_fract(IntervalResult x) {
|
|
|
54104
54185
|
return ia_fract(x.value);
|
|
54105
54186
|
}
|
|
54106
54187
|
|
|
54188
|
+
IntervalResult ia_trunc(IntervalResult x) {
|
|
54189
|
+
if (ia_is_error(x.status)) return x;
|
|
54190
|
+
return ia_trunc(x.value);
|
|
54191
|
+
}
|
|
54192
|
+
|
|
54107
54193
|
IntervalResult ia_mod(IntervalResult a, IntervalResult b) {
|
|
54108
54194
|
if (ia_is_error(a.status)) return a;
|
|
54109
54195
|
if (ia_is_error(b.status)) return b;
|
|
@@ -54120,6 +54206,22 @@ IntervalResult ia_mod(vec2 a, IntervalResult b) {
|
|
|
54120
54206
|
return ia_mod(a, b.value);
|
|
54121
54207
|
}
|
|
54122
54208
|
|
|
54209
|
+
IntervalResult ia_remainder(IntervalResult a, IntervalResult b) {
|
|
54210
|
+
if (ia_is_error(a.status)) return a;
|
|
54211
|
+
if (ia_is_error(b.status)) return b;
|
|
54212
|
+
return ia_remainder(a.value, b.value);
|
|
54213
|
+
}
|
|
54214
|
+
|
|
54215
|
+
IntervalResult ia_remainder(IntervalResult a, vec2 b) {
|
|
54216
|
+
if (ia_is_error(a.status)) return a;
|
|
54217
|
+
return ia_remainder(a.value, b);
|
|
54218
|
+
}
|
|
54219
|
+
|
|
54220
|
+
IntervalResult ia_remainder(vec2 a, IntervalResult b) {
|
|
54221
|
+
if (ia_is_error(b.status)) return b;
|
|
54222
|
+
return ia_remainder(a, b.value);
|
|
54223
|
+
}
|
|
54224
|
+
|
|
54123
54225
|
IntervalResult ia_min(IntervalResult a, IntervalResult b) {
|
|
54124
54226
|
if (ia_is_error(a.status)) return a;
|
|
54125
54227
|
if (ia_is_error(b.status)) return b;
|
|
@@ -54510,8 +54612,15 @@ var INTERVAL_GLSL_FUNCTIONS = {
|
|
|
54510
54612
|
Exp: (args, compile) => `ia_exp(${compile(args[0])})`,
|
|
54511
54613
|
Floor: (args, compile) => `ia_floor(${compile(args[0])})`,
|
|
54512
54614
|
Fract: (args, compile) => `ia_fract(${compile(args[0])})`,
|
|
54615
|
+
Truncate: (args, compile) => `ia_trunc(${compile(args[0])})`,
|
|
54616
|
+
Lb: (args, compile) => `ia_log2(${compile(args[0])})`,
|
|
54513
54617
|
Ln: (args, compile) => `ia_ln(${compile(args[0])})`,
|
|
54618
|
+
Log: (args, compile) => {
|
|
54619
|
+
if (args.length === 1) return `ia_log10(${compile(args[0])})`;
|
|
54620
|
+
return `ia_div(ia_ln(${compile(args[0])}), ia_ln(${compile(args[1])}))`;
|
|
54621
|
+
},
|
|
54514
54622
|
Mod: (args, compile) => `ia_mod(${compile(args[0])}, ${compile(args[1])})`,
|
|
54623
|
+
Remainder: (args, compile) => `ia_remainder(${compile(args[0])}, ${compile(args[1])})`,
|
|
54515
54624
|
Max: (args, compile) => {
|
|
54516
54625
|
if (args.length === 0) return "ia_point(-1e38)";
|
|
54517
54626
|
if (args.length === 1) return compile(args[0]);
|
|
@@ -54544,6 +54653,15 @@ var INTERVAL_GLSL_FUNCTIONS = {
|
|
|
54544
54653
|
}
|
|
54545
54654
|
throw new Error("Interval GLSL does not support variable exponents");
|
|
54546
54655
|
},
|
|
54656
|
+
Root: (args, compile) => {
|
|
54657
|
+
const [arg, exp3] = args;
|
|
54658
|
+
if (arg === null) throw new Error("Root: no argument");
|
|
54659
|
+
if (exp3 === null || exp3?.re === 2) return `ia_sqrt(${compile(arg)})`;
|
|
54660
|
+
if (exp3?.isNumberLiteral && exp3.im === 0) {
|
|
54661
|
+
return `ia_pow(${compile(arg)}, ${1 / exp3.re})`;
|
|
54662
|
+
}
|
|
54663
|
+
throw new Error("Interval GLSL does not support variable root indices");
|
|
54664
|
+
},
|
|
54547
54665
|
Round: (args, compile) => `ia_round(${compile(args[0])})`,
|
|
54548
54666
|
Sign: (args, compile) => `ia_sign(${compile(args[0])})`,
|
|
54549
54667
|
Sqrt: (args, compile) => `ia_sqrt(${compile(args[0])})`,
|
|
@@ -56486,10 +56604,10 @@ function defToString(name, def, v) {
|
|
|
56486
56604
|
// src/compute-engine.ts
|
|
56487
56605
|
init_types6();
|
|
56488
56606
|
init_base_compiler();
|
|
56489
|
-
var version = "0.35.
|
|
56607
|
+
var version = "0.35.6";
|
|
56490
56608
|
globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
|
|
56491
56609
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
56492
|
-
version: "0.35.
|
|
56610
|
+
version: "0.35.6"
|
|
56493
56611
|
};
|
|
56494
56612
|
export {
|
|
56495
56613
|
BaseCompiler,
|