Skip to content

Fix ComplexF64 support in mul! and add interface tests#16

Closed
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:mainfrom
ChrisRackauckas-Claude:interface-check-20260107-073433
Closed

Fix ComplexF64 support in mul! and add interface tests#16
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:mainfrom
ChrisRackauckas-Claude:interface-check-20260107-073433

Conversation

@ChrisRackauckas-Claude
Copy link
Copy Markdown

Summary

  • Fix mul! to support ComplexF64 by replacing fma with muladd
  • Add comprehensive interface compatibility tests for BigFloat, ComplexF64, Float32, and AbstractArray interface

Problem

The fma function is not defined for ComplexF64, causing runtime errors when using mul! with complex matrices:

ERROR: fma not defined for ComplexF64

This affected two mul! methods:

  • mul!(C::Matrix{T}, A::SparseBandedMatrix{T}, B::Matrix{T}, a::Number, b::Number)
  • mul!(C::Matrix{T}, A::Matrix{T}, B::SparseBandedMatrix{T}, a::Number, b::Number)

Solution

Replace fma with muladd in the affected methods. The muladd function works correctly with all numeric types:

  • ComplexF64
  • BigFloat
  • Float32
  • Int64

The other two mul! methods already used muladd, so this change makes the implementation consistent.

Tests Added

New interface tests in test/interface.jl verify:

  • BigFloat support (construction, getindex, setindex!, mul!)
  • ComplexF64 support (construction, getindex, mul!)
  • Float32 support (construction, mul!)
  • AbstractArray interface (size, length, eltype, firstindex, lastindex, IndexStyle, iteration)

Test Results

All 54 tests pass (27 new interface tests added).

cc @ChrisRackauckas

🤖 Generated with Claude Code

Replace `fma` with `muladd` in two mul! methods to enable ComplexF64
support. The `fma` function is not defined for ComplexF64, causing
runtime errors. The `muladd` function works with all numeric types
including ComplexF64, BigFloat, Float32, and Int64.

Changes:
- src/SparseBandedMatrices.jl: Replace fma with muladd in
  mul!(Matrix, SparseBandedMatrix, Matrix) and
  mul!(Matrix, Matrix, SparseBandedMatrix)
- test/interface.jl: Add interface compatibility tests for
  BigFloat, ComplexF64, Float32, and AbstractArray interface
- test/runtests.jl: Include new interface tests

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ChrisRackauckas-Claude ChrisRackauckas-Claude force-pushed the interface-check-20260107-073433 branch from 1c64f05 to 3ac9e26 Compare January 11, 2026 17:10
@ChrisRackauckas-Claude
Copy link
Copy Markdown
Author

Closing this PR as redundant. All changes from this PR (mul! fixes and interface tests) were already incorporated via PR #17. After rebasing, there are no unique changes left to merge.

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.

4 participants