@ac-kit/math-analysis 0.1.11 → 0.3.0

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 (111) hide show
  1. package/CHANGELOG.md +155 -0
  2. package/README.md +167 -10
  3. package/dist/differentiation/finite-difference.d.ts +41 -0
  4. package/dist/differentiation/finite-difference.d.ts.map +1 -0
  5. package/dist/differentiation/finite-difference.js +53 -0
  6. package/dist/differentiation/finite-difference.js.map +1 -0
  7. package/dist/differentiation/gradient.d.ts +73 -0
  8. package/dist/differentiation/gradient.d.ts.map +1 -0
  9. package/dist/differentiation/gradient.js +167 -0
  10. package/dist/differentiation/gradient.js.map +1 -0
  11. package/dist/index.d.ts +20 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +20 -0
  14. package/dist/index.js.map +1 -1
  15. package/dist/interpolation/barycentric-interpolator.d.ts +29 -0
  16. package/dist/interpolation/barycentric-interpolator.d.ts.map +1 -0
  17. package/dist/interpolation/barycentric-interpolator.js +94 -0
  18. package/dist/interpolation/barycentric-interpolator.js.map +1 -0
  19. package/dist/legendre/_legendre-kernel.d.ts +22 -0
  20. package/dist/legendre/_legendre-kernel.d.ts.map +1 -0
  21. package/dist/legendre/_legendre-kernel.js +232 -0
  22. package/dist/legendre/_legendre-kernel.js.map +1 -0
  23. package/dist/legendre/legendre-fully-normalized.d.ts +52 -0
  24. package/dist/legendre/legendre-fully-normalized.d.ts.map +1 -0
  25. package/dist/legendre/legendre-fully-normalized.js +62 -0
  26. package/dist/legendre/legendre-fully-normalized.js.map +1 -0
  27. package/dist/legendre/legendre-index.d.ts +27 -0
  28. package/dist/legendre/legendre-index.d.ts.map +1 -0
  29. package/dist/legendre/legendre-index.js +31 -0
  30. package/dist/legendre/legendre-index.js.map +1 -0
  31. package/dist/legendre/legendre-schmidt.d.ts +37 -0
  32. package/dist/legendre/legendre-schmidt.d.ts.map +1 -0
  33. package/dist/legendre/legendre-schmidt.js +47 -0
  34. package/dist/legendre/legendre-schmidt.js.map +1 -0
  35. package/dist/ode/runge-kutta4.d.ts +46 -0
  36. package/dist/ode/runge-kutta4.d.ts.map +1 -0
  37. package/dist/ode/runge-kutta4.js +85 -0
  38. package/dist/ode/runge-kutta4.js.map +1 -0
  39. package/dist/optimize/_more-thuente.d.ts +95 -0
  40. package/dist/optimize/_more-thuente.d.ts.map +1 -0
  41. package/dist/optimize/_more-thuente.js +333 -0
  42. package/dist/optimize/_more-thuente.js.map +1 -0
  43. package/dist/optimize/_wolfe-line-search.d.ts +85 -0
  44. package/dist/optimize/_wolfe-line-search.d.ts.map +1 -0
  45. package/dist/optimize/_wolfe-line-search.js +193 -0
  46. package/dist/optimize/_wolfe-line-search.js.map +1 -0
  47. package/dist/optimize/bfgs.d.ts +262 -0
  48. package/dist/optimize/bfgs.d.ts.map +1 -0
  49. package/dist/optimize/bfgs.js +418 -0
  50. package/dist/optimize/bfgs.js.map +1 -0
  51. package/dist/optimize/lbfgs.d.ts +199 -0
  52. package/dist/optimize/lbfgs.d.ts.map +1 -0
  53. package/dist/optimize/lbfgs.js +383 -0
  54. package/dist/optimize/lbfgs.js.map +1 -0
  55. package/dist/optimize/levenberg-marquardt.d.ts +78 -0
  56. package/dist/optimize/levenberg-marquardt.d.ts.map +1 -0
  57. package/dist/optimize/levenberg-marquardt.js +204 -0
  58. package/dist/optimize/levenberg-marquardt.js.map +1 -0
  59. package/dist/optimize/nelder-mead.d.ts +68 -0
  60. package/dist/optimize/nelder-mead.d.ts.map +1 -0
  61. package/dist/optimize/nelder-mead.js +198 -0
  62. package/dist/optimize/nelder-mead.js.map +1 -0
  63. package/dist/quadrature/adaptive-quadrature.d.ts +53 -0
  64. package/dist/quadrature/adaptive-quadrature.d.ts.map +1 -0
  65. package/dist/quadrature/adaptive-quadrature.js +175 -0
  66. package/dist/quadrature/adaptive-quadrature.js.map +1 -0
  67. package/dist/quadrature/gauss-legendre.d.ts +27 -0
  68. package/dist/quadrature/gauss-legendre.d.ts.map +1 -0
  69. package/dist/quadrature/gauss-legendre.js +111 -0
  70. package/dist/quadrature/gauss-legendre.js.map +1 -0
  71. package/dist/quadrature/simpsons-rule.d.ts +27 -0
  72. package/dist/quadrature/simpsons-rule.d.ts.map +1 -0
  73. package/dist/quadrature/simpsons-rule.js +44 -0
  74. package/dist/quadrature/simpsons-rule.js.map +1 -0
  75. package/dist/roots/_brent-kernel.d.ts +38 -0
  76. package/dist/roots/_brent-kernel.d.ts.map +1 -0
  77. package/dist/roots/_brent-kernel.js +112 -0
  78. package/dist/roots/_brent-kernel.js.map +1 -0
  79. package/dist/roots/_grown.d.ts +7 -0
  80. package/dist/roots/_grown.d.ts.map +1 -0
  81. package/dist/roots/_grown.js +19 -0
  82. package/dist/roots/_grown.js.map +1 -0
  83. package/dist/roots/_level-search.d.ts +154 -0
  84. package/dist/roots/_level-search.d.ts.map +1 -0
  85. package/dist/roots/_level-search.js +556 -0
  86. package/dist/roots/_level-search.js.map +1 -0
  87. package/dist/roots/brent.d.ts +59 -0
  88. package/dist/roots/brent.d.ts.map +1 -0
  89. package/dist/roots/brent.js +115 -0
  90. package/dist/roots/brent.js.map +1 -0
  91. package/dist/roots/find-level-bands.d.ts +148 -0
  92. package/dist/roots/find-level-bands.d.ts.map +1 -0
  93. package/dist/roots/find-level-bands.js +351 -0
  94. package/dist/roots/find-level-bands.js.map +1 -0
  95. package/dist/roots/find-level-crossings.d.ts +143 -0
  96. package/dist/roots/find-level-crossings.d.ts.map +1 -0
  97. package/dist/roots/find-level-crossings.js +162 -0
  98. package/dist/roots/find-level-crossings.js.map +1 -0
  99. package/dist/roots/level-search-options.d.ts +56 -0
  100. package/dist/roots/level-search-options.d.ts.map +1 -0
  101. package/dist/roots/level-search-options.js +2 -0
  102. package/dist/roots/level-search-options.js.map +1 -0
  103. package/dist/roots/newton-raphson.d.ts +31 -0
  104. package/dist/roots/newton-raphson.d.ts.map +1 -0
  105. package/dist/roots/newton-raphson.js +69 -0
  106. package/dist/roots/newton-raphson.js.map +1 -0
  107. package/dist/series/sum-series.d.ts +43 -0
  108. package/dist/series/sum-series.d.ts.map +1 -0
  109. package/dist/series/sum-series.js +70 -0
  110. package/dist/series/sum-series.js.map +1 -0
  111. package/package.json +8 -5
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_legendre-kernel.js","sourceRoot":"","sources":["../../src/legendre/_legendre-kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAExE,4EAA4E;AAC5E,4EAA4E;AAC5E,0EAA0E;AAC1E,yEAAyE;AACzE,+EAA+E;AAC/E,4EAA4E;AAC5E,8EAA8E;AAC9E,0EAA0E;AAC1E,oBAAoB;AACpB,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,cAAc,CAAC;AACzC,uEAAuE;AACvE,8DAA8D;AAC9D,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,CAAC;AAC7B,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;AAC7B,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,+EAA+E;AAC/E,MAAM,cAAc,GAAG,CAAC,IAAI,CAAC;AAC7B,2EAA2E;AAC3E,MAAM,oBAAoB,GAAG,CAAC,IAAI,CAAC;AACnC,MAAM,KAAK,GAAG,GAAG,CAAC;AAClB,0EAA0E;AAC1E,MAAM,KAAK,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;AAElC,IAAI,MAAM,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;AACjC,IAAI,aAAa,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,CAAC;AAExC,gEAAgE;AAChE,SAAS,YAAY,CAAC,KAAa;IAClC,IAAI,MAAM,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;QAC5B,OAAO;IACR,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,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` of
3
+ * every degree `n ≤ maxDegree` and order `0 ≤ m ≤ n` into `out`, in the order
4
+ * of {@link legendreIndex}, and their derivatives `dP̄ₙₘ/dθ` with respect to the
5
+ * colatitude `θ` into `derivativesOut` when given. Returns `out`.
6
+ *
7
+ * The normalisation of geodesy and gravity field models (EGM2008, the geoid):
8
+ * `P̄ₙₘ = √((2 − δₘ₀)(2n + 1)(n − m)! / (n + m)!) Pₙₘ`, so that the mean of
9
+ * `(P̄ₙₘ(cos θ) cos mλ)²` over the sphere is `1`, without the Condon–Shortley
10
+ * phase `(−1)ᵐ`. It is {@link legendreSchmidt}'s times `√(2n + 1)`.
11
+ *
12
+ * Stable to degree 2190 (EGM2008's) and beyond, at every colatitude: the
13
+ * recursion is Holmes and Featherstone's modified forward column method, each
14
+ * order's column run as `P̄ₙₘ / sinᵐθ` with a scaled seed and multiplied back
15
+ * by `sinᵐθ` with its exponent kept apart, so no intermediate overflows to
16
+ * degree 2700 (past about 2850 the scaled columns do, near the poles), and a
17
+ * value too small for binary64 (high orders near the poles) underflows to the
18
+ * subnormal range or to `0` instead of corrupting its column. The derivatives
19
+ * come from the neighbouring orders, with no division by `sin θ`, so they are
20
+ * exact at the poles too. Measured against 60-digit references, the error of a
21
+ * degree-n entry stays below `10⁻¹¹ √(2n + 1)` to degree 2190, and below `10⁻¹³
22
+ * √(2n + 1)` to degree 100; the cosine near a pole is taken from the half
23
+ * angle, so a colatitude of `10⁻⁶` loses nothing to `cos θ` rounding to within
24
+ * `10⁻¹⁶` of `1`. Near `θ = π` a double holds the colatitude itself only to
25
+ * `2⁻⁵² π` absolute; evaluate a southern point at `π − θ` and apply `P̄ₙₘ(−t) =
26
+ * (−1)ⁿ⁺ᵐ P̄ₙₘ(t)` when that matters.
27
+ *
28
+ * O(maxDegree²) time; O(maxDegree) memory for a table of integer square roots
29
+ * kept between calls, which grows to the largest degree asked for. Nothing is
30
+ * allocated once that table is large enough.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const length = legendreTableLength(2190);
35
+ * const values = new Float64Array(length);
36
+ * const derivatives = new Float64Array(length);
37
+ * legendreFullyNormalized(values, 2190, colatitude, derivatives);
38
+ * values[legendreIndex(2190, 1000)]; // P̄₂₁₉₀,₁₀₀₀(cos θ)
39
+ * ```;
40
+ *
41
+ * @param out Receives the values; entries past {@link legendreTableLength}
42
+ * `(maxDegree)` are left alone.
43
+ * @param maxDegree The highest degree, a non-negative integer.
44
+ * @param colatitude `θ`, radians in `[0, π]`; `NaN` fills both tables with
45
+ * `NaN`.
46
+ * @param derivativesOut Receives `dP̄ₙₘ/dθ`; must not overlap `out`.
47
+ * @throws {RangeError} When `maxDegree` is not a non-negative integer, a table
48
+ * is too short for it, the tables overlap or `colatitude` is outside `[0,
49
+ * π]`; nothing is written.
50
+ */
51
+ export declare function legendreFullyNormalized(out: Float64Array, maxDegree: number, colatitude: number, derivativesOut?: Float64Array): Float64Array;
52
+ //# sourceMappingURL=legendre-fully-normalized.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legendre-fully-normalized.d.ts","sourceRoot":"","sources":["../../src/legendre/legendre-fully-normalized.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,YAAY,GAC3B,YAAY,CAcd"}
@@ -0,0 +1,62 @@
1
+ import { LEGENDRE_COLATITUDE_, legendreCheck_, legendreFillNaN_, legendreKernel_, } from "./_legendre-kernel.js";
2
+ /**
3
+ * Writes the fully normalised associated Legendre functions `P̄ₙₘ(cos θ)` of
4
+ * every degree `n ≤ maxDegree` and order `0 ≤ m ≤ n` into `out`, in the order
5
+ * of {@link legendreIndex}, and their derivatives `dP̄ₙₘ/dθ` with respect to the
6
+ * colatitude `θ` into `derivativesOut` when given. Returns `out`.
7
+ *
8
+ * The normalisation of geodesy and gravity field models (EGM2008, the geoid):
9
+ * `P̄ₙₘ = √((2 − δₘ₀)(2n + 1)(n − m)! / (n + m)!) Pₙₘ`, so that the mean of
10
+ * `(P̄ₙₘ(cos θ) cos mλ)²` over the sphere is `1`, without the Condon–Shortley
11
+ * phase `(−1)ᵐ`. It is {@link legendreSchmidt}'s times `√(2n + 1)`.
12
+ *
13
+ * Stable to degree 2190 (EGM2008's) and beyond, at every colatitude: the
14
+ * recursion is Holmes and Featherstone's modified forward column method, each
15
+ * order's column run as `P̄ₙₘ / sinᵐθ` with a scaled seed and multiplied back
16
+ * by `sinᵐθ` with its exponent kept apart, so no intermediate overflows to
17
+ * degree 2700 (past about 2850 the scaled columns do, near the poles), and a
18
+ * value too small for binary64 (high orders near the poles) underflows to the
19
+ * subnormal range or to `0` instead of corrupting its column. The derivatives
20
+ * come from the neighbouring orders, with no division by `sin θ`, so they are
21
+ * exact at the poles too. Measured against 60-digit references, the error of a
22
+ * degree-n entry stays below `10⁻¹¹ √(2n + 1)` to degree 2190, and below `10⁻¹³
23
+ * √(2n + 1)` to degree 100; the cosine near a pole is taken from the half
24
+ * angle, so a colatitude of `10⁻⁶` loses nothing to `cos θ` rounding to within
25
+ * `10⁻¹⁶` of `1`. Near `θ = π` a double holds the colatitude itself only to
26
+ * `2⁻⁵² π` absolute; evaluate a southern point at `π − θ` and apply `P̄ₙₘ(−t) =
27
+ * (−1)ⁿ⁺ᵐ P̄ₙₘ(t)` when that matters.
28
+ *
29
+ * O(maxDegree²) time; O(maxDegree) memory for a table of integer square roots
30
+ * kept between calls, which grows to the largest degree asked for. Nothing is
31
+ * allocated once that table is large enough.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * const length = legendreTableLength(2190);
36
+ * const values = new Float64Array(length);
37
+ * const derivatives = new Float64Array(length);
38
+ * legendreFullyNormalized(values, 2190, colatitude, derivatives);
39
+ * values[legendreIndex(2190, 1000)]; // P̄₂₁₉₀,₁₀₀₀(cos θ)
40
+ * ```;
41
+ *
42
+ * @param out Receives the values; entries past {@link legendreTableLength}
43
+ * `(maxDegree)` are left alone.
44
+ * @param maxDegree The highest degree, a non-negative integer.
45
+ * @param colatitude `θ`, radians in `[0, π]`; `NaN` fills both tables with
46
+ * `NaN`.
47
+ * @param derivativesOut Receives `dP̄ₙₘ/dθ`; must not overlap `out`.
48
+ * @throws {RangeError} When `maxDegree` is not a non-negative integer, a table
49
+ * is too short for it, the tables overlap or `colatitude` is outside `[0,
50
+ * π]`; nothing is written.
51
+ */
52
+ export function legendreFullyNormalized(out, maxDegree, colatitude, derivativesOut) {
53
+ LEGENDRE_COLATITUDE_[0] = colatitude;
54
+ const length = legendreCheck_("legendreFullyNormalized", out, derivativesOut, maxDegree);
55
+ if (colatitude !== colatitude) {
56
+ legendreFillNaN_(out, derivativesOut, length);
57
+ return out;
58
+ }
59
+ legendreKernel_(out, derivativesOut, maxDegree, false);
60
+ return out;
61
+ }
62
+ //# sourceMappingURL=legendre-fully-normalized.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legendre-fully-normalized.js","sourceRoot":"","sources":["../../src/legendre/legendre-fully-normalized.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,eAAe,GACf,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,MAAM,UAAU,uBAAuB,CACtC,GAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,cAA6B;IAE7B,oBAAoB,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC;IACrC,MAAM,MAAM,GAAG,cAAc,CAC5B,yBAAyB,EACzB,GAAG,EACH,cAAc,EACd,SAAS,CACT,CAAC;IACF,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;QAC/B,gBAAgB,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;QAC9C,OAAO,GAAG,CAAC;IACZ,CAAC;IACD,eAAe,CAAC,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IACvD,OAAO,GAAG,CAAC;AACZ,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The position of degree `degree` and order `order` in a triangular table of
3
+ * associated Legendre functions, as {@link legendreSchmidt} and
4
+ * {@link legendreFullyNormalized} write it: degree by degree, each degree's
5
+ * orders `0` to `degree` in turn, so `(0, 0)` is at `0`, `(1, 0)` at `1`, `(1,
6
+ * 1)` at `2`, `(2, 0)` at `3`. The index is `degree (degree + 1) / 2 + order`.
7
+ *
8
+ * Not checked: `degree` and `order` are integers with `0 ≤ order ≤ degree`.
9
+ * O(1).
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * legendreIndex(2, 1); // 4
14
+ * legendreIndex(12, 12); // 90, the last entry of a degree-12 table
15
+ * ```;
16
+ */
17
+ export declare function legendreIndex(degree: number, order: number): number;
18
+ /**
19
+ * The number of entries of a triangular table up to degree `maxDegree`, every
20
+ * order of every degree from `0`: `(maxDegree + 1)(maxDegree + 2) / 2`. A
21
+ * degree-12 table (the World Magnetic Model) has 91 entries, a degree-2190 one
22
+ * (EGM2008) 2 401 336.
23
+ *
24
+ * Not checked: `maxDegree` is a non-negative integer. O(1).
25
+ */
26
+ export declare function legendreTableLength(maxDegree: number): number;
27
+ //# sourceMappingURL=legendre-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legendre-index.d.ts","sourceRoot":"","sources":["../../src/legendre/legendre-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE7D"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The position of degree `degree` and order `order` in a triangular table of
3
+ * associated Legendre functions, as {@link legendreSchmidt} and
4
+ * {@link legendreFullyNormalized} write it: degree by degree, each degree's
5
+ * orders `0` to `degree` in turn, so `(0, 0)` is at `0`, `(1, 0)` at `1`, `(1,
6
+ * 1)` at `2`, `(2, 0)` at `3`. The index is `degree (degree + 1) / 2 + order`.
7
+ *
8
+ * Not checked: `degree` and `order` are integers with `0 ≤ order ≤ degree`.
9
+ * O(1).
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * legendreIndex(2, 1); // 4
14
+ * legendreIndex(12, 12); // 90, the last entry of a degree-12 table
15
+ * ```;
16
+ */
17
+ export function legendreIndex(degree, order) {
18
+ return (degree * (degree + 1)) / 2 + order;
19
+ }
20
+ /**
21
+ * The number of entries of a triangular table up to degree `maxDegree`, every
22
+ * order of every degree from `0`: `(maxDegree + 1)(maxDegree + 2) / 2`. A
23
+ * degree-12 table (the World Magnetic Model) has 91 entries, a degree-2190 one
24
+ * (EGM2008) 2 401 336.
25
+ *
26
+ * Not checked: `maxDegree` is a non-negative integer. O(1).
27
+ */
28
+ export function legendreTableLength(maxDegree) {
29
+ return ((maxDegree + 1) * (maxDegree + 2)) / 2;
30
+ }
31
+ //# sourceMappingURL=legendre-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legendre-index.js","sourceRoot":"","sources":["../../src/legendre/legendre-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,aAAa,CAAC,MAAc,EAAE,KAAa;IAC1D,OAAO,CAAC,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC5C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACpD,OAAO,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Writes the Schmidt semi-normalised associated Legendre functions `Pₙᵐ(cos θ)`
3
+ * of every degree `n ≤ maxDegree` and order `0 ≤ m ≤ n` into `out`, in the
4
+ * order of {@link legendreIndex}, and their derivatives `dPₙᵐ/dθ` with respect
5
+ * to the colatitude `θ` into `derivativesOut` when given. Returns `out`.
6
+ *
7
+ * The normalisation of geomagnetism (the World Magnetic Model, the IGRF): `Pₙᵐ
8
+ * = √((2 − δₘ₀)(n − m)! / (n + m)!) Pₙₘ`, so that `Σₘ (Pₙᵐ)² = 1` for every
9
+ * degree, without the Condon–Shortley phase `(−1)ᵐ`. It is
10
+ * {@link legendreFullyNormalized}'s divided by `√(2n + 1)`, and shares its
11
+ * recursion, so it is as stable: to degree 2190 and beyond (2700) at every
12
+ * colatitude, and with derivatives exact at the poles.
13
+ *
14
+ * O(maxDegree²) time; O(maxDegree) memory for a table of integer square roots
15
+ * kept between calls. Nothing is allocated once that table is large enough.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const values = new Float64Array(legendreTableLength(12));
20
+ * const derivatives = new Float64Array(legendreTableLength(12));
21
+ * legendreSchmidt(values, 12, Math.PI / 3, derivatives);
22
+ * values[legendreIndex(1, 1)]; // sin θ = 0.8660254037844386
23
+ * derivatives[legendreIndex(1, 0)]; // −sin θ
24
+ * ```;
25
+ *
26
+ * @param out Receives the values; entries past {@link legendreTableLength}
27
+ * `(maxDegree)` are left alone.
28
+ * @param maxDegree The highest degree, a non-negative integer.
29
+ * @param colatitude `θ`, radians in `[0, π]`; `NaN` fills both tables with
30
+ * `NaN`.
31
+ * @param derivativesOut Receives `dPₙᵐ/dθ`; must not overlap `out`.
32
+ * @throws {RangeError} When `maxDegree` is not a non-negative integer, a table
33
+ * is too short for it, the tables overlap or `colatitude` is outside `[0,
34
+ * π]`; nothing is written.
35
+ */
36
+ export declare function legendreSchmidt(out: Float64Array, maxDegree: number, colatitude: number, derivativesOut?: Float64Array): Float64Array;
37
+ //# sourceMappingURL=legendre-schmidt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legendre-schmidt.d.ts","sourceRoot":"","sources":["../../src/legendre/legendre-schmidt.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,eAAe,CAC9B,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,cAAc,CAAC,EAAE,YAAY,GAC3B,YAAY,CAcd"}
@@ -0,0 +1,47 @@
1
+ import { LEGENDRE_COLATITUDE_, legendreCheck_, legendreFillNaN_, legendreKernel_, } from "./_legendre-kernel.js";
2
+ /**
3
+ * Writes the Schmidt semi-normalised associated Legendre functions `Pₙᵐ(cos θ)`
4
+ * of every degree `n ≤ maxDegree` and order `0 ≤ m ≤ n` into `out`, in the
5
+ * order of {@link legendreIndex}, and their derivatives `dPₙᵐ/dθ` with respect
6
+ * to the colatitude `θ` into `derivativesOut` when given. Returns `out`.
7
+ *
8
+ * The normalisation of geomagnetism (the World Magnetic Model, the IGRF): `Pₙᵐ
9
+ * = √((2 − δₘ₀)(n − m)! / (n + m)!) Pₙₘ`, so that `Σₘ (Pₙᵐ)² = 1` for every
10
+ * degree, without the Condon–Shortley phase `(−1)ᵐ`. It is
11
+ * {@link legendreFullyNormalized}'s divided by `√(2n + 1)`, and shares its
12
+ * recursion, so it is as stable: to degree 2190 and beyond (2700) at every
13
+ * colatitude, and with derivatives exact at the poles.
14
+ *
15
+ * O(maxDegree²) time; O(maxDegree) memory for a table of integer square roots
16
+ * kept between calls. Nothing is allocated once that table is large enough.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const values = new Float64Array(legendreTableLength(12));
21
+ * const derivatives = new Float64Array(legendreTableLength(12));
22
+ * legendreSchmidt(values, 12, Math.PI / 3, derivatives);
23
+ * values[legendreIndex(1, 1)]; // sin θ = 0.8660254037844386
24
+ * derivatives[legendreIndex(1, 0)]; // −sin θ
25
+ * ```;
26
+ *
27
+ * @param out Receives the values; entries past {@link legendreTableLength}
28
+ * `(maxDegree)` are left alone.
29
+ * @param maxDegree The highest degree, a non-negative integer.
30
+ * @param colatitude `θ`, radians in `[0, π]`; `NaN` fills both tables with
31
+ * `NaN`.
32
+ * @param derivativesOut Receives `dPₙᵐ/dθ`; must not overlap `out`.
33
+ * @throws {RangeError} When `maxDegree` is not a non-negative integer, a table
34
+ * is too short for it, the tables overlap or `colatitude` is outside `[0,
35
+ * π]`; nothing is written.
36
+ */
37
+ export function legendreSchmidt(out, maxDegree, colatitude, derivativesOut) {
38
+ LEGENDRE_COLATITUDE_[0] = colatitude;
39
+ const length = legendreCheck_("legendreSchmidt", out, derivativesOut, maxDegree);
40
+ if (colatitude !== colatitude) {
41
+ legendreFillNaN_(out, derivativesOut, length);
42
+ return out;
43
+ }
44
+ legendreKernel_(out, derivativesOut, maxDegree, true);
45
+ return out;
46
+ }
47
+ //# sourceMappingURL=legendre-schmidt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legendre-schmidt.js","sourceRoot":"","sources":["../../src/legendre/legendre-schmidt.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAChB,eAAe,GACf,MAAM,uBAAuB,CAAC;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,eAAe,CAC9B,GAAiB,EACjB,SAAiB,EACjB,UAAkB,EAClB,cAA6B;IAE7B,oBAAoB,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC;IACrC,MAAM,MAAM,GAAG,cAAc,CAC5B,iBAAiB,EACjB,GAAG,EACH,cAAc,EACd,SAAS,CACT,CAAC;IACF,IAAI,UAAU,KAAK,UAAU,EAAE,CAAC;QAC/B,gBAAgB,CAAC,GAAG,EAAE,cAAc,EAAE,MAAM,CAAC,CAAC;QAC9C,OAAO,GAAG,CAAC;IACZ,CAAC;IACD,eAAe,CAAC,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACtD,OAAO,GAAG,CAAC;AACZ,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * The right-hand side of `y′ = f(t, y)` for a system of `n` equations: writes
3
+ * the derivative of the state `y` at time `t` into `out`. `y` must not be
4
+ * modified, and `out` is never `y`.
5
+ */
6
+ export type OdeSystem = (t: number, y: Float64Array, out: Float64Array) => void;
7
+ /** A trajectory: `steps + 1` times and the state at each, row by row. */
8
+ export type OdeTrajectory = {
9
+ /** The times, from the start to the end of the span. */
10
+ readonly t: Float64Array;
11
+ /** The states, `t.length × dimension`, row-major: row `i` is `y(t[i])`. */
12
+ readonly y: Float64Array;
13
+ /** The number of equations. */
14
+ readonly dimension: number;
15
+ };
16
+ /**
17
+ * Integrates the system `y′ = f(t, y)` from `y(tSpan[0]) = y0` to `tSpan[1]`
18
+ * with the classical fourth-order Runge–Kutta method, in `steps` equal steps:
19
+ * the standard fixed-step integrator, error `O(h⁴)`, four evaluations of `f`
20
+ * per step. A scalar equation is a system of one.
21
+ *
22
+ * The span may run backwards (`tSpan[1] < tSpan[0]`). Each time is computed
23
+ * from the start and the step index, not accumulated, so the last one is
24
+ * exactly `tSpan[1]`. The trajectory is the only allocation besides four stage
25
+ * vectors; `f` writes into a buffer it is given.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * // The harmonic oscillator y″ = −y as a system: (y, y′)′ = (y′, −y).
30
+ * const { y } = rungeKutta4((t, state, out) => {
31
+ * out[0] = state[1]!;
32
+ * out[1] = -state[0]!;
33
+ * }, [1, 0], [0, Math.PI], 100);
34
+ * // y.at(-2) ≈ −1 = cos π
35
+ * ```;
36
+ *
37
+ * @param f The right-hand side.
38
+ * @param y0 The initial state.
39
+ * @param tSpan The start and end times.
40
+ * @param steps The number of steps, a positive integer.
41
+ * @returns The times and states of the trajectory.
42
+ * @throws {RangeError} When `steps` is not a positive integer, `y0` is empty,
43
+ * or a time is not finite.
44
+ */
45
+ export declare function rungeKutta4(f: OdeSystem, y0: ArrayLike<number>, tSpan: readonly [number, number], steps: number): OdeTrajectory;
46
+ //# sourceMappingURL=runge-kutta4.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runge-kutta4.d.ts","sourceRoot":"","sources":["../../src/ode/runge-kutta4.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,GAAG,EAAE,YAAY,KAAK,IAAI,CAAC;AAEhF,yEAAyE;AACzE,MAAM,MAAM,aAAa,GAAG;IAC3B,wDAAwD;IACxD,QAAQ,CAAC,CAAC,EAAE,YAAY,CAAC;IACzB,2EAA2E;IAC3E,QAAQ,CAAC,CAAC,EAAE,YAAY,CAAC;IACzB,+BAA+B;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,WAAW,CAC1B,CAAC,EAAE,SAAS,EACZ,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,EACrB,KAAK,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,KAAK,EAAE,MAAM,GACX,aAAa,CA+Df"}
@@ -0,0 +1,85 @@
1
+ import { describeValue } from "@ac-kit/core";
2
+ /**
3
+ * Integrates the system `y′ = f(t, y)` from `y(tSpan[0]) = y0` to `tSpan[1]`
4
+ * with the classical fourth-order Runge–Kutta method, in `steps` equal steps:
5
+ * the standard fixed-step integrator, error `O(h⁴)`, four evaluations of `f`
6
+ * per step. A scalar equation is a system of one.
7
+ *
8
+ * The span may run backwards (`tSpan[1] < tSpan[0]`). Each time is computed
9
+ * from the start and the step index, not accumulated, so the last one is
10
+ * exactly `tSpan[1]`. The trajectory is the only allocation besides four stage
11
+ * vectors; `f` writes into a buffer it is given.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * // The harmonic oscillator y″ = −y as a system: (y, y′)′ = (y′, −y).
16
+ * const { y } = rungeKutta4((t, state, out) => {
17
+ * out[0] = state[1]!;
18
+ * out[1] = -state[0]!;
19
+ * }, [1, 0], [0, Math.PI], 100);
20
+ * // y.at(-2) ≈ −1 = cos π
21
+ * ```;
22
+ *
23
+ * @param f The right-hand side.
24
+ * @param y0 The initial state.
25
+ * @param tSpan The start and end times.
26
+ * @param steps The number of steps, a positive integer.
27
+ * @returns The times and states of the trajectory.
28
+ * @throws {RangeError} When `steps` is not a positive integer, `y0` is empty,
29
+ * or a time is not finite.
30
+ */
31
+ export function rungeKutta4(f, y0, tSpan, steps) {
32
+ if (!Number.isSafeInteger(steps) || steps < 1) {
33
+ throw new RangeError(`rungeKutta4: steps must be a positive integer, got ${describeValue(steps)}`);
34
+ }
35
+ const dimension = y0.length;
36
+ if (dimension === 0) {
37
+ throw new RangeError("rungeKutta4: the initial state is empty");
38
+ }
39
+ const [start, end] = tSpan;
40
+ if (start - start !== 0 || end - end !== 0) {
41
+ throw new RangeError(`rungeKutta4: the span [${start}, ${end}] is not finite`);
42
+ }
43
+ const times = new Float64Array(steps + 1);
44
+ const states = new Float64Array((steps + 1) * dimension);
45
+ for (let index = 0; index < dimension; index++) {
46
+ states[index] = y0[index];
47
+ }
48
+ times[0] = start;
49
+ const h = (end - start) / steps;
50
+ const state = new Float64Array(dimension);
51
+ const stage = new Float64Array(dimension);
52
+ const k1 = new Float64Array(dimension);
53
+ const k2 = new Float64Array(dimension);
54
+ const k3 = new Float64Array(dimension);
55
+ const k4 = new Float64Array(dimension);
56
+ state.set(states.subarray(0, dimension));
57
+ for (let step = 0; step < steps; step++) {
58
+ const t = times[step];
59
+ const half = t + h / 2;
60
+ const next = step + 1 === steps ? end : start + (step + 1) * h;
61
+ f(t, state, k1);
62
+ for (let index = 0; index < dimension; index++) {
63
+ stage[index] = state[index] + (h / 2) * k1[index];
64
+ }
65
+ f(half, stage, k2);
66
+ for (let index = 0; index < dimension; index++) {
67
+ stage[index] = state[index] + (h / 2) * k2[index];
68
+ }
69
+ f(half, stage, k3);
70
+ for (let index = 0; index < dimension; index++) {
71
+ stage[index] = state[index] + h * k3[index];
72
+ }
73
+ f(next, stage, k4);
74
+ const row = (step + 1) * dimension;
75
+ for (let index = 0; index < dimension; index++) {
76
+ const value = state[index] +
77
+ (h / 6) * (k1[index] + 2 * k2[index] + 2 * k3[index] + k4[index]);
78
+ state[index] = value;
79
+ states[row + index] = value;
80
+ }
81
+ times[step + 1] = next;
82
+ }
83
+ return { t: times, y: states, dimension };
84
+ }
85
+ //# sourceMappingURL=runge-kutta4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runge-kutta4.js","sourceRoot":"","sources":["../../src/ode/runge-kutta4.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAmB7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,WAAW,CAC1B,CAAY,EACZ,EAAqB,EACrB,KAAgC,EAChC,KAAa;IAEb,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,UAAU,CACnB,sDAAsD,aAAa,CAAC,KAAK,CAAC,EAAE,CAC5E,CAAC;IACH,CAAC;IACD,MAAM,SAAS,GAAG,EAAE,CAAC,MAAM,CAAC;IAC5B,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,UAAU,CAAC,yCAAyC,CAAC,CAAC;IACjE,CAAC;IACD,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;IAC3B,IAAI,KAAK,GAAG,KAAK,KAAK,CAAC,IAAI,GAAG,GAAG,GAAG,KAAK,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,UAAU,CACnB,0BAA0B,KAAK,KAAK,GA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CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAE,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAE,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAE,GAAG,EAAE,CAAC,KAAK,CAAE,CAAC,CAAC;YACvE,KAAK,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;YACrB,MAAM,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;QAC7B,CAAC;QACD,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC;IACxB,CAAC;IACD,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,95 @@
1
+ /** The step is still being searched for: evaluate at `stp` and call again. */
2
+ export declare const SEARCH_CONTINUE_ = 0;
3
+ /** `stp` satisfies the strong Wolfe conditions. */
4
+ export declare const SEARCH_CONVERGED_ = 1;
5
+ /**
6
+ * No further progress is possible (rounding errors, the interval of uncertainty
7
+ * below `xtol`, or a step bound reached): the caller falls back on the best
8
+ * point it evaluated.
9
+ */
10
+ export declare const SEARCH_STALLED_ = 2;
11
+ /**
12
+ * The line search of Moré and Thuente (_ACM TOMS_ 20(3), 1994), as MINPACK-2's
13
+ * `dcsrch`/`dcstep`: a step `stp > 0` along a descent direction satisfying the
14
+ * strong Wolfe conditions
15
+ *
16
+ * ```text
17
+ * φ(stp) ≤ φ(0) + ftol · stp · φ′(0) (sufficient decrease)
18
+ * |φ′(stp)| ≤ gtol · |φ′(0)| (curvature)
19
+ * ```
20
+ *
21
+ * By safeguarded cubic and quadratic interpolation inside an interval of
22
+ * uncertainty that it brackets and shrinks. A state machine driven by its
23
+ * caller, as `dcsrch` is: set `stp`, `value` and `slope` (φ(0) and φ′(0) < 0),
24
+ * call {@link start}; then repeatedly evaluate φ and φ′ at `stp`, store them in
25
+ * `value` and `slope`, and call {@link iterate}, which answers with a
26
+ * `SEARCH_…` code and the next `stp`.
27
+ *
28
+ * Every number passes through fields, never arguments or return values: a
29
+ * double crossing a call the engine does not inline is boxed. For the same
30
+ * reason {@link step_} uses no `Math.sign`, `Math.max` or `Math.sqrt`: a search
31
+ * runs a few times a minimisation, so it stays in the engine's mid tier
32
+ * (Maglev), which calls those builtins with boxed doubles (`Math.sign` on Node
33
+ * 24 and 26, the other two on Node 24). Sign tests, comparisons and `** 0.5`
34
+ * stand in for them. `** 0.5` equals `Math.sqrt` for every finite or NaN
35
+ * radicand, the only kind it is given.
36
+ */
37
+ export declare class MoreThuente_ {
38
+ /** The sufficient-decrease constant `ftol` (Wolfe's `c₁`). */
39
+ ftol: number;
40
+ /** The curvature constant `gtol` (Wolfe's `c₂`), above `ftol`. */
41
+ gtol: number;
42
+ /** The relative width of the interval of uncertainty that stops the search. */
43
+ xtol: number;
44
+ /** The least step. */
45
+ stpmin: number;
46
+ /** The largest step. */
47
+ stpmax: number;
48
+ /** The step to evaluate next; the initial step before {@link start}. */
49
+ stp: number;
50
+ /** `φ(stp)`, written by the caller; `φ(0)` before {@link start}. */
51
+ value: number;
52
+ /** `φ′(stp)`, written by the caller; `φ′(0)` before {@link start}. */
53
+ slope: number;
54
+ private brackt_;
55
+ private stage_;
56
+ private finit_;
57
+ private ginit_;
58
+ private gtest_;
59
+ private stx_;
60
+ private fx_;
61
+ private gx_;
62
+ private sty_;
63
+ private fy_;
64
+ private gy_;
65
+ private stmin_;
66
+ private stmax_;
67
+ private width_;
68
+ private width1_;
69
+ /** The least step found not finite; trial steps stay below it. */
70
+ private limit_;
71
+ constructor();
72
+ /** Starts a search from `value = φ(0)` and `slope = φ′(0) < 0` at `stp`. */
73
+ start(): void;
74
+ /**
75
+ * The caller found `φ` or `φ′` not finite at `stp`: halves the step back
76
+ * towards the best one so far, and keeps every later trial below it.
77
+ */
78
+ retreat(): void;
79
+ /**
80
+ * One step of `dcsrch` with `value` and `slope` evaluated at `stp`.
81
+ *
82
+ * @returns A `SEARCH_…` code; with {@link SEARCH_CONTINUE_}, the next trial
83
+ * step in `stp`.
84
+ */
85
+ iterate(): number;
86
+ /**
87
+ * `dcstep`: from the interval ends `(stx, fx, gx)`, `(sty, fy, gy)` and the
88
+ * trial `(stp, value, slope)`, a safeguarded new trial step into `stp`, the
89
+ * interval updated to keep a minimiser inside. Its step bounds are the
90
+ * stage's `stmin_` and `stmax_`, as `dcsrch` passes them, not the global
91
+ * ones.
92
+ */
93
+ private step_;
94
+ }
95
+ //# sourceMappingURL=_more-thuente.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_more-thuente.d.ts","sourceRoot":"","sources":["../../src/optimize/_more-thuente.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,mDAAmD;AACnD,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;;GAIG;AACH,eAAO,MAAM,eAAe,IAAI,CAAC;AAMjC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,YAAY;IACxB,8DAA8D;IACvD,IAAI,SAAQ;IACnB,kEAAkE;IAC3D,IAAI,SAAO;IAClB,+EAA+E;IACxE,IAAI,SAAO;IAClB,sBAAsB;IACf,MAAM,SAAO;IACpB,wBAAwB;IACjB,MAAM,SAAO;IACpB,wEAAwE;IACjE,GAAG,SAAO;IACjB,oEAAoE;IAC7D,KAAK,SAAO;IACnB,sEAAsE;IAC/D,KAAK,SAAO;IAEnB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,MAAM,CAAO;IACrB,OAAO,CAAC,MAAM,CAAO;IACrB,OAAO,CAAC,MAAM,CAAO;IACrB,OAAO,CAAC,IAAI,CAAO;IACnB,OAAO,CAAC,GAAG,CAAO;IAClB,OAAO,CAAC,GAAG,CAAO;IAClB,OAAO,CAAC,IAAI,CAAO;IACnB,OAAO,CAAC,GAAG,CAAO;IAClB,O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