Skip to content

Add commutator and anticommutator functions - #64

Merged
Krastanov merged 2 commits into
qojulia:mainfrom
Krastanov-agent:upstream-commutator-functions
Nov 29, 2025
Merged

Add commutator and anticommutator functions#64
Krastanov merged 2 commits into
qojulia:mainfrom
Krastanov-agent:upstream-commutator-functions

Conversation

@Krastanov-agent

Copy link
Copy Markdown
Contributor

Summary

  • Add commutator(A, B) function that computes [A, B] = AB - BA
  • Add anticommutator(A, B) function that computes {A, B} = AB + BA
  • These are fundamental quantum mechanical operations for operator algebra
  • Includes comprehensive documentation with examples

New Functions

  • commutator(A::AbstractOperator, B::AbstractOperator): Computes the commutator [A, B] = AB - BA
  • anticommutator(A::AbstractOperator, B::AbstractOperator): Computes the anticommutator {A, B} = AB + BA

These functions provide essential quantum mechanical operations that are widely used in:

  • Quantum mechanics (canonical commutation relations)
  • Quantum field theory (anticommutation relations for fermions)
  • Quantum error correction
  • Hamiltonian simulation

Examples

# Pauli matrix commutators
σx = sigmax()
σy = sigmay()
comm = commutator(σx, σy)  # Returns 2i*σz

# Fermionic anticommutators  
σx = sigmax()
σz = sigmaz()
anticomm = anticommutator(σx, σz)  # Returns zero matrix

Test plan

  • Verify commutator function works correctly on example operators
  • Test anticommutator function produces expected results
  • Check canonical commutation/anticommutation relations hold
  • Verify exports work and no name conflicts exist

🤖 Generated with Claude Code

- Add commutator(A, B) function that computes [A, B] = AB - BA
- Add anticommutator(A, B) function that computes {A, B} = AB + BA
- These are fundamental quantum mechanical operations for operator algebra
- Includes comprehensive documentation with examples

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

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 18, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 33.18%. Comparing base (bcf7093) to head (3e68b86).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/linalg.jl 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #64      +/-   ##
==========================================
- Coverage   33.25%   33.18%   -0.08%     
==========================================
  Files          15       15              
  Lines         442      443       +1     
==========================================
  Hits          147      147              
- Misses        295      296       +1     

☔ 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.

@Krastanov
Krastanov merged commit cffd492 into qojulia:main Nov 29, 2025
8 of 11 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.

3 participants