@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
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
import { assert } from "../../../assert.js";
|
|
9
9
|
import { BitSet } from "../../../binary/BitSet.js";
|
|
10
|
+
import { BinaryDataType } from "../../../binary/type/BinaryDataType.js";
|
|
11
|
+
import { SquareMatrix } from "../../../math/matrix/SquareMatrix.js";
|
|
12
|
+
import { vector_dot_offset } from "../../vec/vector_dot_offset.js";
|
|
13
|
+
import { vector_axpy_offset } from "../../vec/vector_axpy_offset.js";
|
|
14
|
+
import { givens_rotation_coefficients } from "../../../math/linalg/givens/givens_rotation_coefficients.js";
|
|
15
|
+
import { givens_apply_rows_offset } from "../../../math/linalg/givens/givens_apply_rows_offset.js";
|
|
10
16
|
|
|
11
17
|
export class Subspan {
|
|
12
18
|
/**
|
|
@@ -44,58 +50,42 @@ export class Subspan {
|
|
|
44
50
|
this.members = new Int32Array(dim + 1);
|
|
45
51
|
|
|
46
52
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
R[i] = new Array(dim);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// initialize Q vector
|
|
56
|
-
for (let i = 0; i < dim; i++) {
|
|
57
|
-
for (let j = 0; j < dim; j++) {
|
|
58
|
-
// set diagonal to 1
|
|
59
|
-
Q[j][i] = (i === j) ? 1.0 : 0.0;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
53
|
+
// Q and R are dim x dim, column-major (per SquareMatrix). The k-th
|
|
54
|
+
// column lives contiguously at offsets [k*dim, (k+1)*dim). Inner
|
|
55
|
+
// loops index the flat .data buffer directly with offset arithmetic
|
|
56
|
+
// rather than going through subarray views — see vector_dot_offset
|
|
57
|
+
// and friends.
|
|
63
58
|
/**
|
|
64
|
-
*
|
|
65
|
-
* @type {number[][]}
|
|
59
|
+
* @type {SquareMatrix}
|
|
66
60
|
*/
|
|
67
|
-
this.Q =
|
|
61
|
+
this.Q = new SquareMatrix(dim, BinaryDataType.Float64);
|
|
62
|
+
this.Q.eye();
|
|
68
63
|
|
|
69
64
|
/**
|
|
70
|
-
*
|
|
71
|
-
* @type {number[][]}
|
|
65
|
+
* @type {SquareMatrix}
|
|
72
66
|
*/
|
|
73
|
-
this.R =
|
|
67
|
+
this.R = new SquareMatrix(dim, BinaryDataType.Float64);
|
|
74
68
|
|
|
75
69
|
/**
|
|
76
70
|
* D sized vector
|
|
77
|
-
* @type {
|
|
71
|
+
* @type {Float64Array}
|
|
78
72
|
*/
|
|
79
|
-
this.u = new
|
|
73
|
+
this.u = new Float64Array(dim);
|
|
80
74
|
/**
|
|
81
75
|
* D sized vector
|
|
82
|
-
* @type {
|
|
76
|
+
* @type {Float64Array}
|
|
83
77
|
*/
|
|
84
|
-
this.w = new
|
|
78
|
+
this.w = new Float64Array(dim);
|
|
85
79
|
|
|
86
80
|
this.r = 0;
|
|
87
81
|
|
|
88
82
|
/**
|
|
89
|
-
* Givens
|
|
90
|
-
*
|
|
83
|
+
* Givens rotation coefficients scratch: cs[0] = c, cs[1] = s.
|
|
84
|
+
* Holding this as an instance field avoids per-call allocation of a
|
|
85
|
+
* fresh 2-element array — see givens_rotation_coefficients's contract.
|
|
86
|
+
* @type {Float64Array}
|
|
91
87
|
*/
|
|
92
|
-
this.
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Givens S coefficient
|
|
96
|
-
* @type {number}
|
|
97
|
-
*/
|
|
98
|
-
this.s = 0;
|
|
88
|
+
this.cs = new Float64Array(2);
|
|
99
89
|
|
|
100
90
|
|
|
101
91
|
this.membership.set(k, true);
|
|
@@ -183,41 +173,6 @@ export class Subspan {
|
|
|
183
173
|
return this.members[this.r];
|
|
184
174
|
}
|
|
185
175
|
|
|
186
|
-
/**
|
|
187
|
-
* Determine the Givens coefficients <i>(c,s)</i> satisfying
|
|
188
|
-
*
|
|
189
|
-
* <pre>
|
|
190
|
-
* c * a + s * b = +/- (a^2 + b^2) c * b - s * a = 0
|
|
191
|
-
* </pre>
|
|
192
|
-
*
|
|
193
|
-
* We don't care about the signs here, for efficiency, so make sure not to rely on them anywhere.
|
|
194
|
-
*
|
|
195
|
-
* <i>Source:</i> "Matrix Computations" (2nd edition) by Gene H. B. Golub & Charles F. B. Van Loan
|
|
196
|
-
* (Johns Hopkins University Press, 1989), p. 216.
|
|
197
|
-
*
|
|
198
|
-
* Note that the code of this class sometimes does not call this method but only mentions it in a
|
|
199
|
-
* comment. The reason for this is performance; Java does not allow an efficient way of returning
|
|
200
|
-
* a pair of doubles, so we sometimes manually "inline" `givens()` for the sake of
|
|
201
|
-
* performance.
|
|
202
|
-
* @param {number} a
|
|
203
|
-
* @param {number} b
|
|
204
|
-
* @private
|
|
205
|
-
*/
|
|
206
|
-
givens(a, b) {
|
|
207
|
-
if (b === 0.0) {
|
|
208
|
-
this.c = 1.0;
|
|
209
|
-
this.s = 0.0;
|
|
210
|
-
} else if (Math.abs(b) > Math.abs(a)) {
|
|
211
|
-
const t = a / b;
|
|
212
|
-
this.s = 1 / Math.sqrt(1 + t * t);
|
|
213
|
-
this.c = this.s * t;
|
|
214
|
-
} else {
|
|
215
|
-
const t = b / a;
|
|
216
|
-
this.c = 1 / Math.sqrt(1 + t * t);
|
|
217
|
-
this.s = this.c * t;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
176
|
/**
|
|
222
177
|
* Appends the new column <i>u</i> (which is a member field of this instance) to the right of <i>A
|
|
223
178
|
* = QR</i>, updating <i>Q</i> and <i>R</i>. It assumes <i>r</i> to still be the old value, i.e.,
|
|
@@ -228,30 +183,28 @@ export class Subspan {
|
|
|
228
183
|
* @private
|
|
229
184
|
*/
|
|
230
185
|
appendColumn() {
|
|
231
|
-
const R = this.R;
|
|
232
|
-
const Q = this.Q;
|
|
233
|
-
|
|
234
186
|
const dim = this.dim;
|
|
235
187
|
|
|
188
|
+
const u = this.u;
|
|
189
|
+
const Q = this.Q.data;
|
|
190
|
+
const R = this.R.data;
|
|
191
|
+
const cs = this.cs;
|
|
192
|
+
|
|
193
|
+
const rOff = this.r * dim;
|
|
194
|
+
|
|
236
195
|
for (let i = 0; i < dim; ++i) {
|
|
237
|
-
R[
|
|
238
|
-
for (let k = 0; k < dim; ++k) {
|
|
239
|
-
R[this.r][i] += Q[i][k] * this.u[k];
|
|
240
|
-
}
|
|
196
|
+
R[rOff + i] = vector_dot_offset(Q, i * dim, u, 0, dim);
|
|
241
197
|
}
|
|
242
198
|
|
|
243
199
|
for (let j = dim - 1; j > this.r; --j) {
|
|
244
200
|
|
|
245
|
-
|
|
246
|
-
|
|
201
|
+
givens_rotation_coefficients(R[rOff + j - 1], R[rOff + j], cs);
|
|
202
|
+
const c = cs[0];
|
|
203
|
+
const s = cs[1];
|
|
247
204
|
|
|
248
|
-
|
|
249
|
-
let a = Q[j - 1][i];
|
|
250
|
-
let b = Q[j][i];
|
|
251
|
-
Q[j - 1][i] = this.c * a + this.s * b;
|
|
252
|
-
Q[j][i] = this.c * b - this.s * a;
|
|
253
|
-
}
|
|
205
|
+
R[rOff + j - 1] = c * R[rOff + j - 1] + s * R[rOff + j];
|
|
254
206
|
|
|
207
|
+
givens_apply_rows_offset(Q, (j - 1) * dim, j * dim, c, s, dim);
|
|
255
208
|
}
|
|
256
209
|
|
|
257
210
|
}
|
|
@@ -310,32 +263,21 @@ export class Subspan {
|
|
|
310
263
|
w[i] = S.coord(o, i) - p[i];
|
|
311
264
|
}
|
|
312
265
|
|
|
313
|
-
const Q = this.Q;
|
|
266
|
+
const Q = this.Q.data;
|
|
314
267
|
|
|
315
268
|
const r = this.r;
|
|
316
269
|
|
|
317
270
|
for (let j = 0; j < r; ++j) {
|
|
318
|
-
let scale = 0;
|
|
319
271
|
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
for (let i = 0; i < dim; ++i) {
|
|
323
|
-
scale += w[i] * QJ[i];
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
for (let i = 0; i < dim; ++i) {
|
|
327
|
-
w[i] -= scale * QJ[i];
|
|
328
|
-
}
|
|
272
|
+
const qOff = j * dim;
|
|
329
273
|
|
|
330
|
-
|
|
274
|
+
const scale = vector_dot_offset(w, 0, Q, qOff, dim);
|
|
331
275
|
|
|
332
|
-
|
|
276
|
+
vector_axpy_offset(w, 0, -scale, Q, qOff, dim);
|
|
333
277
|
|
|
334
|
-
for (let i = 0; i < dim; ++i) {
|
|
335
|
-
sl += w[i] * w[i];
|
|
336
278
|
}
|
|
337
279
|
|
|
338
|
-
return
|
|
280
|
+
return vector_dot_offset(w, 0, w, 0, dim);
|
|
339
281
|
}
|
|
340
282
|
|
|
341
283
|
/**
|
|
@@ -413,32 +355,32 @@ export class Subspan {
|
|
|
413
355
|
}
|
|
414
356
|
|
|
415
357
|
const w = this.w;
|
|
416
|
-
const Q = this.Q;
|
|
358
|
+
const Q = this.Q.data;
|
|
417
359
|
|
|
418
360
|
for (let i = 0; i < dim; ++i) {
|
|
419
|
-
w[i] = 0;
|
|
420
|
-
for (let k = 0; k < dim; ++k) {
|
|
421
|
-
w[i] += Q[i][k] * u[k];
|
|
422
|
-
}
|
|
361
|
+
w[i] = vector_dot_offset(Q, i * dim, u, 0, dim);
|
|
423
362
|
}
|
|
424
363
|
|
|
425
364
|
let origin_lambda = 1;
|
|
426
365
|
|
|
427
|
-
const R = this.R;
|
|
366
|
+
const R = this.R.data;
|
|
367
|
+
const r = this.r;
|
|
368
|
+
|
|
369
|
+
for (let j = r - 1; j >= 0; --j) {
|
|
428
370
|
|
|
429
|
-
|
|
371
|
+
const jjOff = j * dim;
|
|
430
372
|
|
|
431
|
-
for (let k = j + 1; k <
|
|
432
|
-
w[j] -= lambdas[k] * R[k
|
|
373
|
+
for (let k = j + 1; k < r; ++k) {
|
|
374
|
+
w[j] -= lambdas[k] * R[k * dim + j];
|
|
433
375
|
}
|
|
434
376
|
|
|
435
|
-
const lj = w[j] / R[j]
|
|
377
|
+
const lj = w[j] / R[jjOff + j];
|
|
436
378
|
|
|
437
379
|
lambdas[j] = lj;
|
|
438
380
|
origin_lambda -= lj;
|
|
439
381
|
}
|
|
440
382
|
|
|
441
|
-
lambdas[
|
|
383
|
+
lambdas[r] = origin_lambda;
|
|
442
384
|
}
|
|
443
385
|
|
|
444
386
|
/**
|
|
@@ -451,34 +393,34 @@ export class Subspan {
|
|
|
451
393
|
|
|
452
394
|
let cursor = pos;
|
|
453
395
|
|
|
454
|
-
const R = this.R;
|
|
455
|
-
const Q = this.Q;
|
|
396
|
+
const R = this.R.data;
|
|
397
|
+
const Q = this.Q.data;
|
|
456
398
|
|
|
457
399
|
const dim = this.dim;
|
|
400
|
+
const cs = this.cs;
|
|
401
|
+
const r = this.r;
|
|
458
402
|
|
|
459
|
-
for (; cursor <
|
|
460
|
-
|
|
461
|
-
this.givens(R[cursor][cursor], R[cursor][cursor + 1]);
|
|
462
|
-
R[cursor][cursor] = this.c * R[cursor][cursor] + this.s * R[cursor][cursor + 1];
|
|
403
|
+
for (; cursor < r; ++cursor) {
|
|
463
404
|
|
|
464
|
-
|
|
405
|
+
const cOff = cursor * dim;
|
|
465
406
|
|
|
466
|
-
|
|
467
|
-
|
|
407
|
+
givens_rotation_coefficients(R[cOff + cursor], R[cOff + cursor + 1], cs);
|
|
408
|
+
const c = cs[0];
|
|
409
|
+
const s = cs[1];
|
|
468
410
|
|
|
469
|
-
|
|
470
|
-
R[j][cursor + 1] = this.c * b - this.s * a;
|
|
471
|
-
}
|
|
411
|
+
R[cOff + cursor] = c * R[cOff + cursor] + s * R[cOff + cursor + 1];
|
|
472
412
|
|
|
473
|
-
for (let
|
|
413
|
+
for (let j = cursor + 1; j < r; ++j) {
|
|
474
414
|
|
|
475
|
-
const
|
|
476
|
-
const
|
|
415
|
+
const jOff = j * dim;
|
|
416
|
+
const a = R[jOff + cursor];
|
|
417
|
+
const b = R[jOff + cursor + 1];
|
|
477
418
|
|
|
478
|
-
|
|
479
|
-
|
|
419
|
+
R[jOff + cursor] = c * a + s * b;
|
|
420
|
+
R[jOff + cursor + 1] = c * b - s * a;
|
|
480
421
|
}
|
|
481
422
|
|
|
423
|
+
givens_apply_rows_offset(Q, cOff, cOff + dim, c, s, dim);
|
|
482
424
|
}
|
|
483
425
|
|
|
484
426
|
}
|
|
@@ -497,42 +439,41 @@ export class Subspan {
|
|
|
497
439
|
const w = this.w;
|
|
498
440
|
const u = this.u;
|
|
499
441
|
|
|
500
|
-
const Q = this.Q;
|
|
501
|
-
const R = this.R;
|
|
442
|
+
const Q = this.Q.data;
|
|
443
|
+
const R = this.R.data;
|
|
444
|
+
const cs = this.cs;
|
|
445
|
+
const r = this.r;
|
|
502
446
|
|
|
503
447
|
for (let i = 0; i < dim; ++i) {
|
|
504
|
-
w[i] = 0;
|
|
505
|
-
|
|
506
|
-
for (let k = 0; k < dim; ++k) {
|
|
507
|
-
w[i] += Q[i][k] * u[k];
|
|
508
|
-
}
|
|
448
|
+
w[i] = vector_dot_offset(Q, i * dim, u, 0, dim);
|
|
509
449
|
}
|
|
510
450
|
|
|
511
451
|
for (let k = dim - 1; k > 0; --k) {
|
|
512
452
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
R[k - 1][k - 1] *= this.c;
|
|
453
|
+
givens_rotation_coefficients(w[k - 1], w[k], cs);
|
|
454
|
+
const c = cs[0];
|
|
455
|
+
const s = cs[1];
|
|
517
456
|
|
|
518
|
-
|
|
519
|
-
const a = R[j][k - 1];
|
|
520
|
-
const b = R[j][k];
|
|
521
|
-
R[j][k - 1] = this.c * a + this.s * b;
|
|
522
|
-
R[j][k] = this.c * b - this.s * a;
|
|
523
|
-
}
|
|
457
|
+
w[k - 1] = c * w[k - 1] + s * w[k];
|
|
524
458
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
459
|
+
const prevOff = (k - 1) * dim;
|
|
460
|
+
R[prevOff + k] = -s * R[prevOff + k - 1];
|
|
461
|
+
R[prevOff + k - 1] *= c;
|
|
462
|
+
|
|
463
|
+
for (let j = k; j < r; ++j) {
|
|
464
|
+
const jOff = j * dim;
|
|
465
|
+
const a = R[jOff + k - 1];
|
|
466
|
+
const b = R[jOff + k];
|
|
467
|
+
R[jOff + k - 1] = c * a + s * b;
|
|
468
|
+
R[jOff + k] = c * b - s * a;
|
|
530
469
|
}
|
|
531
470
|
|
|
471
|
+
givens_apply_rows_offset(Q, prevOff, prevOff + dim, c, s, dim);
|
|
532
472
|
}
|
|
533
473
|
|
|
534
|
-
|
|
535
|
-
|
|
474
|
+
const w0 = w[0];
|
|
475
|
+
for (let j = 0; j < r; ++j) {
|
|
476
|
+
R[j * dim] += w0;
|
|
536
477
|
}
|
|
537
478
|
|
|
538
479
|
this.hessenberg_clear(0);
|
|
@@ -562,19 +503,25 @@ export class Subspan {
|
|
|
562
503
|
|
|
563
504
|
this.special_rank_1_update();
|
|
564
505
|
} else {
|
|
565
|
-
const R = this.R;
|
|
566
|
-
|
|
567
|
-
const dummy = R[index];
|
|
506
|
+
const R = this.R.data;
|
|
507
|
+
const dim = this.dim;
|
|
568
508
|
|
|
569
509
|
const members = this.members;
|
|
570
510
|
|
|
511
|
+
// Shift the column block [index+1 .. r-1] down by one position.
|
|
512
|
+
// Each column is `dim` contiguous floats in column-major storage,
|
|
513
|
+
// so the whole shift is a single copyWithin call.
|
|
514
|
+
const dstOff = index * dim;
|
|
515
|
+
const srcOff = (index + 1) * dim;
|
|
516
|
+
const endOff = this.r * dim;
|
|
517
|
+
R.copyWithin(dstOff, srcOff, endOff);
|
|
518
|
+
|
|
571
519
|
for (let j = index + 1; j < this.r; ++j) {
|
|
572
|
-
R[j - 1] = R[j];
|
|
573
520
|
members[j - 1] = members[j];
|
|
574
521
|
}
|
|
575
522
|
|
|
576
523
|
members[this.r - 1] = members[this.r];
|
|
577
|
-
|
|
524
|
+
--this.r;
|
|
578
525
|
|
|
579
526
|
this.hessenberg_clear(index);
|
|
580
527
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"miniball_compute_quality.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/packing/miniball/miniball_compute_quality.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,8DAFY,OAAO,
|
|
1
|
+
{"version":3,"file":"miniball_compute_quality.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/packing/miniball/miniball_compute_quality.js"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,8DAFY,OAAO,CAmDlB;wBA3DqB,cAAc"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {sqr} from "../../../math/sqr.js";
|
|
2
1
|
import {Quality} from "./Quality.js";
|
|
2
|
+
import {vector_dot} from "../../vec/vector_dot.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Verifies that the computed ball is indeed the miniball.
|
|
@@ -36,11 +36,7 @@ export function miniball_compute_quality(miniball) {
|
|
|
36
36
|
miniball.centerToPoint[i] = points.coord(k, i) - center[i];
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
for (let i = 0; i < dimension_count; ++i) {
|
|
42
|
-
sqDist += sqr(miniball.centerToPoint[i]);
|
|
43
|
-
}
|
|
39
|
+
const sqDist = vector_dot(miniball.centerToPoint, miniball.centerToPoint, dimension_count);
|
|
44
40
|
|
|
45
41
|
ball_error = Math.sqrt(sqDist) - miniball.radius();
|
|
46
42
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* N-dimensional AXPY (BLAS-style): in-place adds `alpha * x` into `y`.
|
|
3
|
+
*
|
|
4
|
+
* y[i] += alpha * x[i] for i in [0, n)
|
|
5
|
+
*
|
|
6
|
+
* @param {number[]|Float32Array|Float64Array} y receives the in-place update
|
|
7
|
+
* @param {number} alpha
|
|
8
|
+
* @param {number[]|Float32Array|Float64Array} x
|
|
9
|
+
* @param {number} n number of elements
|
|
10
|
+
*/
|
|
11
|
+
export function vector_axpy(y: number[] | Float32Array | Float64Array, alpha: number, x: number[] | Float32Array | Float64Array, n: number): void;
|
|
12
|
+
//# sourceMappingURL=vector_axpy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector_axpy.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec/vector_axpy.js"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,+BALW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,SAClC,MAAM,KACN,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,KAClC,MAAM,QAMhB"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* N-dimensional AXPY (BLAS-style): in-place adds `alpha * x` into `y`.
|
|
3
|
+
*
|
|
4
|
+
* y[i] += alpha * x[i] for i in [0, n)
|
|
5
|
+
*
|
|
6
|
+
* @param {number[]|Float32Array|Float64Array} y receives the in-place update
|
|
7
|
+
* @param {number} alpha
|
|
8
|
+
* @param {number[]|Float32Array|Float64Array} x
|
|
9
|
+
* @param {number} n number of elements
|
|
10
|
+
*/
|
|
11
|
+
export function vector_axpy(y, alpha, x, n) {
|
|
12
|
+
for (let i = 0; i < n; ++i) {
|
|
13
|
+
y[i] += alpha * x[i];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* N-dimensional AXPY over offset slices of two flat buffers.
|
|
3
|
+
*
|
|
4
|
+
* y[yOff + i] += alpha * x[xOff + i] for i in [0, n)
|
|
5
|
+
*
|
|
6
|
+
* Use when the operands are columns/rows of a flat matrix; passing offsets
|
|
7
|
+
* avoids per-call `.subarray(...)` header allocation.
|
|
8
|
+
*
|
|
9
|
+
* @param {number[]|Float32Array|Float64Array} y receives in-place update
|
|
10
|
+
* @param {number} yOff starting index into y
|
|
11
|
+
* @param {number} alpha
|
|
12
|
+
* @param {number[]|Float32Array|Float64Array} x
|
|
13
|
+
* @param {number} xOff starting index into x
|
|
14
|
+
* @param {number} n number of elements
|
|
15
|
+
*/
|
|
16
|
+
export function vector_axpy_offset(y: number[] | Float32Array | Float64Array, yOff: number, alpha: number, x: number[] | Float32Array | Float64Array, xOff: number, n: number): void;
|
|
17
|
+
//# sourceMappingURL=vector_axpy_offset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector_axpy_offset.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec/vector_axpy_offset.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,sCAPW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,QAClC,MAAM,SACN,MAAM,KACN,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,QAClC,MAAM,KACN,MAAM,QAMhB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* N-dimensional AXPY over offset slices of two flat buffers.
|
|
3
|
+
*
|
|
4
|
+
* y[yOff + i] += alpha * x[xOff + i] for i in [0, n)
|
|
5
|
+
*
|
|
6
|
+
* Use when the operands are columns/rows of a flat matrix; passing offsets
|
|
7
|
+
* avoids per-call `.subarray(...)` header allocation.
|
|
8
|
+
*
|
|
9
|
+
* @param {number[]|Float32Array|Float64Array} y receives in-place update
|
|
10
|
+
* @param {number} yOff starting index into y
|
|
11
|
+
* @param {number} alpha
|
|
12
|
+
* @param {number[]|Float32Array|Float64Array} x
|
|
13
|
+
* @param {number} xOff starting index into x
|
|
14
|
+
* @param {number} n number of elements
|
|
15
|
+
*/
|
|
16
|
+
export function vector_axpy_offset(y, yOff, alpha, x, xOff, n) {
|
|
17
|
+
for (let i = 0; i < n; ++i) {
|
|
18
|
+
y[yOff + i] += alpha * x[xOff + i];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* N-dimensional dot product over offset slices of two flat buffers.
|
|
3
|
+
*
|
|
4
|
+
* sum_{i=0..n-1} a[aOff + i] * b[bOff + i]
|
|
5
|
+
*
|
|
6
|
+
* Use when the operands are columns/rows of a flat matrix laid out in a
|
|
7
|
+
* single typed array — passing the buffer plus an offset avoids the header
|
|
8
|
+
* allocation that `.subarray(...)` would incur on every call.
|
|
9
|
+
*
|
|
10
|
+
* @param {number[]|Float32Array|Float64Array} a
|
|
11
|
+
* @param {number} aOff starting index into a
|
|
12
|
+
* @param {number[]|Float32Array|Float64Array} b
|
|
13
|
+
* @param {number} bOff starting index into b
|
|
14
|
+
* @param {number} n number of elements
|
|
15
|
+
* @return {number}
|
|
16
|
+
*/
|
|
17
|
+
export function vector_dot_offset(a: number[] | Float32Array | Float64Array, aOff: number, b: number[] | Float32Array | Float64Array, bOff: number, n: number): number;
|
|
18
|
+
//# sourceMappingURL=vector_dot_offset.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector_dot_offset.d.ts","sourceRoot":"","sources":["../../../../../src/core/geom/vec/vector_dot_offset.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,qCAPW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,QAClC,MAAM,KACN,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,QAClC,MAAM,KACN,MAAM,GACL,MAAM,CAUjB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* N-dimensional dot product over offset slices of two flat buffers.
|
|
3
|
+
*
|
|
4
|
+
* sum_{i=0..n-1} a[aOff + i] * b[bOff + i]
|
|
5
|
+
*
|
|
6
|
+
* Use when the operands are columns/rows of a flat matrix laid out in a
|
|
7
|
+
* single typed array — passing the buffer plus an offset avoids the header
|
|
8
|
+
* allocation that `.subarray(...)` would incur on every call.
|
|
9
|
+
*
|
|
10
|
+
* @param {number[]|Float32Array|Float64Array} a
|
|
11
|
+
* @param {number} aOff starting index into a
|
|
12
|
+
* @param {number[]|Float32Array|Float64Array} b
|
|
13
|
+
* @param {number} bOff starting index into b
|
|
14
|
+
* @param {number} n number of elements
|
|
15
|
+
* @return {number}
|
|
16
|
+
*/
|
|
17
|
+
export function vector_dot_offset(a, aOff, b, bOff, n) {
|
|
18
|
+
let result = 0;
|
|
19
|
+
|
|
20
|
+
for (let i = 0; i < n; i++) {
|
|
21
|
+
result += a[aOff + i] * b[bOff + i];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluate a univariate polynomial with real coefficients at a complex point,
|
|
3
|
+
* via Horner's method.
|
|
4
|
+
*
|
|
5
|
+
* p(z) = coeffs[0] + coeffs[1] · z + ... + coeffs[degree] · z^degree
|
|
6
|
+
*
|
|
7
|
+
* The result is written into `result` as `[Re(p(z)), Im(p(z))]`.
|
|
8
|
+
*
|
|
9
|
+
* @param {number[]|Float32Array|Float64Array} result 2-element output buffer
|
|
10
|
+
* @param {number[]|Float32Array|Float64Array} coeffs ascending-power, length ≥ degree + 1
|
|
11
|
+
* @param {number} degree polynomial degree, ≥ 0
|
|
12
|
+
* @param {number} zr real part of z
|
|
13
|
+
* @param {number} zi imaginary part of z
|
|
14
|
+
*/
|
|
15
|
+
export function complex_horner_eval(result: number[] | Float32Array | Float64Array, coeffs: number[] | Float32Array | Float64Array, degree: number, zr: number, zi: number): void;
|
|
16
|
+
//# sourceMappingURL=complex_horner_eval.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complex_horner_eval.d.ts","sourceRoot":"","sources":["../../../../../src/core/math/complex/complex_horner_eval.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,4CANW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,UAClC,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,UAClC,MAAM,MACN,MAAM,MACN,MAAM,QAkBhB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evaluate a univariate polynomial with real coefficients at a complex point,
|
|
3
|
+
* via Horner's method.
|
|
4
|
+
*
|
|
5
|
+
* p(z) = coeffs[0] + coeffs[1] · z + ... + coeffs[degree] · z^degree
|
|
6
|
+
*
|
|
7
|
+
* The result is written into `result` as `[Re(p(z)), Im(p(z))]`.
|
|
8
|
+
*
|
|
9
|
+
* @param {number[]|Float32Array|Float64Array} result 2-element output buffer
|
|
10
|
+
* @param {number[]|Float32Array|Float64Array} coeffs ascending-power, length ≥ degree + 1
|
|
11
|
+
* @param {number} degree polynomial degree, ≥ 0
|
|
12
|
+
* @param {number} zr real part of z
|
|
13
|
+
* @param {number} zi imaginary part of z
|
|
14
|
+
*/
|
|
15
|
+
export function complex_horner_eval(result, coeffs, degree, zr, zi) {
|
|
16
|
+
let pr = coeffs[degree];
|
|
17
|
+
let pi = 0;
|
|
18
|
+
|
|
19
|
+
for (let i = degree - 1; i >= 0; i--) {
|
|
20
|
+
|
|
21
|
+
const new_pr = pr * zr - pi * zi + coeffs[i];
|
|
22
|
+
const new_pi = pr * zi + pi * zr;
|
|
23
|
+
|
|
24
|
+
pr = new_pr;
|
|
25
|
+
pi = new_pi;
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
result[0] = pr;
|
|
30
|
+
result[1] = pi;
|
|
31
|
+
}
|
package/src/core/math/fabsf.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Float ABS, from standard C lib
|
|
3
|
-
* @
|
|
4
|
-
* @returns {number}
|
|
3
|
+
* @deprecated use Math.abs directly instead
|
|
5
4
|
*/
|
|
6
|
-
export
|
|
5
|
+
export const fabsf: (x: number) => number;
|
|
7
6
|
//# sourceMappingURL=fabsf.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fabsf.d.ts","sourceRoot":"","sources":["../../../../src/core/math/fabsf.js"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"fabsf.d.ts","sourceRoot":"","sources":["../../../../src/core/math/fabsf.js"],"names":[],"mappings":"AAAA;;;GAGG;AACH,0CAA6B"}
|
package/src/core/math/fabsf.js
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
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: number[] | Float64Array | Float32Array, coeffs: number[] | Float64Array | Float32Array, base: number, offset: number): void;
|
|
26
|
+
//# sourceMappingURL=cubic_residual_times_derivative_accumulate.d.ts.map
|