Skip to content

Reduce Eigen allocations with fixed-size matrix and vector types - #1502

Open
schaubh wants to merge 9 commits into
developfrom
feature/fix_eigen_size
Open

Reduce Eigen allocations with fixed-size matrix and vector types#1502
schaubh wants to merge 9 commits into
developfrom
feature/fix_eigen_size

Conversation

@schaubh

@schaubh schaubh commented Jul 31, 2026

Copy link
Copy Markdown
Contributor
  • Review: By commit
  • Merge strategy: Merge (no squash)

Description

This PR reduces Eigen heap allocations and unnecessary copies by replacing dynamically sized matrices and vectors with fixed-size or partially fixed-size types where dimensions are known at compile time.

The commits are organized by subsystem:

  1. Eigen/C-array conversions and geodetic utilities
  2. Common numerical utilities
  3. Gauss-Markov propagation
  4. SimpleNav and PlanetNav
  5. Lambert planning and validation
  6. Small-body navigation filters
  7. Effector-control algorithms
  8. Remaining three-dimensional simulation and control paths
  9. Release-note documentation

The changes preserve existing numerical behavior and message interfaces. The SWIG-visible dynamic Eigen conversion functions remain available, while C++ overloads avoid converting fixed-size Eigen expressions to temporary MatrixXd objects.

Verification

  • Completed a full incremental C++ and SWIG build.
  • Passed 18 Eigen conversion and geodetic CTests.
  • Passed 8 targeted state-architecture, small-body EKF, small-body UKF, and MTB Python tests.
  • Confirmed git diff --check passes.

No tests were added or re-baselined because the changes optimize internal storage and expression evaluation without changing expected results. Existing conversion and module tests exercise the affected behavior.

Documentation

No module input/output documentation or user-facing configuration was invalidated.

Inline comments describing row-major and column-major conversions were updated for the new implementations. A release-note snippet documents the reduction in Eigen heap allocation across the affected utilities and modules.

Future work

No required follow-up is anticipated.

@schaubh
schaubh requested a review from andrewmorell July 31, 2026 17:35
@schaubh schaubh self-assigned this Jul 31, 2026
@schaubh
schaubh requested a review from a team as a code owner July 31, 2026 17:35
@schaubh schaubh added enhancement New feature or request build Build system or compilation enhancement labels Jul 31, 2026
@schaubh schaubh added this to Basilisk Jul 31, 2026
@schaubh schaubh moved this to 👀 In review in Basilisk Jul 31, 2026
schaubh added a commit that referenced this pull request Jul 31, 2026
Use row-major Eigen maps to avoid transpose temporaries, add overloads
that preserve fixed-size Eigen expressions, and use fixed-size 3x3
matrices for geodetic frame conversions.
schaubh added a commit that referenced this pull request Jul 31, 2026
Pass BSpline, Discretize, and Saturate inputs by reference, avoid
unnecessary vector copies during discretization, and use fixed
two-column storage for saturation bounds.
schaubh added a commit that referenced this pull request Jul 31, 2026
Preallocate random, noise, and propagated-state vectors to avoid
per-step allocations, and pass configuration and state data by
reference.
schaubh added a commit that referenced this pull request Jul 31, 2026
Represent the SimpleNav and PlanetNav error transition matrices with
compile-time dimensions and keep per-step propagation in fixed-size
storage.
schaubh added a commit that referenced this pull request Jul 31, 2026
Represent six-element states and covariance transformations with
compile-time Eigen types throughout Lambert planning, validation, and
Runge-Kutta propagation.
@schaubh
schaubh force-pushed the feature/fix_eigen_size branch from 549c290 to 8033d96 Compare July 31, 2026 17:36
schaubh added a commit that referenced this pull request Jul 31, 2026
Encode EKF and UKF state, covariance, sigma-point, and measurement
dimensions in their Eigen types, and remove the redundant runtime
dimension counters.
schaubh added a commit that referenced this pull request Jul 31, 2026
Constrain mass-matrix blocks and VSCMG steering matrices to their
fixed three-row or three-column dimensions and avoid copying stored
momentum into a dynamic vector.
schaubh added a commit that referenced this pull request Jul 31, 2026
Replace dynamic three-dimensional matrices and vectors with fixed-size
types or direct maps in waypoint control, magnetic torque bars, gravity,
radiation, and ground mapping.
schaubh added a commit that referenced this pull request Jul 31, 2026
schaubh added a commit that referenced this pull request Jul 31, 2026
Use row-major Eigen maps to avoid transpose temporaries, add overloads
that preserve fixed-size Eigen expressions, and use fixed-size 3x3
matrices for geodetic frame conversions.
schaubh added a commit that referenced this pull request Jul 31, 2026
Pass BSpline, Discretize, and Saturate inputs by reference, avoid
unnecessary vector copies during discretization, and use fixed
two-column storage for saturation bounds.
schaubh added a commit that referenced this pull request Jul 31, 2026
Preallocate random, noise, and propagated-state vectors to avoid
per-step allocations, and pass configuration and state data by
reference.
schaubh added a commit that referenced this pull request Jul 31, 2026
Represent the SimpleNav and PlanetNav error transition matrices with
compile-time dimensions and keep per-step propagation in fixed-size
storage.
schaubh added a commit that referenced this pull request Jul 31, 2026
Represent six-element states and covariance transformations with
compile-time Eigen types throughout Lambert planning, validation, and
Runge-Kutta propagation.
@schaubh
schaubh force-pushed the feature/fix_eigen_size branch from 8033d96 to 638d72c Compare July 31, 2026 21:09
schaubh added a commit that referenced this pull request Jul 31, 2026
Encode EKF and UKF state, covariance, sigma-point, and measurement
dimensions in their Eigen types, and remove the redundant runtime
dimension counters.
schaubh added a commit that referenced this pull request Jul 31, 2026
Constrain mass-matrix blocks and VSCMG steering matrices to their
fixed three-row or three-column dimensions and avoid copying stored
momentum into a dynamic vector.
schaubh added a commit that referenced this pull request Jul 31, 2026
Replace dynamic three-dimensional matrices and vectors with fixed-size
types or direct maps in waypoint control, magnetic torque bars, gravity,
radiation, and ground mapping.
schaubh added a commit that referenced this pull request Jul 31, 2026
schaubh added 3 commits August 1, 2026 15:52
Use row-major Eigen maps to avoid transpose temporaries, add overloads
that preserve fixed-size Eigen expressions, and use fixed-size 3x3
matrices for geodetic frame conversions.
Pass BSpline, Discretize, and Saturate inputs by reference, avoid
unnecessary vector copies during discretization, and use fixed
two-column storage for saturation bounds.
Preallocate random, noise, and propagated-state vectors to avoid
per-step allocations, and pass configuration and state data by
reference.
schaubh added 6 commits August 1, 2026 15:52
Represent the SimpleNav and PlanetNav error transition matrices with
compile-time dimensions and keep per-step propagation in fixed-size
storage.
Represent six-element states and covariance transformations with
compile-time Eigen types throughout Lambert planning, validation, and
Runge-Kutta propagation.
Encode EKF and UKF state, covariance, sigma-point, and measurement
dimensions in their Eigen types, and remove the redundant runtime
dimension counters.
Constrain mass-matrix blocks and VSCMG steering matrices to their
fixed three-row or three-column dimensions and avoid copying stored
momentum into a dynamic vector.
Replace dynamic three-dimensional matrices and vectors with fixed-size
types or direct maps in waypoint control, magnetic torque bars, gravity,
radiation, and ground mapping.
@schaubh
schaubh force-pushed the feature/fix_eigen_size branch from 638d72c to 716196e Compare August 1, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build Build system or compilation enhancement enhancement New feature or request

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

1 participant