@ac-kit/math-linear 0.2.0 → 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 (178) hide show
  1. package/CHANGELOG.md +268 -0
  2. package/README.md +229 -16
  3. package/dist/_brand.d.ts +14 -0
  4. package/dist/_brand.d.ts.map +1 -0
  5. package/dist/_brand.js +2 -0
  6. package/dist/_brand.js.map +1 -0
  7. package/dist/_invert.d.ts +19 -0
  8. package/dist/_invert.d.ts.map +1 -0
  9. package/dist/_invert.js +48 -0
  10. package/dist/_invert.js.map +1 -0
  11. package/dist/_slerp.d.ts +15 -0
  12. package/dist/_slerp.d.ts.map +1 -1
  13. package/dist/_slerp.js +47 -0
  14. package/dist/_slerp.js.map +1 -1
  15. package/dist/_strided-range.d.ts +23 -0
  16. package/dist/_strided-range.d.ts.map +1 -0
  17. package/dist/_strided-range.js +75 -0
  18. package/dist/_strided-range.js.map +1 -0
  19. package/dist/_trs.d.ts +38 -0
  20. package/dist/_trs.d.ts.map +1 -0
  21. package/dist/_trs.js +132 -0
  22. package/dist/_trs.js.map +1 -0
  23. package/dist/affine2-array.d.ts +53 -0
  24. package/dist/affine2-array.d.ts.map +1 -0
  25. package/dist/affine2-array.js +107 -0
  26. package/dist/affine2-array.js.map +1 -0
  27. package/dist/affine2-componentwise.d.ts +28 -0
  28. package/dist/affine2-componentwise.d.ts.map +1 -0
  29. package/dist/affine2-componentwise.js +66 -0
  30. package/dist/affine2-componentwise.js.map +1 -0
  31. package/dist/affine2.d.ts +144 -0
  32. package/dist/affine2.d.ts.map +1 -0
  33. package/dist/affine2.js +375 -0
  34. package/dist/affine2.js.map +1 -0
  35. package/dist/affine3-array.d.ts +53 -0
  36. package/dist/affine3-array.d.ts.map +1 -0
  37. package/dist/affine3-array.js +137 -0
  38. package/dist/affine3-array.js.map +1 -0
  39. package/dist/affine3-componentwise.d.ts +32 -0
  40. package/dist/affine3-componentwise.d.ts.map +1 -0
  41. package/dist/affine3-componentwise.js +100 -0
  42. package/dist/affine3-componentwise.js.map +1 -0
  43. package/dist/affine3.d.ts +192 -0
  44. package/dist/affine3.d.ts.map +1 -0
  45. package/dist/affine3.js +718 -0
  46. package/dist/affine3.js.map +1 -0
  47. package/dist/checked/index.d.ts +35 -0
  48. package/dist/checked/index.d.ts.map +1 -0
  49. package/dist/checked/index.js +58 -0
  50. package/dist/checked/index.js.map +1 -0
  51. package/dist/euler.d.ts +65 -0
  52. package/dist/euler.d.ts.map +1 -0
  53. package/dist/euler.js +217 -0
  54. package/dist/euler.js.map +1 -0
  55. package/dist/index.d.ts +29 -0
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +29 -0
  58. package/dist/index.js.map +1 -1
  59. package/dist/kl-activations.d.ts.map +1 -1
  60. package/dist/kl-activations.js +4 -3
  61. package/dist/kl-activations.js.map +1 -1
  62. package/dist/mat2x2-array.d.ts +36 -0
  63. package/dist/mat2x2-array.d.ts.map +1 -0
  64. package/dist/mat2x2-array.js +71 -0
  65. package/dist/mat2x2-array.js.map +1 -0
  66. package/dist/mat2x2-componentwise.d.ts +86 -0
  67. package/dist/mat2x2-componentwise.d.ts.map +1 -0
  68. package/dist/mat2x2-componentwise.js +199 -0
  69. package/dist/mat2x2-componentwise.js.map +1 -0
  70. package/dist/mat2x2.d.ts +67 -25
  71. package/dist/mat2x2.d.ts.map +1 -1
  72. package/dist/mat2x2.js +150 -94
  73. package/dist/mat2x2.js.map +1 -1
  74. package/dist/mat3x3-array.d.ts +36 -0
  75. package/dist/mat3x3-array.d.ts.map +1 -0
  76. package/dist/mat3x3-array.js +91 -0
  77. package/dist/mat3x3-array.js.map +1 -0
  78. package/dist/mat3x3-componentwise.d.ts +86 -0
  79. package/dist/mat3x3-componentwise.d.ts.map +1 -0
  80. package/dist/mat3x3-componentwise.js +299 -0
  81. package/dist/mat3x3-componentwise.js.map +1 -0
  82. package/dist/mat3x3.d.ts +131 -48
  83. package/dist/mat3x3.d.ts.map +1 -1
  84. package/dist/mat3x3.js +434 -193
  85. package/dist/mat3x3.js.map +1 -1
  86. package/dist/mat4x4-array.d.ts +46 -0
  87. package/dist/mat4x4-array.d.ts.map +1 -0
  88. package/dist/mat4x4-array.js +133 -0
  89. package/dist/mat4x4-array.js.map +1 -0
  90. package/dist/mat4x4-componentwise.d.ts +87 -0
  91. package/dist/mat4x4-componentwise.d.ts.map +1 -0
  92. package/dist/mat4x4-componentwise.js +434 -0
  93. package/dist/mat4x4-componentwise.js.map +1 -0
  94. package/dist/mat4x4.d.ts +195 -67
  95. package/dist/mat4x4.d.ts.map +1 -1
  96. package/dist/mat4x4.js +849 -335
  97. package/dist/mat4x4.js.map +1 -1
  98. package/dist/projection.d.ts +98 -0
  99. package/dist/projection.d.ts.map +1 -0
  100. package/dist/projection.js +369 -0
  101. package/dist/projection.js.map +1 -0
  102. package/dist/quaternion-array.d.ts +47 -0
  103. package/dist/quaternion-array.d.ts.map +1 -0
  104. package/dist/quaternion-array.js +86 -0
  105. package/dist/quaternion-array.js.map +1 -0
  106. package/dist/quaternion.d.ts +104 -22
  107. package/dist/quaternion.d.ts.map +1 -1
  108. package/dist/quaternion.js +294 -181
  109. package/dist/quaternion.js.map +1 -1
  110. package/dist/transform.d.ts +220 -0
  111. package/dist/transform.d.ts.map +1 -0
  112. package/dist/transform.js +412 -0
  113. package/dist/transform.js.map +1 -0
  114. package/dist/tridiagonal.d.ts +52 -0
  115. package/dist/tridiagonal.d.ts.map +1 -0
  116. package/dist/tridiagonal.js +90 -0
  117. package/dist/tridiagonal.js.map +1 -0
  118. package/dist/upload.d.ts +55 -0
  119. package/dist/upload.d.ts.map +1 -0
  120. package/dist/upload.js +129 -0
  121. package/dist/upload.js.map +1 -0
  122. package/dist/vec2-array-componentwise.d.ts +189 -0
  123. package/dist/vec2-array-componentwise.d.ts.map +1 -0
  124. package/dist/vec2-array-componentwise.js +424 -0
  125. package/dist/vec2-array-componentwise.js.map +1 -0
  126. package/dist/vec2-array.d.ts +53 -0
  127. package/dist/vec2-array.d.ts.map +1 -0
  128. package/dist/vec2-array.js +123 -0
  129. package/dist/vec2-array.js.map +1 -0
  130. package/dist/vec2-componentwise.d.ts +311 -0
  131. package/dist/vec2-componentwise.d.ts.map +1 -0
  132. package/dist/vec2-componentwise.js +542 -0
  133. package/dist/vec2-componentwise.js.map +1 -0
  134. package/dist/vec2.d.ts +97 -82
  135. package/dist/vec2.d.ts.map +1 -1
  136. package/dist/vec2.js +121 -216
  137. package/dist/vec2.js.map +1 -1
  138. package/dist/vec3-array-componentwise.d.ts +189 -0
  139. package/dist/vec3-array-componentwise.d.ts.map +1 -0
  140. package/dist/vec3-array-componentwise.js +458 -0
  141. package/dist/vec3-array-componentwise.js.map +1 -0
  142. package/dist/vec3-array.d.ts +102 -0
  143. package/dist/vec3-array.d.ts.map +1 -0
  144. package/dist/vec3-array.js +299 -0
  145. package/dist/vec3-array.js.map +1 -0
  146. package/dist/vec3-componentwise.d.ts +310 -0
  147. package/dist/vec3-componentwise.d.ts.map +1 -0
  148. package/dist/vec3-componentwise.js +594 -0
  149. package/dist/vec3-componentwise.js.map +1 -0
  150. package/dist/vec3.d.ts +177 -87
  151. package/dist/vec3.d.ts.map +1 -1
  152. package/dist/vec3.js +366 -273
  153. package/dist/vec3.js.map +1 -1
  154. package/dist/vec4-array-componentwise.d.ts +155 -0
  155. package/dist/vec4-array-componentwise.d.ts.map +1 -0
  156. package/dist/vec4-array-componentwise.js +401 -0
  157. package/dist/vec4-array-componentwise.js.map +1 -0
  158. package/dist/vec4-array.d.ts +12 -0
  159. package/dist/vec4-array.d.ts.map +1 -0
  160. package/dist/vec4-array.js +43 -0
  161. package/dist/vec4-array.js.map +1 -0
  162. package/dist/vec4-componentwise.d.ts +299 -0
  163. package/dist/vec4-componentwise.d.ts.map +1 -0
  164. package/dist/vec4-componentwise.js +637 -0
  165. package/dist/vec4-componentwise.js.map +1 -0
  166. package/dist/vec4.d.ts +57 -53
  167. package/dist/vec4.d.ts.map +1 -1
  168. package/dist/vec4.js +94 -246
  169. package/dist/vec4.js.map +1 -1
  170. package/dist/view-basis.d.ts +15 -0
  171. package/dist/view-basis.d.ts.map +1 -0
  172. package/dist/view-basis.js +29 -0
  173. package/dist/view-basis.js.map +1 -0
  174. package/dist/viewport.d.ts +114 -0
  175. package/dist/viewport.d.ts.map +1 -0
  176. package/dist/viewport.js +250 -0
  177. package/dist/viewport.js.map +1 -0
  178. package/package.json +18 -9
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Solves the tridiagonal system `A · x = right` by the Thomas algorithm
3
+ * (Gaussian elimination without pivoting, restricted to the three diagonals; L.
4
+ * H. Thomas, 1949; Golub & Van Loan, _Matrix Computations_, 4th ed., §4.3.6).
5
+ * Row `i` of `A` is
6
+ *
7
+ * ```text
8
+ * lower[i − 1] · x[i − 1] + diagonal[i] · x[i] + upper[i] · x[i + 1] = right[i]
9
+ * ```
10
+ *
11
+ * With the out-of-range terms absent, so `lower` and `upper` hold `n − 1`
12
+ * numbers each (LAPACK's `dl`, `d`, `du` layout).
13
+ *
14
+ * Stability: elimination without pivoting is backward stable, and meets no zero
15
+ * pivot, when `A` is diagonally dominant by rows (`|diagonal[i]| ≥ |lower[i −
16
+ * 1]| + |upper[i]|`, strictly in at least one row of every irreducible block)
17
+ * or by columns, or symmetric positive definite (Higham, _Accuracy and
18
+ * Stability of Numerical Algorithms_, 2nd ed., §9.6). Spline and
19
+ * finite-difference systems are of that kind. Other non-singular matrices can
20
+ * meet a zero pivot, which returns `false`, or a tiny one that loses accuracy:
21
+ * solve them with a pivoting LU.
22
+ *
23
+ * Checks, in this order: the lengths (a `RangeError`), then each pivot as the
24
+ * elimination reaches it, which is the only test on the values: the first zero
25
+ * pivot returns `false` with `out` all `NaN`, whatever the other entries hold
26
+ * (a `NaN` anywhere included). Non-finite entries are not checked otherwise:
27
+ * with no zero pivot met they propagate into `out` and the call returns `true`
28
+ * (S13; checking finiteness belongs at the caller's boundary, S13a). Plain
29
+ * arithmetic, so the range is that of the rest of the package: entries and
30
+ * intermediate products within about [1e−150, 1e150]; beyond (a 1e308
31
+ * diagonal), the elimination can overflow to `Infinity` and still return
32
+ * `true`.
33
+ *
34
+ * Complexity: O(n) time, no allocation.
35
+ *
36
+ * @param out - The solution `x`, `n` numbers. May be `right` itself.
37
+ * @param lower - The sub-diagonal, `n − 1` numbers: `lower[i]` is `A[i +
38
+ * 1][i]`.
39
+ * @param diagonal - The diagonal, `n` numbers.
40
+ * @param upper - The super-diagonal, `n − 1` numbers: `upper[i]` is `A[i][i +
41
+ * 1]`.
42
+ * @param right - The right-hand side, `n` numbers.
43
+ * @param scratch - Working space of `n − 1` numbers, overwritten. May be
44
+ * `upper` itself, which is then overwritten.
45
+ * @returns `false` when the elimination meets a zero pivot, `out` then all
46
+ * `NaN`; `true` otherwise, non-finite values propagating into `out`.
47
+ * @throws {RangeError} When `out`, `right` and `diagonal` do not have the same
48
+ * length `n`, or `lower`, `upper` and `scratch` do not have `max(n − 1, 0)`
49
+ * numbers.
50
+ */
51
+ export declare function tridiagonalSolve(out: Float64Array, lower: Float64Array, diagonal: Float64Array, upper: Float64Array, right: Float64Array, scratch: Float64Array): boolean;
52
+ //# sourceMappingURL=tridiagonal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tridiagonal.d.ts","sourceRoot":"","sources":["../src/tridiagonal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAgB,gBAAgB,CAC/B,GAAG,EAAE,YAAY,EACjB,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,YAAY,EACtB,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,YAAY,EACnB,OAAO,EAAE,YAAY,GACnB,OAAO,CAuDT"}
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Solves the tridiagonal system `A · x = right` by the Thomas algorithm
3
+ * (Gaussian elimination without pivoting, restricted to the three diagonals; L.
4
+ * H. Thomas, 1949; Golub & Van Loan, _Matrix Computations_, 4th ed., §4.3.6).
5
+ * Row `i` of `A` is
6
+ *
7
+ * ```text
8
+ * lower[i − 1] · x[i − 1] + diagonal[i] · x[i] + upper[i] · x[i + 1] = right[i]
9
+ * ```
10
+ *
11
+ * With the out-of-range terms absent, so `lower` and `upper` hold `n − 1`
12
+ * numbers each (LAPACK's `dl`, `d`, `du` layout).
13
+ *
14
+ * Stability: elimination without pivoting is backward stable, and meets no zero
15
+ * pivot, when `A` is diagonally dominant by rows (`|diagonal[i]| ≥ |lower[i −
16
+ * 1]| + |upper[i]|`, strictly in at least one row of every irreducible block)
17
+ * or by columns, or symmetric positive definite (Higham, _Accuracy and
18
+ * Stability of Numerical Algorithms_, 2nd ed., §9.6). Spline and
19
+ * finite-difference systems are of that kind. Other non-singular matrices can
20
+ * meet a zero pivot, which returns `false`, or a tiny one that loses accuracy:
21
+ * solve them with a pivoting LU.
22
+ *
23
+ * Checks, in this order: the lengths (a `RangeError`), then each pivot as the
24
+ * elimination reaches it, which is the only test on the values: the first zero
25
+ * pivot returns `false` with `out` all `NaN`, whatever the other entries hold
26
+ * (a `NaN` anywhere included). Non-finite entries are not checked otherwise:
27
+ * with no zero pivot met they propagate into `out` and the call returns `true`
28
+ * (S13; checking finiteness belongs at the caller's boundary, S13a). Plain
29
+ * arithmetic, so the range is that of the rest of the package: entries and
30
+ * intermediate products within about [1e−150, 1e150]; beyond (a 1e308
31
+ * diagonal), the elimination can overflow to `Infinity` and still return
32
+ * `true`.
33
+ *
34
+ * Complexity: O(n) time, no allocation.
35
+ *
36
+ * @param out - The solution `x`, `n` numbers. May be `right` itself.
37
+ * @param lower - The sub-diagonal, `n − 1` numbers: `lower[i]` is `A[i +
38
+ * 1][i]`.
39
+ * @param diagonal - The diagonal, `n` numbers.
40
+ * @param upper - The super-diagonal, `n − 1` numbers: `upper[i]` is `A[i][i +
41
+ * 1]`.
42
+ * @param right - The right-hand side, `n` numbers.
43
+ * @param scratch - Working space of `n − 1` numbers, overwritten. May be
44
+ * `upper` itself, which is then overwritten.
45
+ * @returns `false` when the elimination meets a zero pivot, `out` then all
46
+ * `NaN`; `true` otherwise, non-finite values propagating into `out`.
47
+ * @throws {RangeError} When `out`, `right` and `diagonal` do not have the same
48
+ * length `n`, or `lower`, `upper` and `scratch` do not have `max(n − 1, 0)`
49
+ * numbers.
50
+ */
51
+ export function tridiagonalSolve(out, lower, diagonal, upper, right, scratch) {
52
+ const size = diagonal.length;
53
+ const offSize = size === 0 ? 0 : size - 1;
54
+ if (out.length !== size ||
55
+ right.length !== size ||
56
+ lower.length !== offSize ||
57
+ upper.length !== offSize ||
58
+ scratch.length !== offSize) {
59
+ throw new RangeError(`tridiagonalSolve: out, right and diagonal need one length n and lower, upper and scratch n − 1, got out ${out.length}, lower ${lower.length}, diagonal ${size}, upper ${upper.length}, right ${right.length}, scratch ${scratch.length}`);
60
+ }
61
+ if (size === 0) {
62
+ return true;
63
+ }
64
+ let pivot = diagonal[0];
65
+ if (pivot === 0) {
66
+ out.fill(Number.NaN);
67
+ return false;
68
+ }
69
+ if (size > 1) {
70
+ scratch[0] = upper[0] / pivot;
71
+ }
72
+ out[0] = right[0] / pivot;
73
+ for (let index = 1; index < size; index++) {
74
+ const factor = lower[index - 1];
75
+ pivot = diagonal[index] - factor * scratch[index - 1];
76
+ if (pivot === 0) {
77
+ out.fill(Number.NaN);
78
+ return false;
79
+ }
80
+ if (index < offSize) {
81
+ scratch[index] = upper[index] / pivot;
82
+ }
83
+ out[index] = (right[index] - factor * out[index - 1]) / pivot;
84
+ }
85
+ for (let index = size - 2; index >= 0; index--) {
86
+ out[index] = out[index] - scratch[index] * out[index + 1];
87
+ }
88
+ return true;
89
+ }
90
+ //# sourceMappingURL=tridiagonal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tridiagonal.js","sourceRoot":"","sources":["../src/tridiagonal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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E,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC;QAEjC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAE,GAAG,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC;QAExD,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;YACjB,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACrB,OAAO,KAAK,CAAC;QACd,CAAC;QAED,IAAI,KAAK,GAAG,OAAO,EAAE,CAAC;YACrB,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAE,GAAG,KAAK,CAAC;QACxC,CAAC;QAED,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAE,GAAG,MAAM,GAAG,GAAG,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC,GAAG,KAAK,CAAC;IACjE,CAAC;IAED,KAAK,IAAI,KAAK,GAAG,IAAI,GAAG,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC;QAChD,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,KAAK,CAAE,GAAG,OAAO,CAAC,KAAK,CAAE,GAAG,GAAG,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC;IAC9D,CAAC;IAED,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -0,0 +1,55 @@
1
+ import type { ReadonlyQuaternion } from "@ac-kit/math-complex";
2
+ import type { ReadonlyAffine2 } from "./affine2.js";
3
+ import type { ReadonlyAffine3 } from "./affine3.js";
4
+ import type { ReadonlyMat2x2 } from "./mat2x2.js";
5
+ import type { ReadonlyMat3x3 } from "./mat3x3.js";
6
+ import type { ReadonlyMat4x4 } from "./mat4x4.js";
7
+ /**
8
+ * Writes the four entries of `m`, in storage (column) order, narrowed to 32
9
+ * bits, into `array` from `offset`: unrolled stores, which cost a few
10
+ * nanoseconds where `Float32Array.prototype.set` on an array costs fifteen. An
11
+ * entry past the end of `array` is dropped, as for any typed array store. Not a
12
+ * uniform layout: see {@link mat3x3StoreStd140Float32} for the types a uniform
13
+ * block pads.
14
+ */
15
+ export declare function mat2x2StoreFloat32(array: Float32Array, offset: number, m: ReadonlyMat2x2): void;
16
+ /**
17
+ * Writes the nine entries of `m`, in storage (column) order, narrowed to 32
18
+ * bits, into `array` from `offset`, tight. A uniform block pads each column to
19
+ * four floats instead: use {@link mat3x3StoreStd140Float32} for one.
20
+ */
21
+ export declare function mat3x3StoreFloat32(array: Float32Array, offset: number, m: ReadonlyMat3x3): void;
22
+ /**
23
+ * Writes the sixteen entries of `m`, in storage (column) order, narrowed to 32
24
+ * bits, into `array` from `offset`. The columns are four floats apart, so this
25
+ * is also the layout of a `mat4x4f` in a uniform block.
26
+ */
27
+ export declare function mat4x4StoreFloat32(array: Float32Array, offset: number, m: ReadonlyMat4x4): void;
28
+ /**
29
+ * Writes the four components `x, y, z, w` of `q`, narrowed to 32 bits, into
30
+ * `array` from `offset`: an instance rotation or a `vec4f` uniform.
31
+ */
32
+ export declare function quaternionStoreFloat32(array: Float32Array, offset: number, q: ReadonlyQuaternion): void;
33
+ /**
34
+ * Writes `m` as a `mat3x3f` of a uniform block, narrowed to 32 bits: three
35
+ * columns of three floats, each followed by a padding `0`, twelve floats from
36
+ * `offset` (std140, and WGSL's uniform layout, which `@ac-kit/graphics-gpu`
37
+ * makes identical). Every float of the field is written, the padding too.
38
+ */
39
+ export declare function mat3x3StoreStd140Float32(array: Float32Array, offset: number, m: ReadonlyMat3x3): void;
40
+ /**
41
+ * Writes `transform` as a `mat4x3f` of a uniform block, narrowed to 32 bits:
42
+ * four columns of three floats (the axes, then the translation), each followed
43
+ * by a padding `0`, sixteen floats from `offset`. Every float of the field is
44
+ * written, the padding too.
45
+ */
46
+ export declare function affine3StoreStd140Float32(array: Float32Array, offset: number, transform: ReadonlyAffine3): void;
47
+ /**
48
+ * Writes the 2D affine `transform` as a `mat3x3f` of a uniform block holding
49
+ * the homogeneous matrix, narrowed to 32 bits: the columns `(a, b, 0)`, `(c, d,
50
+ * 0)` and `(e, f, 1)`, each followed by a padding `0`, twelve floats from
51
+ * `offset`: what `@ac-kit/graphics-gpu` does with a 2-row source. Every float
52
+ * of the field is written, the padding too.
53
+ */
54
+ export declare function affine2StoreStd140Float32(array: Float32Array, offset: number, transform: ReadonlyAffine2): void;
55
+ //# sourceMappingURL=upload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,CAAC,EAAE,cAAc,GACf,IAAI,CAKN;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,CAAC,EAAE,cAAc,GACf,IAAI,CAUN;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,CAAC,EAAE,cAAc,GACf,IAAI,CAiBN;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACrC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,CAAC,EAAE,kBAAkB,GACnB,IAAI,CAKN;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACvC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,CAAC,EAAE,cAAc,GACf,IAAI,CAaN;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,eAAe,GACxB,IAAI,CAiBN;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,eAAe,GACxB,IAAI,CAaN"}
package/dist/upload.js ADDED
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Writes the four entries of `m`, in storage (column) order, narrowed to 32
3
+ * bits, into `array` from `offset`: unrolled stores, which cost a few
4
+ * nanoseconds where `Float32Array.prototype.set` on an array costs fifteen. An
5
+ * entry past the end of `array` is dropped, as for any typed array store. Not a
6
+ * uniform layout: see {@link mat3x3StoreStd140Float32} for the types a uniform
7
+ * block pads.
8
+ */
9
+ export function mat2x2StoreFloat32(array, offset, m) {
10
+ array[offset] = m[0];
11
+ array[offset + 1] = m[1];
12
+ array[offset + 2] = m[2];
13
+ array[offset + 3] = m[3];
14
+ }
15
+ /**
16
+ * Writes the nine entries of `m`, in storage (column) order, narrowed to 32
17
+ * bits, into `array` from `offset`, tight. A uniform block pads each column to
18
+ * four floats instead: use {@link mat3x3StoreStd140Float32} for one.
19
+ */
20
+ export function mat3x3StoreFloat32(array, offset, m) {
21
+ array[offset] = m[0];
22
+ array[offset + 1] = m[1];
23
+ array[offset + 2] = m[2];
24
+ array[offset + 3] = m[3];
25
+ array[offset + 4] = m[4];
26
+ array[offset + 5] = m[5];
27
+ array[offset + 6] = m[6];
28
+ array[offset + 7] = m[7];
29
+ array[offset + 8] = m[8];
30
+ }
31
+ /**
32
+ * Writes the sixteen entries of `m`, in storage (column) order, narrowed to 32
33
+ * bits, into `array` from `offset`. The columns are four floats apart, so this
34
+ * is also the layout of a `mat4x4f` in a uniform block.
35
+ */
36
+ export function mat4x4StoreFloat32(array, offset, m) {
37
+ array[offset] = m[0];
38
+ array[offset + 1] = m[1];
39
+ array[offset + 2] = m[2];
40
+ array[offset + 3] = m[3];
41
+ array[offset + 4] = m[4];
42
+ array[offset + 5] = m[5];
43
+ array[offset + 6] = m[6];
44
+ array[offset + 7] = m[7];
45
+ array[offset + 8] = m[8];
46
+ array[offset + 9] = m[9];
47
+ array[offset + 10] = m[10];
48
+ array[offset + 11] = m[11];
49
+ array[offset + 12] = m[12];
50
+ array[offset + 13] = m[13];
51
+ array[offset + 14] = m[14];
52
+ array[offset + 15] = m[15];
53
+ }
54
+ /**
55
+ * Writes the four components `x, y, z, w` of `q`, narrowed to 32 bits, into
56
+ * `array` from `offset`: an instance rotation or a `vec4f` uniform.
57
+ */
58
+ export function quaternionStoreFloat32(array, offset, q) {
59
+ array[offset] = q[0];
60
+ array[offset + 1] = q[1];
61
+ array[offset + 2] = q[2];
62
+ array[offset + 3] = q[3];
63
+ }
64
+ /**
65
+ * Writes `m` as a `mat3x3f` of a uniform block, narrowed to 32 bits: three
66
+ * columns of three floats, each followed by a padding `0`, twelve floats from
67
+ * `offset` (std140, and WGSL's uniform layout, which `@ac-kit/graphics-gpu`
68
+ * makes identical). Every float of the field is written, the padding too.
69
+ */
70
+ export function mat3x3StoreStd140Float32(array, offset, m) {
71
+ array[offset] = m[0];
72
+ array[offset + 1] = m[1];
73
+ array[offset + 2] = m[2];
74
+ array[offset + 3] = 0;
75
+ array[offset + 4] = m[3];
76
+ array[offset + 5] = m[4];
77
+ array[offset + 6] = m[5];
78
+ array[offset + 7] = 0;
79
+ array[offset + 8] = m[6];
80
+ array[offset + 9] = m[7];
81
+ array[offset + 10] = m[8];
82
+ array[offset + 11] = 0;
83
+ }
84
+ /**
85
+ * Writes `transform` as a `mat4x3f` of a uniform block, narrowed to 32 bits:
86
+ * four columns of three floats (the axes, then the translation), each followed
87
+ * by a padding `0`, sixteen floats from `offset`. Every float of the field is
88
+ * written, the padding too.
89
+ */
90
+ export function affine3StoreStd140Float32(array, offset, transform) {
91
+ array[offset] = transform[0];
92
+ array[offset + 1] = transform[1];
93
+ array[offset + 2] = transform[2];
94
+ array[offset + 3] = 0;
95
+ array[offset + 4] = transform[3];
96
+ array[offset + 5] = transform[4];
97
+ array[offset + 6] = transform[5];
98
+ array[offset + 7] = 0;
99
+ array[offset + 8] = transform[6];
100
+ array[offset + 9] = transform[7];
101
+ array[offset + 10] = transform[8];
102
+ array[offset + 11] = 0;
103
+ array[offset + 12] = transform[9];
104
+ array[offset + 13] = transform[10];
105
+ array[offset + 14] = transform[11];
106
+ array[offset + 15] = 0;
107
+ }
108
+ /**
109
+ * Writes the 2D affine `transform` as a `mat3x3f` of a uniform block holding
110
+ * the homogeneous matrix, narrowed to 32 bits: the columns `(a, b, 0)`, `(c, d,
111
+ * 0)` and `(e, f, 1)`, each followed by a padding `0`, twelve floats from
112
+ * `offset`: what `@ac-kit/graphics-gpu` does with a 2-row source. Every float
113
+ * of the field is written, the padding too.
114
+ */
115
+ export function affine2StoreStd140Float32(array, offset, transform) {
116
+ array[offset] = transform[0];
117
+ array[offset + 1] = transform[1];
118
+ array[offset + 2] = 0;
119
+ array[offset + 3] = 0;
120
+ array[offset + 4] = transform[2];
121
+ array[offset + 5] = transform[3];
122
+ array[offset + 6] = 0;
123
+ array[offset + 7] = 0;
124
+ array[offset + 8] = transform[4];
125
+ array[offset + 9] = transform[5];
126
+ array[offset + 10] = 1;
127
+ array[offset + 11] = 0;
128
+ }
129
+ //# sourceMappingURL=upload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.js","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":"AAQA;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CACjC,KAAmB,EACnB,MAAc,EACd,CAAiB;IAEjB,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACrB,KAA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G,EAAE,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACxC,KAAmB,EACnB,MAAc,EACd,SAA0B;IAE1B,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IAC7B,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IACjC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACtB,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACtB,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IACjC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IACjC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACtB,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;IACtB,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IACjC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;IACjC,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;IACvB,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC"}
@@ -0,0 +1,189 @@
1
+ import type { ReadonlyVec2, Vec2 } from "./vec2.js";
2
+ /**
3
+ * Creates a buffer for `count` vec2 elements: a zero-filled `Float64Array` of
4
+ * `count × 2` numbers, element `i` at `[i·2, i·2 + 2)`. Allocates.
5
+ *
6
+ * @throws {RangeError} When `count` is not a non-negative safe integer or
7
+ * `count × 2` is not a valid typed array length.
8
+ */
9
+ export declare function vec2ArrayCreate(count: number): Float64Array<ArrayBuffer>;
10
+ /**
11
+ * Creates a buffer holding `values`, element `i` being `values[i]`. O(n),
12
+ * allocates.
13
+ */
14
+ export declare function vec2ArrayFromValues(values: readonly ReadonlyVec2[]): Float64Array<ArrayBuffer>;
15
+ /**
16
+ * Reads every element of `array` into a Vec2 made by {@link vec2Of}, so each one
17
+ * is a clean array of doubles (never `Array.from` or a spread, which would not
18
+ * start from the creator's template). A tail shorter than one element is
19
+ * ignored. O(n), allocates one value per element.
20
+ */
21
+ export declare function vec2ArrayToValues(array: Float64Array): Vec2[];
22
+ /**
23
+ * Narrows a tight binary64 buffer into an interleaved binary32 one: element `i`
24
+ * of `input` goes to `out[outOffset + i·outStride …]`, offset and stride
25
+ * counted in numbers, the other numbers of each stride untouched (a vertex
26
+ * buffer's normals, colours, …). For the whole array with no stride use
27
+ * `Float32Array.prototype.set`. `out` and `input` share no memory. O(n).
28
+ *
29
+ * @returns `out`.
30
+ * @throws {RangeError} Unless `input.length` is a multiple of 2, `count`, the
31
+ * offset and the stride are non-negative integers (the stride at least 2 from
32
+ * two elements on), the last element fits in `out`, and `out` and `input`
33
+ * share no memory.
34
+ */
35
+ export declare function vec2ArrayNarrowStrided<T extends Float32Array>(out: T, outOffset: number, outStride: number, input: Float64Array): T;
36
+ /**
37
+ * Widens an interleaved binary32 buffer (a glTF accessor, a readback) into a
38
+ * tight binary64 one: element `i` of `out` is read from `input[inputOffset +
39
+ * i·inputStride …]`, offset and stride counted in numbers. The element count is
40
+ * `out.length / 2`. `out` and `input` share no memory. O(n).
41
+ *
42
+ * @returns `out`.
43
+ * @throws {RangeError} Unless `out.length` is a multiple of 2, the offset and
44
+ * the stride are non-negative integers (the stride at least 2 from two
45
+ * elements on), the last element lies inside `input`, and `out` and `input`
46
+ * share no memory.
47
+ */
48
+ export declare function vec2ArrayWidenStrided<T extends Float64Array>(out: T, input: Float32Array, inputOffset: number, inputStride: number): T;
49
+ /**
50
+ * Narrows `input − origin` to binary32 in one pass, the subtraction in
51
+ * binary64: large coordinates (a map in metres, a time axis in milliseconds)
52
+ * keep their precision relative to a nearby `origin`, where narrowing first
53
+ * loses it. `out` and `input` hold the same number of elements and share no
54
+ * memory (a `Float32Array` and a `Float64Array` over one buffer overlap in
55
+ * bytes, and the narrowing would read what it already wrote). O(n).
56
+ *
57
+ * @returns `out`.
58
+ * @throws {RangeError} Unless `out` and `input` have the same length, a
59
+ * multiple of 2, and share no memory.
60
+ */
61
+ export declare function vec2ArrayNarrowRelative<T extends Float32Array>(out: T, input: Float64Array, origin: ReadonlyVec2): T;
62
+ /**
63
+ * {@link vec2ArrayNarrowRelative} into an interleaved buffer: element `i` goes
64
+ * to `out[outOffset + i·outStride …]`, offset and stride counted in numbers.
65
+ * `out` and `input` share no memory. O(n).
66
+ *
67
+ * @returns `out`.
68
+ * @throws {RangeError} Unless `input.length` is a multiple of 2, `count`, the
69
+ * offset and the stride are non-negative integers (the stride at least 2 from
70
+ * two elements on), the last element fits in `out`, and `out` and `input`
71
+ * share no memory.
72
+ */
73
+ export declare function vec2ArrayNarrowRelativeStrided<T extends Float32Array>(out: T, outOffset: number, outStride: number, input: Float64Array, origin: ReadonlyVec2): T;
74
+ /**
75
+ * The mean Euclidean distance of the elements of `values` to `center`: the
76
+ * spread of a gesture's touch points, for one. Plain arithmetic, so right where
77
+ * the largest difference lies between about `1e−150` and `1e150`. No element
78
+ * gives `NaN`. O(n).
79
+ *
80
+ * @throws {RangeError} Unless `values.length` is a multiple of 2.
81
+ */
82
+ export declare function vec2ArrayMeanDistance(values: Float64Array, center: ReadonlyVec2): number;
83
+ /**
84
+ * Writes `a + b`, element by element, into `out`. One fused pass over tight
85
+ * buffers; the element count is `a.length / 2`. `out` may be `a` or `b`, but
86
+ * not a partially overlapping view of either. O(n).
87
+ *
88
+ * @returns `out`.
89
+ * @throws {RangeError} Unless `out`, `a` and `b` have the same length, a
90
+ * multiple of 2.
91
+ */
92
+ export declare function vec2ArrayAdd<T extends Float64Array>(out: T, a: Float64Array, b: Float64Array): T;
93
+ /**
94
+ * Writes `a − b`, element by element, into `out`. `out` may be `a` or `b`, but
95
+ * not a partially overlapping view. O(n).
96
+ *
97
+ * @returns `out`.
98
+ * @throws {RangeError} Unless `out`, `a` and `b` have the same length, a
99
+ * multiple of 2.
100
+ */
101
+ export declare function vec2ArraySubtract<T extends Float64Array>(out: T, a: Float64Array, b: Float64Array): T;
102
+ /**
103
+ * Writes `a · scalar`, element by element, into `out`. `out` may be `a`, but
104
+ * not a partially overlapping view. O(n).
105
+ *
106
+ * @returns `out`.
107
+ * @throws {RangeError} Unless `out` and `a` have the same length, a multiple of 2.
108
+ */
109
+ export declare function vec2ArrayMultiplyScalar<T extends Float64Array>(out: T, a: Float64Array, scalar: number): T;
110
+ /**
111
+ * Writes `a + b · scale`, element by element, into `out`: two roundings per
112
+ * component, not a fused multiply-add. `out` may be `a` or `b`, but not a
113
+ * partially overlapping view. O(n).
114
+ *
115
+ * @returns `out`.
116
+ * @throws {RangeError} Unless `out`, `a` and `b` have the same length, a
117
+ * multiple of 2.
118
+ */
119
+ export declare function vec2ArrayAddScaled<T extends Float64Array>(out: T, a: Float64Array, b: Float64Array, scale: number): T;
120
+ /**
121
+ * Writes `a + offset`, `offset` added to every element, into `out`. `out` may
122
+ * be `a`, but not a partially overlapping view. O(n).
123
+ *
124
+ * @returns `out`.
125
+ * @throws {RangeError} Unless `out` and `a` have the same length, a multiple of 2.
126
+ */
127
+ export declare function vec2ArrayTranslate<T extends Float64Array>(out: T, a: Float64Array, offset: ReadonlyVec2): T;
128
+ /**
129
+ * Writes `a + (b − a)·t`, element by element, into `out`, the expression of
130
+ * `@ac-kit/math-scalar`'s `lerp` written inline as {@link vec2Lerp} computes it
131
+ * (a kernel calls no per-component helper): a morph between two buffers, such
132
+ * as a chart transition. A `t` outside `[0, 1]` extrapolates. `out` may be `a`
133
+ * or `b`, but not a partially overlapping view. O(n).
134
+ *
135
+ * @returns `out`.
136
+ * @throws {RangeError} Unless `out`, `a` and `b` have the same length, a
137
+ * multiple of 2.
138
+ */
139
+ export declare function vec2ArrayLerp<T extends Float64Array>(out: T, a: Float64Array, b: Float64Array, t: number): T;
140
+ /**
141
+ * Writes every element of `a` scaled to unit length into `out`, as
142
+ * {@link vec2Normalize} does for one: a zero element stays zero, and a `NaN`
143
+ * component gives `NaN` throughout that element. Plain arithmetic, right where
144
+ * the largest component lies between about `1e−150` and `1e150`. `out` may be
145
+ * `a`, but not a partially overlapping view. O(n).
146
+ *
147
+ * @returns `out`.
148
+ * @throws {RangeError} Unless `out` and `a` have the same length, a multiple of 2.
149
+ */
150
+ export declare function vec2ArrayNormalize<T extends Float64Array>(out: T, a: Float64Array): T;
151
+ /**
152
+ * Writes the mean of the elements of `values` into `out`, in plain arithmetic.
153
+ * No element gives `NaN` in every component. O(n).
154
+ *
155
+ * @returns `out`.
156
+ * @throws {RangeError} Unless `values.length` is a multiple of 2.
157
+ */
158
+ export declare function vec2ArrayMean(out: Vec2, values: Float64Array): Vec2;
159
+ /**
160
+ * Writes `Σ wᵢ·vᵢ / Σ wᵢ` into `out`, one weight per element, in plain
161
+ * arithmetic. A zero total weight (no element included) gives `NaN` in every
162
+ * component. See {@link vec2ArrayWeightedMeanPrecise} for cancelling terms.
163
+ * O(n).
164
+ *
165
+ * @returns `out`.
166
+ * @throws {RangeError} Unless `values.length` is a multiple of 2 and
167
+ * `weights.length` is the number of elements.
168
+ */
169
+ export declare function vec2ArrayWeightedMean(out: Vec2, values: Float64Array, weights: Float64Array): Vec2;
170
+ /**
171
+ * {@link vec2ArrayWeightedMean} with the numerator and the total weight summed
172
+ * exactly: every product `wᵢ·vᵢ` and the rounding error it dropped (what
173
+ * `@ac-kit/math-scalar`'s `twoProductError` recovers) go into `@ac-kit/core`'s
174
+ * `PreciseSum`, which is exact however the terms cancel (`[1e16, 1, 1e100,
175
+ * −1e100, −1e16]` with unit weights sums to `1`) and settles intermediate
176
+ * overflow. The only roundings left are the final one of each sum and the
177
+ * division. Exact where each product `wᵢ·vᵢ` stays in the normal range, from
178
+ * about `1e−290` to `1e300`: a product that underflows to zero
179
+ * (`Number.MIN_VALUE` with weight `0.5`) or overflows to infinity
180
+ * (`Number.MAX_VALUE` with weight `2`) is lost or infinite before it is summed,
181
+ * as in the plain form. It allocates one `PreciseSum` per component and one for
182
+ * the weights per call, and costs several times the plain form. O(n).
183
+ *
184
+ * @returns `out`.
185
+ * @throws {RangeError} Unless `values.length` is a multiple of 2 and
186
+ * `weights.length` is the number of elements.
187
+ */
188
+ export declare function vec2ArrayWeightedMeanPrecise(out: Vec2, values: Float64Array, weights: Float64Array): Vec2;
189
+ //# sourceMappingURL=vec2-array-componentwise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vec2-array-componentwise.d.ts","sourceRoot":"","sources":["../src/vec2-array-componentwise.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEpD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,WAAW,CAAC,CAGxE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,SAAS,YAAY,EAAE,GAC7B,YAAY,CAAC,WAAW,CAAC,CAS3B;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,EAAE,CAM7D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,YAAY,EAC5D,GAAG,EAAE,CAAC,EACN,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,YAAY,GACjB,CAAC,CA8BH;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,YAAY,EAC3D,GAAG,EAAE,CAAC,EACN,KAAK,EAAE,YAAY,EACnB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GACjB,C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