@photivra/engine 2.10.0 → 2.11.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.
Files changed (115) hide show
  1. package/CHANGELOG.md +139 -1
  2. package/CITATION.cff +1 -1
  3. package/NODE_SUPPORT.md +21 -3
  4. package/README.md +6 -6
  5. package/SECURITY.md +1 -1
  6. package/dist/core/portable-math.d.ts +6 -0
  7. package/dist/core/portable-math.js +39 -0
  8. package/dist/core/portable-math.js.map +1 -1
  9. package/dist/core/version.d.ts +1 -1
  10. package/dist/core/version.js +1 -1
  11. package/dist/core/version.js.map +1 -1
  12. package/dist/facade/chart-material-layers.d.ts +115 -0
  13. package/dist/facade/chart-material-layers.js +224 -0
  14. package/dist/facade/chart-material-layers.js.map +1 -0
  15. package/dist/facade/chart-radiance-batch.d.ts +8 -2
  16. package/dist/facade/chart-radiance-batch.js +11 -4
  17. package/dist/facade/chart-radiance-batch.js.map +1 -1
  18. package/dist/facade/chart-scenes.d.ts +134 -0
  19. package/dist/facade/chart-scenes.js +32 -22
  20. package/dist/facade/chart-scenes.js.map +1 -1
  21. package/dist/facade/diffraction-provider.d.ts +8 -2
  22. package/dist/facade/diffraction-provider.js +71 -2
  23. package/dist/facade/diffraction-provider.js.map +1 -1
  24. package/dist/facade/display-view-gpu-session.d.ts +18 -0
  25. package/dist/facade/display-view-gpu-session.js +280 -0
  26. package/dist/facade/display-view-gpu-session.js.map +1 -0
  27. package/dist/facade/display-view-gpu.d.ts +146 -0
  28. package/dist/facade/display-view-gpu.js +59 -0
  29. package/dist/facade/display-view-gpu.js.map +1 -0
  30. package/dist/facade/display-view.d.ts +48 -1
  31. package/dist/facade/display-view.js +7 -7
  32. package/dist/facade/display-view.js.map +1 -1
  33. package/dist/facade/expected-signal-setup.d.ts +5 -0
  34. package/dist/facade/expected-signal-setup.js +16 -0
  35. package/dist/facade/expected-signal-setup.js.map +1 -1
  36. package/dist/facade/expected-signal.d.ts +48 -3
  37. package/dist/facade/expected-signal.js +8 -0
  38. package/dist/facade/expected-signal.js.map +1 -1
  39. package/dist/facade/scene-radiance.d.ts +4 -2
  40. package/dist/facade/scene-radiance.js +7 -4
  41. package/dist/facade/scene-radiance.js.map +1 -1
  42. package/dist/facade/simulate-capture.d.ts +32 -5
  43. package/dist/facade/simulate-capture.js +148 -24
  44. package/dist/facade/simulate-capture.js.map +1 -1
  45. package/dist/facade/simulate-display-view.d.ts +31 -3
  46. package/dist/facade/simulate-display-view.js +72 -12
  47. package/dist/facade/simulate-display-view.js.map +1 -1
  48. package/dist/gpu/chart-composite-gpu.d.ts +119 -0
  49. package/dist/gpu/chart-composite-gpu.js +572 -0
  50. package/dist/gpu/chart-composite-gpu.js.map +1 -0
  51. package/dist/gpu/chart-radiance-gpu.d.ts +6 -6
  52. package/dist/gpu/chart-radiance-gpu.js +9 -11
  53. package/dist/gpu/chart-radiance-gpu.js.map +1 -1
  54. package/dist/gpu/display-view-chart-material-module.d.ts +10 -0
  55. package/dist/gpu/display-view-chart-material-module.js +58 -0
  56. package/dist/gpu/display-view-chart-material-module.js.map +1 -0
  57. package/dist/gpu/display-view-composite-material-module.d.ts +68 -0
  58. package/dist/gpu/display-view-composite-material-module.js +248 -0
  59. package/dist/gpu/display-view-composite-material-module.js.map +1 -0
  60. package/dist/gpu/display-view-quality-gpu.d.ts +185 -0
  61. package/dist/gpu/display-view-quality-gpu.js +1000 -0
  62. package/dist/gpu/display-view-quality-gpu.js.map +1 -0
  63. package/dist/gpu/display-view-speed-gpu.d.ts +156 -0
  64. package/dist/gpu/display-view-speed-gpu.js +524 -0
  65. package/dist/gpu/display-view-speed-gpu.js.map +1 -0
  66. package/dist/gpu/image-kernel-accelerator.d.ts +23 -4
  67. package/dist/gpu/image-kernel-accelerator.js +58 -10
  68. package/dist/gpu/image-kernel-accelerator.js.map +1 -1
  69. package/dist/gpu/image-kernel-execution.d.ts +55 -3
  70. package/dist/gpu/image-kernel-execution.js.map +1 -1
  71. package/dist/gpu/sensor-stage-gpu.d.ts +11 -0
  72. package/dist/gpu/sensor-stage-gpu.js +42 -13
  73. package/dist/gpu/sensor-stage-gpu.js.map +1 -1
  74. package/dist/gpu/webgpu-runtime.d.ts +4 -2
  75. package/dist/gpu/webgpu-runtime.js +13 -4
  76. package/dist/gpu/webgpu-runtime.js.map +1 -1
  77. package/dist/gpu/webgpu-switch.d.ts +4 -0
  78. package/dist/gpu/webgpu-switch.js +29 -0
  79. package/dist/gpu/webgpu-switch.js.map +1 -0
  80. package/dist/gpu/wgsl-chart-composite-kernel.d.ts +52 -0
  81. package/dist/gpu/wgsl-chart-composite-kernel.js +515 -0
  82. package/dist/gpu/wgsl-chart-composite-kernel.js.map +1 -0
  83. package/dist/gpu/wgsl-chart-kernel.d.ts +11 -9
  84. package/dist/gpu/wgsl-chart-kernel.js +33 -27
  85. package/dist/gpu/wgsl-chart-kernel.js.map +1 -1
  86. package/dist/gpu/wgsl-display-view-quality-kernel.d.ts +95 -0
  87. package/dist/gpu/wgsl-display-view-quality-kernel.js +769 -0
  88. package/dist/gpu/wgsl-display-view-quality-kernel.js.map +1 -0
  89. package/dist/gpu/wgsl-display-view-speed-kernel.d.ts +75 -0
  90. package/dist/gpu/wgsl-display-view-speed-kernel.js +386 -0
  91. package/dist/gpu/wgsl-display-view-speed-kernel.js.map +1 -0
  92. package/dist/gpu/wgsl-sensor-kernel.d.ts +28 -9
  93. package/dist/gpu/wgsl-sensor-kernel.js +94 -50
  94. package/dist/gpu/wgsl-sensor-kernel.js.map +1 -1
  95. package/dist/index.d.ts +4 -1
  96. package/dist/index.js +2 -0
  97. package/dist/index.js.map +1 -1
  98. package/dist/optics/defocus-disc-kernel.d.ts +61 -0
  99. package/dist/optics/defocus-disc-kernel.js +191 -0
  100. package/dist/optics/defocus-disc-kernel.js.map +1 -0
  101. package/docs/API_REFERENCE.md +45 -1
  102. package/docs/QUICK_START.md +102 -3
  103. package/docs/USAGE.md +52 -2
  104. package/docs/api/core-version.md +1 -1
  105. package/docs/api/exports.json +117 -2
  106. package/docs/api/facade-chart-material-layers.md +137 -0
  107. package/docs/api/facade-chart-radiance-batch.md +7 -2
  108. package/docs/api/facade-display-view-gpu.md +94 -0
  109. package/docs/api/facade-scene-radiance.md +3 -2
  110. package/docs/api/facade-simulate-capture.md +23 -6
  111. package/docs/api/facade-simulate-display-view.md +17 -2
  112. package/docs/api/gpu-image-kernel-accelerator.md +10 -3
  113. package/docs/api/gpu-image-kernel-execution.md +71 -4
  114. package/docs/api/gpu-webgpu-switch.md +23 -0
  115. package/package.json +3 -1
@@ -1 +1 @@
1
- {"version":3,"file":"portable-math.js","sourceRoot":"","sources":["../../src/core/portable-math.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;GAYG;AAEH,MAAM,KAAK,GAAG,CAAC,IAAI,GAAG,CAAC;AACvB,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;AACxB,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;AAC7B,MAAM,QAAQ,GAAG,CAAC,IAAI,GAAG,CAAC;AAE1B;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,GAAG,MAAyB;IACxD,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC,CAAC,SAAS,IAAI,OAAO,CAAC;YAAE,OAAO,GAAG,SAAS,CAAC;IACnD,CAAC;IACD,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAC;IAC/D,MAAM,KAAK,GAAG,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC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AAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;AAChJ,CAAC;AACD,oGAAoG;AACpG,MAAM,UAAU,gBAAgB,CAAC,CAAS;IACxC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAAE,OAAO,GAAG,CAAC;IACpC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IAClF,OAAO,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;AAChJ,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Floating-point helpers that give bit-identical results in every JavaScript engine.\n *\n * ECMAScript requires `+ - * /` and `Math.sqrt` to be correctly rounded IEEE 754 binary64\n * (double-precision) operations. A fixed sequence of them gives the same bits in every\n * conforming engine. `Math.hypot`, `Math.exp`, `Math.atan`, `Math.cos` and the other\n * transcendental functions are \"implementation-approximated\" (ECMA-262 §21.3.2). They can\n * differ in the last bit between V8, JavaScriptCore and SpiderMonkey.\n *\n * So any value that is stored and later recomputed for an exact identity check must use\n * only the correctly rounded operations.\n * @see docs/NUMERICAL_CORRECTNESS.md §Cross-engine determinism\n */\n\nconst LARGE = 2 ** 500;\nconst SMALL = 2 ** -500;\nconst SCALE_DOWN = 2 ** -600;\nconst SCALE_UP = 2 ** 600;\n\n/**\n * Euclidean norm (vector length) of the components. Unlike `Math.hypot`, it uses only correctly\n * rounded IEEE operations, so the result is bit-identical in every JavaScript engine.\n *\n * Components are summed in argument order. Inputs far from 1 are first rescaled by an exact power\n * of two, so squaring cannot overflow or underflow. Non-finite input gives a non-finite result;\n * callers validate inputs first.\n */\nexport function portableHypot(...values: readonly number[]): number {\n let maximum = 0;\n for (const value of values) {\n const magnitude = Math.abs(value);\n if (!(magnitude <= maximum)) maximum = magnitude;\n }\n if (maximum === 0 || !Number.isFinite(maximum)) return maximum;\n const scale = maximum > LARGE ? SCALE_DOWN : maximum < SMALL ? SCALE_UP : 1;\n let sum = 0;\n for (const value of values) {\n const scaled = value * scale;\n sum += scaled * scaled;\n }\n return Math.sqrt(sum) / scale;\n}\n\n/**\n * V8's three-argument `Math.hypot` as a fixed sequence of correctly rounded operations, so the result has V8's bits in\n * every JavaScript engine. The sequence is V8's `MathHypot` (src/builtins/math.tq; also its three-argument\n * `FastMathHypot`): the largest magnitude, starting from 0, normalises the arguments; their squares are summed in\n * argument order with Kahan compensation; the result is the square root of the sum times the largest magnitude. An\n * infinite argument gives Infinity (even beside NaN), otherwise a NaN argument gives NaN, and all zeros give +0.\n *\n * It is not `portableHypot`: that function rescales by powers of two and sums without compensation, so it is portable\n * too but gives other bits than `Math.hypot`. This one replaces `Math.hypot` where today's V8 bits must be kept (the\n * capture's query arithmetic and the display view's copy of it), and makes the other engines compute them too.\n * @see docs/NUMERICAL_CORRECTNESS.md §Cross-engine determinism\n */\nexport function hypot3(a: number, b: number, c: number): number {\n a = Math.abs(a);\n b = Math.abs(b);\n c = Math.abs(c);\n let max = 0;\n if (a > max) max = a;\n if (b > max) max = b;\n if (c > max) max = c;\n if (max === Infinity) return Infinity;\n if (a !== a || b !== b || c !== c) return NaN;\n if (max === 0) return 0;\n let sum = 0, compensation = 0;\n let n = a / max, summand = n * n - compensation, preliminary = sum + summand;\n compensation = (preliminary - sum) - summand;\n sum = preliminary;\n n = b / max;\n summand = n * n - compensation;\n preliminary = sum + summand;\n compensation = (preliminary - sum) - summand;\n sum = preliminary;\n n = c / max;\n summand = n * n - compensation;\n sum = sum + summand;\n return Math.sqrt(sum) * max;\n}\n\n/**\n * True when two finite numbers differ by at most `maximumUlps` ULPs (units in the last place).\n * One ULP here is `Number.EPSILON` times the larger magnitude. Use it to accept an archived value\n * that another engine or an earlier release computed with an implementation-approximated function.\n */\nexport function equalWithinUlps(a: number, b: number, maximumUlps: number): boolean {\n if (!Number.isFinite(a) || !Number.isFinite(b)) return false;\n if (a === b) return true;\n return Math.abs(a - b) <= maximumUlps * Number.EPSILON * Math.max(Math.abs(a), Math.abs(b));\n}\n\n// ---------------------------------------------------------------------------------------------------------------\n// Portable logarithm, exponential, power, cube root and cosine/sine of 2πu.\n//\n// Each function below is a fixed sequence of correctly rounded binary64 operations (+, −, ×, ÷, exact\n// power-of-two scaling through the IEEE 754 bit pattern, Math.round/Math.floor and integer operations), with\n// every constant written as a decimal literal of at most 17 significant digits (ECMAScript converts these\n// exactly to the nearest double). The bits of every result are therefore the same in every conforming\n// JavaScript engine, unlike Math.pow, Math.exp, Math.log, Math.cbrt and Math.cos, which ECMA-262 leaves\n// \"implementation-approximated\" (docs/NUMERICAL_CORRECTNESS.md, \"Cross-engine determinism\").\n//\n// Methods (textbook; no code copied):\n// - Error-free transformations (double-double arithmetic): TwoSum (Knuth, The Art of Computer Programming\n// vol. 2, §4.2.2), FastTwoSum and TwoProduct with Veltkamp's splitting (Dekker, \"A floating-point technique\n// for extending the available precision\", Numerische Mathematik 18, 1971). Exact barring overflow and\n// underflow, which the arguments here cannot reach.\n// - log2(x): x = m·2^e with m in [√½, √2); ln m = 2·atanh(s) = 2(s + s³/3 + s⁵/5 + …), s = (m − 1)/(m + 1),\n// |s| ≤ 0.1716 (J.-M. Muller, Elementary Functions: Algorithms and Implementation, 3rd ed., 2016, ch. 11).\n// s carries a double-double correction; the series runs to s²³ (truncation below 2^-62 relative).\n// - 2^t: t = n + r with n = round(t), |r| ≤ ½; 2^r = e^(r·ln 2) by its Taylor series to degree 14 (truncation\n// below 2^-57 relative), then an exact scaling by 2^n (Muller, ch. 11, \"additive range reduction\").\n// - x^y = 2^(y·log2 x) with log2 x and y·log2 x carried as double-double; e^x = 2^(x·log2 e) and\n// ∛x = 2^(log2 x / 3) likewise; ln x = log2 x · ln 2; e^x − 1 by its Taylor series for |x| < 1.\n// - cos(2πu), sin(2πu): u = q/4 + r with q = round(4u) and |r| ≤ ⅛ (exact), then the Taylor series of cos and\n// sin of 2πr to degrees 18 and 19 (truncation below 2^-66).\n//\n// Error bounds (from the operation counts above): portableExp2, portableExp, portableLog, portableLog2 and\n// portableCbrt within 1 ulp; portableExpm1 within 2 ulps; portablePow within 1 ulp for |y| ≤ 4 (the double-double\n// logarithm has relative error below 2^-56, so the error of y·log2 x adds at most |y|·2^-57·ln 2 relative);\n// portableCosTwoPi and portableSinTwoPi within 2 ulps. Checked against 60-digit decimal references (Python decimal)\n// on 2·10⁵ pseudo-random arguments per function (6·10⁵ for portableLog; |y| ≤ 4 and y = 1/2.4, 1.4 for portablePow):\n// largest errors 0.53 ulp (log, log2), 0.86 (exp2), 0.94 (exp, cbrt, pow), 0.97 (pow with y = 1/2.4), 1.59 (cos,\n// sin of 2πu) and 1.66 (e^x − 1); spot values are in test/portable-math.test.ts. These are accuracy bounds;\n// determinism does not depend on them.\n\n/** Bit access to a double: the high 32-bit word is at index HIGH of the view (detected once, so either byte order works). */\n// The tables and constants below are built by expressions marked pure (/* @__PURE__ */), so a bundler drops them from a\n// bundle that uses none of the functions that read them (a capture-only bundle keeps only portableHypot and equalWithinUlps).\nconst BITS = /* @__PURE__ */ new Float64Array(1), WORDS = /* @__PURE__ */ ((): Uint32Array => new Uint32Array(BITS.buffer))();\nconst HIGH = /* @__PURE__ */ ((): number => (new Uint8Array(new Uint16Array([1]).buffer)[0] === 1 ? 1 : 0))(), LOW = 1 - HIGH;\n/** 2^k for every integer k in [−1074, 1023] at POW2[k + 1074], built by exact halving and doubling. */\nconst POW2 = /* @__PURE__ */ ((): Float64Array => {\n const table = new Float64Array(2098);\n table[1074] = 1;\n for (let k = 1; k <= 1023; k++) table[1074 + k] = table[1073 + k]! * 2;\n for (let k = 1; k <= 1074; k++) table[1074 - k] = table[1075 - k]! / 2;\n return table;\n})();\n/** v·2^k for an integer k in [−1100, 1100]: one exact multiplication (a single rounding only when the result is subnormal). */\nfunction scaleByPowerOfTwo(v: number, k: number): number {\n if (k > 1023) return v * POW2[2097]! * POW2[1074 + k - 1023]!;\n if (k < -1074) return v * POW2[1074 + k + 1074]! * POW2[0]!; // exact first factor (v·2^(k+1074) is normal), one rounding\n return v * POW2[1074 + k]!;\n}\n// Double-double arithmetic, written out inline below (local variables only, which keeps it fast):\n// - FastTwoSum (|a| ≥ |b| or a = 0): s = a + b, err = b − (s − a), so a + b = s + err exactly;\n// - TwoSum (any a, b): s = a + b, b' = s − a, err = (a − (s − b')) + (b − b');\n// - TwoProduct: p = a·b, err = ((ah·bh − p) + ah·bl + al·bh) + al·bl, with Veltkamp's split\n// ah = c − (c − a), al = a − ah, c = (2^27 + 1)·a (and likewise for b), so a·b = p + err exactly.\nconst SPLITTER = 134217729; // 2^27 + 1 (Veltkamp)\nconst LN2_HI = 0.6931471805599453, LN2_LO = 2.3190468138462996e-17;\nconst LOG2E_HI = 1.4426950408889634, LOG2E_LO = 2.0355273740931033e-17;\nconst SQRT2 = 1.4142135623730951, TWO_POW_54 = 18014398509481984, MIN_NORMAL = 2.2250738585072014e-308;\n/** Veltkamp halves of a constant (the same values the split gives at each use). */\nfunction splitHigh(a: number): number { const c = SPLITTER * a; return c - (c - a); }\nconst LN2_HI_H = /* @__PURE__ */ splitHigh(LN2_HI), LN2_HI_L = LN2_HI - LN2_HI_H, LOG2E_HI_H = /* @__PURE__ */ splitHigh(LOG2E_HI), LOG2E_HI_L = LOG2E_HI - LOG2E_HI_H;\n/** The low part of the last double-double result (its high part is the return value). */\nconst LOW_PART = /* @__PURE__ */ new Float64Array(1);\n\n/**\n * log2 m for m in [√½, √2] by the atanh series to s²³ (no table): builds LOG2_TABLE once. Returns the high part, the low\n * part in LOW_PART[0]; relative error below 2^-56.\n */\nfunction log2SeriesDoubleDouble(x: number): number {\n let e = 0;\n if (x < MIN_NORMAL) { x *= TWO_POW_54; e = -54; }\n BITS[0] = x;\n const high = WORDS[HIGH]!;\n e += (high >>> 20) - 1023;\n let m = x * POW2[1074 - ((high >>> 20) - 1023)]!; // exact: m in [1, 2)\n if (m > SQRT2) { m *= 0.5; e += 1; }\n // s = f/(2 + f) with f = m − 1 (exact), as sHi + sLo: 2 + f = dh + dl exactly (FastTwoSum), then the residual\n // f − sHi·(dh + dl) with sHi·dh = p + pe exactly (TwoProduct).\n const f = m - 1, dh = 2 + f, dl = f - (dh - 2), sHi = f / dh, p = sHi * dh;\n let c = SPLITTER * sHi;\n const ah = c - (c - sHi), al = sHi - ah;\n c = SPLITTER * dh;\n const bh = c - (c - dh), bl = dh - bh, pe = ((ah * bh - p) + ah * bl + al * bh) + al * bl;\n const sLo = (((f - p) - pe) - sHi * dl) / dh;\n const z = sHi * sHi;\n const tail = sHi * z * (0.6666666666666666 + z * (0.4 + z * (0.2857142857142857 + z * (0.2222222222222222 + z * (0.18181818181818182 + z * (0.15384615384615385 +\n z * (0.13333333333333333 + z * (0.11764705882352941 + z * (0.10526315789473684 + z * (0.09523809523809523 + z * 0.08695652173913043))))))))));\n // ln m = 2sHi + (2sLo + tail) = lh + ll (FastTwoSum); times log2 e = LOG2E_HI + LOG2E_LO (TwoProduct of the high parts); plus e (TwoSum).\n const a1 = 2 * sHi, b1 = 2 * sLo + tail, lh = a1 + b1, ll = b1 - (lh - a1), q = lh * LOG2E_HI;\n c = SPLITTER * lh;\n const ch = c - (c - lh), cl = lh - ch, qe = ((ch * LOG2E_HI_H - q) + ch * LOG2E_HI_L + cl * LOG2E_HI_H) + cl * LOG2E_HI_L;\n const pl = qe + (lh * LOG2E_LO + ll * LOG2E_HI);\n const t = e + q, tb = t - e, te = (e - (t - tb)) + (q - tb), b2 = te + pl, hi = t + b2;\n LOW_PART[0] = b2 - (hi - t);\n return hi;\n}\n/** log2(k/128) for k = 90 … 182 (the table's range of k = round(128·m), m in [√½, √2]) as double-doubles. */\nconst LOG2_TABLE_LO = /* @__PURE__ */ new Float64Array(183);\nconst LOG2_TABLE_HI = /* @__PURE__ */ ((): Float64Array => {\n const table = new Float64Array(183);\n for (let k = 90; k <= 182; k++) { table[k] = log2SeriesDoubleDouble(k / 128); LOG2_TABLE_LO[k] = LOW_PART[0]!; }\n return table;\n})();\n/**\n * log2 x as a double-double for finite x > 0: returns the high part, the low part in LOW_PART[0]. x = m·2^e with m in\n * [√½, √2]; m = F·(1 + f/F) with F = k/128, k = round(128·m), so log2 m = log2 F (table) + 2·atanh(s)·log2 e with\n * s = f/(m + F), |s| < 2^-8.4, by its series to s⁷ (truncation below 2^-70 relative). Relative error below 2^-56.\n */\nfunction log2DoubleDouble(x: number): number {\n let e = 0;\n if (x < MIN_NORMAL) { x *= TWO_POW_54; e = -54; }\n BITS[0] = x;\n const high = WORDS[HIGH]!;\n e += (high >>> 20) - 1023;\n let m = x * POW2[1074 - ((high >>> 20) - 1023)]!; // exact: m in [1, 2)\n if (m > SQRT2) { m *= 0.5; e += 1; }\n // F = k/128 (exact) and f = m − F (exact, F/2 ≤ m ≤ 2F); m + F = dh + dl exactly (TwoSum); s = f/(dh + dl) as sHi + sLo\n // from the residual f − sHi·(dh + dl), with sHi·dh = p + pe exactly (TwoProduct).\n const k = Math.round(m * 128), F = k / 128, f = m - F, dh = m + F, db = dh - m, dl = (m - (dh - db)) + (F - db);\n const sHi = f / dh, p = sHi * dh;\n let c = SPLITTER * sHi;\n const ah = c - (c - sHi), al = sHi - ah;\n c = SPLITTER * dh;\n const bh = c - (c - dh), bl = dh - bh, pe = ((ah * bh - p) + ah * bl + al * bh) + al * bl;\n const sLo = (((f - p) - pe) - sHi * dl) / dh, z = sHi * sHi;\n const tail = sHi * z * (0.6666666666666666 + z * (0.4 + z * 0.2857142857142857));\n // ln(m/F) = 2sHi + (2sLo + tail) = lh + ll (FastTwoSum); times log2 e = LOG2E_HI + LOG2E_LO (TwoProduct of the high\n // parts); plus log2 F (TwoSum with the table's high part), then plus e (TwoSum).\n const a1 = 2 * sHi, b1 = 2 * sLo + tail, lh = a1 + b1, ll = b1 - (lh - a1), q = lh * LOG2E_HI;\n c = SPLITTER * lh;\n const ch = c - (c - lh), cl = lh - ch, qe = ((ch * LOG2E_HI_H - q) + ch * LOG2E_HI_L + cl * LOG2E_HI_H) + cl * LOG2E_HI_L;\n const pl = qe + (lh * LOG2E_LO + ll * LOG2E_HI), th = LOG2_TABLE_HI[k]!;\n const t = th + q, tb = t - th, low = ((th - (t - tb)) + (q - tb)) + (pl + LOG2_TABLE_LO[k]!);\n const u = e + t, ub = u - e, b2 = ((e - (u - ub)) + (t - ub)) + low, hi = u + b2;\n LOW_PART[0] = b2 - (hi - u);\n return hi;\n}\n/** 2^(th + tl) for a double-double exponent; within 1 ulp (plus the error the exponent carries). */\nfunction exp2DoubleDouble(th: number, tl: number): number {\n if (th !== th) return NaN;\n if (th > 1024) return Infinity;\n if (th < -1080) return 0;\n // th = n + r exactly (|r| ≤ ½); w = r·ln 2 = wh + wl (TwoProduct with LN2_HI, plus r·LN2_LO).\n const n = Math.round(th), r = (th - n) + tl, wh = r * LN2_HI, c = SPLITTER * r, ah = c - (c - r), al = r - ah;\n const wl = (((ah * LN2_HI_H - wh) + ah * LN2_HI_L + al * LN2_HI_H) + al * LN2_HI_L) + r * LN2_LO;\n const q = 0.5 + wh * (0.16666666666666666 + wh * (0.041666666666666664 + wh * (0.008333333333333333 + wh * (0.001388888888888889 + wh * (0.0001984126984126984 +\n wh * (2.48015873015873e-05 + wh * (2.7557319223985893e-06 + wh * (2.755731922398589e-07 + wh * (2.505210838544172e-08 + wh * (2.08767569878681e-09 +\n wh * (1.6059043836821613e-10 + wh * 1.1470745597729725e-11)))))))))));\n return scaleByPowerOfTwo(1 + (wh + (wl + wh * wh * q)), n);\n}\n\n/** log2 x, bit-identical in every JavaScript engine (within 1 ulp). 0 → −∞; negative or NaN → NaN; +∞ → +∞. */\nexport function portableLog2(x: number): number {\n if (!(x > 0)) return x === 0 ? -Infinity : NaN;\n if (x === Infinity) return Infinity;\n const h = log2DoubleDouble(x);\n return h + LOW_PART[0]!;\n}\n/** ln(k/128) for k = 90 … 182 as double-doubles (log2(k/128)·ln 2, TwoProduct with LN2_HI plus the small products). */\nconst LN_TABLE_LO = /* @__PURE__ */ new Float64Array(183);\nconst LN_TABLE_HI = /* @__PURE__ */ ((): Float64Array => {\n const table = new Float64Array(183);\n for (let k = 90; k <= 182; k++) {\n const h = LOG2_TABLE_HI[k]!, l = LOG2_TABLE_LO[k]!, p = h * LN2_HI, c = SPLITTER * h, ah = c - (c - h), al = h - ah;\n const pe = ((ah * LN2_HI_H - p) + ah * LN2_HI_L + al * LN2_HI_H) + al * LN2_HI_L, lo = pe + (h * LN2_LO + l * LN2_HI), hi = p + lo;\n table[k] = hi; LN_TABLE_LO[k] = lo - (hi - p);\n }\n return table;\n})();\n/** ln 2 = LN2_E_HI + LN2_E_LO with the low 32 bits of LN2_E_HI zero, so e·LN2_E_HI is exact for every exponent e here. */\nconst LN2_E_HI = /* @__PURE__ */ ((): number => { BITS[0] = LN2_HI; WORDS[LOW] = 0; return BITS[0]!; })(), LN2_E_LO = (LN2_HI - LN2_E_HI) + LN2_LO;\n/**\n * Natural logarithm, bit-identical in every JavaScript engine (within 1 ulp). 0 → −∞; negative or NaN → NaN; +∞ → +∞.\n * x = m·2^e, m in [√½, √2]; ln x = e·ln 2 + ln F (table, F = k/128, k = round(128·m)) + 2·atanh(s), s = (m − F)/(m + F),\n * with s as a double-double and the three terms added with TwoSum.\n */\nexport function portableLog(x: number): number {\n if (!(x > 0)) return x === 0 ? -Infinity : NaN;\n if (x === Infinity) return Infinity;\n let e = 0;\n if (x < MIN_NORMAL) { x *= TWO_POW_54; e = -54; }\n BITS[0] = x;\n const high = WORDS[HIGH]!;\n e += (high >>> 20) - 1023;\n let m = x * POW2[1074 - ((high >>> 20) - 1023)]!; // exact: m in [1, 2)\n if (m > SQRT2) { m *= 0.5; e += 1; }\n const k = Math.round(m * 128), F = k / 128, f = m - F, dh = m + F, db = dh - m, dl = (m - (dh - db)) + (F - db);\n const sHi = f / dh, p = sHi * dh;\n let c = SPLITTER * sHi;\n const ah = c - (c - sHi), al = sHi - ah;\n c = SPLITTER * dh;\n const bh = c - (c - dh), bl = dh - bh, pe = ((ah * bh - p) + ah * bl + al * bh) + al * bl;\n const sLo = (((f - p) - pe) - sHi * dl) / dh, z = sHi * sHi;\n const tail = sHi * z * (0.6666666666666666 + z * (0.4 + z * 0.2857142857142857));\n // (e·LN2_E_HI + ln F) + 2sHi with TwoSum errors, then the low parts.\n const A = e * LN2_E_HI, B = LN_TABLE_HI[k]!, t = A + B, tb = t - A, te = (A - (t - tb)) + (B - tb);\n const a2 = 2 * sHi, u = t + a2, ub = u - t, ue = (t - (u - ub)) + (a2 - ub);\n return u + ((te + ue) + ((e * LN2_E_LO + LN_TABLE_LO[k]!) + (2 * sLo + tail)));\n}\n/** 2^x, bit-identical in every JavaScript engine (within 1 ulp). */\nexport function portableExp2(x: number): number { return exp2DoubleDouble(x, 0); }\n/** e^x, bit-identical in every JavaScript engine (within 1 ulp). */\nexport function portableExp(x: number): number {\n if (x !== x) return NaN;\n if (x > 710) return Infinity;\n if (x < -746) return 0;\n // x·log2 e = th + tl: x·LOG2E_HI = th + te exactly (TwoProduct), plus x·LOG2E_LO.\n const th = x * LOG2E_HI, c = SPLITTER * x, ah = c - (c - x), al = x - ah;\n const te = ((ah * LOG2E_HI_H - th) + ah * LOG2E_HI_L + al * LOG2E_HI_H) + al * LOG2E_HI_L;\n return exp2DoubleDouble(th, te + x * LOG2E_LO);\n}\n/**\n * e^x − 1, bit-identical in every JavaScript engine (within 2 ulps): the Taylor series to degree 20 for |x| < 1\n * (truncation below 2^-60 relative), else portableExp(x) − 1.\n */\nexport function portableExpm1(x: number): number {\n if (x !== x) return NaN;\n if (x === 0) return x;\n if (!(x > -1 && x < 1)) return portableExp(x) - 1;\n return x + x * x * (0.5 + x * (0.16666666666666666 + x * (0.041666666666666664 + x * (0.008333333333333333 + x * (0.001388888888888889 + x * (0.0001984126984126984 +\n x * (2.48015873015873e-05 + x * (2.7557319223985893e-06 + x * (2.755731922398589e-07 + x * (2.505210838544172e-08 + x * (2.08767569878681e-09 +\n x * (1.6059043836821613e-10 + x * (1.1470745597729725e-11 + x * (7.647163731819816e-13 + x * (4.779477332387385e-14 + x * (2.8114572543455206e-15 +\n x * (1.5619206968586225e-16 + x * (8.22063524662433e-18 + x * 4.110317623312165e-19))))))))))))))))));\n}\n/**\n * x^y for x ≥ 0 and finite y, bit-identical in every JavaScript engine (within 1 ulp for |y| ≤ 4). x = 0 gives 0 for\n * y > 0, 1 for y = 0 and +∞ for y < 0; negative x or a non-finite argument gives NaN (the callers never pass them).\n */\nexport function portablePow(x: number, y: number): number {\n if (!(x >= 0) || !Number.isFinite(x) || !Number.isFinite(y)) return NaN;\n if (y === 0 || x === 1) return 1;\n if (x === 0) return y > 0 ? 0 : Infinity;\n // y·(lh + ll): lh·y = p + pe exactly (TwoProduct), then FastTwoSum(p, pe + ll·y).\n const lh = log2DoubleDouble(x), ll = LOW_PART[0]!, p = lh * y;\n let c = SPLITTER * lh;\n const ah = c - (c - lh), al = lh - ah;\n c = SPLITTER * y;\n const bh = c - (c - y), bl = y - bh, pe = ((ah * bh - p) + ah * bl + al * bh) + al * bl;\n const b = pe + ll * y, th = p + b;\n return exp2DoubleDouble(th, b - (th - p));\n}\n/** ∛(2^r) for r = 0, 1, 2 (only scale the cube root's starting value, so their last bits do not matter). */\nconst CBRT_POWERS_OF_TWO = [1, 1.2599210498948732, 1.5874010519681994];\n/**\n * Cube root, bit-identical in every JavaScript engine (within 1 ulp; exact for ±0, ±∞ and cubes of powers of two).\n * |x| = m·2^(3q + r) with m in [1, 2) and r in {0, 1, 2}, w = m·2^r: a cubic fit to ∛m (within 1.7·10⁻⁴) times ∛(2^r),\n * one Halley step y ← y(y³ + 2w)/(2y³ + w) (cubic convergence: below 10⁻¹¹), then one Newton step y + (w − y³)/(3y²)\n * with w − y³ formed exactly (TwoProduct), which leaves only the final rounding and errors near 10⁻²².\n */\nexport function portableCbrt(x: number): number {\n if (x === 0 || x !== x || !Number.isFinite(x)) return x;\n let a = x < 0 ? -x : x, shift = 0;\n if (a < MIN_NORMAL) { a *= TWO_POW_54; shift = -18; }\n BITS[0] = a;\n const high = WORDS[HIGH]!, e = (high >>> 20) - 1023, q = Math.floor(e / 3), r = e - 3 * q;\n const m = a * POW2[1074 - e]!, w = m * CBRT_SCALE[r]!; // exact: m in [1, 2)\n let y = (0.5561432746078446 + m * (0.5806821751356804 + m * (-0.15894786280039686 + m * 0.022291567104952514))) * CBRT_POWERS_OF_TWO[r]!;\n const y3 = y * y * y;\n y = y * (y3 + 2 * w) / (2 * y3 + w);\n // y² = p + pe exactly; y³ = p·y + pe·y = t + te (TwoProduct of p and y, plus pe·y); w − y³ = (w − t) − te.\n const p = y * y;\n let c = SPLITTER * y;\n const yh = c - (c - y), yl = y - yh, pe = ((yh * yh - p) + yh * yl + yl * yh) + yl * yl, t = p * y;\n c = SPLITTER * p;\n const ph = c - (c - p), pll = p - ph, te = (((ph * yh - t) + ph * yl + pll * yh) + pll * yl) + pe * y;\n const root = scaleByPowerOfTwo(y + ((w - t) - te) / (3 * p), q + shift);\n return x < 0 ? -root : root;\n}\n/** 2^r for r = 0, 1, 2. */\nconst CBRT_SCALE = [1, 2, 4];\n/** cos(2πr) and sin(2πr) for |r| ≤ ⅛ (Taylor series in z = r²). */\nfunction cosTwoPiReduced(r: number): number {\n const z = r * r;\n return 1 + z * (-19.739208802178716 + z * (64.9393940226683 + z * (-85.45681720669373 + z * (60.24464137187666 + z * (-26.4262567833744 + z * (7.903536371318469 +\n z * (-1.714390711088672 + z * (0.28200596845579123 + z * -0.03638284114254567))))))));\n}\nfunction sinTwoPiReduced(r: number): number {\n const z = r * r;\n return r * (6.283185307179586 + z * (-41.34170224039976 + z * (81.60524927607506 + z * (-76.70585975306139 + z * (42.058693944897655 + z * (-15.09464257682299 +\n z * (3.819952584848282 + z * (-0.7181223017785006 + z * (0.10422916220813984 + z * -0.012031585942120627)))))))));\n}\n/** cos(2πu) for finite u (u in turns), bit-identical in every JavaScript engine (within 2 ulps). */\nexport function portableCosTwoPi(u: number): number {\n if (!Number.isFinite(u)) return NaN;\n const t = 4 * u, q = Math.round(t), r = (t - q) / 4, quadrant = ((q % 4) + 4) % 4;\n return quadrant === 0 ? cosTwoPiReduced(r) : quadrant === 1 ? -sinTwoPiReduced(r) : quadrant === 2 ? -cosTwoPiReduced(r) : sinTwoPiReduced(r);\n}\n/** sin(2πu) for finite u (u in turns), bit-identical in every JavaScript engine (within 2 ulps). */\nexport function portableSinTwoPi(u: number): number {\n if (!Number.isFinite(u)) return NaN;\n const t = 4 * u, q = Math.round(t), r = (t - q) / 4, quadrant = ((q % 4) + 4) % 4;\n return quadrant === 0 ? sinTwoPiReduced(r) : quadrant === 1 ? cosTwoPiReduced(r) : quadrant === 2 ? -sinTwoPiReduced(r) : -cosTwoPiReduced(r);\n}\n"]}
1
+ {"version":3,"file":"portable-math.js","sourceRoot":"","sources":["../../src/core/portable-math.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;;;;;;GAYG;AAEH,MAAM,KAAK,GAAG,CAAC,IAAI,GAAG,CAAC;AACvB,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;AACxB,MAAM,UAAU,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC;AAC7B,MAAM,QAAQ,GAAG,CAAC,IAAI,GAAG,CAAC;AAE1B;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,GAAG,MAAyB;IACxD,IAAI,OAA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C,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1B,IAAI,EAAE,IAAI,GAAG;QAAE,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC;IACrC,MAAM,MAAM,GAAG,CAAC,OAAO,GAAG,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;IAC9E,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;AAClC,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Floating-point helpers that give bit-identical results in every JavaScript engine.\n *\n * ECMAScript requires `+ - * /` and `Math.sqrt` to be correctly rounded IEEE 754 binary64\n * (double-precision) operations. A fixed sequence of them gives the same bits in every\n * conforming engine. `Math.hypot`, `Math.exp`, `Math.atan`, `Math.cos` and the other\n * transcendental functions are \"implementation-approximated\" (ECMA-262 §21.3.2). They can\n * differ in the last bit between V8, JavaScriptCore and SpiderMonkey.\n *\n * So any value that is stored and later recomputed for an exact identity check must use\n * only the correctly rounded operations.\n * @see docs/NUMERICAL_CORRECTNESS.md §Cross-engine determinism\n */\n\nconst LARGE = 2 ** 500;\nconst SMALL = 2 ** -500;\nconst SCALE_DOWN = 2 ** -600;\nconst SCALE_UP = 2 ** 600;\n\n/**\n * Euclidean norm (vector length) of the components. Unlike `Math.hypot`, it uses only correctly\n * rounded IEEE operations, so the result is bit-identical in every JavaScript engine.\n *\n * Components are summed in argument order. Inputs far from 1 are first rescaled by an exact power\n * of two, so squaring cannot overflow or underflow. Non-finite input gives a non-finite result;\n * callers validate inputs first.\n */\nexport function portableHypot(...values: readonly number[]): number {\n let maximum = 0;\n for (const value of values) {\n const magnitude = Math.abs(value);\n if (!(magnitude <= maximum)) maximum = magnitude;\n }\n if (maximum === 0 || !Number.isFinite(maximum)) return maximum;\n const scale = maximum > LARGE ? SCALE_DOWN : maximum < SMALL ? SCALE_UP : 1;\n let sum = 0;\n for (const value of values) {\n const scaled = value * scale;\n sum += scaled * scaled;\n }\n return Math.sqrt(sum) / scale;\n}\n\n/**\n * V8's three-argument `Math.hypot` as a fixed sequence of correctly rounded operations, so the result has V8's bits in\n * every JavaScript engine. The sequence is V8's `MathHypot` (src/builtins/math.tq; also its three-argument\n * `FastMathHypot`): the largest magnitude, starting from 0, normalises the arguments; their squares are summed in\n * argument order with Kahan compensation; the result is the square root of the sum times the largest magnitude. An\n * infinite argument gives Infinity (even beside NaN), otherwise a NaN argument gives NaN, and all zeros give +0.\n *\n * It is not `portableHypot`: that function rescales by powers of two and sums without compensation, so it is portable\n * too but gives other bits than `Math.hypot`. This one replaces `Math.hypot` where today's V8 bits must be kept (the\n * capture's query arithmetic and the display view's copy of it), and makes the other engines compute them too.\n * @see docs/NUMERICAL_CORRECTNESS.md §Cross-engine determinism\n */\nexport function hypot3(a: number, b: number, c: number): number {\n a = Math.abs(a);\n b = Math.abs(b);\n c = Math.abs(c);\n let max = 0;\n if (a > max) max = a;\n if (b > max) max = b;\n if (c > max) max = c;\n if (max === Infinity) return Infinity;\n if (a !== a || b !== b || c !== c) return NaN;\n if (max === 0) return 0;\n let sum = 0, compensation = 0;\n let n = a / max, summand = n * n - compensation, preliminary = sum + summand;\n compensation = (preliminary - sum) - summand;\n sum = preliminary;\n n = b / max;\n summand = n * n - compensation;\n preliminary = sum + summand;\n compensation = (preliminary - sum) - summand;\n sum = preliminary;\n n = c / max;\n summand = n * n - compensation;\n sum = sum + summand;\n return Math.sqrt(sum) * max;\n}\n\n/**\n * True when two finite numbers differ by at most `maximumUlps` ULPs (units in the last place).\n * One ULP here is `Number.EPSILON` times the larger magnitude. Use it to accept an archived value\n * that another engine or an earlier release computed with an implementation-approximated function.\n */\nexport function equalWithinUlps(a: number, b: number, maximumUlps: number): boolean {\n if (!Number.isFinite(a) || !Number.isFinite(b)) return false;\n if (a === b) return true;\n return Math.abs(a - b) <= maximumUlps * Number.EPSILON * Math.max(Math.abs(a), Math.abs(b));\n}\n\n// ---------------------------------------------------------------------------------------------------------------\n// Portable logarithm, exponential, power, cube root and cosine/sine of 2πu.\n//\n// Each function below is a fixed sequence of correctly rounded binary64 operations (+, −, ×, ÷, exact\n// power-of-two scaling through the IEEE 754 bit pattern, Math.round/Math.floor and integer operations), with\n// every constant written as a decimal literal of at most 17 significant digits (ECMAScript converts these\n// exactly to the nearest double). The bits of every result are therefore the same in every conforming\n// JavaScript engine, unlike Math.pow, Math.exp, Math.log, Math.cbrt and Math.cos, which ECMA-262 leaves\n// \"implementation-approximated\" (docs/NUMERICAL_CORRECTNESS.md, \"Cross-engine determinism\").\n//\n// Methods (textbook; no code copied):\n// - Error-free transformations (double-double arithmetic): TwoSum (Knuth, The Art of Computer Programming\n// vol. 2, §4.2.2), FastTwoSum and TwoProduct with Veltkamp's splitting (Dekker, \"A floating-point technique\n// for extending the available precision\", Numerische Mathematik 18, 1971). Exact barring overflow and\n// underflow, which the arguments here cannot reach.\n// - log2(x): x = m·2^e with m in [√½, √2); ln m = 2·atanh(s) = 2(s + s³/3 + s⁵/5 + …), s = (m − 1)/(m + 1),\n// |s| ≤ 0.1716 (J.-M. Muller, Elementary Functions: Algorithms and Implementation, 3rd ed., 2016, ch. 11).\n// s carries a double-double correction; the series runs to s²³ (truncation below 2^-62 relative).\n// - 2^t: t = n + r with n = round(t), |r| ≤ ½; 2^r = e^(r·ln 2) by its Taylor series to degree 14 (truncation\n// below 2^-57 relative), then an exact scaling by 2^n (Muller, ch. 11, \"additive range reduction\").\n// - x^y = 2^(y·log2 x) with log2 x and y·log2 x carried as double-double; e^x = 2^(x·log2 e) and\n// ∛x = 2^(log2 x / 3) likewise; ln x = log2 x · ln 2; e^x − 1 by its Taylor series for |x| < 1.\n// - cos(2πu), sin(2πu): u = q/4 + r with q = round(4u) and |r| ≤ ⅛ (exact), then the Taylor series of cos and\n// sin of 2πr to degrees 18 and 19 (truncation below 2^-66).\n//\n// Error bounds (from the operation counts above): portableExp2, portableExp, portableLog, portableLog2 and\n// portableCbrt within 1 ulp; portableExpm1 within 2 ulps; portablePow within 1 ulp for |y| ≤ 4 (the double-double\n// logarithm has relative error below 2^-56, so the error of y·log2 x adds at most |y|·2^-57·ln 2 relative);\n// portableCosTwoPi and portableSinTwoPi within 2 ulps. Checked against 60-digit decimal references (Python decimal)\n// on 2·10⁵ pseudo-random arguments per function (6·10⁵ for portableLog; |y| ≤ 4 and y = 1/2.4, 1.4 for portablePow):\n// largest errors 0.53 ulp (log, log2), 0.86 (exp2), 0.94 (exp, cbrt, pow), 0.97 (pow with y = 1/2.4), 1.59 (cos,\n// sin of 2πu) and 1.66 (e^x − 1); spot values are in test/portable-math.test.ts. These are accuracy bounds;\n// determinism does not depend on them.\n\n/** Bit access to a double: the high 32-bit word is at index HIGH of the view (detected once, so either byte order works). */\n// The tables and constants below are built by expressions marked pure (/* @__PURE__ */), so a bundler drops them from a\n// bundle that uses none of the functions that read them (a capture-only bundle keeps only portableHypot and equalWithinUlps).\nconst BITS = /* @__PURE__ */ new Float64Array(1), WORDS = /* @__PURE__ */ ((): Uint32Array => new Uint32Array(BITS.buffer))();\nconst HIGH = /* @__PURE__ */ ((): number => (new Uint8Array(new Uint16Array([1]).buffer)[0] === 1 ? 1 : 0))(), LOW = 1 - HIGH;\n/** 2^k for every integer k in [−1074, 1023] at POW2[k + 1074], built by exact halving and doubling. */\nconst POW2 = /* @__PURE__ */ ((): Float64Array => {\n const table = new Float64Array(2098);\n table[1074] = 1;\n for (let k = 1; k <= 1023; k++) table[1074 + k] = table[1073 + k]! * 2;\n for (let k = 1; k <= 1074; k++) table[1074 - k] = table[1075 - k]! / 2;\n return table;\n})();\n/** v·2^k for an integer k in [−1100, 1100]: one exact multiplication (a single rounding only when the result is subnormal). */\nfunction scaleByPowerOfTwo(v: number, k: number): number {\n if (k > 1023) return v * POW2[2097]! * POW2[1074 + k - 1023]!;\n if (k < -1074) return v * POW2[1074 + k + 1074]! * POW2[0]!; // exact first factor (v·2^(k+1074) is normal), one rounding\n return v * POW2[1074 + k]!;\n}\n// Double-double arithmetic, written out inline below (local variables only, which keeps it fast):\n// - FastTwoSum (|a| ≥ |b| or a = 0): s = a + b, err = b − (s − a), so a + b = s + err exactly;\n// - TwoSum (any a, b): s = a + b, b' = s − a, err = (a − (s − b')) + (b − b');\n// - TwoProduct: p = a·b, err = ((ah·bh − p) + ah·bl + al·bh) + al·bl, with Veltkamp's split\n// ah = c − (c − a), al = a − ah, c = (2^27 + 1)·a (and likewise for b), so a·b = p + err exactly.\nconst SPLITTER = 134217729; // 2^27 + 1 (Veltkamp)\nconst LN2_HI = 0.6931471805599453, LN2_LO = 2.3190468138462996e-17;\nconst LOG2E_HI = 1.4426950408889634, LOG2E_LO = 2.0355273740931033e-17;\nconst SQRT2 = 1.4142135623730951, TWO_POW_54 = 18014398509481984, MIN_NORMAL = 2.2250738585072014e-308;\n/** Veltkamp halves of a constant (the same values the split gives at each use). */\nfunction splitHigh(a: number): number { const c = SPLITTER * a; return c - (c - a); }\nconst LN2_HI_H = /* @__PURE__ */ splitHigh(LN2_HI), LN2_HI_L = LN2_HI - LN2_HI_H, LOG2E_HI_H = /* @__PURE__ */ splitHigh(LOG2E_HI), LOG2E_HI_L = LOG2E_HI - LOG2E_HI_H;\n/** The low part of the last double-double result (its high part is the return value). */\nconst LOW_PART = /* @__PURE__ */ new Float64Array(1);\n\n/**\n * log2 m for m in [√½, √2] by the atanh series to s²³ (no table): builds LOG2_TABLE once. Returns the high part, the low\n * part in LOW_PART[0]; relative error below 2^-56.\n */\nfunction log2SeriesDoubleDouble(x: number): number {\n let e = 0;\n if (x < MIN_NORMAL) { x *= TWO_POW_54; e = -54; }\n BITS[0] = x;\n const high = WORDS[HIGH]!;\n e += (high >>> 20) - 1023;\n let m = x * POW2[1074 - ((high >>> 20) - 1023)]!; // exact: m in [1, 2)\n if (m > SQRT2) { m *= 0.5; e += 1; }\n // s = f/(2 + f) with f = m − 1 (exact), as sHi + sLo: 2 + f = dh + dl exactly (FastTwoSum), then the residual\n // f − sHi·(dh + dl) with sHi·dh = p + pe exactly (TwoProduct).\n const f = m - 1, dh = 2 + f, dl = f - (dh - 2), sHi = f / dh, p = sHi * dh;\n let c = SPLITTER * sHi;\n const ah = c - (c - sHi), al = sHi - ah;\n c = SPLITTER * dh;\n const bh = c - (c - dh), bl = dh - bh, pe = ((ah * bh - p) + ah * bl + al * bh) + al * bl;\n const sLo = (((f - p) - pe) - sHi * dl) / dh;\n const z = sHi * sHi;\n const tail = sHi * z * (0.6666666666666666 + z * (0.4 + z * (0.2857142857142857 + z * (0.2222222222222222 + z * (0.18181818181818182 + z * (0.15384615384615385 +\n z * (0.13333333333333333 + z * (0.11764705882352941 + z * (0.10526315789473684 + z * (0.09523809523809523 + z * 0.08695652173913043))))))))));\n // ln m = 2sHi + (2sLo + tail) = lh + ll (FastTwoSum); times log2 e = LOG2E_HI + LOG2E_LO (TwoProduct of the high parts); plus e (TwoSum).\n const a1 = 2 * sHi, b1 = 2 * sLo + tail, lh = a1 + b1, ll = b1 - (lh - a1), q = lh * LOG2E_HI;\n c = SPLITTER * lh;\n const ch = c - (c - lh), cl = lh - ch, qe = ((ch * LOG2E_HI_H - q) + ch * LOG2E_HI_L + cl * LOG2E_HI_H) + cl * LOG2E_HI_L;\n const pl = qe + (lh * LOG2E_LO + ll * LOG2E_HI);\n const t = e + q, tb = t - e, te = (e - (t - tb)) + (q - tb), b2 = te + pl, hi = t + b2;\n LOW_PART[0] = b2 - (hi - t);\n return hi;\n}\n/** log2(k/128) for k = 90 … 182 (the table's range of k = round(128·m), m in [√½, √2]) as double-doubles. */\nconst LOG2_TABLE_LO = /* @__PURE__ */ new Float64Array(183);\nconst LOG2_TABLE_HI = /* @__PURE__ */ ((): Float64Array => {\n const table = new Float64Array(183);\n for (let k = 90; k <= 182; k++) { table[k] = log2SeriesDoubleDouble(k / 128); LOG2_TABLE_LO[k] = LOW_PART[0]!; }\n return table;\n})();\n/**\n * log2 x as a double-double for finite x > 0: returns the high part, the low part in LOW_PART[0]. x = m·2^e with m in\n * [√½, √2]; m = F·(1 + f/F) with F = k/128, k = round(128·m), so log2 m = log2 F (table) + 2·atanh(s)·log2 e with\n * s = f/(m + F), |s| < 2^-8.4, by its series to s⁷ (truncation below 2^-70 relative). Relative error below 2^-56.\n */\nfunction log2DoubleDouble(x: number): number {\n let e = 0;\n if (x < MIN_NORMAL) { x *= TWO_POW_54; e = -54; }\n BITS[0] = x;\n const high = WORDS[HIGH]!;\n e += (high >>> 20) - 1023;\n let m = x * POW2[1074 - ((high >>> 20) - 1023)]!; // exact: m in [1, 2)\n if (m > SQRT2) { m *= 0.5; e += 1; }\n // F = k/128 (exact) and f = m − F (exact, F/2 ≤ m ≤ 2F); m + F = dh + dl exactly (TwoSum); s = f/(dh + dl) as sHi + sLo\n // from the residual f − sHi·(dh + dl), with sHi·dh = p + pe exactly (TwoProduct).\n const k = Math.round(m * 128), F = k / 128, f = m - F, dh = m + F, db = dh - m, dl = (m - (dh - db)) + (F - db);\n const sHi = f / dh, p = sHi * dh;\n let c = SPLITTER * sHi;\n const ah = c - (c - sHi), al = sHi - ah;\n c = SPLITTER * dh;\n const bh = c - (c - dh), bl = dh - bh, pe = ((ah * bh - p) + ah * bl + al * bh) + al * bl;\n const sLo = (((f - p) - pe) - sHi * dl) / dh, z = sHi * sHi;\n const tail = sHi * z * (0.6666666666666666 + z * (0.4 + z * 0.2857142857142857));\n // ln(m/F) = 2sHi + (2sLo + tail) = lh + ll (FastTwoSum); times log2 e = LOG2E_HI + LOG2E_LO (TwoProduct of the high\n // parts); plus log2 F (TwoSum with the table's high part), then plus e (TwoSum).\n const a1 = 2 * sHi, b1 = 2 * sLo + tail, lh = a1 + b1, ll = b1 - (lh - a1), q = lh * LOG2E_HI;\n c = SPLITTER * lh;\n const ch = c - (c - lh), cl = lh - ch, qe = ((ch * LOG2E_HI_H - q) + ch * LOG2E_HI_L + cl * LOG2E_HI_H) + cl * LOG2E_HI_L;\n const pl = qe + (lh * LOG2E_LO + ll * LOG2E_HI), th = LOG2_TABLE_HI[k]!;\n const t = th + q, tb = t - th, low = ((th - (t - tb)) + (q - tb)) + (pl + LOG2_TABLE_LO[k]!);\n const u = e + t, ub = u - e, b2 = ((e - (u - ub)) + (t - ub)) + low, hi = u + b2;\n LOW_PART[0] = b2 - (hi - u);\n return hi;\n}\n/** 2^(th + tl) for a double-double exponent; within 1 ulp (plus the error the exponent carries). */\nfunction exp2DoubleDouble(th: number, tl: number): number {\n if (th !== th) return NaN;\n if (th > 1024) return Infinity;\n if (th < -1080) return 0;\n // th = n + r exactly (|r| ≤ ½); w = r·ln 2 = wh + wl (TwoProduct with LN2_HI, plus r·LN2_LO).\n const n = Math.round(th), r = (th - n) + tl, wh = r * LN2_HI, c = SPLITTER * r, ah = c - (c - r), al = r - ah;\n const wl = (((ah * LN2_HI_H - wh) + ah * LN2_HI_L + al * LN2_HI_H) + al * LN2_HI_L) + r * LN2_LO;\n const q = 0.5 + wh * (0.16666666666666666 + wh * (0.041666666666666664 + wh * (0.008333333333333333 + wh * (0.001388888888888889 + wh * (0.0001984126984126984 +\n wh * (2.48015873015873e-05 + wh * (2.7557319223985893e-06 + wh * (2.755731922398589e-07 + wh * (2.505210838544172e-08 + wh * (2.08767569878681e-09 +\n wh * (1.6059043836821613e-10 + wh * 1.1470745597729725e-11)))))))))));\n return scaleByPowerOfTwo(1 + (wh + (wl + wh * wh * q)), n);\n}\n\n/** log2 x, bit-identical in every JavaScript engine (within 1 ulp). 0 → −∞; negative or NaN → NaN; +∞ → +∞. */\nexport function portableLog2(x: number): number {\n if (!(x > 0)) return x === 0 ? -Infinity : NaN;\n if (x === Infinity) return Infinity;\n const h = log2DoubleDouble(x);\n return h + LOW_PART[0]!;\n}\n/** ln(k/128) for k = 90 … 182 as double-doubles (log2(k/128)·ln 2, TwoProduct with LN2_HI plus the small products). */\nconst LN_TABLE_LO = /* @__PURE__ */ new Float64Array(183);\nconst LN_TABLE_HI = /* @__PURE__ */ ((): Float64Array => {\n const table = new Float64Array(183);\n for (let k = 90; k <= 182; k++) {\n const h = LOG2_TABLE_HI[k]!, l = LOG2_TABLE_LO[k]!, p = h * LN2_HI, c = SPLITTER * h, ah = c - (c - h), al = h - ah;\n const pe = ((ah * LN2_HI_H - p) + ah * LN2_HI_L + al * LN2_HI_H) + al * LN2_HI_L, lo = pe + (h * LN2_LO + l * LN2_HI), hi = p + lo;\n table[k] = hi; LN_TABLE_LO[k] = lo - (hi - p);\n }\n return table;\n})();\n/** ln 2 = LN2_E_HI + LN2_E_LO with the low 32 bits of LN2_E_HI zero, so e·LN2_E_HI is exact for every exponent e here. */\nconst LN2_E_HI = /* @__PURE__ */ ((): number => { BITS[0] = LN2_HI; WORDS[LOW] = 0; return BITS[0]!; })(), LN2_E_LO = (LN2_HI - LN2_E_HI) + LN2_LO;\n/**\n * Natural logarithm, bit-identical in every JavaScript engine (within 1 ulp). 0 → −∞; negative or NaN → NaN; +∞ → +∞.\n * x = m·2^e, m in [√½, √2]; ln x = e·ln 2 + ln F (table, F = k/128, k = round(128·m)) + 2·atanh(s), s = (m − F)/(m + F),\n * with s as a double-double and the three terms added with TwoSum.\n */\nexport function portableLog(x: number): number {\n if (!(x > 0)) return x === 0 ? -Infinity : NaN;\n if (x === Infinity) return Infinity;\n let e = 0;\n if (x < MIN_NORMAL) { x *= TWO_POW_54; e = -54; }\n BITS[0] = x;\n const high = WORDS[HIGH]!;\n e += (high >>> 20) - 1023;\n let m = x * POW2[1074 - ((high >>> 20) - 1023)]!; // exact: m in [1, 2)\n if (m > SQRT2) { m *= 0.5; e += 1; }\n const k = Math.round(m * 128), F = k / 128, f = m - F, dh = m + F, db = dh - m, dl = (m - (dh - db)) + (F - db);\n const sHi = f / dh, p = sHi * dh;\n let c = SPLITTER * sHi;\n const ah = c - (c - sHi), al = sHi - ah;\n c = SPLITTER * dh;\n const bh = c - (c - dh), bl = dh - bh, pe = ((ah * bh - p) + ah * bl + al * bh) + al * bl;\n const sLo = (((f - p) - pe) - sHi * dl) / dh, z = sHi * sHi;\n const tail = sHi * z * (0.6666666666666666 + z * (0.4 + z * 0.2857142857142857));\n // (e·LN2_E_HI + ln F) + 2sHi with TwoSum errors, then the low parts.\n const A = e * LN2_E_HI, B = LN_TABLE_HI[k]!, t = A + B, tb = t - A, te = (A - (t - tb)) + (B - tb);\n const a2 = 2 * sHi, u = t + a2, ub = u - t, ue = (t - (u - ub)) + (a2 - ub);\n return u + ((te + ue) + ((e * LN2_E_LO + LN_TABLE_LO[k]!) + (2 * sLo + tail)));\n}\n/** 2^x, bit-identical in every JavaScript engine (within 1 ulp). */\nexport function portableExp2(x: number): number { return exp2DoubleDouble(x, 0); }\n/** e^x, bit-identical in every JavaScript engine (within 1 ulp). */\nexport function portableExp(x: number): number {\n if (x !== x) return NaN;\n if (x > 710) return Infinity;\n if (x < -746) return 0;\n // x·log2 e = th + tl: x·LOG2E_HI = th + te exactly (TwoProduct), plus x·LOG2E_LO.\n const th = x * LOG2E_HI, c = SPLITTER * x, ah = c - (c - x), al = x - ah;\n const te = ((ah * LOG2E_HI_H - th) + ah * LOG2E_HI_L + al * LOG2E_HI_H) + al * LOG2E_HI_L;\n return exp2DoubleDouble(th, te + x * LOG2E_LO);\n}\n/**\n * e^x − 1, bit-identical in every JavaScript engine (within 2 ulps): the Taylor series to degree 20 for |x| < 1\n * (truncation below 2^-60 relative), else portableExp(x) − 1.\n */\nexport function portableExpm1(x: number): number {\n if (x !== x) return NaN;\n if (x === 0) return x;\n if (!(x > -1 && x < 1)) return portableExp(x) - 1;\n return x + x * x * (0.5 + x * (0.16666666666666666 + x * (0.041666666666666664 + x * (0.008333333333333333 + x * (0.001388888888888889 + x * (0.0001984126984126984 +\n x * (2.48015873015873e-05 + x * (2.7557319223985893e-06 + x * (2.755731922398589e-07 + x * (2.505210838544172e-08 + x * (2.08767569878681e-09 +\n x * (1.6059043836821613e-10 + x * (1.1470745597729725e-11 + x * (7.647163731819816e-13 + x * (4.779477332387385e-14 + x * (2.8114572543455206e-15 +\n x * (1.5619206968586225e-16 + x * (8.22063524662433e-18 + x * 4.110317623312165e-19))))))))))))))))));\n}\n/**\n * x^y for x ≥ 0 and finite y, bit-identical in every JavaScript engine (within 1 ulp for |y| ≤ 4). x = 0 gives 0 for\n * y > 0, 1 for y = 0 and +∞ for y < 0; negative x or a non-finite argument gives NaN (the callers never pass them).\n */\nexport function portablePow(x: number, y: number): number {\n if (!(x >= 0) || !Number.isFinite(x) || !Number.isFinite(y)) return NaN;\n if (y === 0 || x === 1) return 1;\n if (x === 0) return y > 0 ? 0 : Infinity;\n // y·(lh + ll): lh·y = p + pe exactly (TwoProduct), then FastTwoSum(p, pe + ll·y).\n const lh = log2DoubleDouble(x), ll = LOW_PART[0]!, p = lh * y;\n let c = SPLITTER * lh;\n const ah = c - (c - lh), al = lh - ah;\n c = SPLITTER * y;\n const bh = c - (c - y), bl = y - bh, pe = ((ah * bh - p) + ah * bl + al * bh) + al * bl;\n const b = pe + ll * y, th = p + b;\n return exp2DoubleDouble(th, b - (th - p));\n}\n/** ∛(2^r) for r = 0, 1, 2 (only scale the cube root's starting value, so their last bits do not matter). */\nconst CBRT_POWERS_OF_TWO = [1, 1.2599210498948732, 1.5874010519681994];\n/**\n * Cube root, bit-identical in every JavaScript engine (within 1 ulp; exact for ±0, ±∞ and cubes of powers of two).\n * |x| = m·2^(3q + r) with m in [1, 2) and r in {0, 1, 2}, w = m·2^r: a cubic fit to ∛m (within 1.7·10⁻⁴) times ∛(2^r),\n * one Halley step y ← y(y³ + 2w)/(2y³ + w) (cubic convergence: below 10⁻¹¹), then one Newton step y + (w − y³)/(3y²)\n * with w − y³ formed exactly (TwoProduct), which leaves only the final rounding and errors near 10⁻²².\n */\nexport function portableCbrt(x: number): number {\n if (x === 0 || x !== x || !Number.isFinite(x)) return x;\n let a = x < 0 ? -x : x, shift = 0;\n if (a < MIN_NORMAL) { a *= TWO_POW_54; shift = -18; }\n BITS[0] = a;\n const high = WORDS[HIGH]!, e = (high >>> 20) - 1023, q = Math.floor(e / 3), r = e - 3 * q;\n const m = a * POW2[1074 - e]!, w = m * CBRT_SCALE[r]!; // exact: m in [1, 2)\n let y = (0.5561432746078446 + m * (0.5806821751356804 + m * (-0.15894786280039686 + m * 0.022291567104952514))) * CBRT_POWERS_OF_TWO[r]!;\n const y3 = y * y * y;\n y = y * (y3 + 2 * w) / (2 * y3 + w);\n // y² = p + pe exactly; y³ = p·y + pe·y = t + te (TwoProduct of p and y, plus pe·y); w − y³ = (w − t) − te.\n const p = y * y;\n let c = SPLITTER * y;\n const yh = c - (c - y), yl = y - yh, pe = ((yh * yh - p) + yh * yl + yl * yh) + yl * yl, t = p * y;\n c = SPLITTER * p;\n const ph = c - (c - p), pll = p - ph, te = (((ph * yh - t) + ph * yl + pll * yh) + pll * yl) + pe * y;\n const root = scaleByPowerOfTwo(y + ((w - t) - te) / (3 * p), q + shift);\n return x < 0 ? -root : root;\n}\n/** 2^r for r = 0, 1, 2. */\nconst CBRT_SCALE = [1, 2, 4];\n/** cos(2πr) and sin(2πr) for |r| ≤ ⅛ (Taylor series in z = r²). */\nfunction cosTwoPiReduced(r: number): number {\n const z = r * r;\n return 1 + z * (-19.739208802178716 + z * (64.9393940226683 + z * (-85.45681720669373 + z * (60.24464137187666 + z * (-26.4262567833744 + z * (7.903536371318469 +\n z * (-1.714390711088672 + z * (0.28200596845579123 + z * -0.03638284114254567))))))));\n}\nfunction sinTwoPiReduced(r: number): number {\n const z = r * r;\n return r * (6.283185307179586 + z * (-41.34170224039976 + z * (81.60524927607506 + z * (-76.70585975306139 + z * (42.058693944897655 + z * (-15.09464257682299 +\n z * (3.819952584848282 + z * (-0.7181223017785006 + z * (0.10422916220813984 + z * -0.012031585942120627)))))))));\n}\n/** cos(2πu) for finite u (u in turns), bit-identical in every JavaScript engine (within 2 ulps). */\nexport function portableCosTwoPi(u: number): number {\n if (!Number.isFinite(u)) return NaN;\n const t = 4 * u, q = Math.round(t), r = (t - q) / 4, quadrant = ((q % 4) + 4) % 4;\n return quadrant === 0 ? cosTwoPiReduced(r) : quadrant === 1 ? -sinTwoPiReduced(r) : quadrant === 2 ? -cosTwoPiReduced(r) : sinTwoPiReduced(r);\n}\n/** sin(2πu) for finite u (u in turns), bit-identical in every JavaScript engine (within 2 ulps). */\nexport function portableSinTwoPi(u: number): number {\n if (!Number.isFinite(u)) return NaN;\n const t = 4 * u, q = Math.round(t), r = (t - q) / 4, quadrant = ((q % 4) + 4) % 4;\n return quadrant === 0 ? sinTwoPiReduced(r) : quadrant === 1 ? cosTwoPiReduced(r) : quadrant === 2 ? -sinTwoPiReduced(r) : -cosTwoPiReduced(r);\n}\n/**\n * Maclaurin coefficients of arcsin x = Σ a_n·x^(2n+1)/(2n + 1), a_n = (2n)!/(4^n·(n!)²), a_n = a_(n−1)·(2n − 1)/(2n)\n * (the binomial series of 1/√(1 − t²) integrated term by term; NIST DLMF 4.24.1, free), for n = 1 … 24. Built from\n * correctly rounded operations only, so the table is the same in every engine. For |x| ≤ ½ the first omitted term is\n * below 2^-56·|x|.\n */\nconst ASIN_SERIES = /* @__PURE__ */ ((): Float64Array => {\n const table = new Float64Array(24);\n let a = 1;\n for (let n = 1; n <= 24; n++) { a = a * (2 * n - 1) / (2 * n); table[n - 1] = a / (2 * n + 1); }\n return table;\n})();\n/** π/2 = PIO2_HI + PIO2_LO (PIO2_HI the double nearest π/2, PIO2_LO the double nearest the remainder). */\nconst PIO2_HI = 1.5707963267948966, PIO2_LO = 6.123233995736766e-17;\n/** arcsin x for |x| ≤ ½ (Horner on the table above). */\nfunction asinReduced(x: number): number {\n const z = x * x;\n let p = ASIN_SERIES[23]!;\n for (let n = 22; n >= 0; n--) p = ASIN_SERIES[n]! + z * p;\n return x + x * (z * p);\n}\n/**\n * arcsin x in radians for x in [−1, 1], bit-identical in every JavaScript engine (within 2 ulps; `Math.asin` is\n * implementation-approximated). Outside [−1, 1], or NaN → NaN. For |x| ≤ ½ the Maclaurin series; above,\n * arcsin x = π/2 − 2·arcsin √((1 − x)/2) (the half-angle identity; 1 − x and the halving are exact there).\n */\nexport function portableAsin(x: number): number {\n if (!(x >= -1 && x <= 1)) return NaN;\n const ax = x < 0 ? -x : x;\n if (ax <= 0.5) return asinReduced(x);\n const result = (PIO2_HI - 2 * asinReduced(Math.sqrt((1 - ax) / 2))) + PIO2_LO;\n return x < 0 ? -result : result;\n}\n"]}
@@ -6,4 +6,4 @@
6
6
  * own versions. Release checks confirm it matches package.json and the packed package.
7
7
  * @see docs/RELEASE_1_0_1.md
8
8
  */
9
- export declare const ENGINE_API_VERSION: "2.10.0";
9
+ export declare const ENGINE_API_VERSION: "2.11.1";
@@ -7,5 +7,5 @@
7
7
  * own versions. Release checks confirm it matches package.json and the packed package.
8
8
  * @see docs/RELEASE_1_0_1.md
9
9
  */
10
- export const ENGINE_API_VERSION = "2.10.0";
10
+ export const ENGINE_API_VERSION = "2.11.1";
11
11
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/core/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAiB,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Version of the engine release. Since 1.0.1 it equals the npm package version.\n *\n * New captures and plans record this version as their creator. Archived records keep the\n * version they were made with. Proof-of-concept (POC), schema and model contracts have their\n * own versions. Release checks confirm it matches package.json and the packed package.\n * @see docs/RELEASE_1_0_1.md\n */\nexport const ENGINE_API_VERSION = \"2.10.0\" as const;\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/core/version.ts"],"names":[],"mappings":"AAAA,sCAAsC;AAEtC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAiB,CAAC","sourcesContent":["// SPDX-License-Identifier: Apache-2.0\n\n/**\n * Version of the engine release. Since 1.0.1 it equals the npm package version.\n *\n * New captures and plans record this version as their creator. Archived records keep the\n * version they were made with. Proof-of-concept (POC), schema and model contracts have their\n * own versions. Release checks confirm it matches package.json and the packed package.\n * @see docs/RELEASE_1_0_1.md\n */\nexport const ENGINE_API_VERSION = \"2.11.1\" as const;\n"]}
@@ -0,0 +1,115 @@
1
+ import { type ChartReflectance, type ChartScene, type ResolvedChartScene } from "./chart-scenes.js";
2
+ import type { CallerMaterialScene } from "./scene-radiance.js";
3
+ /** A filled polygon: rings as flat [x0, y0, x1, y1, …] in mask units (y down), non-zero winding over all rings. */
4
+ export interface ChartMaskPolygon {
5
+ kind: "polygon";
6
+ rings: readonly (readonly number[])[];
7
+ }
8
+ /** A stroked circle: the points at distance innerRadius ≤ d ≤ outerRadius from the centre, mask units. */
9
+ export interface ChartMaskAnnulus {
10
+ kind: "annulus";
11
+ centerX: number;
12
+ centerY: number;
13
+ innerRadius: number;
14
+ outerRadius: number;
15
+ }
16
+ export type ChartMaskShape = ChartMaskPolygon | ChartMaskAnnulus;
17
+ /** A shape mask printed over the chart: its box [0, unitsWidth] × [0, unitsHeight] (y down) fills `rectangle` (frame units, v up). */
18
+ export interface ChartMaskLayer {
19
+ kind: "shape-mask";
20
+ rectangle: {
21
+ u0: number;
22
+ v0: number;
23
+ u1: number;
24
+ v1: number;
25
+ };
26
+ unitsWidth: number;
27
+ unitsHeight: number;
28
+ /** 1 to 4096 shapes, in order; the ink material where any contains the point. */
29
+ shapes: readonly ChartMaskShape[];
30
+ backgroundReflectance: ChartReflectance;
31
+ inkReflectance: ChartReflectance;
32
+ }
33
+ /** A chart under 1 to 16 shape-mask layers, as data; `resolveChartMaterialLayers` evaluates it. */
34
+ export interface ChartMaterialLayerScene {
35
+ kind: "material-layers";
36
+ sceneId: string;
37
+ chart: ChartScene;
38
+ layers: readonly ChartMaskLayer[];
39
+ }
40
+ /** The cell index grain of every layer: cells across and down the mask box. */
41
+ export declare const CHART_MASK_INDEX_GRAIN: Readonly<{
42
+ cellsX: 64;
43
+ cellsY: 16;
44
+ }>;
45
+ /** Limits of a declared scene. */
46
+ export declare const CHART_MATERIAL_LAYER_LIMITS: Readonly<{
47
+ maximumLayers: 16;
48
+ maximumShapes: 4096;
49
+ maximumRings: 256;
50
+ maximumEdges: 65536;
51
+ }>;
52
+ /** Internal: a shape with its bounding box and flattened edges (polygon) or squared radii (annulus). */
53
+ export type ResolvedChartMaskShape = {
54
+ kind: "polygon";
55
+ box: readonly [number, number, number, number];
56
+ edges: Float64Array;
57
+ } | {
58
+ kind: "annulus";
59
+ box: readonly [number, number, number, number];
60
+ centerX: number;
61
+ centerY: number;
62
+ inner2: number;
63
+ outer2: number;
64
+ };
65
+ export interface ResolvedChartMaskLayer {
66
+ rectangle: {
67
+ u0: number;
68
+ v0: number;
69
+ u1: number;
70
+ v1: number;
71
+ };
72
+ unitsWidth: number;
73
+ unitsHeight: number;
74
+ /** Mask units per frame unit: unitsWidth / (u1 − u0) and unitsHeight / (v1 − v0). */
75
+ scaleX: number;
76
+ scaleY: number;
77
+ shapes: readonly ResolvedChartMaskShape[];
78
+ cellsX: number;
79
+ cellsY: number;
80
+ cellWidth: number;
81
+ cellHeight: number;
82
+ /** Per cell (row by row), the shape indices whose bounding box meets the cell grown by one cell. */
83
+ cells: readonly Uint32Array[];
84
+ backgroundMaterial: number;
85
+ inkMaterial: number;
86
+ /** Whether a point in mask units is ink (through the cell index). */
87
+ containsUnits(x: number, y: number): boolean;
88
+ }
89
+ export interface ResolvedChartMaterialLayers {
90
+ kind: "material-layers";
91
+ sceneId: string;
92
+ /** The chart under the layers; its materials come first in `materials`. */
93
+ chart: ResolvedChartScene;
94
+ layers: readonly ResolvedChartMaskLayer[];
95
+ materials: ResolvedChartScene["materials"];
96
+ /** Internal: the caller input behind each material (undefined for an engine neutral), for the scene digest. */
97
+ materialInputs: readonly unknown[];
98
+ /** Material index at a frame point (u right, v up): the topmost layer whose rectangle holds the point, else the chart. */
99
+ materialAt(u: number, v: number): number;
100
+ /** The same scene as a caller material scene for `simulateCapture` and the display view (chart-local coordinates when the chart has a size). */
101
+ callerScene: CallerMaterialScene;
102
+ }
103
+ /** Non-zero winding over the edges (x0, y0, x1, y1), as the reference evaluates it; the GPU runs the same comparisons. */
104
+ export declare function polygonWinding(edges: Float64Array, x: number, y: number): number;
105
+ /** Whether a resolved shape contains a point in mask units (the full test, without the cell index). */
106
+ export declare function shapeContains(shape: ResolvedChartMaskShape, x: number, y: number): boolean;
107
+ /**
108
+ * Validates a declared material scene and resolves its chart (in a frame of `aspect` = height / width) and its
109
+ * layers. `materialAt` is the float64 reference the GPU stage is checked against, and `callerScene` is the same
110
+ * scene for `simulateCapture`'s `scene` option.
111
+ */
112
+ export declare function resolveChartMaterialLayers(input: {
113
+ scene: ChartMaterialLayerScene;
114
+ aspect: number;
115
+ }): ResolvedChartMaterialLayers;
@@ -0,0 +1,224 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ /**
3
+ * Declared material scenes (#477): an engine chart under shape-mask layers, given as data rather than as a
4
+ * `materialAt` function, so that both the float64 reference and the `webgpu-f32` chart stage can evaluate
5
+ * them. An application that prints a label on a chart (a logo and a line of text as filled polygons and
6
+ * stroked rings, in the label's own units) describes it here; the engine holds no label of its own.
7
+ *
8
+ * A layer maps its mask box, [0, unitsWidth] × [0, unitsHeight] with y down, onto a frame rectangle. Inside
9
+ * that rectangle the layer decides the material: the ink material where any of its shapes contains the
10
+ * point, its background material elsewhere. Later layers cover earlier ones, and the chart shows outside
11
+ * every layer. Shapes are polygons under the non-zero winding rule (several rings per shape; a stroked
12
+ * polyline is its rectangles as rings of one orientation) and annuli (stroked circles).
13
+ *
14
+ * Each layer carries a cell index of {@link CHART_MASK_INDEX_GRAIN} cells over its box: a cell lists the
15
+ * shapes whose bounding box meets the cell grown by one cell on every side, so `containsUnits` tests only
16
+ * those. A computed cell can be off by one from the true one only through the rounding of one subtraction
17
+ * and one multiplication, far less than a cell (the grain is checked against the coordinates' magnitude
18
+ * when the layer is resolved), and a shape left out of a cell's list lies a whole cell away from any point
19
+ * that resolves to it, so the indexed test gives the full test's answer at every point. The GPU uses the same
20
+ * index (docs/WEBGPU.md, "Scene radiance on the GPU").
21
+ */
22
+ import { InvalidConfigurationError } from "../core/configuration-error.js";
23
+ import { requireInputKeys, requireInputObject } from "../core/record-validation.js";
24
+ import { resolveChartScene, resolveChartMaterial, chartMaterialInputs } from "./chart-scenes.js";
25
+ /** The cell index grain of every layer: cells across and down the mask box. */
26
+ export const CHART_MASK_INDEX_GRAIN = Object.freeze({ cellsX: 64, cellsY: 16 });
27
+ /** Limits of a declared scene. */
28
+ export const CHART_MATERIAL_LAYER_LIMITS = Object.freeze({ maximumLayers: 16, maximumShapes: 4096, maximumRings: 256, maximumEdges: 65_536 });
29
+ const SCENE_ID = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$/u;
30
+ const finite = (value, name) => {
31
+ if (typeof value !== "number" || !Number.isFinite(value))
32
+ throw new InvalidConfigurationError(name + " must be a finite number.");
33
+ return value;
34
+ };
35
+ /** The smallest cell the one-cell margin covers: the rounding of (x − 0)·scale is a few units in the last place of the coordinates. */
36
+ const minimumCell = (extent) => Math.max(extent, Number.MIN_VALUE) * 2 ** -20;
37
+ function resolvePolygon(shape, name) {
38
+ const rings = shape.rings;
39
+ if (!Array.isArray(rings) || rings.length < 1 || rings.length > CHART_MATERIAL_LAYER_LIMITS.maximumRings)
40
+ throw new InvalidConfigurationError(name + " needs 1 to 256 rings.");
41
+ let count = 0;
42
+ for (const ring of rings) {
43
+ if (!Array.isArray(ring) || ring.length < 6 || ring.length % 2 !== 0)
44
+ throw new InvalidConfigurationError(name + " rings need at least three (x, y) vertices.");
45
+ count += ring.length / 2;
46
+ }
47
+ if (count > CHART_MATERIAL_LAYER_LIMITS.maximumEdges)
48
+ throw new InvalidConfigurationError(name + " has more than 65536 edges.");
49
+ const edges = new Float64Array(4 * count);
50
+ let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity, e = 0;
51
+ for (const ring of rings) {
52
+ const n = ring.length / 2;
53
+ for (let k = 0; k < n; k++) {
54
+ const x0 = finite(ring[2 * k], name + " vertex"), y0 = finite(ring[2 * k + 1], name + " vertex");
55
+ const next = k + 1 === n ? 0 : k + 1, x1 = finite(ring[2 * next], name + " vertex"), y1 = finite(ring[2 * next + 1], name + " vertex");
56
+ edges[e++] = x0;
57
+ edges[e++] = y0;
58
+ edges[e++] = x1;
59
+ edges[e++] = y1;
60
+ minX = Math.min(minX, x0);
61
+ minY = Math.min(minY, y0);
62
+ maxX = Math.max(maxX, x0);
63
+ maxY = Math.max(maxY, y0);
64
+ }
65
+ }
66
+ return { kind: "polygon", box: [minX, minY, maxX, maxY], edges };
67
+ }
68
+ /** Non-zero winding over the edges (x0, y0, x1, y1), as the reference evaluates it; the GPU runs the same comparisons. */
69
+ export function polygonWinding(edges, x, y) {
70
+ let winding = 0;
71
+ for (let k = 0; k < edges.length; k += 4) {
72
+ const x0 = edges[k], y0 = edges[k + 1], x1 = edges[k + 2], y1 = edges[k + 3];
73
+ const side = (x1 - x0) * (y - y0) - (x - x0) * (y1 - y0);
74
+ if (y0 <= y) {
75
+ if (y1 > y && side > 0)
76
+ winding++;
77
+ }
78
+ else if (y1 <= y && side < 0)
79
+ winding--;
80
+ }
81
+ return winding;
82
+ }
83
+ /** Whether a resolved shape contains a point in mask units (the full test, without the cell index). */
84
+ export function shapeContains(shape, x, y) {
85
+ const b = shape.box;
86
+ if (!(x >= b[0] && x <= b[2] && y >= b[1] && y <= b[3]))
87
+ return false;
88
+ if (shape.kind === "annulus") {
89
+ const d2 = (x - shape.centerX) * (x - shape.centerX) + (y - shape.centerY) * (y - shape.centerY);
90
+ return d2 >= shape.inner2 && d2 <= shape.outer2;
91
+ }
92
+ return polygonWinding(shape.edges, x, y) !== 0;
93
+ }
94
+ function resolveLayer(value, name, aspect, materials, inputs) {
95
+ requireInputObject(value, name);
96
+ const layer = value;
97
+ for (const key of Object.keys(layer)) {
98
+ if (!["kind", "rectangle", "unitsWidth", "unitsHeight", "shapes", "backgroundReflectance", "inkReflectance"].includes(key))
99
+ throw new InvalidConfigurationError("Unknown " + name + " field: " + key + ".");
100
+ }
101
+ if (layer.kind !== "shape-mask")
102
+ throw new InvalidConfigurationError(name + ".kind must be shape-mask.");
103
+ requireInputObject(layer.rectangle, name + ".rectangle");
104
+ const r = layer.rectangle;
105
+ for (const key of Object.keys(r))
106
+ if (!["u0", "v0", "u1", "v1"].includes(key))
107
+ throw new InvalidConfigurationError("Unknown " + name + ".rectangle field: " + key + ".");
108
+ const u0 = finite(r.u0, name + ".rectangle.u0"), v0 = finite(r.v0, name + ".rectangle.v0"), u1 = finite(r.u1, name + ".rectangle.u1"), v1 = finite(r.v1, name + ".rectangle.v1");
109
+ if (!(u1 > u0 && v1 > v0) || Math.max(Math.abs(u0), Math.abs(u1)) > 1e6 || Math.max(Math.abs(v0), Math.abs(v1)) > 1e6 * Math.max(1, aspect)) {
110
+ throw new InvalidConfigurationError(name + ".rectangle needs u0 < u1 and v0 < v1 within 10^6 frame units.");
111
+ }
112
+ const unitsWidth = finite(layer.unitsWidth, name + ".unitsWidth"), unitsHeight = finite(layer.unitsHeight, name + ".unitsHeight");
113
+ if (!(unitsWidth > 0 && unitsHeight > 0 && unitsWidth <= 1e9 && unitsHeight <= 1e9))
114
+ throw new InvalidConfigurationError(name + " units must be positive and at most 10^9.");
115
+ const list = layer.shapes;
116
+ if (!Array.isArray(list) || list.length < 1 || list.length > CHART_MATERIAL_LAYER_LIMITS.maximumShapes)
117
+ throw new InvalidConfigurationError(name + ".shapes must list 1 to 4096 shapes.");
118
+ const shapes = list.map((shape, index) => {
119
+ const label = name + ".shapes[" + index + "]";
120
+ requireInputObject(shape, label);
121
+ const s = shape;
122
+ if (s.kind === "polygon") {
123
+ for (const key of Object.keys(s))
124
+ if (key !== "kind" && key !== "rings")
125
+ throw new InvalidConfigurationError("Unknown " + label + " field: " + key + ".");
126
+ return resolvePolygon(s, label);
127
+ }
128
+ if (s.kind !== "annulus")
129
+ throw new InvalidConfigurationError(label + ".kind must be polygon or annulus.");
130
+ for (const key of Object.keys(s))
131
+ if (!["kind", "centerX", "centerY", "innerRadius", "outerRadius"].includes(key))
132
+ throw new InvalidConfigurationError("Unknown " + label + " field: " + key + ".");
133
+ const cx = finite(s.centerX, label + ".centerX"), cy = finite(s.centerY, label + ".centerY");
134
+ const inner = finite(s.innerRadius, label + ".innerRadius"), outer = finite(s.outerRadius, label + ".outerRadius");
135
+ if (!(inner >= 0 && outer > inner))
136
+ throw new InvalidConfigurationError(label + " needs 0 ≤ innerRadius < outerRadius.");
137
+ return { kind: "annulus", box: [cx - outer, cy - outer, cx + outer, cy + outer], centerX: cx, centerY: cy, inner2: inner * inner, outer2: outer * outer };
138
+ });
139
+ for (const shape of shapes) {
140
+ if (!shape.box.every((c) => Math.abs(c) <= 1e9))
141
+ throw new InvalidConfigurationError(name + " shape coordinates must stay within 10^9 units.");
142
+ }
143
+ const backgroundMaterial = materials.length;
144
+ materials.push(resolveChartMaterial(layer.backgroundReflectance, name + ".backgroundReflectance"));
145
+ inputs.push(typeof layer.backgroundReflectance === "number" ? undefined : layer.backgroundReflectance);
146
+ const inkMaterial = materials.length;
147
+ materials.push(resolveChartMaterial(layer.inkReflectance, name + ".inkReflectance"));
148
+ inputs.push(typeof layer.inkReflectance === "number" ? undefined : layer.inkReflectance);
149
+ // The cell index over the mask box; the grain must stay large against the coordinates' rounding (see the header).
150
+ const { cellsX, cellsY } = CHART_MASK_INDEX_GRAIN, cellWidth = unitsWidth / cellsX, cellHeight = unitsHeight / cellsY;
151
+ const extentX = Math.max(unitsWidth, ...shapes.map((s) => Math.max(Math.abs(s.box[0]), Math.abs(s.box[2]))));
152
+ const extentY = Math.max(unitsHeight, ...shapes.map((s) => Math.max(Math.abs(s.box[1]), Math.abs(s.box[3]))));
153
+ if (!(cellWidth > minimumCell(extentX) && cellHeight > minimumCell(extentY)))
154
+ throw new InvalidConfigurationError(name + ": the shapes extend too far beyond the mask box for its cell index.");
155
+ const cells = [];
156
+ for (let j = 0; j < cellsY; j++) {
157
+ for (let i = 0; i < cellsX; i++) {
158
+ const x0 = (i - 1) * cellWidth, x1 = (i + 2) * cellWidth, y0 = (j - 1) * cellHeight, y1 = (j + 2) * cellHeight, listed = [];
159
+ shapes.forEach((s, k) => { if (s.box[0] <= x1 && s.box[2] >= x0 && s.box[1] <= y1 && s.box[3] >= y0)
160
+ listed.push(k); });
161
+ cells.push(Uint32Array.from(listed));
162
+ }
163
+ }
164
+ const scaleX = unitsWidth / (u1 - u0), scaleY = unitsHeight / (v1 - v0);
165
+ return Object.freeze({ rectangle: Object.freeze({ u0, v0, u1, v1 }), unitsWidth, unitsHeight, scaleX, scaleY, shapes: Object.freeze(shapes), cellsX, cellsY, cellWidth, cellHeight,
166
+ cells: Object.freeze(cells), backgroundMaterial, inkMaterial,
167
+ containsUnits(x, y) {
168
+ let i = Math.floor(x / cellWidth), j = Math.floor(y / cellHeight);
169
+ if (!(i > 0))
170
+ i = 0;
171
+ else if (i >= cellsX)
172
+ i = cellsX - 1;
173
+ if (!(j > 0))
174
+ j = 0;
175
+ else if (j >= cellsY)
176
+ j = cellsY - 1;
177
+ const list = cells[j * cellsX + i];
178
+ for (let k = 0; k < list.length; k++)
179
+ if (shapeContains(shapes[list[k]], x, y))
180
+ return true;
181
+ return false;
182
+ } });
183
+ }
184
+ /**
185
+ * Validates a declared material scene and resolves its chart (in a frame of `aspect` = height / width) and its
186
+ * layers. `materialAt` is the float64 reference the GPU stage is checked against, and `callerScene` is the same
187
+ * scene for `simulateCapture`'s `scene` option.
188
+ */
189
+ export function resolveChartMaterialLayers(input) {
190
+ requireInputKeys(input, "resolveChartMaterialLayers", ["scene", "aspect"]);
191
+ const { scene, aspect } = input;
192
+ requireInputObject(scene, "scene");
193
+ const record = scene;
194
+ for (const key of Object.keys(record))
195
+ if (!["kind", "sceneId", "chart", "layers"].includes(key))
196
+ throw new InvalidConfigurationError("Unknown scene field: " + key + ".");
197
+ if (record.kind !== "material-layers")
198
+ throw new InvalidConfigurationError("scene.kind must be material-layers.");
199
+ if (typeof record.sceneId !== "string" || !SCENE_ID.test(record.sceneId))
200
+ throw new InvalidConfigurationError("A material-layers scene needs a public sceneId.");
201
+ if (typeof aspect !== "number" || !Number.isFinite(aspect) || aspect <= 0)
202
+ throw new InvalidConfigurationError("Chart aspect must be positive.");
203
+ const chart = resolveChartScene({ scene: record.chart, aspect });
204
+ const list = record.layers;
205
+ if (!Array.isArray(list) || list.length < 1 || list.length > CHART_MATERIAL_LAYER_LIMITS.maximumLayers)
206
+ throw new InvalidConfigurationError("layers must list 1 to 16 shape-mask layers.");
207
+ const materials = [...chart.materials], inputs = [...chartMaterialInputs(chart)];
208
+ const layers = list.map((layer, index) => resolveLayer(layer, "layers[" + index + "]", aspect, materials, inputs));
209
+ const materialAt = (u, v) => {
210
+ for (let l = layers.length - 1; l >= 0; l--) {
211
+ const layer = layers[l], r = layer.rectangle;
212
+ if (u < r.u0 || u > r.u1 || v < r.v0 || v > r.v1)
213
+ continue;
214
+ return layer.containsUnits((u - r.u0) * layer.scaleX, (r.v1 - v) * layer.scaleY) ? layer.inkMaterial : layer.backgroundMaterial;
215
+ }
216
+ return chart.materialAt(u, v);
217
+ };
218
+ const callerMaterials = materials.map((m, k) => (m.kind === "neutral" ? m.reflectance : inputs[k]));
219
+ const callerScene = Object.freeze({ kind: "material-function", sceneId: record.sceneId, materials: Object.freeze(callerMaterials),
220
+ materialAt: (p) => materialAt(p.chartU ?? p.u, p.chartV ?? p.v) });
221
+ return Object.freeze({ kind: "material-layers", sceneId: record.sceneId, chart, layers: Object.freeze(layers), materials: Object.freeze(materials),
222
+ materialInputs: Object.freeze(inputs), materialAt, callerScene });
223
+ }
224
+ //# sourceMappingURL=chart-material-layers.js.map