@ac-kit/math-linear 0.2.1 → 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 +257 -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,36 @@
1
+ import type { ReadonlyMat2x2, Mat2x2 } from "./mat2x2.js";
2
+ /**
3
+ * Writes element `index` of `array`, the numbers at `[index·4, index·4 + 4)`,
4
+ * into `out`. Each component is written as `+array[i]`, so an index past the
5
+ * end of `array` gives `NaN`, never `undefined`: the matrix stays clean
6
+ * whatever the caller does. Checking the index is the job of the checked
7
+ * layer.
8
+ *
9
+ * The matrix is copied: it is never a view of `array`. O(1).
10
+ */
11
+ export declare function mat2x2Load(out: Mat2x2, array: Float64Array, index: number): Mat2x2;
12
+ /**
13
+ * Writes `value` into `array` as element `index`, at `[index·4, index·4 + 4)`.
14
+ * An element past the end of `array` writes nothing, as a typed array drops an
15
+ * out-of-range write. O(1).
16
+ */
17
+ export declare function mat2x2Store(array: Float64Array, index: number, value: ReadonlyMat2x2): void;
18
+ /**
19
+ * Like {@link mat2x2Load} for interleaved data: element `index` starts at
20
+ * `offset + index·stride`, both counted in numbers, and its 4 components follow
21
+ * one another. An index past the end gives `NaN` components. O(1).
22
+ */
23
+ export declare function mat2x2LoadStrided(out: Mat2x2, array: Float64Array, offset: number, stride: number, index: number): Mat2x2;
24
+ /**
25
+ * Like {@link mat2x2Store} for interleaved data: element `index` starts at
26
+ * `offset + index·stride`, both counted in numbers. A component past the end of
27
+ * `array` writes nothing. O(1).
28
+ */
29
+ export declare function mat2x2StoreStrided(array: Float64Array, offset: number, stride: number, index: number, value: ReadonlyMat2x2): void;
30
+ /**
31
+ * Whether every number of `array` is finite: the check for a buffer of mat2x2
32
+ * elements read from untrusted data or about to be uploaded. The length is not
33
+ * required to be a multiple of 4 (see `assertFiniteBuffer` for that). O(n).
34
+ */
35
+ export declare function mat2x2ArrayIsFinite(array: Float64Array): boolean;
36
+ //# sourceMappingURL=mat2x2-array.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mat2x2-array.d.ts","sourceRoot":"","sources":["../src/mat2x2-array.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1D;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACzB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,GACX,MAAM,CAQR;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAC1B,KAAK,EAAE,YAAY,EACnB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,cAAc,GACnB,IAAI,CAMN;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAChC,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACX,MAAM,CAQR;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,YAAY,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,cAAc,GACnB,IAAI,CAMN;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAOhE"}
@@ -0,0 +1,71 @@
1
+ // Generated from scripts/templates/value-array.liquid by scripts/generate-componentwise.ts. Do not edit.
2
+ /**
3
+ * Writes element `index` of `array`, the numbers at `[index·4, index·4 + 4)`,
4
+ * into `out`. Each component is written as `+array[i]`, so an index past the
5
+ * end of `array` gives `NaN`, never `undefined`: the matrix stays clean
6
+ * whatever the caller does. Checking the index is the job of the checked
7
+ * layer.
8
+ *
9
+ * The matrix is copied: it is never a view of `array`. O(1).
10
+ */
11
+ export function mat2x2Load(out, array, index) {
12
+ const base = index * 4;
13
+ // The `!` is for the compiler: past the end `+undefined` is `NaN`.
14
+ out[0] = +array[base];
15
+ out[1] = +array[base + 1];
16
+ out[2] = +array[base + 2];
17
+ out[3] = +array[base + 3];
18
+ return out;
19
+ }
20
+ /**
21
+ * Writes `value` into `array` as element `index`, at `[index·4, index·4 + 4)`.
22
+ * An element past the end of `array` writes nothing, as a typed array drops an
23
+ * out-of-range write. O(1).
24
+ */
25
+ export function mat2x2Store(array, index, value) {
26
+ const base = index * 4;
27
+ array[base] = value[0];
28
+ array[base + 1] = value[1];
29
+ array[base + 2] = value[2];
30
+ array[base + 3] = value[3];
31
+ }
32
+ /**
33
+ * Like {@link mat2x2Load} for interleaved data: element `index` starts at
34
+ * `offset + index·stride`, both counted in numbers, and its 4 components follow
35
+ * one another. An index past the end gives `NaN` components. O(1).
36
+ */
37
+ export function mat2x2LoadStrided(out, array, offset, stride, index) {
38
+ const base = offset + index * stride;
39
+ // The `!` is for the compiler: past the end `+undefined` is `NaN`.
40
+ out[0] = +array[base];
41
+ out[1] = +array[base + 1];
42
+ out[2] = +array[base + 2];
43
+ out[3] = +array[base + 3];
44
+ return out;
45
+ }
46
+ /**
47
+ * Like {@link mat2x2Store} for interleaved data: element `index` starts at
48
+ * `offset + index·stride`, both counted in numbers. A component past the end of
49
+ * `array` writes nothing. O(1).
50
+ */
51
+ export function mat2x2StoreStrided(array, offset, stride, index, value) {
52
+ const base = offset + index * stride;
53
+ array[base] = value[0];
54
+ array[base + 1] = value[1];
55
+ array[base + 2] = value[2];
56
+ array[base + 3] = value[3];
57
+ }
58
+ /**
59
+ * Whether every number of `array` is finite: the check for a buffer of mat2x2
60
+ * elements read from untrusted data or about to be uploaded. The length is not
61
+ * required to be a multiple of 4 (see `assertFiniteBuffer` for that). O(n).
62
+ */
63
+ export function mat2x2ArrayIsFinite(array) {
64
+ for (let index = 0; index < array.length; index++) {
65
+ if (!Number.isFinite(array[index])) {
66
+ return false;
67
+ }
68
+ }
69
+ return true;
70
+ }
71
+ //# sourceMappingURL=mat2x2-array.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mat2x2-array.js","sourceRoot":"","sources":["../src/mat2x2-array.ts"],"names":[],"mappings":"AAAA,yGAAyG;AAIzG;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CACzB,GAAW,EACX,KAAmB,EACnB,KAAa;IAEb,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC;IACvB,mEAAmE;IACnE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAE,CAAC;IACvB,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC;IAC3B,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC;IAC3B,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAE,CAAC;IAC3B,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAC1B,KAAmB,EACnB,KAAa,EACb,KAAqB;IAErB,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC;IACvB,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;AAC5B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAChC,GAAW,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AC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -0,0 +1,86 @@
1
+ import { type IsCloseToOptions } from "@ac-kit/core";
2
+ import type { ReadonlyMat2x2, Mat2x2 } from "./mat2x2.js";
3
+ /**
4
+ * Creates the identity matrix.
5
+ *
6
+ * Allocates; keep it out of hot loops.
7
+ */
8
+ export declare function mat2x2Create(): Mat2x2;
9
+ /**
10
+ * Creates the matrix from its entries in storage order, the columns one after
11
+ * the other (`m10` is row 1, column 0): the order of the type's labels, of a
12
+ * `Float64Array` and of a GPU buffer. See {@link mat2x2OfRows} for the order of
13
+ * a textbook.
14
+ *
15
+ * Allocates; keep it out of hot loops.
16
+ */
17
+ export declare function mat2x2Of(m00: number, m10: number, m01: number, m11: number): Mat2x2;
18
+ /**
19
+ * Creates the matrix from its entries row by row, as a matrix is written on
20
+ * paper: the first 2 arguments are the first row.
21
+ *
22
+ * Allocates; keep it out of hot loops.
23
+ */
24
+ export declare function mat2x2OfRows(m00: number, m01: number, m10: number, m11: number): Mat2x2;
25
+ /**
26
+ * Creates a copy of `m`. Like every creator it starts from a clean array.
27
+ *
28
+ * Allocates; keep it out of hot loops.
29
+ */
30
+ export declare function mat2x2Clone(m: ReadonlyMat2x2): Mat2x2;
31
+ /**
32
+ * The checked way in from untyped data (JSON, messages, arrays of unknown
33
+ * origin): `source[offset … offset + 4)` copied into `out`, each element that
34
+ * is not a number written as `NaN`, an index below zero or at or past
35
+ * `source.length` too, so `out` never holds a non-number. Test the result with
36
+ * {@link mat2x2IsFinite} when `NaN` must not get through. A cold path. O(1).
37
+ *
38
+ * `source` may be `out` itself: the 4 elements are read before the first write.
39
+ *
40
+ * @param out The matrix to fill.
41
+ * @param source The array to read, of any length and any content, the entries
42
+ * in storage order.
43
+ * @param offset The index of the first entry in `source`.
44
+ * @returns `out`.
45
+ */
46
+ export declare function mat2x2FromArray(out: Mat2x2, source: ArrayLike<number>, offset?: number): Mat2x2;
47
+ /** Writes the matrix with the entries in storage order into `out`. */
48
+ export declare function mat2x2Set(out: Mat2x2, m00: number, m10: number, m01: number, m11: number): Mat2x2;
49
+ /** Writes the matrix with the entries given row by row into `out`. */
50
+ export declare function mat2x2SetRows(out: Mat2x2, m00: number, m01: number, m10: number, m11: number): Mat2x2;
51
+ /** Writes a copy of `m` into `out`. */
52
+ export declare function mat2x2Copy(out: Mat2x2, m: ReadonlyMat2x2): Mat2x2;
53
+ /** Writes the identity matrix into `out`. */
54
+ export declare function mat2x2Identity(out: Mat2x2): Mat2x2;
55
+ /** Writes the zero matrix into `out`. */
56
+ export declare function mat2x2Zero(out: Mat2x2): Mat2x2;
57
+ /** Writes `a + b`, entry by entry, into `out`. `out` may be `a` or `b`. */
58
+ export declare function mat2x2Add(out: Mat2x2, a: ReadonlyMat2x2, b: ReadonlyMat2x2): Mat2x2;
59
+ /** Writes `a − b`, entry by entry, into `out`. `out` may be `a` or `b`. */
60
+ export declare function mat2x2Subtract(out: Mat2x2, a: ReadonlyMat2x2, b: ReadonlyMat2x2): Mat2x2;
61
+ /** Writes `m · scalar`, every entry multiplied, into `out`. `out` may be `m`. */
62
+ export declare function mat2x2MultiplyScalar(out: Mat2x2, m: ReadonlyMat2x2, scalar: number): Mat2x2;
63
+ /** Writes `−m`, every entry negated, into `out`. `out` may be `m`. */
64
+ export declare function mat2x2Negate(out: Mat2x2, m: ReadonlyMat2x2): Mat2x2;
65
+ /**
66
+ * Exact entry-wise equality: `−0` equals `+0`, and `NaN` equals nothing, itself
67
+ * included. See {@link mat2x2IsClose} for a tolerant test.
68
+ */
69
+ export declare function mat2x2Equals(a: ReadonlyMat2x2, b: ReadonlyMat2x2): boolean;
70
+ /**
71
+ * Entry-wise approximate equality, each pair compared by `@ac-kit/core`'s
72
+ * `isCloseTo` with `options`: none means exact.
73
+ *
74
+ * Not transitive, so it is not an equality in the sense a `Set` or `Map` needs,
75
+ * and never a basis for ordering — use {@link mat2x2Equals} there. The tolerance
76
+ * is required: a matrix carries no units of its own, so only the caller knows
77
+ * what counts as close.
78
+ */
79
+ export declare function mat2x2IsClose(a: ReadonlyMat2x2, b: ReadonlyMat2x2, options: IsCloseToOptions): boolean;
80
+ /**
81
+ * Whether every entry is a finite number: the check to run after parsing
82
+ * untrusted data or before an upload, as operations never check. An entry that
83
+ * is not a number at all counts as not finite.
84
+ */
85
+ export declare function mat2x2IsFinite(m: ReadonlyMat2x2): boolean;
86
+ //# sourceMappingURL=mat2x2-componentwise.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mat2x2-componentwise.d.ts","sourceRoot":"","sources":["../src/mat2x2-componentwise.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,gBAAgB,EAAiB,MAAM,cAAc,CAAC;AAE/E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAQ1D;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAOrC;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACvB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACT,MAAM,CAOR;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC3B,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,GACT,MAAM,CAOR;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,CAOrD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EACzB,MAAM,SAAI,GACR,MAAM,CAUR;AAED,sEAAsE;AACtE,wBAAgB,SAAS,CACxB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE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@@ -0,0 +1,199 @@
1
+ // Generated from scripts/templates/mat-componentwise.liquid by scripts/generate-componentwise.ts. Do not edit.
2
+ import { isCloseTo, numberAtOrNaN } from "@ac-kit/core";
3
+ /**
4
+ * Every creator copies this array, which holds non-integer doubles and is never
5
+ * exposed: nothing a caller does can change the element kind it copies.
6
+ */
7
+ const TEMPLATE_ = [0.5, 0.5, 0.5, 0.5];
8
+ /**
9
+ * Creates the identity matrix.
10
+ *
11
+ * Allocates; keep it out of hot loops.
12
+ */
13
+ export function mat2x2Create() {
14
+ const out = TEMPLATE_.slice();
15
+ out[0] = 1;
16
+ out[1] = 0;
17
+ out[2] = 0;
18
+ out[3] = 1;
19
+ return out;
20
+ }
21
+ /**
22
+ * Creates the matrix from its entries in storage order, the columns one after
23
+ * the other (`m10` is row 1, column 0): the order of the type's labels, of a
24
+ * `Float64Array` and of a GPU buffer. See {@link mat2x2OfRows} for the order of
25
+ * a textbook.
26
+ *
27
+ * Allocates; keep it out of hot loops.
28
+ */
29
+ export function mat2x2Of(m00, m10, m01, m11) {
30
+ const out = TEMPLATE_.slice();
31
+ out[0] = m00;
32
+ out[1] = m10;
33
+ out[2] = m01;
34
+ out[3] = m11;
35
+ return out;
36
+ }
37
+ /**
38
+ * Creates the matrix from its entries row by row, as a matrix is written on
39
+ * paper: the first 2 arguments are the first row.
40
+ *
41
+ * Allocates; keep it out of hot loops.
42
+ */
43
+ export function mat2x2OfRows(m00, m01, m10, m11) {
44
+ const out = TEMPLATE_.slice();
45
+ out[0] = m00;
46
+ out[2] = m01;
47
+ out[1] = m10;
48
+ out[3] = m11;
49
+ return out;
50
+ }
51
+ /**
52
+ * Creates a copy of `m`. Like every creator it starts from a clean array.
53
+ *
54
+ * Allocates; keep it out of hot loops.
55
+ */
56
+ export function mat2x2Clone(m) {
57
+ const out = TEMPLATE_.slice();
58
+ out[0] = m[0];
59
+ out[1] = m[1];
60
+ out[2] = m[2];
61
+ out[3] = m[3];
62
+ return out;
63
+ }
64
+ /**
65
+ * The checked way in from untyped data (JSON, messages, arrays of unknown
66
+ * origin): `source[offset … offset + 4)` copied into `out`, each element that
67
+ * is not a number written as `NaN`, an index below zero or at or past
68
+ * `source.length` too, so `out` never holds a non-number. Test the result with
69
+ * {@link mat2x2IsFinite} when `NaN` must not get through. A cold path. O(1).
70
+ *
71
+ * `source` may be `out` itself: the 4 elements are read before the first write.
72
+ *
73
+ * @param out The matrix to fill.
74
+ * @param source The array to read, of any length and any content, the entries
75
+ * in storage order.
76
+ * @param offset The index of the first entry in `source`.
77
+ * @returns `out`.
78
+ */
79
+ export function mat2x2FromArray(out, source, offset = 0) {
80
+ const m00 = numberAtOrNaN(source, offset);
81
+ const m10 = numberAtOrNaN(source, offset + 1);
82
+ const m01 = numberAtOrNaN(source, offset + 2);
83
+ const m11 = numberAtOrNaN(source, offset + 3);
84
+ out[0] = m00;
85
+ out[1] = m10;
86
+ out[2] = m01;
87
+ out[3] = m11;
88
+ return out;
89
+ }
90
+ /** Writes the matrix with the entries in storage order into `out`. */
91
+ export function mat2x2Set(out, m00, m10, m01, m11) {
92
+ out[0] = m00;
93
+ out[1] = m10;
94
+ out[2] = m01;
95
+ out[3] = m11;
96
+ return out;
97
+ }
98
+ /** Writes the matrix with the entries given row by row into `out`. */
99
+ export function mat2x2SetRows(out, m00, m01, m10, m11) {
100
+ out[0] = m00;
101
+ out[2] = m01;
102
+ out[1] = m10;
103
+ out[3] = m11;
104
+ return out;
105
+ }
106
+ /** Writes a copy of `m` into `out`. */
107
+ export function mat2x2Copy(out, m) {
108
+ const m00 = m[0];
109
+ const m10 = m[1];
110
+ const m01 = m[2];
111
+ const m11 = m[3];
112
+ out[0] = m00;
113
+ out[1] = m10;
114
+ out[2] = m01;
115
+ out[3] = m11;
116
+ return out;
117
+ }
118
+ /** Writes the identity matrix into `out`. */
119
+ export function mat2x2Identity(out) {
120
+ out[0] = 1;
121
+ out[1] = 0;
122
+ out[2] = 0;
123
+ out[3] = 1;
124
+ return out;
125
+ }
126
+ /** Writes the zero matrix into `out`. */
127
+ export function mat2x2Zero(out) {
128
+ out[0] = 0;
129
+ out[1] = 0;
130
+ out[2] = 0;
131
+ out[3] = 0;
132
+ return out;
133
+ }
134
+ /** Writes `a + b`, entry by entry, into `out`. `out` may be `a` or `b`. */
135
+ export function mat2x2Add(out, a, b) {
136
+ out[0] = a[0] + b[0];
137
+ out[1] = a[1] + b[1];
138
+ out[2] = a[2] + b[2];
139
+ out[3] = a[3] + b[3];
140
+ return out;
141
+ }
142
+ /** Writes `a − b`, entry by entry, into `out`. `out` may be `a` or `b`. */
143
+ export function mat2x2Subtract(out, a, b) {
144
+ out[0] = a[0] - b[0];
145
+ out[1] = a[1] - b[1];
146
+ out[2] = a[2] - b[2];
147
+ out[3] = a[3] - b[3];
148
+ return out;
149
+ }
150
+ /** Writes `m · scalar`, every entry multiplied, into `out`. `out` may be `m`. */
151
+ export function mat2x2MultiplyScalar(out, m, scalar) {
152
+ out[0] = m[0] * scalar;
153
+ out[1] = m[1] * scalar;
154
+ out[2] = m[2] * scalar;
155
+ out[3] = m[3] * scalar;
156
+ return out;
157
+ }
158
+ /** Writes `−m`, every entry negated, into `out`. `out` may be `m`. */
159
+ export function mat2x2Negate(out, m) {
160
+ out[0] = -m[0];
161
+ out[1] = -m[1];
162
+ out[2] = -m[2];
163
+ out[3] = -m[3];
164
+ return out;
165
+ }
166
+ /**
167
+ * Exact entry-wise equality: `−0` equals `+0`, and `NaN` equals nothing, itself
168
+ * included. See {@link mat2x2IsClose} for a tolerant test.
169
+ */
170
+ export function mat2x2Equals(a, b) {
171
+ return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3];
172
+ }
173
+ /**
174
+ * Entry-wise approximate equality, each pair compared by `@ac-kit/core`'s
175
+ * `isCloseTo` with `options`: none means exact.
176
+ *
177
+ * Not transitive, so it is not an equality in the sense a `Set` or `Map` needs,
178
+ * and never a basis for ordering — use {@link mat2x2Equals} there. The tolerance
179
+ * is required: a matrix carries no units of its own, so only the caller knows
180
+ * what counts as close.
181
+ */
182
+ export function mat2x2IsClose(a, b, options) {
183
+ return (isCloseTo(a[0], b[0], options) &&
184
+ isCloseTo(a[1], b[1], options) &&
185
+ isCloseTo(a[2], b[2], options) &&
186
+ isCloseTo(a[3], b[3], options));
187
+ }
188
+ /**
189
+ * Whether every entry is a finite number: the check to run after parsing
190
+ * untrusted data or before an upload, as operations never check. An entry that
191
+ * is not a number at all counts as not finite.
192
+ */
193
+ export function mat2x2IsFinite(m) {
194
+ return (Number.isFinite(m[0]) &&
195
+ Number.isFinite(m[1]) &&
196
+ Number.isFinite(m[2]) &&
197
+ Number.isFinite(m[3]));
198
+ }
199
+ //# sourceMappingURL=mat2x2-componentwise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mat2x2-componentwise.js","sourceRoot":"","sources":["../src/mat2x2-componentwise.ts"],"names":[],"mappings":"AAAA,+GAA+G;AAE/G,OAAO,EAAE,SAAS,EAAyB,aAAa,EAAE,MAAM,cAAc,CAAC;AAI/E;;;GAGG;AACH,MAAM,SAAS,GAAsB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAE1D;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC3B,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAY,CAAC;IACxC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACX,OAAO,GAAG,CAAC;AACZ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CACvB,GAAW,EACX,GAAW,EACX,GAAW,EACX,GAAW;IAEX,MAAM,GAAG,GAAG,SAAS,CAAC,KAAK,EAAY,CAAC;IACxC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CA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C,CAAC,CAAC,CAAC,CACrB,CAAC;AACH,CAAC"}
package/dist/mat2x2.d.ts CHANGED
@@ -1,30 +1,72 @@
1
- import { type IsCloseToOptions } from "@ac-kit/core";
2
- import { Vec2 } from "./vec2.js";
3
- export type Mat2x2 = [[number, number], [number, number]];
4
- export declare const MAT2X2_ZERO: [[0, 0], [0, 0]];
5
- export declare const MAT2X2_IDENTITY: [[1, 0], [0, 1]];
6
- export declare function mat2x2Add(a: Mat2x2, b: Mat2x2): Mat2x2;
7
- export declare function mat2x2MultiplyScalar(matrix: Mat2x2, scalar: number): Mat2x2;
8
- export declare function mat2x2MultiplyCols(matrix: Mat2x2, vector: Vec2): Mat2x2;
9
- export declare function mat2x2MultiplyRows(matrix: Mat2x2, vector: Vec2): Mat2x2;
10
- export declare function mat2x2Multiply(a: Mat2x2, b: Mat2x2): Mat2x2;
11
- export declare function mat2x2Transpose(matrix: Mat2x2): Mat2x2;
12
- export declare function mat2x2Determinant(matrix: Mat2x2): number;
13
- /** Exact element-wise equality. See {@link mat2x2IsClose} for a tolerant test. */
14
- export declare function mat2x2Equals(a: Mat2x2, b: Mat2x2): boolean;
15
- /**
16
- * Element-wise approximate equality.
1
+ import type { Brand_ } from "./_brand.js";
2
+ import type { ReadonlyVec2 } from "./vec2.js";
3
+ /**
4
+ * A 2 × 2 matrix, stored flat and column-major, `[m00, m10, m01, m11]`: entry
5
+ * (row `r`, column `c`) is at index `2c + r`, as WebGL, WebGPU and WGSL lay
6
+ * matrices out. A plain array of four binary64 numbers carrying a type-level
7
+ * brand. Operations treat vectors as columns, so `mat2x2Multiply(out, a, b)` is
8
+ * `a · b` and applies `b` first.
17
9
  *
18
- * Not transitive, so it is not an equality in the sense a `Set` or `Map` needs,
19
- * and never a basis for ordering — use {@link mat2x2Equals} there.
10
+ * Only {@link mat2x2Create}, {@link mat2x2Of}, {@link mat2x2OfRows},
11
+ * {@link mat2x2Clone}, {@link mat2x2FromArray} and the functions that write an
12
+ * `out` make one; see {@link Vec3} for the rules that bind callers who bypass
13
+ * the types.
14
+ */
15
+ export type Mat2x2 = [m00: number, m10: number, m01: number, m11: number] & Brand_<"Mat2x2">;
16
+ /** A {@link Mat2x2} that is only read. */
17
+ export type ReadonlyMat2x2 = readonly [
18
+ m00: number,
19
+ m10: number,
20
+ m01: number,
21
+ m11: number
22
+ ] & Brand_<"Mat2x2">;
23
+ /**
24
+ * Writes the product `a · b` into `out`: `b` is applied first. Not commutative.
25
+ * Plain arithmetic: each entry is within two roundings of the exact value
26
+ * relative to the sum of the absolute values of its terms, so it can lose every
27
+ * digit where the terms cancel (see {@link mat2x2MultiplyPrecise}). `out` may be
28
+ * `a` or `b`.
29
+ */
30
+ export declare function mat2x2Multiply(out: Mat2x2, a: ReadonlyMat2x2, b: ReadonlyMat2x2): Mat2x2;
31
+ /**
32
+ * {@link mat2x2Multiply} with each entry a compensated sum of products, within
33
+ * 1.5 ULP of the exact value however badly the terms cancel. `out` may be `a`
34
+ * or `b`.
35
+ */
36
+ export declare function mat2x2MultiplyPrecise(out: Mat2x2, a: ReadonlyMat2x2, b: ReadonlyMat2x2): Mat2x2;
37
+ /**
38
+ * Writes `m · diag(v)` into `out`: column `c` of `m` multiplied by `v[c]`.
39
+ * `out` may be `m`.
40
+ */
41
+ export declare function mat2x2ScaleColumns(out: Mat2x2, m: ReadonlyMat2x2, v: ReadonlyVec2): Mat2x2;
42
+ /**
43
+ * Writes `diag(v) · m` into `out`: row `r` of `m` multiplied by `v[r]`. `out`
44
+ * may be `m`.
45
+ */
46
+ export declare function mat2x2ScaleRows(out: Mat2x2, m: ReadonlyMat2x2, v: ReadonlyVec2): Mat2x2;
47
+ /** Writes the transpose of `m` into `out`. `out` may be `m`. */
48
+ export declare function mat2x2Transpose(out: Mat2x2, m: ReadonlyMat2x2): Mat2x2;
49
+ /**
50
+ * The determinant, in plain arithmetic: the signed area scale of the
51
+ * transformation.
52
+ */
53
+ export declare function mat2x2Determinant(m: ReadonlyMat2x2): number;
54
+ /**
55
+ * Writes the inverse of `m` into `out` and returns `true`. When `m` has no
56
+ * inverse a binary64 number can hold (the determinant is zero, an entry is not
57
+ * finite, or an entry of the inverse overflows) `out` is filled with `NaN` and
58
+ * the result is `false`: `true` always comes with a finite `out`, never a stale
59
+ * or partial matrix, and nothing throws. A matrix of one very large or very
60
+ * small magnitude, whose determinant overflows or underflows, is inverted all
61
+ * the same (`diag(1e-150)` gives `diag(1e150)`), by scaling it by a power of
62
+ * two first. Plain arithmetic. `out` may be `m`.
20
63
  */
21
- export declare function mat2x2IsClose(a: Mat2x2, b: Mat2x2, tolerance: IsCloseToOptions): boolean;
64
+ export declare function mat2x2Invert(out: Mat2x2, m: ReadonlyMat2x2): boolean;
22
65
  /**
23
- * Creates a 2×2 rotation matrix for the given angle in radians
24
- * (counter-clockwise).
66
+ * Writes the rotation by `angle` radians, counter-clockwise, into `out`: `[cos,
67
+ * sin, −sin, cos]`.
25
68
  */
26
- export declare function mat2x2FromRotation(angle: number): Mat2x2;
27
- export declare function mat2x2Invert(matrix: Mat2x2): Mat2x2;
28
- export declare function mat2x2Negate(matrix: Mat2x2): Mat2x2;
29
- export declare function mat2x2Sub(a: Mat2x2, b: Mat2x2): Mat2x2;
69
+ export declare function mat2x2FromRotation(out: Mat2x2, angle: number): Mat2x2;
70
+ /** Writes the scale `diag(scale)` into `out`. */
71
+ export declare function mat2x2FromScale(out: Mat2x2, scale: ReadonlyVec2): Mat2x2;
30
72
  //# sourceMappingURL=mat2x2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mat2x2.d.ts","sourceRoot":"","sources":["../src/mat2x2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AA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