@ac-kit/math-linear 0.2.1 → 0.4.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 +337 -0
  2. package/README.md +232 -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 +214 -0
  8. package/dist/_invert.d.ts.map +1 -0
  9. package/dist/_invert.js +884 -0
  10. package/dist/_invert.js.map +1 -0
  11. package/dist/_slerp.d.ts +29 -0
  12. package/dist/_slerp.d.ts.map +1 -1
  13. package/dist/_slerp.js +103 -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 +156 -0
  32. package/dist/affine2.d.ts.map +1 -0
  33. package/dist/affine2.js +437 -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 +205 -0
  44. package/dist/affine3.d.ts.map +1 -0
  45. package/dist/affine3.js +792 -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 +79 -25
  71. package/dist/mat2x2.d.ts.map +1 -1
  72. package/dist/mat2x2.js +192 -93
  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 +153 -48
  83. package/dist/mat3x3.d.ts.map +1 -1
  84. package/dist/mat3x3.js +470 -192
  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 +221 -67
  95. package/dist/mat4x4.d.ts.map +1 -1
  96. package/dist/mat4x4.js +972 -334
  97. package/dist/mat4x4.js.map +1 -1
  98. package/dist/projection.d.ts +113 -0
  99. package/dist/projection.d.ts.map +1 -0
  100. package/dist/projection.js +418 -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 +106 -22
  107. package/dist/quaternion.d.ts.map +1 -1
  108. package/dist/quaternion.js +253 -182
  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 +207 -0
  123. package/dist/vec2-array-componentwise.d.ts.map +1 -0
  124. package/dist/vec2-array-componentwise.js +472 -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 +207 -0
  139. package/dist/vec3-array-componentwise.d.ts.map +1 -0
  140. package/dist/vec3-array-componentwise.js +510 -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 +391 -272
  153. package/dist/vec3.js.map +1 -1
  154. package/dist/vec4-array-componentwise.d.ts +198 -0
  155. package/dist/vec4-array-componentwise.d.ts.map +1 -0
  156. package/dist/vec4-array-componentwise.js +521 -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 +59 -53
  167. package/dist/vec4.d.ts.map +1 -1
  168. package/dist/vec4.js +74 -249
  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 +19 -9
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,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACzB,KAAK,CAAC,MAAM,GAAG,C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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,207 @@
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
+ * Splits a tight binary64 buffer into two binary32 parts in one pass: for each
51
+ * number `x`, `high = fround(x)` at `out[highOffset + i·outStride …]` and `low
52
+ * = fround(x − high)` at `out[lowOffset + i·outStride …]`, offsets and stride
53
+ * counted in numbers, the other numbers of each stride untouched. `high + low`
54
+ * keeps about 48 bits of `x` (the two-float "split" positions of a vertex
55
+ * buffer, recombined relative to a reference on the GPU). `x − high` is exact
56
+ * in binary64; past the binary32 range `high` is infinite. `out` and `input`
57
+ * share no memory. O(n), no allocation.
58
+ *
59
+ * @returns `out`.
60
+ * @throws {RangeError} Unless `input.length` is a multiple of 2, the offsets
61
+ * and the stride are non-negative integers (the stride at least 2 from two
62
+ * elements on), the two parts of every element lie apart from each other and
63
+ * from the parts of the other elements, the last element fits in `out`, and
64
+ * `out` and `input` share no memory.
65
+ */
66
+ export declare function vec2ArraySplitStrided<T extends Float32Array>(out: T, highOffset: number, lowOffset: number, outStride: number, input: Float64Array): T;
67
+ /**
68
+ * Narrows `input − origin` to binary32 in one pass, the subtraction in
69
+ * binary64: large coordinates (a map in metres, a time axis in milliseconds)
70
+ * keep their precision relative to a nearby `origin`, where narrowing first
71
+ * loses it. `out` and `input` hold the same number of elements and share no
72
+ * memory (a `Float32Array` and a `Float64Array` over one buffer overlap in
73
+ * bytes, and the narrowing would read what it already wrote). O(n).
74
+ *
75
+ * @returns `out`.
76
+ * @throws {RangeError} Unless `out` and `input` have the same length, a
77
+ * multiple of 2, and share no memory.
78
+ */
79
+ export declare function vec2ArrayNarrowRelative<T extends Float32Array>(out: T, input: Float64Array, origin: ReadonlyVec2): T;
80
+ /**
81
+ * {@link vec2ArrayNarrowRelative} into an interleaved buffer: element `i` goes
82
+ * to `out[outOffset + i·outStride …]`, offset and stride counted in numbers.
83
+ * `out` and `input` share no memory. O(n).
84
+ *
85
+ * @returns `out`.
86
+ * @throws {RangeError} Unless `input.length` is a multiple of 2, `count`, the
87
+ * offset and the stride are non-negative integers (the stride at least 2 from
88
+ * two elements on), the last element fits in `out`, and `out` and `input`
89
+ * share no memory.
90
+ */
91
+ export declare function vec2ArrayNarrowRelativeStrided<T extends Float32Array>(out: T, outOffset: number, outStride: number, input: Float64Array, origin: ReadonlyVec2): T;
92
+ /**
93
+ * The mean Euclidean distance of the elements of `values` to `center`: the
94
+ * spread of a gesture's touch points, for one. Plain arithmetic, so right where
95
+ * the largest difference lies between about `1e−150` and `1e150`. No element
96
+ * gives `NaN`. O(n).
97
+ *
98
+ * @throws {RangeError} Unless `values.length` is a multiple of 2.
99
+ */
100
+ export declare function vec2ArrayMeanDistance(values: Float64Array, center: ReadonlyVec2): number;
101
+ /**
102
+ * Writes `a + b`, element by element, into `out`. One fused pass over tight
103
+ * buffers; the element count is `a.length / 2`. `out` may be `a` or `b`, but
104
+ * not a partially overlapping view of either. O(n).
105
+ *
106
+ * @returns `out`.
107
+ * @throws {RangeError} Unless `out`, `a` and `b` have the same length, a
108
+ * multiple of 2.
109
+ */
110
+ export declare function vec2ArrayAdd<T extends Float64Array>(out: T, a: Float64Array, b: Float64Array): T;
111
+ /**
112
+ * Writes `a − b`, element by element, into `out`. `out` may be `a` or `b`, but
113
+ * not a 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 vec2ArraySubtract<T extends Float64Array>(out: T, a: Float64Array, b: Float64Array): T;
120
+ /**
121
+ * Writes `a · scalar`, element by element, into `out`. `out` may be `a`, but
122
+ * 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 vec2ArrayMultiplyScalar<T extends Float64Array>(out: T, a: Float64Array, scalar: number): T;
128
+ /**
129
+ * Writes `a + b · scale`, element by element, into `out`: two roundings per
130
+ * component, not a fused multiply-add. `out` may be `a` or `b`, but not a
131
+ * partially overlapping view. O(n).
132
+ *
133
+ * @returns `out`.
134
+ * @throws {RangeError} Unless `out`, `a` and `b` have the same length, a
135
+ * multiple of 2.
136
+ */
137
+ export declare function vec2ArrayAddScaled<T extends Float64Array>(out: T, a: Float64Array, b: Float64Array, scale: number): T;
138
+ /**
139
+ * Writes `a + offset`, `offset` added to every element, into `out`. `out` may
140
+ * be `a`, but not a partially overlapping view. O(n).
141
+ *
142
+ * @returns `out`.
143
+ * @throws {RangeError} Unless `out` and `a` have the same length, a multiple of 2.
144
+ */
145
+ export declare function vec2ArrayTranslate<T extends Float64Array>(out: T, a: Float64Array, offset: ReadonlyVec2): T;
146
+ /**
147
+ * Writes `a + (b − a)·t`, element by element, into `out`, the expression of
148
+ * `@ac-kit/math-scalar`'s `lerp` written inline as {@link vec2Lerp} computes it
149
+ * (a kernel calls no per-component helper): a morph between two buffers, such
150
+ * as a chart transition. A `t` outside `[0, 1]` extrapolates. `out` may be `a`
151
+ * or `b`, but not a partially overlapping view. O(n).
152
+ *
153
+ * @returns `out`.
154
+ * @throws {RangeError} Unless `out`, `a` and `b` have the same length, a
155
+ * multiple of 2.
156
+ */
157
+ export declare function vec2ArrayLerp<T extends Float64Array>(out: T, a: Float64Array, b: Float64Array, t: number): T;
158
+ /**
159
+ * Writes every element of `a` scaled to unit length into `out`, as
160
+ * {@link vec2Normalize} does for one: a zero element stays zero, and a `NaN`
161
+ * component gives `NaN` throughout that element. Plain arithmetic, right where
162
+ * the largest component lies between about `1e−150` and `1e150`. `out` may be
163
+ * `a`, but not a partially overlapping view. O(n).
164
+ *
165
+ * @returns `out`.
166
+ * @throws {RangeError} Unless `out` and `a` have the same length, a multiple of 2.
167
+ */
168
+ export declare function vec2ArrayNormalize<T extends Float64Array>(out: T, a: Float64Array): T;
169
+ /**
170
+ * Writes the mean of the elements of `values` into `out`, in plain arithmetic.
171
+ * No element gives `NaN` in every component. O(n).
172
+ *
173
+ * @returns `out`.
174
+ * @throws {RangeError} Unless `values.length` is a multiple of 2.
175
+ */
176
+ export declare function vec2ArrayMean(out: Vec2, values: Float64Array): Vec2;
177
+ /**
178
+ * Writes `Σ wᵢ·vᵢ / Σ wᵢ` into `out`, one weight per element, in plain
179
+ * arithmetic. A zero total weight (no element included) gives `NaN` in every
180
+ * component. See {@link vec2ArrayWeightedMeanPrecise} for cancelling terms.
181
+ * O(n).
182
+ *
183
+ * @returns `out`.
184
+ * @throws {RangeError} Unless `values.length` is a multiple of 2 and
185
+ * `weights.length` is the number of elements.
186
+ */
187
+ export declare function vec2ArrayWeightedMean(out: Vec2, values: Float64Array, weights: Float64Array): Vec2;
188
+ /**
189
+ * {@link vec2ArrayWeightedMean} with the numerator and the total weight summed
190
+ * exactly: every product `wᵢ·vᵢ` and the rounding error it dropped (what
191
+ * `@ac-kit/math-scalar`'s `twoProductError` recovers) go into `@ac-kit/core`'s
192
+ * `PreciseSum`, which is exact however the terms cancel (`[1e16, 1, 1e100,
193
+ * −1e100, −1e16]` with unit weights sums to `1`) and settles intermediate
194
+ * overflow. The only roundings left are the final one of each sum and the
195
+ * division. Exact where each product `wᵢ·vᵢ` stays in the normal range, from
196
+ * about `1e−290` to `1e300`: a product that underflows to zero
197
+ * (`Number.MIN_VALUE` with weight `0.5`) or overflows to infinity
198
+ * (`Number.MAX_VALUE` with weight `2`) is lost or infinite before it is summed,
199
+ * as in the plain form. It allocates one `PreciseSum` per component and one for
200
+ * the weights per call, and costs several times the plain form. O(n).
201
+ *
202
+ * @returns `out`.
203
+ * @throws {RangeError} Unless `values.length` is a multiple of 2 and
204
+ * `weights.length` is the number of elements.
205
+ */
206
+ export declare function vec2ArrayWeightedMeanPrecise(out: Vec2, values: Float64Array, weights: Float64Array): Vec2;
207
+ //# 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,S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