Skip to content

Implement matrix and vector interfaces#18

Merged
goerz merged 2 commits intomasterfrom
matrix-vector-interfaces
Feb 22, 2026
Merged

Implement matrix and vector interfaces#18
goerz merged 2 commits intomasterfrom
matrix-vector-interfaces

Conversation

@goerz
Copy link
Member

@goerz goerz commented Feb 21, 2026

This properly defines supports_vector_interface and supports_matrix_interface for GradVector and GradgenOperator, respectively, and implement the full required interface, as checked by check_operator and check_state.

This is a prerequisite to propagating gradient vectors via ExponentialUtilities (or similar external packages that assume an AbstractVector interface), see JuliaQuantumControl/QuantumPropagators.jl#97

This properly defines `supports_vector_interface` and
`supports_matrix_interface` for `GradVector` and `GradgenOperator`,
respectively, and implement the full required interface, as checked by
`check_operator` and `check_state`.
@goerz goerz added the enhancement New feature or request label Feb 21, 2026
@goerz goerz requested a review from Copilot February 21, 2026 19:05
@codecov
Copy link

codecov bot commented Feb 21, 2026

Codecov Report

❌ Patch coverage is 96.26168% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.5%. Comparing base (856448a) to head (db43eca).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/linalg.jl 96.1% 4 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master     #18     +/-   ##
========================================
+ Coverage    80.0%   87.5%   +7.5%     
========================================
  Files           5       5             
  Lines         185     278     +93     
========================================
+ Hits          148     243     +95     
+ Misses         37      35      -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

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 expands GradVector and GradgenOperator to provide the vector/matrix interfaces expected by QuantumPropagators.Interfaces (via check_state / check_operator), enabling compatibility with external propagation utilities that assume array-like behavior.

Changes:

  • Adds full vector-like Base/LinearAlgebra interface methods for GradVector (e.g., size, getindex, setindex!, iterate, and similar variants).
  • Adds matrix-like Base/LinearAlgebra interface methods for GradgenOperator (e.g., getindex, iterate, length, and similar variants) and defines supports_matrix_interface.
  • Extends interface-focused tests to validate the new behaviors and trait reporting.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/linalg.jl Implements vector/matrix interface methods (size/getindex/iterate/similar etc.) plus mul! and dot overloads to satisfy interface checks.
src/grad_vector.jl Defines supports_vector_interface / type-based supports_inplace for GradVector and updates resetgradvec! to use type-based trait checks.
src/gradgen_operator.jl Defines type-based supports_inplace and supports_matrix_interface for GradgenOperator.
test/test_interface.jl Adds targeted tests for vector/matrix interface compliance and trait behavior for both dense and static backends.

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

Copy link

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

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


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

@goerz goerz merged commit 93391c3 into master Feb 22, 2026
9 checks passed
@goerz goerz deleted the matrix-vector-interfaces branch February 22, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants