@cortex-js/compute-engine 0.35.0 → 0.35.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 +507 -150
- package/dist/compute-engine.min.esm.js +233 -38
- package/dist/compute-engine.min.umd.js +233 -38
- package/dist/compute-engine.umd.js +507 -150
- 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 +1 -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 +9 -9
- package/dist/types/compute-engine/interval/elementary.d.ts +14 -14
- package/dist/types/compute-engine/interval/index.d.ts +1 -1
- package/dist/types/compute-engine/interval/trigonometric.d.ts +17 -17
- 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 +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Compute Engine 0.35.
|
|
1
|
+
/** Compute Engine 0.35.1 */
|
|
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;
|
|
@@ -20107,6 +20107,14 @@ var ComputeEngine = (() => {
|
|
|
20107
20107
|
return `return ${_BaseCompiler.compile(args[0], target)}`;
|
|
20108
20108
|
if (h === "If") {
|
|
20109
20109
|
if (args.length !== 3) throw new Error("If: wrong number of arguments");
|
|
20110
|
+
const fn2 = target.functions?.(h);
|
|
20111
|
+
if (fn2) {
|
|
20112
|
+
if (typeof fn2 === "function") {
|
|
20113
|
+
return fn2(args, (expr) => _BaseCompiler.compile(expr, target), target);
|
|
20114
|
+
}
|
|
20115
|
+
if (args === null) return `${fn2}()`;
|
|
20116
|
+
return `${fn2}(${args.map((x) => _BaseCompiler.compile(x, target)).join(", ")})`;
|
|
20117
|
+
}
|
|
20110
20118
|
return `((${_BaseCompiler.compile(args[0], target)}) ? (${_BaseCompiler.compile(
|
|
20111
20119
|
args[1],
|
|
20112
20120
|
target
|
|
@@ -52279,49 +52287,64 @@ Error in definition of "${name}"`,
|
|
|
52279
52287
|
return { lo: Math.pow(base.lo, n), hi: Math.pow(base.hi, n) };
|
|
52280
52288
|
}
|
|
52281
52289
|
function pow3(base, exp3) {
|
|
52290
|
+
const unwrapped = unwrapOrPropagate(base);
|
|
52291
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52292
|
+
const [baseVal] = unwrapped;
|
|
52282
52293
|
if (Number.isInteger(exp3)) {
|
|
52283
52294
|
if (exp3 >= 0) {
|
|
52284
|
-
return ok(intPow2(
|
|
52295
|
+
return ok(intPow2(baseVal, exp3));
|
|
52285
52296
|
} else {
|
|
52286
|
-
if (containsZero(
|
|
52297
|
+
if (containsZero(baseVal)) {
|
|
52287
52298
|
return { kind: "singular" };
|
|
52288
52299
|
}
|
|
52289
|
-
const denom = intPow2(
|
|
52300
|
+
const denom = intPow2(baseVal, -exp3);
|
|
52290
52301
|
return ok({ lo: 1 / denom.hi, hi: 1 / denom.lo });
|
|
52291
52302
|
}
|
|
52292
52303
|
} else {
|
|
52293
|
-
if (isNegative(
|
|
52304
|
+
if (isNegative(baseVal)) {
|
|
52294
52305
|
return { kind: "empty" };
|
|
52295
52306
|
}
|
|
52296
|
-
if (
|
|
52297
|
-
const value = exp3 > 0 ? { lo: 0, hi: Math.pow(
|
|
52307
|
+
if (baseVal.lo < 0) {
|
|
52308
|
+
const value = exp3 > 0 ? { lo: 0, hi: Math.pow(baseVal.hi, exp3) } : { lo: Math.pow(baseVal.hi, exp3), hi: Infinity };
|
|
52298
52309
|
return { kind: "partial", value, domainClipped: "lo" };
|
|
52299
52310
|
}
|
|
52300
52311
|
if (exp3 > 0) {
|
|
52301
|
-
return ok({
|
|
52312
|
+
return ok({
|
|
52313
|
+
lo: Math.pow(baseVal.lo, exp3),
|
|
52314
|
+
hi: Math.pow(baseVal.hi, exp3)
|
|
52315
|
+
});
|
|
52302
52316
|
} else {
|
|
52303
|
-
if (
|
|
52317
|
+
if (baseVal.lo === 0) {
|
|
52304
52318
|
return {
|
|
52305
52319
|
kind: "partial",
|
|
52306
|
-
value: { lo: Math.pow(
|
|
52320
|
+
value: { lo: Math.pow(baseVal.hi, exp3), hi: Infinity },
|
|
52307
52321
|
domainClipped: "hi"
|
|
52308
52322
|
};
|
|
52309
52323
|
}
|
|
52310
|
-
return ok({
|
|
52324
|
+
return ok({
|
|
52325
|
+
lo: Math.pow(baseVal.hi, exp3),
|
|
52326
|
+
hi: Math.pow(baseVal.lo, exp3)
|
|
52327
|
+
});
|
|
52311
52328
|
}
|
|
52312
52329
|
}
|
|
52313
52330
|
}
|
|
52314
52331
|
function powInterval(base, exp3) {
|
|
52315
|
-
|
|
52332
|
+
const unwrapped = unwrapOrPropagate(base, exp3);
|
|
52333
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52334
|
+
const [baseVal, expVal] = unwrapped;
|
|
52335
|
+
if (baseVal.hi <= 0) {
|
|
52316
52336
|
return { kind: "empty" };
|
|
52317
52337
|
}
|
|
52318
|
-
if (
|
|
52319
|
-
const posBase = {
|
|
52338
|
+
if (baseVal.lo <= 0) {
|
|
52339
|
+
const posBase = {
|
|
52340
|
+
lo: Math.max(baseVal.lo, Number.EPSILON),
|
|
52341
|
+
hi: baseVal.hi
|
|
52342
|
+
};
|
|
52320
52343
|
const corners2 = [
|
|
52321
|
-
Math.pow(posBase.lo,
|
|
52322
|
-
Math.pow(posBase.lo,
|
|
52323
|
-
Math.pow(posBase.hi,
|
|
52324
|
-
Math.pow(posBase.hi,
|
|
52344
|
+
Math.pow(posBase.lo, expVal.lo),
|
|
52345
|
+
Math.pow(posBase.lo, expVal.hi),
|
|
52346
|
+
Math.pow(posBase.hi, expVal.lo),
|
|
52347
|
+
Math.pow(posBase.hi, expVal.hi)
|
|
52325
52348
|
];
|
|
52326
52349
|
return {
|
|
52327
52350
|
kind: "partial",
|
|
@@ -52330,10 +52353,10 @@ Error in definition of "${name}"`,
|
|
|
52330
52353
|
};
|
|
52331
52354
|
}
|
|
52332
52355
|
const corners = [
|
|
52333
|
-
Math.pow(
|
|
52334
|
-
Math.pow(
|
|
52335
|
-
Math.pow(
|
|
52336
|
-
Math.pow(
|
|
52356
|
+
Math.pow(baseVal.lo, expVal.lo),
|
|
52357
|
+
Math.pow(baseVal.lo, expVal.hi),
|
|
52358
|
+
Math.pow(baseVal.hi, expVal.lo),
|
|
52359
|
+
Math.pow(baseVal.hi, expVal.hi)
|
|
52337
52360
|
];
|
|
52338
52361
|
return ok({ lo: Math.min(...corners), hi: Math.max(...corners) });
|
|
52339
52362
|
}
|
|
@@ -52344,79 +52367,115 @@ Error in definition of "${name}"`,
|
|
|
52344
52367
|
return ok({ lo: Math.exp(xVal.lo), hi: Math.exp(xVal.hi) });
|
|
52345
52368
|
}
|
|
52346
52369
|
function ln2(x) {
|
|
52347
|
-
|
|
52370
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52371
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52372
|
+
const [xVal] = unwrapped;
|
|
52373
|
+
if (xVal.hi <= 0) {
|
|
52348
52374
|
return { kind: "empty" };
|
|
52349
52375
|
}
|
|
52350
|
-
if (
|
|
52351
|
-
return ok({ lo: Math.log(
|
|
52376
|
+
if (xVal.lo > 0) {
|
|
52377
|
+
return ok({ lo: Math.log(xVal.lo), hi: Math.log(xVal.hi) });
|
|
52352
52378
|
}
|
|
52353
52379
|
return {
|
|
52354
52380
|
kind: "partial",
|
|
52355
|
-
value: { lo: -Infinity, hi: Math.log(
|
|
52381
|
+
value: { lo: -Infinity, hi: Math.log(xVal.hi) },
|
|
52356
52382
|
domainClipped: "lo"
|
|
52357
52383
|
};
|
|
52358
52384
|
}
|
|
52359
52385
|
function log102(x) {
|
|
52360
|
-
|
|
52386
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52387
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52388
|
+
const [xVal] = unwrapped;
|
|
52389
|
+
if (xVal.hi <= 0) {
|
|
52361
52390
|
return { kind: "empty" };
|
|
52362
52391
|
}
|
|
52363
|
-
if (
|
|
52364
|
-
return ok({ lo: Math.log10(
|
|
52392
|
+
if (xVal.lo > 0) {
|
|
52393
|
+
return ok({ lo: Math.log10(xVal.lo), hi: Math.log10(xVal.hi) });
|
|
52365
52394
|
}
|
|
52366
52395
|
return {
|
|
52367
52396
|
kind: "partial",
|
|
52368
|
-
value: { lo: -Infinity, hi: Math.log10(
|
|
52397
|
+
value: { lo: -Infinity, hi: Math.log10(xVal.hi) },
|
|
52369
52398
|
domainClipped: "lo"
|
|
52370
52399
|
};
|
|
52371
52400
|
}
|
|
52372
52401
|
function log22(x) {
|
|
52373
|
-
|
|
52402
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52403
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52404
|
+
const [xVal] = unwrapped;
|
|
52405
|
+
if (xVal.hi <= 0) {
|
|
52374
52406
|
return { kind: "empty" };
|
|
52375
52407
|
}
|
|
52376
|
-
if (
|
|
52377
|
-
return ok({ lo: Math.log2(
|
|
52408
|
+
if (xVal.lo > 0) {
|
|
52409
|
+
return ok({ lo: Math.log2(xVal.lo), hi: Math.log2(xVal.hi) });
|
|
52378
52410
|
}
|
|
52379
52411
|
return {
|
|
52380
52412
|
kind: "partial",
|
|
52381
|
-
value: { lo: -Infinity, hi: Math.log2(
|
|
52413
|
+
value: { lo: -Infinity, hi: Math.log2(xVal.hi) },
|
|
52382
52414
|
domainClipped: "lo"
|
|
52383
52415
|
};
|
|
52384
52416
|
}
|
|
52385
52417
|
function abs2(x) {
|
|
52386
|
-
|
|
52387
|
-
|
|
52418
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52419
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52420
|
+
const [xVal] = unwrapped;
|
|
52421
|
+
if (xVal.lo >= 0) {
|
|
52422
|
+
return ok(xVal);
|
|
52388
52423
|
}
|
|
52389
|
-
if (
|
|
52390
|
-
return ok({ lo: -
|
|
52424
|
+
if (xVal.hi <= 0) {
|
|
52425
|
+
return ok({ lo: -xVal.hi, hi: -xVal.lo });
|
|
52391
52426
|
}
|
|
52392
|
-
return ok({ lo: 0, hi: Math.max(-
|
|
52427
|
+
return ok({ lo: 0, hi: Math.max(-xVal.lo, xVal.hi) });
|
|
52393
52428
|
}
|
|
52394
52429
|
function floor2(x) {
|
|
52395
|
-
|
|
52430
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52431
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52432
|
+
const [xVal] = unwrapped;
|
|
52433
|
+
return ok({ lo: Math.floor(xVal.lo), hi: Math.floor(xVal.hi) });
|
|
52396
52434
|
}
|
|
52397
52435
|
function ceil2(x) {
|
|
52398
|
-
|
|
52436
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52437
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52438
|
+
const [xVal] = unwrapped;
|
|
52439
|
+
return ok({ lo: Math.ceil(xVal.lo), hi: Math.ceil(xVal.hi) });
|
|
52399
52440
|
}
|
|
52400
52441
|
function round2(x) {
|
|
52401
|
-
|
|
52442
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52443
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52444
|
+
const [xVal] = unwrapped;
|
|
52445
|
+
return ok({ lo: Math.round(xVal.lo), hi: Math.round(xVal.hi) });
|
|
52402
52446
|
}
|
|
52403
52447
|
function min2(a, b) {
|
|
52404
|
-
|
|
52448
|
+
const unwrapped = unwrapOrPropagate(a, b);
|
|
52449
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52450
|
+
const [aVal, bVal] = unwrapped;
|
|
52451
|
+
return ok({
|
|
52452
|
+
lo: Math.min(aVal.lo, bVal.lo),
|
|
52453
|
+
hi: Math.min(aVal.hi, bVal.hi)
|
|
52454
|
+
});
|
|
52405
52455
|
}
|
|
52406
52456
|
function max2(a, b) {
|
|
52407
|
-
|
|
52457
|
+
const unwrapped = unwrapOrPropagate(a, b);
|
|
52458
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52459
|
+
const [aVal, bVal] = unwrapped;
|
|
52460
|
+
return ok({
|
|
52461
|
+
lo: Math.max(aVal.lo, bVal.lo),
|
|
52462
|
+
hi: Math.max(aVal.hi, bVal.hi)
|
|
52463
|
+
});
|
|
52408
52464
|
}
|
|
52409
52465
|
function mod2(a, b) {
|
|
52410
|
-
|
|
52466
|
+
const unwrapped = unwrapOrPropagate(a, b);
|
|
52467
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52468
|
+
const [aVal, bVal] = unwrapped;
|
|
52469
|
+
if (containsZero(bVal)) {
|
|
52411
52470
|
return { kind: "singular" };
|
|
52412
52471
|
}
|
|
52413
|
-
const bAbs = Math.max(Math.abs(
|
|
52414
|
-
const aWidth =
|
|
52472
|
+
const bAbs = Math.max(Math.abs(bVal.lo), Math.abs(bVal.hi));
|
|
52473
|
+
const aWidth = aVal.hi - aVal.lo;
|
|
52415
52474
|
if (aWidth >= bAbs) {
|
|
52416
52475
|
return ok({ lo: 0, hi: bAbs });
|
|
52417
52476
|
}
|
|
52418
|
-
const modLo = (
|
|
52419
|
-
const modHi = (
|
|
52477
|
+
const modLo = (aVal.lo % bAbs + bAbs) % bAbs;
|
|
52478
|
+
const modHi = (aVal.hi % bAbs + bAbs) % bAbs;
|
|
52420
52479
|
if (modLo <= modHi) {
|
|
52421
52480
|
return ok({ lo: modLo, hi: modHi });
|
|
52422
52481
|
} else {
|
|
@@ -52424,11 +52483,14 @@ Error in definition of "${name}"`,
|
|
|
52424
52483
|
}
|
|
52425
52484
|
}
|
|
52426
52485
|
function sign2(x) {
|
|
52427
|
-
|
|
52428
|
-
if (
|
|
52429
|
-
|
|
52430
|
-
if (
|
|
52431
|
-
if (
|
|
52486
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52487
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52488
|
+
const [xVal] = unwrapped;
|
|
52489
|
+
if (xVal.lo > 0) return ok({ lo: 1, hi: 1 });
|
|
52490
|
+
if (xVal.hi < 0) return ok({ lo: -1, hi: -1 });
|
|
52491
|
+
if (xVal.lo === 0 && xVal.hi === 0) return ok({ lo: 0, hi: 0 });
|
|
52492
|
+
if (xVal.lo < 0 && xVal.hi > 0) return ok({ lo: -1, hi: 1 });
|
|
52493
|
+
if (xVal.lo === 0) return ok({ lo: 0, hi: 1 });
|
|
52432
52494
|
return ok({ lo: -1, hi: 0 });
|
|
52433
52495
|
}
|
|
52434
52496
|
|
|
@@ -52438,231 +52500,298 @@ Error in definition of "${name}"`,
|
|
|
52438
52500
|
var HALF_PI = Math.PI / 2;
|
|
52439
52501
|
var THREE_HALF_PI = 3 * Math.PI / 2;
|
|
52440
52502
|
function sin2(x) {
|
|
52441
|
-
|
|
52503
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52504
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52505
|
+
const [xVal] = unwrapped;
|
|
52506
|
+
if (xVal.hi - xVal.lo >= TWO_PI) {
|
|
52442
52507
|
return ok({ lo: -1, hi: 1 });
|
|
52443
52508
|
}
|
|
52444
|
-
const sinLo = Math.sin(
|
|
52445
|
-
const sinHi = Math.sin(
|
|
52509
|
+
const sinLo = Math.sin(xVal.lo);
|
|
52510
|
+
const sinHi = Math.sin(xVal.hi);
|
|
52446
52511
|
let lo = Math.min(sinLo, sinHi);
|
|
52447
52512
|
let hi = Math.max(sinLo, sinHi);
|
|
52448
|
-
if (containsExtremum(
|
|
52513
|
+
if (containsExtremum(xVal, HALF_PI, TWO_PI)) {
|
|
52449
52514
|
hi = 1;
|
|
52450
52515
|
}
|
|
52451
|
-
if (containsExtremum(
|
|
52516
|
+
if (containsExtremum(xVal, THREE_HALF_PI, TWO_PI)) {
|
|
52452
52517
|
lo = -1;
|
|
52453
52518
|
}
|
|
52454
52519
|
return ok({ lo, hi });
|
|
52455
52520
|
}
|
|
52456
52521
|
function cos2(x) {
|
|
52457
|
-
|
|
52522
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52523
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52524
|
+
const [xVal] = unwrapped;
|
|
52525
|
+
if (xVal.hi - xVal.lo >= TWO_PI) {
|
|
52458
52526
|
return ok({ lo: -1, hi: 1 });
|
|
52459
52527
|
}
|
|
52460
|
-
const cosLo = Math.cos(
|
|
52461
|
-
const cosHi = Math.cos(
|
|
52528
|
+
const cosLo = Math.cos(xVal.lo);
|
|
52529
|
+
const cosHi = Math.cos(xVal.hi);
|
|
52462
52530
|
let lo = Math.min(cosLo, cosHi);
|
|
52463
52531
|
let hi = Math.max(cosLo, cosHi);
|
|
52464
|
-
if (containsExtremum(
|
|
52532
|
+
if (containsExtremum(xVal, 0, TWO_PI)) {
|
|
52465
52533
|
hi = 1;
|
|
52466
52534
|
}
|
|
52467
|
-
if (containsExtremum(
|
|
52535
|
+
if (containsExtremum(xVal, PI2, TWO_PI)) {
|
|
52468
52536
|
lo = -1;
|
|
52469
52537
|
}
|
|
52470
52538
|
return ok({ lo, hi });
|
|
52471
52539
|
}
|
|
52472
52540
|
function tan2(x) {
|
|
52473
|
-
|
|
52541
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52542
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52543
|
+
const [xVal] = unwrapped;
|
|
52544
|
+
if (xVal.hi - xVal.lo >= PI2) {
|
|
52474
52545
|
return { kind: "singular" };
|
|
52475
52546
|
}
|
|
52476
|
-
if (containsExtremum(
|
|
52477
|
-
const n = Math.ceil((
|
|
52547
|
+
if (containsExtremum(xVal, HALF_PI, PI2)) {
|
|
52548
|
+
const n = Math.ceil((xVal.lo - HALF_PI) / PI2);
|
|
52478
52549
|
const poleAt = HALF_PI + n * PI2;
|
|
52479
52550
|
return { kind: "singular", at: poleAt };
|
|
52480
52551
|
}
|
|
52481
|
-
const tanLo = Math.tan(
|
|
52482
|
-
const tanHi = Math.tan(
|
|
52552
|
+
const tanLo = Math.tan(xVal.lo);
|
|
52553
|
+
const tanHi = Math.tan(xVal.hi);
|
|
52483
52554
|
if (tanLo > 1e10 && tanHi < -1e10 || tanLo < -1e10 && tanHi > 1e10) {
|
|
52484
52555
|
return { kind: "singular" };
|
|
52485
52556
|
}
|
|
52486
52557
|
return ok({ lo: tanLo, hi: tanHi });
|
|
52487
52558
|
}
|
|
52488
52559
|
function cot(x) {
|
|
52489
|
-
|
|
52560
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52561
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52562
|
+
const [xVal] = unwrapped;
|
|
52563
|
+
if (xVal.hi - xVal.lo >= PI2) {
|
|
52490
52564
|
return { kind: "singular" };
|
|
52491
52565
|
}
|
|
52492
|
-
if (containsExtremum(
|
|
52493
|
-
const n = Math.ceil(
|
|
52566
|
+
if (containsExtremum(xVal, 0, PI2)) {
|
|
52567
|
+
const n = Math.ceil(xVal.lo / PI2);
|
|
52494
52568
|
const poleAt = n * PI2;
|
|
52495
52569
|
return { kind: "singular", at: poleAt };
|
|
52496
52570
|
}
|
|
52497
|
-
const cotLo = 1 / Math.tan(
|
|
52498
|
-
const cotHi = 1 / Math.tan(
|
|
52571
|
+
const cotLo = 1 / Math.tan(xVal.lo);
|
|
52572
|
+
const cotHi = 1 / Math.tan(xVal.hi);
|
|
52499
52573
|
return ok({ lo: Math.min(cotLo, cotHi), hi: Math.max(cotLo, cotHi) });
|
|
52500
52574
|
}
|
|
52501
52575
|
function sec(x) {
|
|
52502
|
-
|
|
52576
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52577
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52578
|
+
const [xVal] = unwrapped;
|
|
52579
|
+
if (xVal.hi - xVal.lo >= PI2) {
|
|
52503
52580
|
return { kind: "singular" };
|
|
52504
52581
|
}
|
|
52505
|
-
if (containsExtremum(
|
|
52506
|
-
const n = Math.ceil((
|
|
52582
|
+
if (containsExtremum(xVal, HALF_PI, PI2)) {
|
|
52583
|
+
const n = Math.ceil((xVal.lo - HALF_PI) / PI2);
|
|
52507
52584
|
const poleAt = HALF_PI + n * PI2;
|
|
52508
52585
|
return { kind: "singular", at: poleAt };
|
|
52509
52586
|
}
|
|
52510
|
-
const secLo = 1 / Math.cos(
|
|
52511
|
-
const secHi = 1 / Math.cos(
|
|
52587
|
+
const secLo = 1 / Math.cos(xVal.lo);
|
|
52588
|
+
const secHi = 1 / Math.cos(xVal.hi);
|
|
52512
52589
|
let lo = Math.min(secLo, secHi);
|
|
52513
52590
|
let hi = Math.max(secLo, secHi);
|
|
52514
|
-
if (containsExtremum(
|
|
52591
|
+
if (containsExtremum(xVal, 0, TWO_PI)) {
|
|
52515
52592
|
lo = Math.min(lo, 1);
|
|
52516
52593
|
hi = Math.max(hi, 1);
|
|
52517
52594
|
}
|
|
52518
|
-
if (containsExtremum(
|
|
52595
|
+
if (containsExtremum(xVal, PI2, TWO_PI)) {
|
|
52519
52596
|
lo = Math.min(lo, -1);
|
|
52520
52597
|
hi = Math.max(hi, -1);
|
|
52521
52598
|
}
|
|
52522
52599
|
return ok({ lo, hi });
|
|
52523
52600
|
}
|
|
52524
52601
|
function csc(x) {
|
|
52525
|
-
|
|
52602
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52603
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52604
|
+
const [xVal] = unwrapped;
|
|
52605
|
+
if (xVal.hi - xVal.lo >= PI2) {
|
|
52526
52606
|
return { kind: "singular" };
|
|
52527
52607
|
}
|
|
52528
|
-
if (containsExtremum(
|
|
52529
|
-
const n = Math.ceil(
|
|
52608
|
+
if (containsExtremum(xVal, 0, PI2)) {
|
|
52609
|
+
const n = Math.ceil(xVal.lo / PI2);
|
|
52530
52610
|
const poleAt = n * PI2;
|
|
52531
52611
|
return { kind: "singular", at: poleAt };
|
|
52532
52612
|
}
|
|
52533
|
-
const cscLo = 1 / Math.sin(
|
|
52534
|
-
const cscHi = 1 / Math.sin(
|
|
52613
|
+
const cscLo = 1 / Math.sin(xVal.lo);
|
|
52614
|
+
const cscHi = 1 / Math.sin(xVal.hi);
|
|
52535
52615
|
let lo = Math.min(cscLo, cscHi);
|
|
52536
52616
|
let hi = Math.max(cscLo, cscHi);
|
|
52537
|
-
if (containsExtremum(
|
|
52617
|
+
if (containsExtremum(xVal, HALF_PI, TWO_PI)) {
|
|
52538
52618
|
lo = Math.min(lo, 1);
|
|
52539
52619
|
hi = Math.max(hi, 1);
|
|
52540
52620
|
}
|
|
52541
|
-
if (containsExtremum(
|
|
52621
|
+
if (containsExtremum(xVal, THREE_HALF_PI, TWO_PI)) {
|
|
52542
52622
|
lo = Math.min(lo, -1);
|
|
52543
52623
|
hi = Math.max(hi, -1);
|
|
52544
52624
|
}
|
|
52545
52625
|
return ok({ lo, hi });
|
|
52546
52626
|
}
|
|
52547
52627
|
function asin2(x) {
|
|
52548
|
-
|
|
52628
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52629
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52630
|
+
const [xVal] = unwrapped;
|
|
52631
|
+
if (xVal.lo > 1 || xVal.hi < -1) {
|
|
52549
52632
|
return { kind: "empty" };
|
|
52550
52633
|
}
|
|
52551
|
-
if (
|
|
52552
|
-
const clippedLo = Math.max(
|
|
52553
|
-
const clippedHi = Math.min(
|
|
52634
|
+
if (xVal.lo < -1 || xVal.hi > 1) {
|
|
52635
|
+
const clippedLo = Math.max(xVal.lo, -1);
|
|
52636
|
+
const clippedHi = Math.min(xVal.hi, 1);
|
|
52554
52637
|
return {
|
|
52555
52638
|
kind: "partial",
|
|
52556
52639
|
value: { lo: Math.asin(clippedLo), hi: Math.asin(clippedHi) },
|
|
52557
|
-
domainClipped:
|
|
52640
|
+
domainClipped: xVal.lo < -1 && xVal.hi > 1 ? "both" : xVal.lo < -1 ? "lo" : "hi"
|
|
52558
52641
|
};
|
|
52559
52642
|
}
|
|
52560
|
-
return ok({ lo: Math.asin(
|
|
52643
|
+
return ok({ lo: Math.asin(xVal.lo), hi: Math.asin(xVal.hi) });
|
|
52561
52644
|
}
|
|
52562
52645
|
function acos2(x) {
|
|
52563
|
-
|
|
52646
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52647
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52648
|
+
const [xVal] = unwrapped;
|
|
52649
|
+
if (xVal.lo > 1 || xVal.hi < -1) {
|
|
52564
52650
|
return { kind: "empty" };
|
|
52565
52651
|
}
|
|
52566
|
-
if (
|
|
52567
|
-
const clippedLo = Math.max(
|
|
52568
|
-
const clippedHi = Math.min(
|
|
52652
|
+
if (xVal.lo < -1 || xVal.hi > 1) {
|
|
52653
|
+
const clippedLo = Math.max(xVal.lo, -1);
|
|
52654
|
+
const clippedHi = Math.min(xVal.hi, 1);
|
|
52569
52655
|
return {
|
|
52570
52656
|
kind: "partial",
|
|
52571
52657
|
value: { lo: Math.acos(clippedHi), hi: Math.acos(clippedLo) },
|
|
52572
|
-
domainClipped:
|
|
52658
|
+
domainClipped: xVal.lo < -1 && xVal.hi > 1 ? "both" : xVal.lo < -1 ? "lo" : "hi"
|
|
52573
52659
|
};
|
|
52574
52660
|
}
|
|
52575
|
-
return ok({ lo: Math.acos(
|
|
52661
|
+
return ok({ lo: Math.acos(xVal.hi), hi: Math.acos(xVal.lo) });
|
|
52576
52662
|
}
|
|
52577
52663
|
function atan3(x) {
|
|
52578
|
-
|
|
52664
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52665
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52666
|
+
const [xVal] = unwrapped;
|
|
52667
|
+
return ok({ lo: Math.atan(xVal.lo), hi: Math.atan(xVal.hi) });
|
|
52579
52668
|
}
|
|
52580
52669
|
function atan22(y, x) {
|
|
52581
|
-
|
|
52582
|
-
|
|
52670
|
+
const unwrapped = unwrapOrPropagate(y, x);
|
|
52671
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52672
|
+
const [yVal, xVal] = unwrapped;
|
|
52673
|
+
if (yVal.lo === yVal.hi && xVal.lo === xVal.hi) {
|
|
52674
|
+
const result = Math.atan2(yVal.lo, xVal.lo);
|
|
52583
52675
|
return ok({ lo: result, hi: result });
|
|
52584
52676
|
}
|
|
52585
52677
|
const angles = [];
|
|
52586
|
-
angles.push(Math.atan2(
|
|
52587
|
-
angles.push(Math.atan2(
|
|
52588
|
-
angles.push(Math.atan2(
|
|
52589
|
-
angles.push(Math.atan2(
|
|
52590
|
-
if (
|
|
52678
|
+
angles.push(Math.atan2(yVal.lo, xVal.lo));
|
|
52679
|
+
angles.push(Math.atan2(yVal.lo, xVal.hi));
|
|
52680
|
+
angles.push(Math.atan2(yVal.hi, xVal.lo));
|
|
52681
|
+
angles.push(Math.atan2(yVal.hi, xVal.hi));
|
|
52682
|
+
if (xVal.lo < 0 && yVal.lo < 0 && yVal.hi > 0) {
|
|
52591
52683
|
return ok({ lo: -PI2, hi: PI2 });
|
|
52592
52684
|
}
|
|
52593
52685
|
return ok({ lo: Math.min(...angles), hi: Math.max(...angles) });
|
|
52594
52686
|
}
|
|
52595
52687
|
function sinh3(x) {
|
|
52596
|
-
|
|
52688
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52689
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52690
|
+
const [xVal] = unwrapped;
|
|
52691
|
+
return ok({ lo: Math.sinh(xVal.lo), hi: Math.sinh(xVal.hi) });
|
|
52597
52692
|
}
|
|
52598
52693
|
function cosh3(x) {
|
|
52599
|
-
|
|
52600
|
-
|
|
52601
|
-
|
|
52602
|
-
|
|
52694
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52695
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52696
|
+
const [xVal] = unwrapped;
|
|
52697
|
+
if (xVal.lo >= 0) {
|
|
52698
|
+
return ok({ lo: Math.cosh(xVal.lo), hi: Math.cosh(xVal.hi) });
|
|
52699
|
+
} else if (xVal.hi <= 0) {
|
|
52700
|
+
return ok({ lo: Math.cosh(xVal.hi), hi: Math.cosh(xVal.lo) });
|
|
52603
52701
|
} else {
|
|
52604
|
-
return ok({
|
|
52702
|
+
return ok({
|
|
52703
|
+
lo: 1,
|
|
52704
|
+
hi: Math.max(Math.cosh(xVal.lo), Math.cosh(xVal.hi))
|
|
52705
|
+
});
|
|
52605
52706
|
}
|
|
52606
52707
|
}
|
|
52607
52708
|
function tanh2(x) {
|
|
52608
|
-
|
|
52709
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52710
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52711
|
+
const [xVal] = unwrapped;
|
|
52712
|
+
return ok({ lo: Math.tanh(xVal.lo), hi: Math.tanh(xVal.hi) });
|
|
52609
52713
|
}
|
|
52610
52714
|
function asinh2(x) {
|
|
52611
|
-
|
|
52715
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52716
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52717
|
+
const [xVal] = unwrapped;
|
|
52718
|
+
return ok({ lo: Math.asinh(xVal.lo), hi: Math.asinh(xVal.hi) });
|
|
52612
52719
|
}
|
|
52613
52720
|
function acosh2(x) {
|
|
52614
|
-
|
|
52721
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52722
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52723
|
+
const [xVal] = unwrapped;
|
|
52724
|
+
if (xVal.hi < 1) {
|
|
52615
52725
|
return { kind: "empty" };
|
|
52616
52726
|
}
|
|
52617
|
-
if (
|
|
52727
|
+
if (xVal.lo < 1) {
|
|
52618
52728
|
return {
|
|
52619
52729
|
kind: "partial",
|
|
52620
|
-
value: { lo: 0, hi: Math.acosh(
|
|
52730
|
+
value: { lo: 0, hi: Math.acosh(xVal.hi) },
|
|
52621
52731
|
domainClipped: "lo"
|
|
52622
52732
|
};
|
|
52623
52733
|
}
|
|
52624
|
-
return ok({ lo: Math.acosh(
|
|
52734
|
+
return ok({ lo: Math.acosh(xVal.lo), hi: Math.acosh(xVal.hi) });
|
|
52625
52735
|
}
|
|
52626
52736
|
function atanh2(x) {
|
|
52627
|
-
|
|
52737
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52738
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52739
|
+
const [xVal] = unwrapped;
|
|
52740
|
+
if (xVal.lo >= 1 || xVal.hi <= -1) {
|
|
52628
52741
|
return { kind: "empty" };
|
|
52629
52742
|
}
|
|
52630
|
-
if (
|
|
52631
|
-
const clippedLo = Math.max(
|
|
52632
|
-
const clippedHi = Math.min(
|
|
52743
|
+
if (xVal.lo <= -1 || xVal.hi >= 1) {
|
|
52744
|
+
const clippedLo = Math.max(xVal.lo, -1 + Number.EPSILON);
|
|
52745
|
+
const clippedHi = Math.min(xVal.hi, 1 - Number.EPSILON);
|
|
52633
52746
|
return {
|
|
52634
52747
|
kind: "partial",
|
|
52635
52748
|
value: { lo: Math.atanh(clippedLo), hi: Math.atanh(clippedHi) },
|
|
52636
|
-
domainClipped:
|
|
52749
|
+
domainClipped: xVal.lo <= -1 && xVal.hi >= 1 ? "both" : xVal.lo <= -1 ? "lo" : "hi"
|
|
52637
52750
|
};
|
|
52638
52751
|
}
|
|
52639
|
-
return ok({ lo: Math.atanh(
|
|
52752
|
+
return ok({ lo: Math.atanh(xVal.lo), hi: Math.atanh(xVal.hi) });
|
|
52640
52753
|
}
|
|
52641
52754
|
|
|
52642
52755
|
// src/compute-engine/interval/comparison.ts
|
|
52643
52756
|
function less(a, b) {
|
|
52644
|
-
|
|
52645
|
-
if (
|
|
52757
|
+
const unwrapped = unwrapOrPropagate(a, b);
|
|
52758
|
+
if (!Array.isArray(unwrapped)) return "maybe";
|
|
52759
|
+
const [aVal, bVal] = unwrapped;
|
|
52760
|
+
if (aVal.hi < bVal.lo) return "true";
|
|
52761
|
+
if (aVal.lo >= bVal.hi) return "false";
|
|
52646
52762
|
return "maybe";
|
|
52647
52763
|
}
|
|
52648
52764
|
function lessEqual(a, b) {
|
|
52649
|
-
|
|
52650
|
-
if (
|
|
52765
|
+
const unwrapped = unwrapOrPropagate(a, b);
|
|
52766
|
+
if (!Array.isArray(unwrapped)) return "maybe";
|
|
52767
|
+
const [aVal, bVal] = unwrapped;
|
|
52768
|
+
if (aVal.hi <= bVal.lo) return "true";
|
|
52769
|
+
if (aVal.lo > bVal.hi) return "false";
|
|
52651
52770
|
return "maybe";
|
|
52652
52771
|
}
|
|
52653
52772
|
function greater(a, b) {
|
|
52654
|
-
|
|
52655
|
-
if (
|
|
52773
|
+
const unwrapped = unwrapOrPropagate(a, b);
|
|
52774
|
+
if (!Array.isArray(unwrapped)) return "maybe";
|
|
52775
|
+
const [aVal, bVal] = unwrapped;
|
|
52776
|
+
if (aVal.lo > bVal.hi) return "true";
|
|
52777
|
+
if (aVal.hi <= bVal.lo) return "false";
|
|
52656
52778
|
return "maybe";
|
|
52657
52779
|
}
|
|
52658
52780
|
function greaterEqual(a, b) {
|
|
52659
|
-
|
|
52660
|
-
if (
|
|
52781
|
+
const unwrapped = unwrapOrPropagate(a, b);
|
|
52782
|
+
if (!Array.isArray(unwrapped)) return "maybe";
|
|
52783
|
+
const [aVal, bVal] = unwrapped;
|
|
52784
|
+
if (aVal.lo >= bVal.hi) return "true";
|
|
52785
|
+
if (aVal.hi < bVal.lo) return "false";
|
|
52661
52786
|
return "maybe";
|
|
52662
52787
|
}
|
|
52663
52788
|
function equal(a, b) {
|
|
52664
|
-
|
|
52665
|
-
if (
|
|
52789
|
+
const unwrapped = unwrapOrPropagate(a, b);
|
|
52790
|
+
if (!Array.isArray(unwrapped)) return "maybe";
|
|
52791
|
+
const [aVal, bVal] = unwrapped;
|
|
52792
|
+
if (aVal.lo === aVal.hi && bVal.lo === bVal.hi && aVal.lo === bVal.lo)
|
|
52793
|
+
return "true";
|
|
52794
|
+
if (aVal.hi < bVal.lo || bVal.hi < aVal.lo) return "false";
|
|
52666
52795
|
return "maybe";
|
|
52667
52796
|
}
|
|
52668
52797
|
function notEqual(a, b) {
|
|
@@ -52686,22 +52815,45 @@ Error in definition of "${name}"`,
|
|
|
52686
52815
|
if (a === "false") return "true";
|
|
52687
52816
|
return "maybe";
|
|
52688
52817
|
}
|
|
52689
|
-
function piecewise(
|
|
52690
|
-
|
|
52818
|
+
function piecewise(xOrCond, conditionOrTrue, trueOrFalse, falseBranch) {
|
|
52819
|
+
if (xOrCond === "true" || xOrCond === "false" || xOrCond === "maybe") {
|
|
52820
|
+
const cond2 = xOrCond;
|
|
52821
|
+
const trueBranch2 = conditionOrTrue;
|
|
52822
|
+
const falseBranchFn2 = trueOrFalse;
|
|
52823
|
+
switch (cond2) {
|
|
52824
|
+
case "true":
|
|
52825
|
+
return trueBranch2();
|
|
52826
|
+
case "false":
|
|
52827
|
+
return falseBranchFn2();
|
|
52828
|
+
case "maybe":
|
|
52829
|
+
return unionResults(trueBranch2(), falseBranchFn2());
|
|
52830
|
+
}
|
|
52831
|
+
}
|
|
52832
|
+
const x = xOrCond;
|
|
52833
|
+
const condition = conditionOrTrue;
|
|
52834
|
+
const trueBranch = trueOrFalse;
|
|
52835
|
+
const falseBranchFn = falseBranch;
|
|
52836
|
+
const unwrapped = unwrapOrPropagate(x);
|
|
52837
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52838
|
+
const [xVal] = unwrapped;
|
|
52839
|
+
const cond = condition(xVal);
|
|
52691
52840
|
switch (cond) {
|
|
52692
52841
|
case "true":
|
|
52693
|
-
return trueBranch(
|
|
52842
|
+
return trueBranch(xVal);
|
|
52694
52843
|
case "false":
|
|
52695
|
-
return
|
|
52844
|
+
return falseBranchFn(xVal);
|
|
52696
52845
|
case "maybe":
|
|
52697
|
-
const t = trueBranch(
|
|
52698
|
-
const f =
|
|
52846
|
+
const t = trueBranch(xVal);
|
|
52847
|
+
const f = falseBranchFn(xVal);
|
|
52699
52848
|
return unionResults(t, f);
|
|
52700
52849
|
}
|
|
52701
52850
|
}
|
|
52702
52851
|
function clamp2(x, lo, hi) {
|
|
52703
|
-
const
|
|
52704
|
-
|
|
52852
|
+
const unwrapped = unwrapOrPropagate(x, lo, hi);
|
|
52853
|
+
if (!Array.isArray(unwrapped)) return unwrapped;
|
|
52854
|
+
const [xVal, loVal, hiVal] = unwrapped;
|
|
52855
|
+
const resultLo = Math.max(xVal.lo, loVal.lo);
|
|
52856
|
+
const resultHi = Math.min(xVal.hi, hiVal.hi);
|
|
52705
52857
|
if (resultLo > resultHi) {
|
|
52706
52858
|
return { kind: "empty" };
|
|
52707
52859
|
}
|
|
@@ -52929,11 +53081,20 @@ Error in definition of "${name}"`,
|
|
|
52929
53081
|
if (args.length !== 3) throw new Error("If: wrong number of arguments");
|
|
52930
53082
|
return `_IA.piecewise(
|
|
52931
53083
|
${compile(args[0])},
|
|
52932
|
-
(
|
|
52933
|
-
(
|
|
52934
|
-
(_x) => ${compile(args[2])}
|
|
53084
|
+
() => ${compile(args[1])},
|
|
53085
|
+
() => ${compile(args[2])}
|
|
52935
53086
|
)`;
|
|
52936
|
-
}
|
|
53087
|
+
},
|
|
53088
|
+
// Comparisons
|
|
53089
|
+
Equal: (args, compile) => `_IA.equal(${compile(args[0])}, ${compile(args[1])})`,
|
|
53090
|
+
NotEqual: (args, compile) => `_IA.notEqual(${compile(args[0])}, ${compile(args[1])})`,
|
|
53091
|
+
LessEqual: (args, compile) => `_IA.lessEqual(${compile(args[0])}, ${compile(args[1])})`,
|
|
53092
|
+
GreaterEqual: (args, compile) => `_IA.greaterEqual(${compile(args[0])}, ${compile(args[1])})`,
|
|
53093
|
+
Less: (args, compile) => `_IA.less(${compile(args[0])}, ${compile(args[1])})`,
|
|
53094
|
+
Greater: (args, compile) => `_IA.greater(${compile(args[0])}, ${compile(args[1])})`,
|
|
53095
|
+
And: (args, compile) => `_IA.and(${compile(args[0])}, ${compile(args[1])})`,
|
|
53096
|
+
Or: (args, compile) => `_IA.or(${compile(args[0])}, ${compile(args[1])})`,
|
|
53097
|
+
Not: (args, compile) => `_IA.not(${compile(args[0])})`
|
|
52937
53098
|
};
|
|
52938
53099
|
var ComputeEngineIntervalFunction = class extends Function {
|
|
52939
53100
|
IA = IntervalArithmetic;
|
|
@@ -53111,6 +53272,10 @@ IntervalResult ia_partial(vec2 v, float clip) {
|
|
|
53111
53272
|
return IntervalResult(v, clip);
|
|
53112
53273
|
}
|
|
53113
53274
|
|
|
53275
|
+
bool ia_is_error(float status) {
|
|
53276
|
+
return status == IA_EMPTY || status == IA_ENTIRE || status == IA_SINGULAR;
|
|
53277
|
+
}
|
|
53278
|
+
|
|
53114
53279
|
// Addition
|
|
53115
53280
|
IntervalResult ia_add(vec2 a, vec2 b) {
|
|
53116
53281
|
return ia_ok(vec2(a.x + b.x - IA_EPS, a.y + b.y + IA_EPS));
|
|
@@ -53426,6 +53591,198 @@ IntervalResult ia_cosh(vec2 x) {
|
|
|
53426
53591
|
IntervalResult ia_tanh(vec2 x) {
|
|
53427
53592
|
return ia_ok(vec2(tanh(x.x) - IA_EPS, tanh(x.y) + IA_EPS));
|
|
53428
53593
|
}
|
|
53594
|
+
|
|
53595
|
+
// IntervalResult overloads for propagation
|
|
53596
|
+
IntervalResult ia_add(IntervalResult a, IntervalResult b) {
|
|
53597
|
+
if (ia_is_error(a.status)) return a;
|
|
53598
|
+
if (ia_is_error(b.status)) return b;
|
|
53599
|
+
return ia_add(a.value, b.value);
|
|
53600
|
+
}
|
|
53601
|
+
|
|
53602
|
+
IntervalResult ia_add(IntervalResult a, vec2 b) {
|
|
53603
|
+
if (ia_is_error(a.status)) return a;
|
|
53604
|
+
return ia_add(a.value, b);
|
|
53605
|
+
}
|
|
53606
|
+
|
|
53607
|
+
IntervalResult ia_add(vec2 a, IntervalResult b) {
|
|
53608
|
+
if (ia_is_error(b.status)) return b;
|
|
53609
|
+
return ia_add(a, b.value);
|
|
53610
|
+
}
|
|
53611
|
+
|
|
53612
|
+
IntervalResult ia_sub(IntervalResult a, IntervalResult b) {
|
|
53613
|
+
if (ia_is_error(a.status)) return a;
|
|
53614
|
+
if (ia_is_error(b.status)) return b;
|
|
53615
|
+
return ia_sub(a.value, b.value);
|
|
53616
|
+
}
|
|
53617
|
+
|
|
53618
|
+
IntervalResult ia_sub(IntervalResult a, vec2 b) {
|
|
53619
|
+
if (ia_is_error(a.status)) return a;
|
|
53620
|
+
return ia_sub(a.value, b);
|
|
53621
|
+
}
|
|
53622
|
+
|
|
53623
|
+
IntervalResult ia_sub(vec2 a, IntervalResult b) {
|
|
53624
|
+
if (ia_is_error(b.status)) return b;
|
|
53625
|
+
return ia_sub(a, b.value);
|
|
53626
|
+
}
|
|
53627
|
+
|
|
53628
|
+
IntervalResult ia_mul(IntervalResult a, IntervalResult b) {
|
|
53629
|
+
if (ia_is_error(a.status)) return a;
|
|
53630
|
+
if (ia_is_error(b.status)) return b;
|
|
53631
|
+
return ia_mul(a.value, b.value);
|
|
53632
|
+
}
|
|
53633
|
+
|
|
53634
|
+
IntervalResult ia_mul(IntervalResult a, vec2 b) {
|
|
53635
|
+
if (ia_is_error(a.status)) return a;
|
|
53636
|
+
return ia_mul(a.value, b);
|
|
53637
|
+
}
|
|
53638
|
+
|
|
53639
|
+
IntervalResult ia_mul(vec2 a, IntervalResult b) {
|
|
53640
|
+
if (ia_is_error(b.status)) return b;
|
|
53641
|
+
return ia_mul(a, b.value);
|
|
53642
|
+
}
|
|
53643
|
+
|
|
53644
|
+
IntervalResult ia_div(IntervalResult a, IntervalResult b) {
|
|
53645
|
+
if (ia_is_error(a.status)) return a;
|
|
53646
|
+
if (ia_is_error(b.status)) return b;
|
|
53647
|
+
return ia_div(a.value, b.value);
|
|
53648
|
+
}
|
|
53649
|
+
|
|
53650
|
+
IntervalResult ia_div(IntervalResult a, vec2 b) {
|
|
53651
|
+
if (ia_is_error(a.status)) return a;
|
|
53652
|
+
return ia_div(a.value, b);
|
|
53653
|
+
}
|
|
53654
|
+
|
|
53655
|
+
IntervalResult ia_div(vec2 a, IntervalResult b) {
|
|
53656
|
+
if (ia_is_error(b.status)) return b;
|
|
53657
|
+
return ia_div(a, b.value);
|
|
53658
|
+
}
|
|
53659
|
+
|
|
53660
|
+
IntervalResult ia_negate(IntervalResult x) {
|
|
53661
|
+
if (ia_is_error(x.status)) return x;
|
|
53662
|
+
return ia_negate(x.value);
|
|
53663
|
+
}
|
|
53664
|
+
|
|
53665
|
+
IntervalResult ia_sqrt(IntervalResult x) {
|
|
53666
|
+
if (ia_is_error(x.status)) return x;
|
|
53667
|
+
return ia_sqrt(x.value);
|
|
53668
|
+
}
|
|
53669
|
+
|
|
53670
|
+
IntervalResult ia_square(IntervalResult x) {
|
|
53671
|
+
if (ia_is_error(x.status)) return x;
|
|
53672
|
+
return ia_square(x.value);
|
|
53673
|
+
}
|
|
53674
|
+
|
|
53675
|
+
IntervalResult ia_exp(IntervalResult x) {
|
|
53676
|
+
if (ia_is_error(x.status)) return x;
|
|
53677
|
+
return ia_exp(x.value);
|
|
53678
|
+
}
|
|
53679
|
+
|
|
53680
|
+
IntervalResult ia_ln(IntervalResult x) {
|
|
53681
|
+
if (ia_is_error(x.status)) return x;
|
|
53682
|
+
return ia_ln(x.value);
|
|
53683
|
+
}
|
|
53684
|
+
|
|
53685
|
+
IntervalResult ia_abs(IntervalResult x) {
|
|
53686
|
+
if (ia_is_error(x.status)) return x;
|
|
53687
|
+
return ia_abs(x.value);
|
|
53688
|
+
}
|
|
53689
|
+
|
|
53690
|
+
IntervalResult ia_sign(IntervalResult x) {
|
|
53691
|
+
if (ia_is_error(x.status)) return x;
|
|
53692
|
+
return ia_sign(x.value);
|
|
53693
|
+
}
|
|
53694
|
+
|
|
53695
|
+
IntervalResult ia_floor(IntervalResult x) {
|
|
53696
|
+
if (ia_is_error(x.status)) return x;
|
|
53697
|
+
return ia_floor(x.value);
|
|
53698
|
+
}
|
|
53699
|
+
|
|
53700
|
+
IntervalResult ia_ceil(IntervalResult x) {
|
|
53701
|
+
if (ia_is_error(x.status)) return x;
|
|
53702
|
+
return ia_ceil(x.value);
|
|
53703
|
+
}
|
|
53704
|
+
|
|
53705
|
+
IntervalResult ia_min(IntervalResult a, IntervalResult b) {
|
|
53706
|
+
if (ia_is_error(a.status)) return a;
|
|
53707
|
+
if (ia_is_error(b.status)) return b;
|
|
53708
|
+
return ia_min(a.value, b.value);
|
|
53709
|
+
}
|
|
53710
|
+
|
|
53711
|
+
IntervalResult ia_min(IntervalResult a, vec2 b) {
|
|
53712
|
+
if (ia_is_error(a.status)) return a;
|
|
53713
|
+
return ia_min(a.value, b);
|
|
53714
|
+
}
|
|
53715
|
+
|
|
53716
|
+
IntervalResult ia_min(vec2 a, IntervalResult b) {
|
|
53717
|
+
if (ia_is_error(b.status)) return b;
|
|
53718
|
+
return ia_min(a, b.value);
|
|
53719
|
+
}
|
|
53720
|
+
|
|
53721
|
+
IntervalResult ia_max(IntervalResult a, IntervalResult b) {
|
|
53722
|
+
if (ia_is_error(a.status)) return a;
|
|
53723
|
+
if (ia_is_error(b.status)) return b;
|
|
53724
|
+
return ia_max(a.value, b.value);
|
|
53725
|
+
}
|
|
53726
|
+
|
|
53727
|
+
IntervalResult ia_max(IntervalResult a, vec2 b) {
|
|
53728
|
+
if (ia_is_error(a.status)) return a;
|
|
53729
|
+
return ia_max(a.value, b);
|
|
53730
|
+
}
|
|
53731
|
+
|
|
53732
|
+
IntervalResult ia_max(vec2 a, IntervalResult b) {
|
|
53733
|
+
if (ia_is_error(b.status)) return b;
|
|
53734
|
+
return ia_max(a, b.value);
|
|
53735
|
+
}
|
|
53736
|
+
|
|
53737
|
+
IntervalResult ia_pow(IntervalResult base, float exp) {
|
|
53738
|
+
if (ia_is_error(base.status)) return base;
|
|
53739
|
+
return ia_pow(base.value, exp);
|
|
53740
|
+
}
|
|
53741
|
+
|
|
53742
|
+
IntervalResult ia_sin(IntervalResult x) {
|
|
53743
|
+
if (ia_is_error(x.status)) return x;
|
|
53744
|
+
return ia_sin(x.value);
|
|
53745
|
+
}
|
|
53746
|
+
|
|
53747
|
+
IntervalResult ia_cos(IntervalResult x) {
|
|
53748
|
+
if (ia_is_error(x.status)) return x;
|
|
53749
|
+
return ia_cos(x.value);
|
|
53750
|
+
}
|
|
53751
|
+
|
|
53752
|
+
IntervalResult ia_tan(IntervalResult x) {
|
|
53753
|
+
if (ia_is_error(x.status)) return x;
|
|
53754
|
+
return ia_tan(x.value);
|
|
53755
|
+
}
|
|
53756
|
+
|
|
53757
|
+
IntervalResult ia_asin(IntervalResult x) {
|
|
53758
|
+
if (ia_is_error(x.status)) return x;
|
|
53759
|
+
return ia_asin(x.value);
|
|
53760
|
+
}
|
|
53761
|
+
|
|
53762
|
+
IntervalResult ia_acos(IntervalResult x) {
|
|
53763
|
+
if (ia_is_error(x.status)) return x;
|
|
53764
|
+
return ia_acos(x.value);
|
|
53765
|
+
}
|
|
53766
|
+
|
|
53767
|
+
IntervalResult ia_atan(IntervalResult x) {
|
|
53768
|
+
if (ia_is_error(x.status)) return x;
|
|
53769
|
+
return ia_atan(x.value);
|
|
53770
|
+
}
|
|
53771
|
+
|
|
53772
|
+
IntervalResult ia_sinh(IntervalResult x) {
|
|
53773
|
+
if (ia_is_error(x.status)) return x;
|
|
53774
|
+
return ia_sinh(x.value);
|
|
53775
|
+
}
|
|
53776
|
+
|
|
53777
|
+
IntervalResult ia_cosh(IntervalResult x) {
|
|
53778
|
+
if (ia_is_error(x.status)) return x;
|
|
53779
|
+
return ia_cosh(x.value);
|
|
53780
|
+
}
|
|
53781
|
+
|
|
53782
|
+
IntervalResult ia_tanh(IntervalResult x) {
|
|
53783
|
+
if (ia_is_error(x.status)) return x;
|
|
53784
|
+
return ia_tanh(x.value);
|
|
53785
|
+
}
|
|
53429
53786
|
`;
|
|
53430
53787
|
var INTERVAL_GLSL_OPERATORS = {
|
|
53431
53788
|
Add: ["ia_add", 20],
|
|
@@ -55422,10 +55779,10 @@ IntervalResult ${functionName}(${params}) {
|
|
|
55422
55779
|
// src/compute-engine.ts
|
|
55423
55780
|
init_types6();
|
|
55424
55781
|
init_base_compiler();
|
|
55425
|
-
var version = "0.35.
|
|
55782
|
+
var version = "0.35.1";
|
|
55426
55783
|
globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
|
|
55427
55784
|
ComputeEngine: ComputeEngine.prototype.constructor,
|
|
55428
|
-
version: "0.35.
|
|
55785
|
+
version: "0.35.1"
|
|
55429
55786
|
};
|
|
55430
55787
|
return __toCommonJS(compute_engine_exports);
|
|
55431
55788
|
})();
|