Skip to content

Fix MATLAB matrix view size check#185

Merged
dellaert merged 1 commit into
masterfrom
feature/matlab-matrix-view-mwsize
May 26, 2026
Merged

Fix MATLAB matrix view size check#185
dellaert merged 1 commit into
masterfrom
feature/matlab-matrix-view-mwsize

Conversation

@dellaert
Copy link
Copy Markdown
Member

Summary

  • widen the MATLAB matrix-view dimension guard before comparing against Eigen::Index
  • keep the no-copy ConstMatrixView unwrap path compatible with GTSAM builds that define MX_COMPAT_32
  • add a generator test assertion for the widened rows comparison

Validation

  • conda run -n py312 python -m unittest tests.test_matlab_wrapper.TestWrap.test_matrix_view_arguments
  • conda run -n py312 python -m unittest discover tests

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a dimension-range guard in the MATLAB unwrapMatrixView path by avoiding a potentially narrowing cast to mwSize before comparing against Eigen::Index limits, and updates the wrapper test to assert the new widened comparison logic.

Changes:

  • Update unwrapMatrixView to compare rows/cols and Eigen::Index::max() using a widened unsigned integer type before casting to Eigen::Index.
  • Keep the no-copy matrix-view unwrap path compatible with builds where mwSize may be 32-bit (e.g., MX_COMPAT_32 scenarios).
  • Add a unit test assertion that the generated header contains the widened rows cast used in the guard.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
matlab.h Widen the dimension guard comparisons for rows/cols vs Eigen::Index max before casting to Eigen::Index.
tests/test_matlab_wrapper.py Assert presence of the widened cast in the generated/checked header content.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dellaert dellaert marked this pull request as ready for review May 26, 2026 21:59
@dellaert dellaert merged commit e86d771 into master May 26, 2026
9 checks passed
@dellaert dellaert deleted the feature/matlab-matrix-view-mwsize branch May 26, 2026 22:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants