Skip to content

New method fidelity for Statevec #386

@matulni

Description

@matulni

This issue qualifies for UnitaryDESIGN 2026!

Context

Given two pure quantum states $\psi_1$, $\psi_2$ the fidelity is defined as

$$F(\psi_1, \psi_2) = |\langle \psi_1 | \psi_2 \rangle|^2.$$

Task

  1. Add a method to the class graphix.sim.statevec.Statevec which allows to compute the fidelity of two quantum states.

Hint: Check :func: graphix.sim.statevec.Statevec.evolve_single.

  1. Add a method isclose which evaluates if two quantum states are equal up to a phase. This method should compute the fidelity and check if it's equal to 1 within certain relative and absolute tolerance.

Hint: Check math.isclose.

  1. Unit tests in graphix often resort to a simulation of two equivalent patterns (obtained with different methods), and the assertion that they represent the same unitary.
    Use the method implemented in 2) to replace

    assert np.abs(np.dot(state.flatten().conjugate(), state2.flatten())) == pytest.approx(1)

    and similar statements in the test suite.

Note: New methods should have the appropriate docstrings and unit tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions