Skip to content

Conversation

@Krastanov-agent
Copy link
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 <[email protected]>
@codecov
Copy link

codecov bot commented Aug 18, 2025

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 33.33%. Comparing base (bcf7093) to head (e7a48db).

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.33%   +0.07%     
==========================================
  Files          15       15              
  Lines         442      444       +2     
==========================================
+ Hits          147      148       +1     
- 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.

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.

2 participants