@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.
- package/package.json +1 -1
- package/src/core/geom/2d/aabb/aabb2_intersects_ray.d.ts.map +1 -1
- package/src/core/geom/2d/aabb/aabb2_intersects_ray.js +5 -7
- package/src/core/geom/2d/hash-grid/shg_query_elements_circle.d.ts.map +1 -1
- package/src/core/geom/2d/hash-grid/shg_query_elements_circle.js +2 -3
- package/src/core/geom/3d/aabb/aabb3_intersects_line_segment.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_intersects_line_segment.js +9 -11
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_circumsphere.js +6 -4
- package/src/core/geom/3d/topology/simplify/quadratic/Quadric3.d.ts.map +1 -1
- package/src/core/geom/3d/topology/simplify/quadratic/Quadric3.js +1 -2
- package/src/core/geom/Quaternion.d.ts +26 -39
- package/src/core/geom/Quaternion.d.ts.map +1 -1
- package/src/core/geom/Quaternion.js +124 -136
- package/src/core/geom/Vector2.d.ts +28 -14
- package/src/core/geom/Vector2.d.ts.map +1 -1
- package/src/core/geom/Vector2.js +114 -97
- package/src/core/geom/Vector3.d.ts +21 -34
- package/src/core/geom/Vector3.d.ts.map +1 -1
- package/src/core/geom/Vector3.js +131 -142
- package/src/core/geom/Vector4.d.ts +21 -30
- package/src/core/geom/Vector4.d.ts.map +1 -1
- package/src/core/geom/Vector4.js +80 -93
- package/src/core/geom/packing/computeBoundingSphereOfSpheres.d.ts.map +1 -1
- package/src/core/geom/packing/computeBoundingSphereOfSpheres.js +23 -6
- package/src/core/geom/packing/miniball/Miniball.d.ts.map +1 -1
- package/src/core/geom/packing/miniball/Miniball.js +4 -11
- package/src/core/geom/packing/miniball/Subspan.d.ts +14 -39
- package/src/core/geom/packing/miniball/Subspan.d.ts.map +1 -1
- package/src/core/geom/packing/miniball/Subspan.js +105 -158
- package/src/core/geom/packing/miniball/miniball_compute_quality.d.ts.map +1 -1
- package/src/core/geom/packing/miniball/miniball_compute_quality.js +2 -6
- package/src/core/geom/vec/vector_axpy.d.ts +12 -0
- package/src/core/geom/vec/vector_axpy.d.ts.map +1 -0
- package/src/core/geom/vec/vector_axpy.js +15 -0
- package/src/core/geom/vec/vector_axpy_offset.d.ts +17 -0
- package/src/core/geom/vec/vector_axpy_offset.d.ts.map +1 -0
- package/src/core/geom/vec/vector_axpy_offset.js +20 -0
- package/src/core/geom/vec/vector_dot_offset.d.ts +18 -0
- package/src/core/geom/vec/vector_dot_offset.d.ts.map +1 -0
- package/src/core/geom/vec/vector_dot_offset.js +25 -0
- package/src/core/math/complex/complex_horner_eval.d.ts +16 -0
- package/src/core/math/complex/complex_horner_eval.d.ts.map +1 -0
- package/src/core/math/complex/complex_horner_eval.js +31 -0
- package/src/core/math/fabsf.d.ts +2 -3
- package/src/core/math/fabsf.d.ts.map +1 -1
- package/src/core/math/fabsf.js +3 -5
- package/src/core/math/linalg/cubic_residual_times_derivative_accumulate.d.ts +26 -0
- package/src/core/math/linalg/cubic_residual_times_derivative_accumulate.d.ts.map +1 -0
- package/src/core/math/linalg/cubic_residual_times_derivative_accumulate.js +43 -0
- package/src/core/math/linalg/eigen/matrix_eigenvalues_in_place.d.ts +2 -1
- package/src/core/math/linalg/eigen/matrix_eigenvalues_in_place.d.ts.map +1 -1
- package/src/core/math/linalg/eigen/matrix_eigenvalues_in_place.js +2 -1
- package/src/core/math/linalg/eigen/matrix_householder_in_place.d.ts +10 -4
- package/src/core/math/linalg/eigen/matrix_householder_in_place.d.ts.map +1 -1
- package/src/core/math/linalg/eigen/matrix_householder_in_place.js +122 -98
- package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts +2 -2
- package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts.map +1 -1
- package/src/core/math/linalg/eigen/matrix_qr_in_place.js +144 -124
- package/src/core/math/linalg/givens/givens_apply_rows.d.ts +22 -0
- package/src/core/math/linalg/givens/givens_apply_rows.d.ts.map +1 -0
- package/src/core/math/linalg/givens/givens_apply_rows.js +28 -0
- package/src/core/math/linalg/givens/givens_apply_rows_offset.d.ts +24 -0
- package/src/core/math/linalg/givens/givens_apply_rows_offset.d.ts.map +1 -0
- package/src/core/math/linalg/givens/givens_apply_rows_offset.js +30 -0
- package/src/core/math/linalg/givens/givens_rotation_coefficients.d.ts +25 -0
- package/src/core/math/linalg/givens/givens_rotation_coefficients.d.ts.map +1 -0
- package/src/core/math/linalg/givens/givens_rotation_coefficients.js +39 -0
- package/src/core/math/linalg/lu_factor_linear_system.d.ts +1 -1
- package/src/core/math/linalg/lu_factor_linear_system.d.ts.map +1 -1
- package/src/core/math/linalg/lu_factor_linear_system.js +108 -117
- package/src/core/math/linalg/lu_solve_linear_system.d.ts +1 -1
- package/src/core/math/linalg/lu_solve_linear_system.js +53 -53
- package/src/core/math/linalg/polynomial_add_into.d.ts +18 -0
- package/src/core/math/linalg/polynomial_add_into.d.ts.map +1 -0
- package/src/core/math/linalg/polynomial_add_into.js +29 -0
- package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.d.ts +6 -1
- package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.d.ts.map +1 -1
- package/src/core/math/linalg/polynomial_complex_roots_aberth_ehrlich.js +48 -50
- package/src/core/math/linalg/polynomial_cubic_derivative_eval.d.ts +15 -0
- package/src/core/math/linalg/polynomial_cubic_derivative_eval.d.ts.map +1 -0
- package/src/core/math/linalg/polynomial_cubic_derivative_eval.js +16 -0
- package/src/core/math/linalg/polynomial_cubic_horner_eval.d.ts +18 -0
- package/src/core/math/linalg/polynomial_cubic_horner_eval.d.ts.map +1 -0
- package/src/core/math/linalg/polynomial_cubic_horner_eval.js +19 -0
- package/src/core/math/linalg/polynomial_cubic_second_derivative_eval.d.ts +13 -0
- package/src/core/math/linalg/polynomial_cubic_second_derivative_eval.d.ts.map +1 -0
- package/src/core/math/linalg/polynomial_cubic_second_derivative_eval.js +14 -0
- package/src/core/math/linalg/polynomial_multiply.d.ts +21 -0
- package/src/core/math/linalg/polynomial_multiply.d.ts.map +1 -0
- package/src/core/math/linalg/polynomial_multiply.js +41 -0
- package/src/core/math/linalg/polynomial_real_roots_in_interval.d.ts +6 -1
- package/src/core/math/linalg/polynomial_real_roots_in_interval.d.ts.map +1 -1
- package/src/core/math/linalg/polynomial_real_roots_in_interval.js +29 -18
- package/src/core/math/linalg/polynomial_root_bound_cauchy.d.ts +17 -0
- package/src/core/math/linalg/polynomial_root_bound_cauchy.d.ts.map +1 -0
- package/src/core/math/linalg/polynomial_root_bound_cauchy.js +30 -0
- package/src/core/math/linalg/polynomial_scale_into.d.ts +14 -0
- package/src/core/math/linalg/polynomial_scale_into.d.ts.map +1 -0
- package/src/core/math/linalg/polynomial_scale_into.js +17 -0
- package/src/core/math/linalg/polynomial_sub_into.d.ts +18 -0
- package/src/core/math/linalg/polynomial_sub_into.d.ts.map +1 -0
- package/src/core/math/linalg/polynomial_sub_into.js +29 -0
- package/src/core/math/linalg/solve_linear_system.d.ts +1 -1
- package/src/core/math/linalg/solve_linear_system.js +1 -1
- package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts +4 -4
- package/src/core/math/linalg/solve_linear_system_GEPP_2x2.d.ts.map +1 -1
- package/src/core/math/linalg/solve_linear_system_GEPP_2x2.js +96 -91
- package/src/core/math/solveQuadratic.d.ts +2 -2
- package/src/core/math/solveQuadratic.d.ts.map +1 -1
- package/src/core/math/solveQuadratic.js +1 -1
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite.d.ts +18 -10
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite.d.ts.map +1 -1
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite.js +18 -10
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.d.ts +13 -6
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.d.ts.map +1 -1
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_1d.js +16 -11
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.d.ts +25 -3
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.d.ts.map +1 -1
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_2d.js +97 -142
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_nd.d.ts +30 -4
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_nd.d.ts.map +1 -1
- package/src/core/math/spline/spline3_hermite_intersection_spline3_hermite_nd.js +188 -132
- package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.d.ts +7 -3
- package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.d.ts.map +1 -1
- package/src/core/math/spline/spline3_hermite_intersects_spline3_hermite.js +35 -6
- package/src/core/science/units/MEASUREMENT_UNITS_SCIENTIFIC.d.ts +17 -0
- package/src/core/science/units/MEASUREMENT_UNITS_SCIENTIFIC.d.ts.map +1 -0
- package/src/core/science/units/MEASUREMENT_UNITS_SCIENTIFIC.js +87 -0
- package/src/core/science/units/MEASUREMENT_UNITS_SI.d.ts +13 -0
- package/src/core/science/units/MEASUREMENT_UNITS_SI.d.ts.map +1 -0
- package/src/core/science/units/MEASUREMENT_UNITS_SI.js +28 -0
- package/src/core/science/units/NamedUnit.d.ts +38 -0
- package/src/core/science/units/NamedUnit.d.ts.map +1 -0
- package/src/core/science/units/NamedUnit.js +48 -0
- package/src/core/science/units/UNIT_DIMENSION_MAPPING.d.ts +14 -0
- package/src/core/science/units/UNIT_DIMENSION_MAPPING.d.ts.map +1 -0
- package/src/core/science/units/UNIT_DIMENSION_MAPPING.js +29 -0
- package/src/core/science/units/UnitDimension.d.ts +26 -0
- package/src/core/science/units/UnitDimension.d.ts.map +1 -0
- package/src/core/science/units/UnitDimension.js +28 -0
- package/src/core/science/units/UnitMatrix.d.ts +117 -0
- package/src/core/science/units/UnitMatrix.d.ts.map +1 -0
- package/src/core/science/units/UnitMatrix.js +251 -0
- package/src/core/science/units/format_quantity.d.ts +25 -0
- package/src/core/science/units/format_quantity.d.ts.map +1 -0
- package/src/core/science/units/format_quantity.js +74 -0
- package/src/core/science/units/magnitude_prefix.d.ts +57 -0
- package/src/core/science/units/magnitude_prefix.d.ts.map +1 -0
- package/src/core/science/units/magnitude_prefix.js +127 -0
- package/src/core/science/units/si/AMPERE.d.ts +7 -0
- package/src/core/science/units/si/AMPERE.d.ts.map +1 -0
- package/src/core/science/units/si/AMPERE.js +13 -0
- package/src/core/science/units/si/CANDELA.d.ts +7 -0
- package/src/core/science/units/si/CANDELA.d.ts.map +1 -0
- package/src/core/science/units/si/CANDELA.js +13 -0
- package/src/core/science/units/si/DIMENSIONLESS.d.ts +8 -0
- package/src/core/science/units/si/DIMENSIONLESS.d.ts.map +1 -0
- package/src/core/science/units/si/DIMENSIONLESS.js +14 -0
- package/src/core/science/units/si/KELVIN.d.ts +7 -0
- package/src/core/science/units/si/KELVIN.d.ts.map +1 -0
- package/src/core/science/units/si/KELVIN.js +13 -0
- package/src/core/science/units/si/KILOGRAM.d.ts +7 -0
- package/src/core/science/units/si/KILOGRAM.d.ts.map +1 -0
- package/src/core/science/units/si/KILOGRAM.js +13 -0
- package/src/core/science/units/si/METER.d.ts +7 -0
- package/src/core/science/units/si/METER.d.ts.map +1 -0
- package/src/core/science/units/si/METER.js +13 -0
- package/src/core/science/units/si/MOLE.d.ts +7 -0
- package/src/core/science/units/si/MOLE.d.ts.map +1 -0
- package/src/core/science/units/si/MOLE.js +13 -0
- package/src/core/science/units/si/SECOND.d.ts +7 -0
- package/src/core/science/units/si/SECOND.d.ts.map +1 -0
- package/src/core/science/units/si/SECOND.js +13 -0
- package/src/core/science/units/si/derived/BECQUEREL.d.ts +10 -0
- package/src/core/science/units/si/derived/BECQUEREL.d.ts.map +1 -0
- package/src/core/science/units/si/derived/BECQUEREL.js +16 -0
- package/src/core/science/units/si/derived/COULOMB.d.ts +7 -0
- package/src/core/science/units/si/derived/COULOMB.d.ts.map +1 -0
- package/src/core/science/units/si/derived/COULOMB.js +13 -0
- package/src/core/science/units/si/derived/FARAD.d.ts +7 -0
- package/src/core/science/units/si/derived/FARAD.d.ts.map +1 -0
- package/src/core/science/units/si/derived/FARAD.js +13 -0
- package/src/core/science/units/si/derived/GRAY.d.ts +10 -0
- package/src/core/science/units/si/derived/GRAY.d.ts.map +1 -0
- package/src/core/science/units/si/derived/GRAY.js +16 -0
- package/src/core/science/units/si/derived/HENRY.d.ts +7 -0
- package/src/core/science/units/si/derived/HENRY.d.ts.map +1 -0
- package/src/core/science/units/si/derived/HENRY.js +13 -0
- package/src/core/science/units/si/derived/HERTZ.d.ts +10 -0
- package/src/core/science/units/si/derived/HERTZ.d.ts.map +1 -0
- package/src/core/science/units/si/derived/HERTZ.js +16 -0
- package/src/core/science/units/si/derived/JOULE.d.ts +7 -0
- package/src/core/science/units/si/derived/JOULE.d.ts.map +1 -0
- package/src/core/science/units/si/derived/JOULE.js +13 -0
- package/src/core/science/units/si/derived/KATAL.d.ts +7 -0
- package/src/core/science/units/si/derived/KATAL.d.ts.map +1 -0
- package/src/core/science/units/si/derived/KATAL.js +13 -0
- package/src/core/science/units/si/derived/LUMEN.d.ts +8 -0
- package/src/core/science/units/si/derived/LUMEN.d.ts.map +1 -0
- package/src/core/science/units/si/derived/LUMEN.js +14 -0
- package/src/core/science/units/si/derived/LUX.d.ts +7 -0
- package/src/core/science/units/si/derived/LUX.d.ts.map +1 -0
- package/src/core/science/units/si/derived/LUX.js +13 -0
- package/src/core/science/units/si/derived/NEWTON.d.ts +7 -0
- package/src/core/science/units/si/derived/NEWTON.d.ts.map +1 -0
- package/src/core/science/units/si/derived/NEWTON.js +13 -0
- package/src/core/science/units/si/derived/OHM.d.ts +7 -0
- package/src/core/science/units/si/derived/OHM.d.ts.map +1 -0
- package/src/core/science/units/si/derived/OHM.js +13 -0
- package/src/core/science/units/si/derived/PASCAL.d.ts +7 -0
- package/src/core/science/units/si/derived/PASCAL.d.ts.map +1 -0
- package/src/core/science/units/si/derived/PASCAL.js +13 -0
- package/src/core/science/units/si/derived/SIEMENS.d.ts +7 -0
- package/src/core/science/units/si/derived/SIEMENS.d.ts.map +1 -0
- package/src/core/science/units/si/derived/SIEMENS.js +13 -0
- package/src/core/science/units/si/derived/SIEVERT.d.ts +10 -0
- package/src/core/science/units/si/derived/SIEVERT.d.ts.map +1 -0
- package/src/core/science/units/si/derived/SIEVERT.js +16 -0
- package/src/core/science/units/si/derived/TESLA.d.ts +7 -0
- package/src/core/science/units/si/derived/TESLA.d.ts.map +1 -0
- package/src/core/science/units/si/derived/TESLA.js +13 -0
- package/src/core/science/units/si/derived/VOLT.d.ts +7 -0
- package/src/core/science/units/si/derived/VOLT.d.ts.map +1 -0
- package/src/core/science/units/si/derived/VOLT.js +13 -0
- package/src/core/science/units/si/derived/WATT.d.ts +7 -0
- package/src/core/science/units/si/derived/WATT.d.ts.map +1 -0
- package/src/core/science/units/si/derived/WATT.js +13 -0
- package/src/core/science/units/si/derived/WEBER.d.ts +7 -0
- package/src/core/science/units/si/derived/WEBER.d.ts.map +1 -0
- package/src/core/science/units/si/derived/WEBER.js +13 -0
- package/src/core/science/units/unit_matrix_to_string.d.ts +29 -0
- package/src/core/science/units/unit_matrix_to_string.d.ts.map +1 -0
- package/src/core/science/units/unit_matrix_to_string.js +403 -0
- package/src/engine/graphics/geometry/MikkT/CalcTexArea.d.ts.map +1 -1
- package/src/engine/graphics/geometry/MikkT/CalcTexArea.js +1 -2
- package/src/engine/graphics/geometry/MikkT/InitTriInfo.d.ts.map +1 -1
- 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
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
u[k + 1]
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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,
|
|
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
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
for (j =
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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"}
|