@woosh/meep-engine 2.135.0 → 2.138.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 (238) hide show
  1. package/package.json +1 -1
  2. package/src/core/geom/2d/aabb/aabb2_intersects_ray.d.ts.map +1 -1
  3. package/src/core/geom/2d/aabb/aabb2_intersects_ray.js +5 -7
  4. package/src/core/geom/2d/hash-grid/shg_query_elements_circle.d.ts.map +1 -1
  5. package/src/core/geom/2d/hash-grid/shg_query_elements_circle.js +2 -3
  6. package/src/core/geom/3d/aabb/aabb3_intersects_line_segment.d.ts.map +1 -1
  7. package/src/core/geom/3d/aabb/aabb3_intersects_line_segment.js +9 -11
  8. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.d.ts.map +1 -1
  9. package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.js +6 -4
  10. package/src/core/geom/3d/topology/simplify/quadratic/Quadric3.d.ts.map +1 -1
  11. package/src/core/geom/3d/topology/simplify/quadratic/Quadric3.js +1 -2
  12. package/src/core/geom/Quaternion.d.ts +26 -39
  13. package/src/core/geom/Quaternion.d.ts.map +1 -1
  14. package/src/core/geom/Quaternion.js +124 -136
  15. package/src/core/geom/Vector2.d.ts +28 -14
  16. package/src/core/geom/Vector2.d.ts.map +1 -1
  17. package/src/core/geom/Vector2.js +114 -97
  18. package/src/core/geom/Vector3.d.ts +21 -34
  19. package/src/core/geom/Vector3.d.ts.map +1 -1
  20. package/src/core/geom/Vector3.js +131 -142
  21. package/src/core/geom/Vector4.d.ts +21 -30
  22. package/src/core/geom/Vector4.d.ts.map +1 -1
  23. package/src/core/geom/Vector4.js +80 -93
  24. package/src/core/geom/packing/computeBoundingSphereOfSpheres.d.ts.map +1 -1
  25. package/src/core/geom/packing/computeBoundingSphereOfSpheres.js +23 -6
  26. package/src/core/geom/packing/miniball/Miniball.d.ts.map +1 -1
  27. package/src/core/geom/packing/miniball/Miniball.js +4 -11
  28. package/src/core/geom/packing/miniball/Subspan.d.ts +14 -39
  29. package/src/core/geom/packing/miniball/Subspan.d.ts.map +1 -1
  30. package/src/core/geom/packing/miniball/Subspan.js +105 -158
  31. package/src/core/geom/packing/miniball/miniball_compute_quality.d.ts.map +1 -1
  32. package/src/core/geom/packing/miniball/miniball_compute_quality.js +2 -6
  33. package/src/core/geom/vec/vector_axpy.d.ts +12 -0
  34. package/src/core/geom/vec/vector_axpy.d.ts.map +1 -0
  35. package/src/core/geom/vec/vector_axpy.js +15 -0
  36. package/src/core/geom/vec/vector_axpy_offset.d.ts +17 -0
  37. package/src/core/geom/vec/vector_axpy_offset.d.ts.map +1 -0
  38. package/src/core/geom/vec/vector_axpy_offset.js +20 -0
  39. package/src/core/geom/vec/vector_dot_offset.d.ts +18 -0
  40. package/src/core/geom/vec/vector_dot_offset.d.ts.map +1 -0
  41. package/src/core/geom/vec/vector_dot_offset.js +25 -0
  42. package/src/core/math/complex/complex_horner_eval.d.ts +16 -0
  43. package/src/core/math/complex/complex_horner_eval.d.ts.map +1 -0
  44. package/src/core/math/complex/complex_horner_eval.js +31 -0
  45. package/src/core/math/fabsf.d.ts +2 -3
  46. package/src/core/math/fabsf.d.ts.map +1 -1
  47. package/src/core/math/fabsf.js +3 -5
  48. package/src/core/math/linalg/cubic_residual_times_derivative_accumulate.d.ts +26 -0
  49. package/src/core/math/linalg/cubic_residual_times_derivative_accumulate.d.ts.map +1 -0
  50. package/src/core/math/linalg/cubic_residual_times_derivative_accumulate.js +43 -0
  51. package/src/core/math/linalg/eigen/matrix_eigenvalues_in_place.d.ts +2 -1
  52. package/src/core/math/linalg/eigen/matrix_eigenvalues_in_place.d.ts.map +1 -1
  53. package/src/core/math/linalg/eigen/matrix_eigenvalues_in_place.js +2 -1
  54. package/src/core/math/linalg/eigen/matrix_householder_in_place.d.ts +10 -4
  55. package/src/core/math/linalg/eigen/matrix_householder_in_place.d.ts.map +1 -1
  56. package/src/core/math/linalg/eigen/matrix_householder_in_place.js +122 -98
  57. package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts +2 -2
  58. package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts.map +1 -1
  59. package/src/core/math/linalg/eigen/matrix_qr_in_place.js +144 -124
  60. package/src/core/math/linalg/givens/givens_apply_rows.d.ts +22 -0
  61. package/src/core/math/linalg/givens/givens_apply_rows.d.ts.map +1 -0
  62. package/src/core/math/linalg/givens/givens_apply_rows.js +28 -0
  63. package/src/core/math/linalg/givens/givens_apply_rows_offset.d.ts +24 -0
  64. package/src/core/math/linalg/givens/givens_apply_rows_offset.d.ts.map +1 -0
  65. package/src/core/math/linalg/givens/givens_apply_rows_offset.js +30 -0
  66. package/src/core/math/linalg/givens/givens_rotation_coefficients.d.ts +25 -0
  67. package/src/core/math/linalg/givens/givens_rotation_coefficients.d.ts.map +1 -0
  68. package/src/core/math/linalg/givens/givens_rotation_coefficients.js +39 -0
  69. package/src/core/math/linalg/lu_factor_linear_system.d.ts +1 -1
  70. package/src/core/math/linalg/lu_factor_linear_system.d.ts.map +1 -1
  71. package/src/core/math/linalg/lu_factor_linear_system.js +108 -117
  72. package/src/core/math/linalg/lu_solve_linear_system.d.ts +1 -1
  73. package/src/core/math/linalg/lu_solve_linear_system.js +53 -53
  74. package/src/core/math/linalg/polynomial_add_into.d.ts +18 -0
  75. package/src/core/math/linalg/polynomial_add_into.d.ts.map +1 -0
  76. package/src/core/math/linalg/polynomial_add_into.js +29 -0
  77. package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.d.ts +6 -1
  78. package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.d.ts.map +1 -1
  79. package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.js +48 -50
  80. package/src/core/math/linalg/polynomial_cubic_derivative_eval.d.ts +15 -0
  81. package/src/core/math/linalg/polynomial_cubic_derivative_eval.d.ts.map +1 -0
  82. package/src/core/math/linalg/polynomial_cubic_derivative_eval.js +16 -0
  83. package/src/core/math/linalg/polynomial_cubic_horner_eval.d.ts +18 -0
  84. package/src/core/math/linalg/polynomial_cubic_horner_eval.d.ts.map +1 -0
  85. package/src/core/math/linalg/polynomial_cubic_horner_eval.js +19 -0
  86. package/src/core/math/linalg/polynomial_cubic_second_derivative_eval.d.ts +13 -0
  87. package/src/core/math/linalg/polynomial_cubic_second_derivative_eval.d.ts.map +1 -0
  88. package/src/core/math/linalg/polynomial_cubic_second_derivative_eval.js +14 -0
  89. package/src/core/math/linalg/polynomial_multiply.d.ts +21 -0
  90. package/src/core/math/linalg/polynomial_multiply.d.ts.map +1 -0
  91. package/src/core/math/linalg/polynomial_multiply.js +41 -0
  92. package/src/core/math/linalg/polynomial_real_roots_in_interval.d.ts +6 -1
  93. package/src/core/math/linalg/polynomial_real_roots_in_interval.d.ts.map +1 -1
  94. package/src/core/math/linalg/polynomial_real_roots_in_interval.js +29 -18
  95. package/src/core/math/linalg/polynomial_root_bound_cauchy.d.ts +17 -0
  96. package/src/core/math/linalg/polynomial_root_bound_cauchy.d.ts.map +1 -0
  97. package/src/core/math/linalg/polynomial_root_bound_cauchy.js +30 -0
  98. package/src/core/math/linalg/polynomial_scale_into.d.ts +14 -0
  99. package/src/core/math/linalg/polynomial_scale_into.d.ts.map +1 -0
  100. package/src/core/math/linalg/polynomial_scale_into.js +17 -0
  101. package/src/core/math/linalg/polynomial_sub_into.d.ts +18 -0
  102. package/src/core/math/linalg/polynomial_sub_into.d.ts.map +1 -0
  103. package/src/core/math/linalg/polynomial_sub_into.js +29 -0
  104. package/src/core/math/linalg/solve_linear_system.d.ts +1 -1
  105. package/src/core/math/linalg/solve_linear_system.js +1 -1
  106. package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts +4 -4
  107. package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts.map +1 -1
  108. package/src/core/math/linalg/solve_linear_system_GEPP_2x2.js +96 -91
  109. package/src/core/math/solveQuadratic.d.ts +2 -2
  110. package/src/core/math/solveQuadratic.d.ts.map +1 -1
  111. package/src/core/math/solveQuadratic.js +1 -1
  112. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite.d.ts +18 -10
  113. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite.d.ts.map +1 -1
  114. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite.js +18 -10
  115. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.d.ts +13 -6
  116. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.d.ts.map +1 -1
  117. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.js +16 -11
  118. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.d.ts +25 -3
  119. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.d.ts.map +1 -1
  120. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.js +97 -142
  121. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_nd.d.ts +30 -4
  122. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_nd.d.ts.map +1 -1
  123. package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_nd.js +188 -132
  124. package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.d.ts +7 -3
  125. package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.d.ts.map +1 -1
  126. package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.js +35 -6
  127. package/src/core/science/units/MEASUREMENT_UNITS_SCIENTIFIC.d.ts +17 -0
  128. package/src/core/science/units/MEASUREMENT_UNITS_SCIENTIFIC.d.ts.map +1 -0
  129. package/src/core/science/units/MEASUREMENT_UNITS_SCIENTIFIC.js +87 -0
  130. package/src/core/science/units/MEASUREMENT_UNITS_SI.d.ts +13 -0
  131. package/src/core/science/units/MEASUREMENT_UNITS_SI.d.ts.map +1 -0
  132. package/src/core/science/units/MEASUREMENT_UNITS_SI.js +28 -0
  133. package/src/core/science/units/NamedUnit.d.ts +38 -0
  134. package/src/core/science/units/NamedUnit.d.ts.map +1 -0
  135. package/src/core/science/units/NamedUnit.js +48 -0
  136. package/src/core/science/units/UNIT_DIMENSION_MAPPING.d.ts +14 -0
  137. package/src/core/science/units/UNIT_DIMENSION_MAPPING.d.ts.map +1 -0
  138. package/src/core/science/units/UNIT_DIMENSION_MAPPING.js +29 -0
  139. package/src/core/science/units/UnitDimension.d.ts +26 -0
  140. package/src/core/science/units/UnitDimension.d.ts.map +1 -0
  141. package/src/core/science/units/UnitDimension.js +28 -0
  142. package/src/core/science/units/UnitMatrix.d.ts +117 -0
  143. package/src/core/science/units/UnitMatrix.d.ts.map +1 -0
  144. package/src/core/science/units/UnitMatrix.js +251 -0
  145. package/src/core/science/units/format_quantity.d.ts +25 -0
  146. package/src/core/science/units/format_quantity.d.ts.map +1 -0
  147. package/src/core/science/units/format_quantity.js +74 -0
  148. package/src/core/science/units/magnitude_prefix.d.ts +57 -0
  149. package/src/core/science/units/magnitude_prefix.d.ts.map +1 -0
  150. package/src/core/science/units/magnitude_prefix.js +127 -0
  151. package/src/core/science/units/si/AMPERE.d.ts +7 -0
  152. package/src/core/science/units/si/AMPERE.d.ts.map +1 -0
  153. package/src/core/science/units/si/AMPERE.js +13 -0
  154. package/src/core/science/units/si/CANDELA.d.ts +7 -0
  155. package/src/core/science/units/si/CANDELA.d.ts.map +1 -0
  156. package/src/core/science/units/si/CANDELA.js +13 -0
  157. package/src/core/science/units/si/DIMENSIONLESS.d.ts +8 -0
  158. package/src/core/science/units/si/DIMENSIONLESS.d.ts.map +1 -0
  159. package/src/core/science/units/si/DIMENSIONLESS.js +14 -0
  160. package/src/core/science/units/si/KELVIN.d.ts +7 -0
  161. package/src/core/science/units/si/KELVIN.d.ts.map +1 -0
  162. package/src/core/science/units/si/KELVIN.js +13 -0
  163. package/src/core/science/units/si/KILOGRAM.d.ts +7 -0
  164. package/src/core/science/units/si/KILOGRAM.d.ts.map +1 -0
  165. package/src/core/science/units/si/KILOGRAM.js +13 -0
  166. package/src/core/science/units/si/METER.d.ts +7 -0
  167. package/src/core/science/units/si/METER.d.ts.map +1 -0
  168. package/src/core/science/units/si/METER.js +13 -0
  169. package/src/core/science/units/si/MOLE.d.ts +7 -0
  170. package/src/core/science/units/si/MOLE.d.ts.map +1 -0
  171. package/src/core/science/units/si/MOLE.js +13 -0
  172. package/src/core/science/units/si/SECOND.d.ts +7 -0
  173. package/src/core/science/units/si/SECOND.d.ts.map +1 -0
  174. package/src/core/science/units/si/SECOND.js +13 -0
  175. package/src/core/science/units/si/derived/BECQUEREL.d.ts +10 -0
  176. package/src/core/science/units/si/derived/BECQUEREL.d.ts.map +1 -0
  177. package/src/core/science/units/si/derived/BECQUEREL.js +16 -0
  178. package/src/core/science/units/si/derived/COULOMB.d.ts +7 -0
  179. package/src/core/science/units/si/derived/COULOMB.d.ts.map +1 -0
  180. package/src/core/science/units/si/derived/COULOMB.js +13 -0
  181. package/src/core/science/units/si/derived/FARAD.d.ts +7 -0
  182. package/src/core/science/units/si/derived/FARAD.d.ts.map +1 -0
  183. package/src/core/science/units/si/derived/FARAD.js +13 -0
  184. package/src/core/science/units/si/derived/GRAY.d.ts +10 -0
  185. package/src/core/science/units/si/derived/GRAY.d.ts.map +1 -0
  186. package/src/core/science/units/si/derived/GRAY.js +16 -0
  187. package/src/core/science/units/si/derived/HENRY.d.ts +7 -0
  188. package/src/core/science/units/si/derived/HENRY.d.ts.map +1 -0
  189. package/src/core/science/units/si/derived/HENRY.js +13 -0
  190. package/src/core/science/units/si/derived/HERTZ.d.ts +10 -0
  191. package/src/core/science/units/si/derived/HERTZ.d.ts.map +1 -0
  192. package/src/core/science/units/si/derived/HERTZ.js +16 -0
  193. package/src/core/science/units/si/derived/JOULE.d.ts +7 -0
  194. package/src/core/science/units/si/derived/JOULE.d.ts.map +1 -0
  195. package/src/core/science/units/si/derived/JOULE.js +13 -0
  196. package/src/core/science/units/si/derived/KATAL.d.ts +7 -0
  197. package/src/core/science/units/si/derived/KATAL.d.ts.map +1 -0
  198. package/src/core/science/units/si/derived/KATAL.js +13 -0
  199. package/src/core/science/units/si/derived/LUMEN.d.ts +8 -0
  200. package/src/core/science/units/si/derived/LUMEN.d.ts.map +1 -0
  201. package/src/core/science/units/si/derived/LUMEN.js +14 -0
  202. package/src/core/science/units/si/derived/LUX.d.ts +7 -0
  203. package/src/core/science/units/si/derived/LUX.d.ts.map +1 -0
  204. package/src/core/science/units/si/derived/LUX.js +13 -0
  205. package/src/core/science/units/si/derived/NEWTON.d.ts +7 -0
  206. package/src/core/science/units/si/derived/NEWTON.d.ts.map +1 -0
  207. package/src/core/science/units/si/derived/NEWTON.js +13 -0
  208. package/src/core/science/units/si/derived/OHM.d.ts +7 -0
  209. package/src/core/science/units/si/derived/OHM.d.ts.map +1 -0
  210. package/src/core/science/units/si/derived/OHM.js +13 -0
  211. package/src/core/science/units/si/derived/PASCAL.d.ts +7 -0
  212. package/src/core/science/units/si/derived/PASCAL.d.ts.map +1 -0
  213. package/src/core/science/units/si/derived/PASCAL.js +13 -0
  214. package/src/core/science/units/si/derived/SIEMENS.d.ts +7 -0
  215. package/src/core/science/units/si/derived/SIEMENS.d.ts.map +1 -0
  216. package/src/core/science/units/si/derived/SIEMENS.js +13 -0
  217. package/src/core/science/units/si/derived/SIEVERT.d.ts +10 -0
  218. package/src/core/science/units/si/derived/SIEVERT.d.ts.map +1 -0
  219. package/src/core/science/units/si/derived/SIEVERT.js +16 -0
  220. package/src/core/science/units/si/derived/TESLA.d.ts +7 -0
  221. package/src/core/science/units/si/derived/TESLA.d.ts.map +1 -0
  222. package/src/core/science/units/si/derived/TESLA.js +13 -0
  223. package/src/core/science/units/si/derived/VOLT.d.ts +7 -0
  224. package/src/core/science/units/si/derived/VOLT.d.ts.map +1 -0
  225. package/src/core/science/units/si/derived/VOLT.js +13 -0
  226. package/src/core/science/units/si/derived/WATT.d.ts +7 -0
  227. package/src/core/science/units/si/derived/WATT.d.ts.map +1 -0
  228. package/src/core/science/units/si/derived/WATT.js +13 -0
  229. package/src/core/science/units/si/derived/WEBER.d.ts +7 -0
  230. package/src/core/science/units/si/derived/WEBER.d.ts.map +1 -0
  231. package/src/core/science/units/si/derived/WEBER.js +13 -0
  232. package/src/core/science/units/unit_matrix_to_string.d.ts +29 -0
  233. package/src/core/science/units/unit_matrix_to_string.d.ts.map +1 -0
  234. package/src/core/science/units/unit_matrix_to_string.js +403 -0
  235. package/src/engine/graphics/geometry/MikkT/CalcTexArea.d.ts.map +1 -1
  236. package/src/engine/graphics/geometry/MikkT/CalcTexArea.js +1 -2
  237. package/src/engine/graphics/geometry/MikkT/InitTriInfo.d.ts.map +1 -1
  238. package/src/engine/graphics/geometry/MikkT/InitTriInfo.js +6 -7
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Applies a Givens rotation (c, s) to two row vectors in place:
3
+ *
4
+ * row_i' = c * row_i + s * row_j
5
+ * row_j' = -s * row_i + c * row_j
6
+ *
7
+ * Each row is treated as a length-n vector and rotated element-by-element.
8
+ *
9
+ * Accepts plain arrays or typed arrays. The two row arguments can be
10
+ * standalone arrays or subarray views into a larger flat matrix — useful
11
+ * for row-major QR/Hessenberg maintenance where the matrix is a single
12
+ * Float64Array and the caller hands in `M.subarray(i*n, (i+1)*n)` and
13
+ * `M.subarray(j*n, (j+1)*n)`.
14
+ *
15
+ * @param {Float64Array|number[]} row_i length >= n
16
+ * @param {Float64Array|number[]} row_j length >= n
17
+ * @param {number} c
18
+ * @param {number} s
19
+ * @param {number} n number of elements to rotate
20
+ */
21
+ export function givens_apply_rows(row_i, row_j, c, s, n) {
22
+ for (let i = 0; i < n; ++i) {
23
+ const a = row_i[i];
24
+ const b = row_j[i];
25
+ row_i[i] = c * a + s * b;
26
+ row_j[i] = c * b - s * a;
27
+ }
28
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Applies a Givens rotation (c, s) to two length-n vectors stored in the
3
+ * same flat buffer at the given offsets. In-place:
4
+ *
5
+ * v_i' = c * v_i + s * v_j
6
+ * v_j' = -s * v_i + c * v_j
7
+ *
8
+ * Naming reflects the original use case (rotating two rows of a matrix),
9
+ * but the helper is layout-agnostic: pass the offsets to two rows of a
10
+ * row-major matrix, or to two columns of a column-major matrix — anything
11
+ * where the pair of vectors lives in a single buffer.
12
+ *
13
+ * Avoids the header allocation that `.subarray(...)` would cost on every
14
+ * call when this is invoked inside a tight QR-update loop.
15
+ *
16
+ * @param {Float64Array|Float32Array|number[]} buf flat buffer holding both vectors
17
+ * @param {number} off_i starting offset of the first vector
18
+ * @param {number} off_j starting offset of the second vector
19
+ * @param {number} c
20
+ * @param {number} s
21
+ * @param {number} n number of elements to rotate
22
+ */
23
+ export function givens_apply_rows_offset(buf: Float64Array | Float32Array | number[], off_i: number, off_j: number, c: number, s: number, n: number): void;
24
+ //# sourceMappingURL=givens_apply_rows_offset.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"givens_apply_rows_offset.d.ts","sourceRoot":"","sources":["../../../../../../src/core/math/linalg/givens/givens_apply_rows_offset.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,8CAPW,YAAY,GAAC,YAAY,GAAC,MAAM,EAAE,SAClC,MAAM,SACN,MAAM,KACN,MAAM,KACN,MAAM,KACN,MAAM,QAShB"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Applies a Givens rotation (c, s) to two length-n vectors stored in the
3
+ * same flat buffer at the given offsets. In-place:
4
+ *
5
+ * v_i' = c * v_i + s * v_j
6
+ * v_j' = -s * v_i + c * v_j
7
+ *
8
+ * Naming reflects the original use case (rotating two rows of a matrix),
9
+ * but the helper is layout-agnostic: pass the offsets to two rows of a
10
+ * row-major matrix, or to two columns of a column-major matrix — anything
11
+ * where the pair of vectors lives in a single buffer.
12
+ *
13
+ * Avoids the header allocation that `.subarray(...)` would cost on every
14
+ * call when this is invoked inside a tight QR-update loop.
15
+ *
16
+ * @param {Float64Array|Float32Array|number[]} buf flat buffer holding both vectors
17
+ * @param {number} off_i starting offset of the first vector
18
+ * @param {number} off_j starting offset of the second vector
19
+ * @param {number} c
20
+ * @param {number} s
21
+ * @param {number} n number of elements to rotate
22
+ */
23
+ export function givens_apply_rows_offset(buf, off_i, off_j, c, s, n) {
24
+ for (let i = 0; i < n; ++i) {
25
+ const a = buf[off_i + i];
26
+ const b = buf[off_j + i];
27
+ buf[off_i + i] = c * a + s * b;
28
+ buf[off_j + i] = c * b - s * a;
29
+ }
30
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Computes the Givens rotation coefficients (c, s) such that
3
+ *
4
+ * [ c s ] [ a ] [ r ]
5
+ * [ -s c ] [ b ] = [ 0 ]
6
+ *
7
+ * with c^2 + s^2 = 1 (so the matrix is a proper rotation).
8
+ *
9
+ * Signs are not pinned down — `r` may be either +sqrt(a^2 + b^2) or its
10
+ * negation depending on the branch taken. Callers that care about the sign
11
+ * of `r` must apply the rotation explicitly and read the rotated value.
12
+ *
13
+ * Writes c to out[0] and s to out[1]. Designed to take an out-param rather
14
+ * than return an object: returning a freshly-allocated {c, s} pair would
15
+ * cost an allocation per call, which matters when this is invoked inside a
16
+ * tight QR-update loop.
17
+ *
18
+ * Source: Golub & Van Loan, Matrix Computations 2nd ed., p. 216.
19
+ *
20
+ * @param {number} a
21
+ * @param {number} b
22
+ * @param {Float64Array|number[]} out length >= 2; receives [c, s]
23
+ */
24
+ export function givens_rotation_coefficients(a: number, b: number, out: Float64Array | number[]): void;
25
+ //# sourceMappingURL=givens_rotation_coefficients.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"givens_rotation_coefficients.d.ts","sourceRoot":"","sources":["../../../../../../src/core/math/linalg/givens/givens_rotation_coefficients.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,gDAJW,MAAM,KACN,MAAM,OACN,YAAY,GAAC,MAAM,EAAE,QAiB/B"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Computes the Givens rotation coefficients (c, s) such that
3
+ *
4
+ * [ c s ] [ a ] [ r ]
5
+ * [ -s c ] [ b ] = [ 0 ]
6
+ *
7
+ * with c^2 + s^2 = 1 (so the matrix is a proper rotation).
8
+ *
9
+ * Signs are not pinned down — `r` may be either +sqrt(a^2 + b^2) or its
10
+ * negation depending on the branch taken. Callers that care about the sign
11
+ * of `r` must apply the rotation explicitly and read the rotated value.
12
+ *
13
+ * Writes c to out[0] and s to out[1]. Designed to take an out-param rather
14
+ * than return an object: returning a freshly-allocated {c, s} pair would
15
+ * cost an allocation per call, which matters when this is invoked inside a
16
+ * tight QR-update loop.
17
+ *
18
+ * Source: Golub & Van Loan, Matrix Computations 2nd ed., p. 216.
19
+ *
20
+ * @param {number} a
21
+ * @param {number} b
22
+ * @param {Float64Array|number[]} out length >= 2; receives [c, s]
23
+ */
24
+ export function givens_rotation_coefficients(a, b, out) {
25
+ if (b === 0.0) {
26
+ out[0] = 1.0;
27
+ out[1] = 0.0;
28
+ } else if (Math.abs(b) > Math.abs(a)) {
29
+ const t = a / b;
30
+ const s = 1 / Math.sqrt(1 + t * t);
31
+ out[0] = s * t;
32
+ out[1] = s;
33
+ } else {
34
+ const t = b / a;
35
+ const c = 1 / Math.sqrt(1 + t * t);
36
+ out[0] = c;
37
+ out[1] = c * t;
38
+ }
39
+ }
@@ -4,7 +4,7 @@
4
4
  * Output factorization LU is in matrix A.
5
5
  * If error is found, method returns false.
6
6
  *
7
- * @param {number[]} A Square matrix, will be modified
7
+ * @param {number[]} A Square matrix, column-major flat layout (A[j*size + i] = element at row i, col j); modified in place to hold the LU factorization
8
8
  * @param {number[]|Uint32Array} index will be written to
9
9
  * @param {number} size Size of the matrix ( 4x4 matrix has size 4 )
10
10
  * @returns {boolean} true if factorization succeeded, false otherwise
@@ -1 +1 @@
1
- {"version":3,"file":"lu_factor_linear_system.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/linalg/lu_factor_linear_system.js"],"names":[],"mappings":"AAYA;;;;;;;;;;GAUG;AACH,2CALW,MAAM,EAAE,SACR,MAAM,EAAE,GAAC,WAAW,QACpB,MAAM,GACJ,OAAO,CA+FnB"}
1
+ {"version":3,"file":"lu_factor_linear_system.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/linalg/lu_factor_linear_system.js"],"names":[],"mappings":"AAYA;;;;;;;;;;GAUG;AACH,2CALW,MAAM,EAAE,SACR,MAAM,EAAE,GAAC,WAAW,QACpB,MAAM,GACJ,OAAO,CAsFnB"}
@@ -1,117 +1,108 @@
1
- import { assert } from "../../assert.js";
2
-
3
- /**
4
- * Error bound during calculations, must be something reasonably large to avoid floating point rounding errors
5
- * @type {number}
6
- */
7
- const SMALL_NUMBER = 1e-12;
8
-
9
- const SCRATCH_SIZE = 16;
10
- // avoid allocation for smaller systems by using a scratch
11
- const scratch = new Float64Array(SCRATCH_SIZE);
12
-
13
- /**
14
- * Factor linear equations Ax = b using LU decomposition A = LU where L is lower triangular matrix and U is upper triangular matrix.
15
- * Input is square matrix A, integer array of pivot indices index[0->n-1], and size of square matrix n.
16
- * Output factorization LU is in matrix A.
17
- * If error is found, method returns false.
18
- *
19
- * @param {number[]} A Square matrix, will be modified
20
- * @param {number[]|Uint32Array} index will be written to
21
- * @param {number} size Size of the matrix ( 4x4 matrix has size 4 )
22
- * @returns {boolean} true if factorization succeeded, false otherwise
23
- */
24
- export function lu_factor_linear_system(A, index, size) {
25
- assert.isNonNegativeInteger(size,'size');
26
-
27
- // double scratch[10];
28
- // double* scale = (size < 10 ? scratch : new double[size]);
29
- //
30
- // int i, j, k;
31
- // int maxI = 0;
32
- // double largest, temp1, temp2, sum;
33
- //
34
- // // Manage number of output warnings
35
- // static int numWarns = 0;
36
- //
37
- // //
38
-
39
- let i, j, k;
40
- let maxI = 0;
41
- let largest, temp1, temp2, sum;
42
-
43
- const scale = size <= SCRATCH_SIZE ? scratch : new Float64Array(size);
44
-
45
- // Loop over rows to get implicit scaling information
46
- //
47
- for (i = 0; i < size; ++i) {
48
- for (largest = 0.0, j = 0; j < size; ++j) {
49
- if ((temp2 = Math.abs(A[i * size + j])) > largest) {
50
- largest = temp2;
51
- }
52
- }
53
-
54
- if (largest === 0.0) {
55
- // Unable to factor linear system
56
-
57
- return false;
58
- }
59
- scale[i] = 1.0 / largest;
60
- }
61
- //
62
- // Loop over all columns using Crout's method
63
- //
64
- for (j = 0; j < size; ++j) {
65
- for (i = 0; i < j; ++i) {
66
- sum = A[i * size + j];
67
- for (k = 0; k < i; ++k) {
68
- sum -= A[i * size + k] * A[k * size + j];
69
- }
70
- A[i * size + j] = sum;
71
- }
72
- //
73
- // Begin search for largest pivot element
74
- //
75
- for (largest = 0.0, i = j; i < size; ++i) {
76
- sum = A[i * size + j];
77
- for (k = 0; k < j; ++k) {
78
- sum -= A[i * size + k] * A[k * size + j];
79
- }
80
- A[i * size + j] = sum;
81
-
82
- if ((temp1 = scale[i] * Math.abs(sum)) >= largest) {
83
- largest = temp1;
84
- maxI = i;
85
- }
86
- }
87
- //
88
- // Check for row interchange
89
- //
90
- if (j !== maxI) {
91
- for (k = 0; k < size; ++k) {
92
- temp1 = A[maxI * size + k];
93
- A[maxI * size + k] = A[j * size + k];
94
- A[j * size + k] = temp1;
95
- }
96
- scale[maxI] = scale[j];
97
- }
98
- //
99
- // Divide by pivot element and perform elimination
100
- //
101
- index[j] = maxI;
102
-
103
- if (Math.abs(A[j * size + j]) <= SMALL_NUMBER) {
104
- // Unable to factor linear system
105
- return false;
106
- }
107
-
108
- if (j !== (size - 1)) {
109
- temp1 = 1.0 / A[j * size + j];
110
- for (i = j + 1; i < size; ++i) {
111
- A[i * size + j] *= temp1;
112
- }
113
- }
114
- }
115
-
116
- return true;
117
- }
1
+ import { assert } from "../../assert.js";
2
+
3
+ /**
4
+ * Error bound during calculations, must be something reasonably large to avoid floating point rounding errors
5
+ * @type {number}
6
+ */
7
+ const SMALL_NUMBER = 1e-12;
8
+
9
+ const SCRATCH_SIZE = 16;
10
+ // avoid allocation for smaller systems by using a scratch
11
+ const scratch = new Float64Array(SCRATCH_SIZE);
12
+
13
+ /**
14
+ * Factor linear equations Ax = b using LU decomposition A = LU where L is lower triangular matrix and U is upper triangular matrix.
15
+ * Input is square matrix A, integer array of pivot indices index[0->n-1], and size of square matrix n.
16
+ * Output factorization LU is in matrix A.
17
+ * If error is found, method returns false.
18
+ *
19
+ * @param {number[]} A Square matrix, column-major flat layout (A[j*size + i] = element at row i, col j); modified in place to hold the LU factorization
20
+ * @param {number[]|Uint32Array} index will be written to
21
+ * @param {number} size Size of the matrix ( 4x4 matrix has size 4 )
22
+ * @returns {boolean} true if factorization succeeded, false otherwise
23
+ */
24
+ export function lu_factor_linear_system(A, index, size) {
25
+ assert.isNonNegativeInteger(size,'size');
26
+
27
+ let i, j, k;
28
+ let maxI = 0;
29
+ let largest, temp1, temp2, sum;
30
+
31
+ const scale = size <= SCRATCH_SIZE ? scratch : new Float64Array(size);
32
+
33
+ // Loop over rows to get implicit scaling information
34
+ //
35
+ for (i = 0; i < size; ++i) {
36
+ for (largest = 0.0, j = 0; j < size; ++j) {
37
+ if ((temp2 = Math.abs(A[j * size + i])) > largest) {
38
+ largest = temp2;
39
+ }
40
+ }
41
+
42
+ if (largest === 0.0) {
43
+ // Unable to factor linear system
44
+
45
+ return false;
46
+ }
47
+ scale[i] = 1.0 / largest;
48
+ }
49
+ //
50
+ // Loop over all columns using Crout's method
51
+ //
52
+ for (j = 0; j < size; ++j) {
53
+ const jOff = j * size;
54
+
55
+ for (i = 0; i < j; ++i) {
56
+ sum = A[jOff + i];
57
+ for (k = 0; k < i; ++k) {
58
+ sum -= A[k * size + i] * A[jOff + k];
59
+ }
60
+ A[jOff + i] = sum;
61
+ }
62
+ //
63
+ // Begin search for largest pivot element
64
+ //
65
+ for (largest = 0.0, i = j; i < size; ++i) {
66
+ sum = A[jOff + i];
67
+ for (k = 0; k < j; ++k) {
68
+ sum -= A[k * size + i] * A[jOff + k];
69
+ }
70
+ A[jOff + i] = sum;
71
+
72
+ if ((temp1 = scale[i] * Math.abs(sum)) >= largest) {
73
+ largest = temp1;
74
+ maxI = i;
75
+ }
76
+ }
77
+ //
78
+ // Check for row interchange
79
+ //
80
+ if (j !== maxI) {
81
+ for (k = 0; k < size; ++k) {
82
+ const kOff = k * size;
83
+ temp1 = A[kOff + maxI];
84
+ A[kOff + maxI] = A[kOff + j];
85
+ A[kOff + j] = temp1;
86
+ }
87
+ scale[maxI] = scale[j];
88
+ }
89
+ //
90
+ // Divide by pivot element and perform elimination
91
+ //
92
+ index[j] = maxI;
93
+
94
+ if (Math.abs(A[jOff + j]) <= SMALL_NUMBER) {
95
+ // Unable to factor linear system
96
+ return false;
97
+ }
98
+
99
+ if (j !== (size - 1)) {
100
+ temp1 = 1.0 / A[jOff + j];
101
+ for (i = j + 1; i < size; ++i) {
102
+ A[jOff + i] *= temp1;
103
+ }
104
+ }
105
+ }
106
+
107
+ return true;
108
+ }
@@ -5,7 +5,7 @@
5
5
  * Note that A=LU and index[] are generated from method LUFactorLinearSystem.
6
6
  * Also, solution vector is written directly over input load vector.
7
7
  *
8
- * @param {number[]} A Square matrix (flattened)
8
+ * @param {number[]} A Square matrix, column-major flat layout (pre-factored LU as produced by lu_factor_linear_system)
9
9
  * @param {number[]|Uint32Array} index
10
10
  * @param {number[]} x Load vector
11
11
  * @param {number} size matrix size ( 4x4 matrix has size 4)
@@ -1,53 +1,53 @@
1
- import { assert } from "../../assert.js";
2
-
3
- /**
4
- * Assumes the system is factorized already. Use {@link lu_factor_linear_system} before if it isn't
5
- * Solve linear equations Ax = b using LU decomposition A = LU where L is lower triangular matrix and U is upper triangular matrix.
6
- * Input is factored matrix A=LU, integer array of pivot indices index[0->n-1], load vector x[0->n-1], and size of square matrix n.
7
- * Note that A=LU and index[] are generated from method LUFactorLinearSystem.
8
- * Also, solution vector is written directly over input load vector.
9
- *
10
- * @param {number[]} A Square matrix (flattened)
11
- * @param {number[]|Uint32Array} index
12
- * @param {number[]} x Load vector
13
- * @param {number} size matrix size ( 4x4 matrix has size 4)
14
- */
15
- export function lu_solve_linear_system(A, index, x, size) {
16
- assert.isNonNegativeInteger(size, 'size');
17
-
18
- let i = 0, j, ii = -1;
19
-
20
- let sum;
21
-
22
- // Proceed with forward and back-substitution for L and U matrices.
23
-
24
- // First, forward substitution.
25
- for (; i < size; ++i) {
26
- const idx = index[i];
27
- sum = x[idx];
28
- x[idx] = x[i];
29
-
30
- if (ii >= 0) {
31
-
32
- for (j = ii; j <= i - 1; ++j) {
33
- sum -= A[i * size + j] * x[j];
34
- }
35
-
36
- } else if (sum !== 0.0) {
37
- ii = i;
38
- }
39
-
40
- x[i] = sum;
41
- }
42
-
43
- // Now, back substitution
44
- for (i = size - 1; i >= 0; i--) {
45
- sum = x[i];
46
-
47
- for (j = i + 1; j < size; ++j) {
48
- sum -= A[i * size + j] * x[j];
49
- }
50
-
51
- x[i] = sum / A[i * size + i];
52
- }
53
- }
1
+ import { assert } from "../../assert.js";
2
+
3
+ /**
4
+ * Assumes the system is factorized already. Use {@link lu_factor_linear_system} before if it isn't
5
+ * Solve linear equations Ax = b using LU decomposition A = LU where L is lower triangular matrix and U is upper triangular matrix.
6
+ * Input is factored matrix A=LU, integer array of pivot indices index[0->n-1], load vector x[0->n-1], and size of square matrix n.
7
+ * Note that A=LU and index[] are generated from method LUFactorLinearSystem.
8
+ * Also, solution vector is written directly over input load vector.
9
+ *
10
+ * @param {number[]} A Square matrix, column-major flat layout (pre-factored LU as produced by lu_factor_linear_system)
11
+ * @param {number[]|Uint32Array} index
12
+ * @param {number[]} x Load vector
13
+ * @param {number} size matrix size ( 4x4 matrix has size 4)
14
+ */
15
+ export function lu_solve_linear_system(A, index, x, size) {
16
+ assert.isNonNegativeInteger(size, 'size');
17
+
18
+ let i = 0, j, ii = -1;
19
+
20
+ let sum;
21
+
22
+ // Proceed with forward and back-substitution for L and U matrices.
23
+
24
+ // First, forward substitution.
25
+ for (; i < size; ++i) {
26
+ const idx = index[i];
27
+ sum = x[idx];
28
+ x[idx] = x[i];
29
+
30
+ if (ii >= 0) {
31
+
32
+ for (j = ii; j <= i - 1; ++j) {
33
+ sum -= A[j * size + i] * x[j];
34
+ }
35
+
36
+ } else if (sum !== 0.0) {
37
+ ii = i;
38
+ }
39
+
40
+ x[i] = sum;
41
+ }
42
+
43
+ // Now, back substitution
44
+ for (i = size - 1; i >= 0; i--) {
45
+ sum = x[i];
46
+
47
+ for (j = i + 1; j < size; ++j) {
48
+ sum -= A[j * size + i] * x[j];
49
+ }
50
+
51
+ x[i] = sum / A[i * size + i];
52
+ }
53
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Adds polynomial `a` into `target` in place.
3
+ *
4
+ * target(x) := target(x) + a(x)
5
+ *
6
+ * Coefficient layout: index i is the coefficient of x^i (ascending). If
7
+ * `a_len > target_len`, the excess coefficients in `target` at indices
8
+ * [target_len, a_len) are first cleared to zero, so the returned length
9
+ * (max of the two input lengths) reflects valid coefficients.
10
+ *
11
+ * @param {number[]|Float64Array|Float32Array} target receives the sum, length >= max(target_len, a_len)
12
+ * @param {number} target_len current number of coefficients in target
13
+ * @param {number[]|Float64Array|Float32Array} a
14
+ * @param {number} a_len number of coefficients in a
15
+ * @returns {number} new logical length of target = max(target_len, a_len)
16
+ */
17
+ export function polynomial_add_into(target: number[] | Float64Array | Float32Array, target_len: number, a: number[] | Float64Array | Float32Array, a_len: number): number;
18
+ //# sourceMappingURL=polynomial_add_into.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"polynomial_add_into.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/linalg/polynomial_add_into.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,4CANW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,cAClC,MAAM,KACN,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,SAClC,MAAM,GACJ,MAAM,CAclB"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Adds polynomial `a` into `target` in place.
3
+ *
4
+ * target(x) := target(x) + a(x)
5
+ *
6
+ * Coefficient layout: index i is the coefficient of x^i (ascending). If
7
+ * `a_len > target_len`, the excess coefficients in `target` at indices
8
+ * [target_len, a_len) are first cleared to zero, so the returned length
9
+ * (max of the two input lengths) reflects valid coefficients.
10
+ *
11
+ * @param {number[]|Float64Array|Float32Array} target receives the sum, length >= max(target_len, a_len)
12
+ * @param {number} target_len current number of coefficients in target
13
+ * @param {number[]|Float64Array|Float32Array} a
14
+ * @param {number} a_len number of coefficients in a
15
+ * @returns {number} new logical length of target = max(target_len, a_len)
16
+ */
17
+ export function polynomial_add_into(target, target_len, a, a_len) {
18
+ const n = a_len > target_len ? a_len : target_len;
19
+
20
+ for (let i = target_len; i < n; i++) {
21
+ target[i] = 0;
22
+ }
23
+
24
+ for (let i = 0; i < a_len; i++) {
25
+ target[i] += a[i];
26
+ }
27
+
28
+ return n;
29
+ }
@@ -14,6 +14,11 @@
14
14
  * @param {Float64Array|number[]} roots_re real parts, length ≥ offset + degree
15
15
  * @param {Float64Array|number[]} roots_im imaginary parts, length ≥ offset + degree
16
16
  * @param {number} offset
17
+ * @param {number} [max_iterations=80] outer iteration cap. Lower values
18
+ * trade worst-case convergence accuracy for speed; the per-iteration
19
+ * convergence check still fires early in the common case. A low cap
20
+ * (~24-32) is appropriate for well-conditioned low-degree polynomials
21
+ * where Aberth typically converges in 15-25 iterations.
17
22
  */
18
- export function polynomial_complex_roots_aberth_ehrlich(coeffs: Float64Array | number[], degree: number, roots_re: Float64Array | number[], roots_im: Float64Array | number[], offset: number): void;
23
+ export function polynomial_complex_roots_aberth_ehrlich(coeffs: Float64Array | number[], degree: number, roots_re: Float64Array | number[], roots_im: Float64Array | number[], offset: number, max_iterations?: number): void;
19
24
  //# sourceMappingURL=polynomial_complex_roots_aberth_ehrlich.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"polynomial_complex_roots_aberth_ehrlich.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.js"],"names":[],"mappings":"AA6DA;;;;;;;;;;;;;;;;GAgBG;AACH,gEANW,YAAY,GAAC,MAAM,EAAE,UACrB,MAAM,YACN,YAAY,GAAC,MAAM,EAAE,YACrB,YAAY,GAAC,MAAM,EAAE,UACrB,MAAM,QAoFhB"}
1
+ {"version":3,"file":"polynomial_complex_roots_aberth_ehrlich.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.js"],"names":[],"mappings":"AA8BA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,gEAXW,YAAY,GAAC,MAAM,EAAE,UACrB,MAAM,YACN,YAAY,GAAC,MAAM,EAAE,YACrB,YAAY,GAAC,MAAM,EAAE,UACrB,MAAM,mBACN,MAAM,QAgHhB"}