Skip to content

Conversation

ChrisRackauckas
Copy link
Member

Summary

  • Fixes method ambiguity error when multiplying Adjoint{T, <:AbstractVector} with Symbolics.Arr{<:Any, 2} (issue Ambiguous method on array adjoint of Num #575)
  • Adds minimal, targeted fix with specific method to resolve dispatch ambiguity
  • Includes test case to verify fix and prevent regression

Details

The issue occurred when trying to compute expressions like d' * E where d is a symbolic vector and E is a symbolic matrix. This caused a method ambiguity between:

  • Base.*(x::Adjoint{T, <:AbstractVector} where T, A::AbstractMatrix)
  • Symbolics.*(A::AbstractMatrix, B::Symbolics.Arr{<:Any, 2})

The fix adds a specific method @wrapped (*)(x::Adjoint{T, <:AbstractVector} where {T}, A::Symbolics.Arr{<:Any, 2}) = _matmul(x, A) false that takes precedence and resolves the ambiguity.

Test plan

  • Added test case that reproduces the original error scenario
  • Verified the fix resolves the method ambiguity
  • Confirmed the result has correct type (Symbolics.Arr)
  • Tested with multiple vector/matrix sizes

Closes #575

🤖 Generated with Claude Code

Resolves issue #575 by adding a specific method for Adjoint{T, <:AbstractVector}
multiplication with Symbolics.Arr{<:Any, 2}. This prevents the ambiguity between
Base's adjoint multiplication method and Symbolics' matrix multiplication.

The fix adds:
- Specific @wrapped method for adjoint-matrix multiplication in src/array-lib.jl
- Test case to verify the fix works and prevent regression

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

Ambiguous method on array adjoint of Num

2 participants