`unitary()`: project nearly-unitary matrices onto the closest unitary

Open
#21 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
backend

Research direction

Start by reading src/circuit.rs around line 144 to see how unitary() checks matrices and how it represents them. The issue suggests projecting accepted matrices with a polar decomposition or one Newton step; confirm the available matrix operations and relevant tests before choosing an approach. Done means accepted nearly-unitary matrices are projected to the closest unitary without changing the API.

Written by the indexing model from the issue text.

Description

enhancement
What you want to do

unitary() accepts matrices that are up to 1e-9 away from unitary (src/circuit.rs:144) and uses them
as given. Each such gate scales the norm by up to 1 ± 1e-9, which adds up over long circuits.

Implementation notes

After the check passes, replace U with its closest unitary, U·(U†U)^(−1/2). For 2×2 that's a
closed-form polar decomposition, or a single Newton step U ← ½(U + U^{−†}), which is enough at
this tolerance.

What it could look like
No API change.
Contributing
  • I would like to open a pull request for this (see CONTRIBUTING.md).
Dominant language
Rust
Stars
1
Forks
0
Avg merge
12m
Merged PRs (30d)
4

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from kaiwave/qsengine

All issues in kaiwave/qsengine

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.