Skip to content

Generalize exa_linalg to AbstractVector/AbstractMatrix#210

Merged
jbcaillau merged 6 commits intodevelopfrom
dynamics-exa
Feb 5, 2026
Merged

Generalize exa_linalg to AbstractVector/AbstractMatrix#210
jbcaillau merged 6 commits intodevelopfrom
dynamics-exa

Conversation

@jbcaillau
Copy link
Copy Markdown
Member

Replace concrete Vector/Matrix types with AbstractVector/AbstractMatrix in all function signatures to support views, reshape, and other abstract array types. This enables operations on SubArray, ReshapedArray, and transposed arrays without creating copies.

Changes:

  • Updated ~40 method signatures from Vector/Matrix to Abstract variants
  • Added Union{Adjoint, Transpose} methods to resolve ambiguities
  • Documented 56 detected ambiguities (24 theoretical, 32 with specialized types like Diagonal/SparseVector that don't occur in practice)
  • Added comprehensive test suite for AbstractArray compatibility
  • Updated dimension mismatch tests to accept DimensionMismatch exception

All 439 tests pass. No breaking changes to existing functionality.

jbcaillau and others added 2 commits January 30, 2026 09:37
Replace concrete Vector/Matrix types with AbstractVector/AbstractMatrix
in all function signatures to support views, reshape, and other abstract
array types. This enables operations on SubArray, ReshapedArray, and
transposed arrays without creating copies.

Changes:
- Updated ~40 method signatures from Vector/Matrix to Abstract variants
- Added Union{Adjoint, Transpose} methods to resolve ambiguities
- Documented 56 detected ambiguities (24 theoretical, 32 with specialized
  types like Diagonal/SparseVector that don't occur in practice)
- Added comprehensive test suite for AbstractArray compatibility
- Updated dimension mismatch tests to accept DimensionMismatch exception

All 439 tests pass. No breaking changes to existing functionality.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 30, 2026

Breakage test results
Date: 2026-02-05 23:07:44

Name Latest Stable
OptimalControl compat: v0.7.2 compat: v0.7.2

jbcaillau and others added 4 commits February 3, 2026 23:34
All 431 tests now pass with no errors.

Implementation fixes:
- Added norm methods for AbstractVector/AbstractMatrix to support SubArray/ReshapedArray
- Added det method for AbstractMatrix to support ReshapedArray
- Added 12 scalar-array multiplication methods (Matrix/Vector × AbstractNode, both directions)
- Added type conversion methods: convert(Null{T}, Null{S}), convert(Real, Null)
- Changed Matrix × Vector to throw DimensionMismatch instead of AssertionError

Test fixes:
- Updated dimension mismatch tests to expect DimensionMismatch (not AssertionError)
- Fixed type checks: adjoint/transpose return wrapper types (AbstractMatrix, not Matrix)
- Fixed reshape type check to accept AbstractMatrix (Julia may simplify to Matrix)

Documentation:
- Added comprehensive guide on "6 Minimal Operations for Linear Algebra Extension"
- Documented scalar iteration protocol and why custom implementations optimize performance
- Clarified what works natively vs what needs custom optimization

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…Array

Added support for array wrapper types while maintaining zero method ambiguities.

Type aliases added:
- Vec1DReal: Vector, SubArray, ReshapedArray, ReinterpretArray (Real only)
- Vec1DNode: Vector, SubArray, ReshapedArray (AbstractNode, no ReinterpretArray)
- Mat2D: Matrix, SubArray, ReshapedArray (2D arrays)
- DenseSubArray/DenseReshapedArray: Restricted to DenseArray parents

Key design decisions:
- ReinterpretArray only for Real types (Complex→Real reinterpretation)
- Restricted to DenseArray parents to avoid SparseArrays ambiguities
- tr/det not defined for SubArray (unavoidable StridedMatrix ambiguity)
- Users can collect/copy views first if needed for tr/det operations

Updated 40+ method signatures across all linear algebra operations.
Added 92 comprehensive tests covering all wrapper type combinations.

Test results:
- All 473 exa_linalg tests pass
- Zero ambiguities in Aqua.test_ambiguities()

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@jbcaillau
Copy link
Copy Markdown
Member Author

Extend exa_linalg to support SubArray, ReshapedArray, and ReinterpretArray
Added support for array wrapper types while maintaining zero method ambiguities.

Type aliases added:

  • Vec1DReal: Vector, SubArray, ReshapedArray, ReinterpretArray (Real only)
  • Vec1DNode: Vector, SubArray, ReshapedArray (AbstractNode, no ReinterpretArray)
  • Mat2D: Matrix, SubArray, ReshapedArray (2D arrays)
  • DenseSubArray/DenseReshapedArray: Restricted to DenseArray parents

Key design decisions:

  • ReinterpretArray only for Real types (Complex→Real reinterpretation)
  • Restricted to DenseArray parents to avoid SparseArrays ambiguities
  • tr/det not defined for SubArray (unavoidable StridedMatrix ambiguity)
  • Users can collect/copy views first if needed for tr/det operations

Updated 40+ method signatures across all linear algebra operations.
Added 92 comprehensive tests covering all wrapper type combinations.

Test results:

  • All 473 exa_linalg tests pass
  • Zero ambiguities in Aqua.test_ambiguities()

Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com

@jbcaillau jbcaillau marked this pull request as ready for review February 5, 2026 23:17
@jbcaillau jbcaillau merged commit 95b3efe into develop Feb 5, 2026
7 of 20 checks passed
@jbcaillau jbcaillau deleted the dynamics-exa branch February 5, 2026 23:17
@jbcaillau jbcaillau mentioned this pull request Mar 9, 2026
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.

1 participant