@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 @@
1
+ {"version":3,"file":"cubic_residual_times_derivative_accumulate.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/linalg/cubic_residual_times_derivative_accumulate.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wEALW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,UAClC,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,QAClC,MAAM,UACN,MAAM,QAoBhB"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Accumulates the quintic `(p(t) - offset) * p'(t)` into `out_quintic`,
3
+ * where `p` is the cubic stored at `coeffs[base..base+3]`:
4
+ *
5
+ * p(t) = coeffs[base] + coeffs[base+1]·t + coeffs[base+2]·t² + coeffs[base+3]·t³
6
+ * p'(t) = coeffs[base+1] + 2·coeffs[base+2]·t + 3·coeffs[base+3]·t²
7
+ *
8
+ * Up to a constant factor of 2, the accumulated polynomial is the derivative
9
+ * of `(p(t) - offset)²`. Summed across "dimensions" (multiple calls with
10
+ * different `(base, offset)` pairs), the resulting quintic's real roots in
11
+ * [0, 1] are the candidate parameter values where the squared distance from
12
+ * the cubic curve `t → (p_0(t), p_1(t), ...)` to a fixed point
13
+ * `(offset_0, offset_1, ...)` is stationary. The factor of 2 is dropped
14
+ * because it does not affect root locations.
15
+ *
16
+ * `out_quintic` must have length ≥ 6. Entries are read-modify-written; the
17
+ * caller is responsible for zeroing the buffer before the first call in a
18
+ * given accumulation.
19
+ *
20
+ * @param {number[]|Float64Array|Float32Array} out_quintic length ≥ 6; receives the running sum
21
+ * @param {number[]|Float64Array|Float32Array} coeffs cubic coefficients laid out at base..base+3
22
+ * @param {number} base index of the constant term of the cubic in `coeffs`
23
+ * @param {number} offset value to subtract from the constant term before forming (p - offset)·p'
24
+ */
25
+ export function cubic_residual_times_derivative_accumulate(out_quintic, coeffs, base, offset) {
26
+ const a0 = coeffs[base] - offset;
27
+ const a1 = coeffs[base + 1];
28
+ const a2 = coeffs[base + 2];
29
+ const a3 = coeffs[base + 3];
30
+
31
+ // p'(t) coefficients: e0 + e1*t + e2*t^2 = a1 + 2*a2*t + 3*a3*t^2
32
+ const e0 = a1;
33
+ const e1 = 2 * a2;
34
+ const e2 = 3 * a3;
35
+
36
+ // (a0 + a1 t + a2 t² + a3 t³) · (e0 + e1 t + e2 t²) accumulated coefficient by coefficient
37
+ out_quintic[0] += a0 * e0;
38
+ out_quintic[1] += a0 * e1 + a1 * e0;
39
+ out_quintic[2] += a0 * e2 + a1 * e1 + a2 * e0;
40
+ out_quintic[3] += a1 * e2 + a2 * e1 + a3 * e0;
41
+ out_quintic[4] += a2 * e2 + a3 * e1;
42
+ out_quintic[5] += a3 * e2;
43
+ }
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * list of eigen values square matrix (allow non-symmetric)
3
3
  * NOTE: Modifies input matrix
4
+ *
4
5
  * @template T extends ArrayLike<number>
5
6
  * @param {T} out
6
- * @param {SquareMatrix} mat
7
+ * @param {SquareMatrix} mat column-major; modified in place
7
8
  * @return {T}
8
9
  */
9
10
  export function matrix_eigenvalues_in_place<T>(out: T, mat: SquareMatrix): T;
@@ -1 +1 @@
1
- {"version":3,"file":"matrix_eigenvalues_in_place.d.ts","sourceRoot":"","sources":["../../../../../../src/core/math/linalg/eigen/matrix_eigenvalues_in_place.js"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,6EASC"}
1
+ {"version":3,"file":"matrix_eigenvalues_in_place.d.ts","sourceRoot":"","sources":["../../../../../../src/core/math/linalg/eigen/matrix_eigenvalues_in_place.js"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,6EASC"}
@@ -5,9 +5,10 @@ import { matrix_qr_in_place } from "./matrix_qr_in_place.js";
5
5
  /**
6
6
  * list of eigen values square matrix (allow non-symmetric)
7
7
  * NOTE: Modifies input matrix
8
+ *
8
9
  * @template T extends ArrayLike<number>
9
10
  * @param {T} out
10
- * @param {SquareMatrix} mat
11
+ * @param {SquareMatrix} mat column-major; modified in place
11
12
  * @return {T}
12
13
  */
13
14
  export function matrix_eigenvalues_in_place(out, mat) {
@@ -1,9 +1,15 @@
1
1
  /**
2
- * NxN matrix Householder reduction
3
- * Return subfunction to upper Hessenberg matrix by Householder transformation
2
+ * NxN matrix Householder reduction to upper Hessenberg form via similarity
3
+ * transformations. After this routine, `a[c*n + r] == 0` for every `r > c+1`
4
+ * — i.e. only the main diagonal and the first sub-diagonal carry nonzeros
5
+ * below the diagonal.
6
+ *
7
+ * Inner loops are arranged so the hot accesses stream one column at a time
8
+ * (contiguous in column-major).
9
+ *
4
10
  * @see http://www-in.aut.ac.jp/~minemura/pub/Csimu/C/QRmethod.html
5
- * @param {number[]} a
11
+ * @param {number[]|Float64Array} a Square matrix, column-major flat layout (a[j*n + i] = row i, col j); modified in place
6
12
  * @param {number} n
7
13
  */
8
- export function matrix_householder_in_place(a: number[], n: number): void;
14
+ export function matrix_householder_in_place(a: number[] | Float64Array, n: number): void;
9
15
  //# sourceMappingURL=matrix_householder_in_place.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"matrix_householder_in_place.d.ts","sourceRoot":"","sources":["../../../../../../src/core/math/linalg/eigen/matrix_householder_in_place.js"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,+CAHW,MAAM,EAAE,KACR,MAAM,QA0FhB"}
1
+ {"version":3,"file":"matrix_householder_in_place.d.ts","sourceRoot":"","sources":["../../../../../../src/core/math/linalg/eigen/matrix_householder_in_place.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,+CAHW,MAAM,EAAE,GAAC,YAAY,KACrB,MAAM,QA4GhB"}
@@ -1,98 +1,122 @@
1
- const EPSILON = 1e-10;
2
-
3
- /**
4
- * NxN matrix Householder reduction
5
- * Return subfunction to upper Hessenberg matrix by Householder transformation
6
- * @see http://www-in.aut.ac.jp/~minemura/pub/Csimu/C/QRmethod.html
7
- * @param {number[]} a
8
- * @param {number} n
9
- */
10
- export function matrix_householder_in_place(a, n) {
11
- const u = new Float64Array(n);
12
- const d = new Float64Array(n);
13
- const ds = new Float64Array(n);
14
-
15
- let i, j, k;
16
- let sum;
17
-
18
- for (k = 0; k <= n - 3; k++) {
19
-
20
- for (i = 0; i <= k; i++) {
21
- u[i] = 0;
22
- }
23
-
24
- for (i = k + 1; i < n; i++) {
25
- u[i] = a[n * i + k];
26
- }
27
-
28
- // Build transformation matrix H
29
- sum = 0.0;
30
-
31
- for (i = k + 1; i < n; i++) {
32
- sum = sum + u[i] * u[i];
33
- }
34
-
35
- if (sum < EPSILON * EPSILON) {
36
- // sub-column already zero — nothing to reduce at this k
37
- continue;
38
- }
39
-
40
- const u_k_1 = u[k + 1];
41
- const u_k_1_abs = Math.abs(u_k_1);
42
-
43
- // sigma = sign(u[k+1]) · ‖u‖. When u[k+1] = 0 the sign is arbitrary
44
- // (entries below are still nonzero by the `sum` check above), so pick
45
- // +‖u‖.
46
- const sigma = u_k_1_abs < EPSILON
47
- ? Math.sqrt(sum)
48
- : Math.sqrt(sum) * u_k_1 / u_k_1_abs;
49
-
50
- u[k + 1] += sigma;
51
-
52
- const v_norm = Math.sqrt(2.0 * sigma * u[k + 1]);
53
-
54
- for (i = k + 1; i < n; i++) {
55
- u[i] /= v_norm;
56
- }
57
-
58
- // Similarity transformation
59
- for (i = 0; i < n; i++) {
60
- d[i] = 0.0;
61
- ds[i] = 0.0;
62
- for (j = k + 1; j <= n - 1; j++) {
63
- const u_j = u[j];
64
-
65
- d[i] += a[n * i + j] * u_j;
66
- ds[i] += a[n * j + i] * u_j;
67
- }
68
- }
69
-
70
- let ud = 0.0;
71
- let uds = 0.0;
72
-
73
- for (i = k + 1; i < n; i++) {
74
- const u_i = u[i];
75
-
76
- ud += u_i * d[i];
77
- uds += u_i * ds[i];
78
- }
79
-
80
- for (i = 0; i < n; i++) {
81
- const u_i = u[i];
82
-
83
- d[i] = 2.0 * (d[i] - ud * u_i);
84
- ds[i] = 2.0 * (ds[i] - uds * u_i);
85
- }
86
-
87
- for (i = 0; i < n; i++) {
88
- const u_i = u[i];
89
- const d_i = d[i];
90
-
91
- const n_i = n * i;
92
-
93
- for (j = 0; j < n; j++) {
94
- a[n_i + j] -= u_i * ds[j] + d_i * u[j];
95
- }
96
- }
97
- }
98
- }
1
+ const EPSILON = 1e-10;
2
+
3
+ /**
4
+ * NxN matrix Householder reduction to upper Hessenberg form via similarity
5
+ * transformations. After this routine, `a[c*n + r] == 0` for every `r > c+1`
6
+ * i.e. only the main diagonal and the first sub-diagonal carry nonzeros
7
+ * below the diagonal.
8
+ *
9
+ * Inner loops are arranged so the hot accesses stream one column at a time
10
+ * (contiguous in column-major).
11
+ *
12
+ * @see http://www-in.aut.ac.jp/~minemura/pub/Csimu/C/QRmethod.html
13
+ * @param {number[]|Float64Array} a Square matrix, column-major flat layout (a[j*n + i] = row i, col j); modified in place
14
+ * @param {number} n
15
+ */
16
+ export function matrix_householder_in_place(a, n) {
17
+ const u = new Float64Array(n);
18
+ const d = new Float64Array(n);
19
+ const ds = new Float64Array(n);
20
+
21
+ let i, j, k;
22
+ let sum;
23
+
24
+ for (k = 0; k <= n - 3; k++) {
25
+
26
+ const kOff = k * n;
27
+
28
+ for (i = 0; i <= k; i++) {
29
+ u[i] = 0;
30
+ }
31
+
32
+ // Read the sub-diagonal of column k. With column-major storage, this
33
+ // is contiguous in memory.
34
+ for (i = k + 1; i < n; i++) {
35
+ u[i] = a[kOff + i];
36
+ }
37
+
38
+ // Build transformation vector
39
+ sum = 0.0;
40
+
41
+ for (i = k + 1; i < n; i++) {
42
+ sum = sum + u[i] * u[i];
43
+ }
44
+
45
+ if (sum < EPSILON * EPSILON) {
46
+ // sub-column already zero nothing to reduce at this k
47
+ continue;
48
+ }
49
+
50
+ const u_k_1 = u[k + 1];
51
+ const u_k_1_abs = Math.abs(u_k_1);
52
+
53
+ // sigma = sign(u[k+1]) · ‖u‖. When u[k+1] = 0 the sign is arbitrary
54
+ // (entries below are still nonzero by the `sum` check above), so pick
55
+ // +‖u‖.
56
+ const sigma = u_k_1_abs < EPSILON
57
+ ? Math.sqrt(sum)
58
+ : Math.sqrt(sum) * u_k_1 / u_k_1_abs;
59
+
60
+ u[k + 1] += sigma;
61
+
62
+ const v_norm = Math.sqrt(2.0 * sigma * u[k + 1]);
63
+
64
+ for (i = k + 1; i < n; i++) {
65
+ u[i] /= v_norm;
66
+ }
67
+
68
+ // Similarity transformation A := (I - 2uuᵀ) A (I - 2uuᵀ).
69
+ // Compute d = A u (matrix-vector with column-major: outer over j,
70
+ // inner over i streams one column at a time).
71
+ for (i = 0; i < n; i++) {
72
+ d[i] = 0.0;
73
+ }
74
+ for (j = k + 1; j < n; j++) {
75
+ const u_j = u[j];
76
+ const jOff = j * n;
77
+ for (i = 0; i < n; i++) {
78
+ d[i] += a[jOff + i] * u_j;
79
+ }
80
+ }
81
+
82
+ // Compute ds = Aᵀ u. In column-major, row i of Aᵀ is column i of A,
83
+ // which is contiguous starting at i*n. So the inner loop streams one
84
+ // column.
85
+ for (i = 0; i < n; i++) {
86
+ let s = 0.0;
87
+ const iOff = i * n;
88
+ for (j = k + 1; j < n; j++) {
89
+ s += a[iOff + j] * u[j];
90
+ }
91
+ ds[i] = s;
92
+ }
93
+
94
+ let ud = 0.0;
95
+ let uds = 0.0;
96
+
97
+ for (i = k + 1; i < n; i++) {
98
+ const u_i = u[i];
99
+
100
+ ud += u_i * d[i];
101
+ uds += u_i * ds[i];
102
+ }
103
+
104
+ for (i = 0; i < n; i++) {
105
+ const u_i = u[i];
106
+
107
+ d[i] = 2.0 * (d[i] - ud * u_i);
108
+ ds[i] = 2.0 * (ds[i] - uds * u_i);
109
+ }
110
+
111
+ // Outer-product update A -= u·dsᵀ + d·uᵀ. Walk one column j at a time
112
+ // (inner i is contiguous within column j).
113
+ for (j = 0; j < n; j++) {
114
+ const u_j = u[j];
115
+ const ds_j = ds[j];
116
+ const jOff = j * n;
117
+ for (i = 0; i < n; i++) {
118
+ a[jOff + i] -= u[i] * ds_j + d[i] * u_j;
119
+ }
120
+ }
121
+ }
122
+ }
@@ -8,8 +8,8 @@
8
8
  * on it indefinitely — only safe today for matrices with all-real eigenvalues.
9
9
  *
10
10
  * @see http://www-in.aut.ac.jp/~minemura/pub/Csimu/C/QRmethod.html
11
- * @param {number[]} a Square matrix
11
+ * @param {number[]|Float64Array} a Square matrix, column-major flat layout (a[j*n + i] = row i, col j); modified in place (R is left on the upper triangle)
12
12
  * @param {number} n size of the matrix in single dimension
13
13
  */
14
- export function matrix_qr_in_place(a: number[], n: number): void;
14
+ export function matrix_qr_in_place(a: number[] | Float64Array, n: number): void;
15
15
  //# sourceMappingURL=matrix_qr_in_place.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"matrix_qr_in_place.d.ts","sourceRoot":"","sources":["../../../../../../src/core/math/linalg/eigen/matrix_qr_in_place.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,sCAHW,MAAM,EAAE,KACR,MAAM,QA8GhB"}
1
+ {"version":3,"file":"matrix_qr_in_place.d.ts","sourceRoot":"","sources":["../../../../../../src/core/math/linalg/eigen/matrix_qr_in_place.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,sCAHW,MAAM,EAAE,GAAC,YAAY,KACrB,MAAM,QAkIhB"}
@@ -1,124 +1,144 @@
1
- const EPSILON = 1e-10;
2
-
3
- /**
4
- * Perform QR factorization in-place.
5
- * Subfunction that analyzes eigenvalues by QR decomposition.
6
- *
7
- * Single-shift Wilkinson iteration: deflates the trailing subdiagonal one row
8
- * at a time as it converges. A complex eigenvalue pair leaves a 2×2 trailing
9
- * block whose inner subdiagonal does not vanish, and this routine will spin
10
- * on it indefinitely — only safe today for matrices with all-real eigenvalues.
11
- *
12
- * @see http://www-in.aut.ac.jp/~minemura/pub/Csimu/C/QRmethod.html
13
- * @param {number[]} a Square matrix
14
- * @param {number} n size of the matrix in single dimension
15
- */
16
- export function matrix_qr_in_place(a, n) {
17
- const q = new Float64Array(n * n);
18
- const w = new Float64Array(n);
19
-
20
- let mu, wa, sinx, cosx, sum1, sum2;
21
- let m = n;
22
-
23
- let i, j, k;
24
-
25
- while (m > 1) {
26
- const a10_index = n * (m - 1) + m - 2;
27
-
28
- const a10 = a[a10_index];
29
-
30
- // Convergence test
31
- if (Math.abs(a10) < EPSILON) {
32
- m = m - 1;
33
- continue;
34
- }
35
-
36
- // Origin movement mu (compute Wilkinson's shift)
37
- const a00 = a[n * (m - 2) + m - 2];
38
- const a01 = a[n * (m - 2) + m - 1];
39
- const a11 = a[n * (m - 1) + m - 1];
40
-
41
- sum1 = a00 + a11;
42
- sum2 = a00 * a11 - a01 * a10;
43
-
44
- wa = sum1 * sum1 - 4.0 * sum2;
45
- if (wa < 0.0) {
46
- wa = 0.0;
47
- } else {
48
- wa = Math.sqrt(wa);
49
- }
50
-
51
- const lam1 = 0.5 * (sum1 + wa);
52
- const lam2 = sum2 / lam1;
53
-
54
- if (Math.abs(a11 - lam1) < Math.abs(a11 - lam2)) {
55
- mu = a11 - lam1;
56
- } else {
57
- mu = a11 - lam2;
58
- }
59
-
60
- for (i = 0; i < m; i++) {
61
- a[n * i + i] -= mu;
62
- }
63
-
64
- // QR decomposition, A becomes R
65
- for (i = 0; i < m * m; i++) {
66
- q[i] = 0.0;
67
- }
68
- for (i = 0; i < m; i++) {
69
- q[m * i + i] = 1.0;
70
- }
71
-
72
- for (i = 0; i < m - 1; i++) {
73
- sum1 = Math.sqrt(a[n * i + i] * a[n * i + i] + a[n * i + n + i] * a[n * i + n + i]);
74
-
75
- if (Math.abs(sum1) < EPSILON) {
76
- sinx = 0.0;
77
- cosx = 0.0;
78
- } else {
79
- sinx = a[n * i + n + i] / sum1;
80
- cosx = a[n * i + i] / sum1;
81
- }
82
-
83
- for (j = i + 1; j < m; j++) {
84
- sum2 = a[n * i + j] * cosx + a[n * i + n + j] * sinx;
85
- a[n * i + n + j] = -a[n * i + j] * sinx + a[n * i + n + j] * cosx;
86
- a[n * i + j] = sum2;
87
- }
88
-
89
- a[n * i + n + i] = 0.0;
90
- a[n * i + i] = sum1;
91
-
92
- for (j = 0; j < m; j++) {
93
- const m_j = m * j;
94
-
95
- sum2 = q[m_j + i] * cosx + q[m_j + i + 1] * sinx;
96
- q[m_j + i + 1] = -q[m_j + i] * sinx + q[m_j + i + 1] * cosx;
97
- q[m_j + i] = sum2;
98
- }
99
-
100
- }
101
-
102
- for (i = 0; i < m; i++) {
103
- const n_i = n * i;
104
-
105
- for (j = i; j < m; j++) {
106
- w[j] = a[n_i + j];
107
- }
108
-
109
- for (j = 0; j < m; j++) {
110
- sum1 = 0.0;
111
-
112
- for (k = i; k < m; k++) {
113
- sum1 += w[k] * q[m * k + j];
114
- }
115
-
116
- a[n_i + j] = sum1;
117
- }
118
- }
119
-
120
- for (i = 0; i < m; i++) {
121
- a[n * i + i] += mu;
122
- }
123
- }
124
- }
1
+ const EPSILON = 1e-10;
2
+
3
+ /**
4
+ * Perform QR factorization in-place.
5
+ * Subfunction that analyzes eigenvalues by QR decomposition.
6
+ *
7
+ * Single-shift Wilkinson iteration: deflates the trailing subdiagonal one row
8
+ * at a time as it converges. A complex eigenvalue pair leaves a 2×2 trailing
9
+ * block whose inner subdiagonal does not vanish, and this routine will spin
10
+ * on it indefinitely — only safe today for matrices with all-real eigenvalues.
11
+ *
12
+ * @see http://www-in.aut.ac.jp/~minemura/pub/Csimu/C/QRmethod.html
13
+ * @param {number[]|Float64Array} a Square matrix, column-major flat layout (a[j*n + i] = row i, col j); modified in place (R is left on the upper triangle)
14
+ * @param {number} n size of the matrix in single dimension
15
+ */
16
+ export function matrix_qr_in_place(a, n) {
17
+ const q = new Float64Array(n * n);
18
+ const w = new Float64Array(n);
19
+
20
+ let mu, wa, sinx, cosx, sum1, sum2;
21
+ let m = n;
22
+
23
+ let i, j, k;
24
+
25
+ while (m > 1) {
26
+ // a[m-1, m-2] in column-major: (m-2)*n + (m-1)
27
+ const a10_index = (m - 2) * n + (m - 1);
28
+
29
+ const a10 = a[a10_index];
30
+
31
+ // Convergence test
32
+ if (Math.abs(a10) < EPSILON) {
33
+ m = m - 1;
34
+ continue;
35
+ }
36
+
37
+ // Origin movement mu (compute Wilkinson's shift)
38
+ const a00 = a[(m - 2) * n + (m - 2)];
39
+ const a01 = a[(m - 1) * n + (m - 2)];
40
+ const a11 = a[(m - 1) * n + (m - 1)];
41
+
42
+ sum1 = a00 + a11;
43
+ sum2 = a00 * a11 - a01 * a10;
44
+
45
+ wa = sum1 * sum1 - 4.0 * sum2;
46
+ if (wa < 0.0) {
47
+ wa = 0.0;
48
+ } else {
49
+ wa = Math.sqrt(wa);
50
+ }
51
+
52
+ const lam1 = 0.5 * (sum1 + wa);
53
+ const lam2 = sum2 / lam1;
54
+
55
+ if (Math.abs(a11 - lam1) < Math.abs(a11 - lam2)) {
56
+ mu = a11 - lam1;
57
+ } else {
58
+ mu = a11 - lam2;
59
+ }
60
+
61
+ // Subtract mu from diagonal
62
+ for (i = 0; i < m; i++) {
63
+ a[i * n + i] -= mu;
64
+ }
65
+
66
+ // QR decomposition, A becomes R
67
+ for (i = 0; i < m * m; i++) {
68
+ q[i] = 0.0;
69
+ }
70
+ for (i = 0; i < m; i++) {
71
+ q[i * m + i] = 1.0;
72
+ }
73
+
74
+ for (i = 0; i < m - 1; i++) {
75
+ // diagonal a[i, i] at i*n + i; sub-diagonal a[i+1, i] at i*n + (i+1)
76
+ const diag = a[i * n + i];
77
+ const subdiag = a[i * n + i + 1];
78
+
79
+ sum1 = Math.sqrt(diag * diag + subdiag * subdiag);
80
+
81
+ if (Math.abs(sum1) < EPSILON) {
82
+ sinx = 0.0;
83
+ cosx = 0.0;
84
+ } else {
85
+ sinx = subdiag / sum1;
86
+ cosx = diag / sum1;
87
+ }
88
+
89
+ // Rotate rows i and i+1 of A for columns j > i. In column-major,
90
+ // those two row entries within column j live at adjacent offsets
91
+ // (j*n + i, j*n + i+1) — contiguous within each column.
92
+ for (j = i + 1; j < m; j++) {
93
+ const jOff = j * n;
94
+ const a_ij = a[jOff + i];
95
+ const a_i1j = a[jOff + i + 1];
96
+ sum2 = a_ij * cosx + a_i1j * sinx;
97
+ a[jOff + i + 1] = -a_ij * sinx + a_i1j * cosx;
98
+ a[jOff + i] = sum2;
99
+ }
100
+
101
+ a[i * n + i + 1] = 0.0;
102
+ a[i * n + i] = sum1;
103
+
104
+ // Accumulate the rotation into Q. In the original (row-major) the
105
+ // inner loop walked j over rows of q, touching (q[j, i], q[j, i+1])
106
+ // which is two columns of q. In column-major those columns are
107
+ // contiguous: i*m..i*m+m-1 and (i+1)*m..(i+1)*m+m-1.
108
+ const qiOff = i * m;
109
+ const qi1Off = (i + 1) * m;
110
+ for (j = 0; j < m; j++) {
111
+ const q_ji = q[qiOff + j];
112
+ const q_ji1 = q[qi1Off + j];
113
+ sum2 = q_ji * cosx + q_ji1 * sinx;
114
+ q[qi1Off + j] = -q_ji * sinx + q_ji1 * cosx;
115
+ q[qiOff + j] = sum2;
116
+ }
117
+ }
118
+
119
+ // A := R * Q. Cache row i of R into w (since R is upper-triangular
120
+ // we only need k >= i), then compute the new row i of A. With
121
+ // column-major a, reading row i is strided accept it; m is small.
122
+ for (i = 0; i < m; i++) {
123
+ for (j = i; j < m; j++) {
124
+ w[j] = a[j * n + i];
125
+ }
126
+
127
+ for (j = 0; j < m; j++) {
128
+ sum1 = 0.0;
129
+
130
+ const qjOff = j * m;
131
+ for (k = i; k < m; k++) {
132
+ sum1 += w[k] * q[qjOff + k];
133
+ }
134
+
135
+ a[j * n + i] = sum1;
136
+ }
137
+ }
138
+
139
+ // Add mu back to diagonal
140
+ for (i = 0; i < m; i++) {
141
+ a[i * n + i] += mu;
142
+ }
143
+ }
144
+ }
@@ -0,0 +1,22 @@
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: Float64Array | number[], row_j: Float64Array | number[], c: number, s: number, n: number): void;
22
+ //# sourceMappingURL=givens_apply_rows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"givens_apply_rows.d.ts","sourceRoot":"","sources":["../../../../../../src/core/math/linalg/givens/givens_apply_rows.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,yCANW,YAAY,GAAC,MAAM,EAAE,SACrB,YAAY,GAAC,MAAM,EAAE,KACrB,MAAM,KACN,MAAM,KACN,MAAM,QAShB"}