Skip to content

Delegate *= scalar to blas.dscal#68

Merged
Quafadas merged 2 commits intomainfrom
copilot/review-blas-delegation-opportunities
Apr 4, 2026
Merged

Delegate *= scalar to blas.dscal#68
Quafadas merged 2 commits intomainfrom
copilot/review-blas-delegation-opportunities

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

The JVM Array[Double] vector ops were inconsistently using BLAS. dot, norm, +=, -=, and /= all delegate to BLAS, but *=(d: Double) was using a manual SIMD loop instead of dscal — the obvious Level 1 BLAS routine for in-place scalar multiplication.

Change

  • *=(d: Double): Replace 12-line SIMD loop with blas.dscal(vec.length, d, vec, 1), matching the pattern already used by /=
  • *(d: Double): benefits automatically since it delegates via vec.clone.tap(_ *= d)
// Before
inline def *=(d: Double): Unit =
  var i = 0
  while i < spd.loopBound(vec.length) do
    DoubleVector.fromArray(spd, vec, i).mul(DoubleVector.broadcast(spd, d)).intoArray(vec, i)
    i += spdl
  end while
  while i < vec.length do
    vec(i) *= d
    i += 1
  end while
end *=

// After
inline def *=(d: Double): Unit =
  blas.dscal(vec.length, d, vec, 1)
end *=

Copilot AI linked an issue Apr 4, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Review vector implementations for missing BLAS delegation Delegate *= scalar to blas.dscal Apr 4, 2026
Copilot AI requested a review from Quafadas April 4, 2026 10:34
@Quafadas Quafadas marked this pull request as ready for review April 4, 2026 10:51
@Quafadas Quafadas merged commit 1a25efb into main Apr 4, 2026
7 checks passed
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.

bLAS missing?

2 participants