Skip to content

Commit

Permalink
chore: add quantum operation
Browse files Browse the repository at this point in the history
[Documentation]

this code demonstrate various quantum channels using clara lib. it perform operations on a quantum state, such as partial transpose, measurement channels application and entropy computation.
`performChannelsOperations()`:
  - step process
    - create the initial state `|00⟩ + |11⟩` and display it
    - perform partial transpose on the first subsystem of the state and display eigen values
    - set up a measurement channels with two kraus operators (pauli Z operatios for `|0⟩` and `|11⟩`)
    - apply the measurement channels to first subsystem and display the resulting state
    - partially trace down the second subsystem and display the resulting state.
    -compute and diplasy the von-neummann entropy of the final state.

Signed-off-by: slowy07 <[email protected]>
  • Loading branch information
slowy07 committed Aug 11, 2023
1 parent 81fd7ea commit 64744bc
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions testing/operation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <iostream>

#include "../include/clara.h"

using namespace clara;

// define constant for kraus operators
const cmat PZ0 = st.pz0;
const cmat PZ1 = st.pz1;

void ChannelOperations() {
// create an initial quantum state
cmat rho = st.pb00;
std::cout << "initial state " << std::endl;
std::cout << disp(rho) << std::endl;

// perform partial transpose of first subsystem
cmat rhoTA = ptranspose(rho, {0});
std::cout << "eigenvalues of the partial transpose of bell-0 state are " << std::endl;
std::cout << disp(transpose(hevals(rhoTA))) << std::endl;

// set up measurement channel with 2 kraus operators
std::cout << "measurement channel with 2 kraus operators" << std::endl;
std::vector<cmat> Ks{PZ0, PZ1};
std::cout << disp(Ks[0]) << "\nand\n" << disp(Ks[1]) << std::endl;

// compute the superoperator matrix of the channel
std::cout << "superoperator matrix of channel: " << std::endl
<< disp(kraus2super(Ks)) << std::endl;

// partially trace down the second subsystem
std::cout << "choi matrix of the channels: " << std::endl;
std::cout << disp(kraus2choi(Ks)) << std::endl;

// apply the measurement channel into the first subsystem
cmat rhoOut = apply(rho, Ks, {0});
std::cout << "after applying the measurement channel on the first qubit" << std::endl;
std::cout << disp(rhoOut);

// partial trace down the second subsystem
cmat rhoA = ptrace(rhoOut, {1});
std::cout << "after partially tracing down the second subsystem " << std::endl
<< disp(rhoA) << std::endl;

// compute the von-neumann entropy of the resulting state
double entropies = entropy(rhoA);
std::cout << "entropy: " << entropies << std::endl;
}

int main() { ChannelOperations(); }

0 comments on commit 64744bc

Please sign in to comment.