diff --git a/include/clara.h b/include/clara.h index c145dd4..7e02de9 100644 --- a/include/clara.h +++ b/include/clara.h @@ -36,6 +36,8 @@ #include #include +#include +#include // inter dependicies #include "classFunction/codes.h" #include "classFunction/exception.h" diff --git a/testing/_test.cpp b/testing/_test.cpp index b8a1b1e..d2d295a 100644 --- a/testing/_test.cpp +++ b/testing/_test.cpp @@ -6,7 +6,6 @@ #include #include -#include "../include/clara.h" #include "../include/experimental/experimental_test.h" /** @@ -18,101 +17,14 @@ */ using namespace clara; +using namespace::experimental; int main() { - std::cout << "testing testing \n"; - - // initialize bit circuit with 70 bits - const idx bits = 70; - experimental::Bit_circuit b{bits}; - - const idx trials = 20; - - // number of trials - b.rand(); - auto c = b; - - /** - * random number generator `gen` is set up using - * random_device for generating random indices. for each trial - * vector `v` is filled wuth values from `0` to `bits-1`. the element - * of `v` represent the indices of the `TOF` (Toffoli) operation. these indices - * are store for later use in trials - */ - std::random_device rd; - std::mt19937 gen{rd()}; - std::vector> indices(trials); - - for (idx i = 0; i < trials; ++i) { - std::vector v(bits); - std::iota(v.begin(), v.end(), 0); - std::shuffle(v.begin(), v.end(), gen); - std::vector tof(v.data(), v.data() + 3); - indices[i] = tof; - } - - /** - * the first half of the trials is performed. the indices for each trials are - * printed, and the `TOF` operations is applied to the `Bit_circuit` using - * corresponding indices - */ - for (idx i = 0; i < trials; ++i) { - std::cout << "first: "; - for (auto&& elem : indices[i]) - std::cout << elem << " "; - std::cout << std::endl; - b.TOF(indices[i]); - } - - /** - * the second half of the trials performed in reverse order. the indices for each - * trial are again printed, and the `TOF` operation is applied to the `Bit_circuit` - * using the corresponding indices - */ - for (idx i = trials; i-- > 0;) { - std::cout << "second: "; - for (auto&& elem : indices[i]) - std::cout << elem << " "; - std::cout << std::endl; - b.TOF(indices[i]); - } - - /** - * the initail and final state are printed. the hamming weight (number of set bits) - * of `b` is displayed. the count of NOT, X and TOF gates used in `b` is printed - */ - std::cout << "initial: " << b << std::endl; - std::cout << "final: " << c << std::endl; - std::cout << "hamming weight: " << b.count() << std::endl; - - std::cout << b.gate_count.NOT << " " << b.gate_count.X << " " << b.gate_count.TOF << std::endl; - std::cout << (b == c) << std::endl; - std::cout << (b != c) << std::endl; - - /** - * various quantum states and projections are created and printed - */ - experimental::Dynamic_bitset bb(9); - bb.set(1).set(3).set(8); - std::cout << bb << std::endl; - - std::cout << "info: " << std::endl; - std::cout << bb.to_string('o', 'X') << std::endl; - - experimental::Dynamic_bitset vlad(20); - std::cout << vlad << std::endl; - - std::vector vv(20); - for (auto& elem : vv) { - std::cout << elem; - } - std::cout << std::endl; - - ket x = (10_ket + 01_ket) / std::sqrt(2); - std::cout << disp(x) << std::endl; - - bra y = (10_bra + 01_bra) / std::sqrt(2); - std::cout << disp(x) << std::endl; - - cmat z = 110_prj; - std::cout << disp(z) << std::endl; + ClaraCircuit claraCircuit(10, 10); + claraCircuit.apply_all(gt.H); + std::cout << claraCircuit.get_num_active_qubits() << std::endl; + + claraCircuit.measure({3, 1, 7}); + std::cout << claraCircuit.get_num_active_qubits() << std::endl; + // std::cout << claraCircuit.get_num_measured_qubits() << std::endl; + // std::cout << claraCircuit.get_num_active_qubits() << std::endl; } diff --git a/testing/channels.cpp b/testing/channels.cpp index 57fbd5a..16b8851 100644 --- a/testing/channels.cpp +++ b/testing/channels.cpp @@ -42,27 +42,27 @@ int main() { std::cout << "their sum is: " << sum(hevals(choim)) << "\n"; - std::vector Kperps = choi2kraus(choim); - std::cout << "kraus rank of channel : " << Kperps.size() << "\n"; - - cmat rho_out1 = clara::apply(rho_in, Kperps); - // verification norm difference - std::cout << "norm difference ouput states: " << norm(rho_out1 - rho_out) << "\n"; - - std::cout << "superoperator matrix:\n"; - cmat smat = kraus2super(Ks); - std::cout << disp(smat) << "\n"; - - std::cout << "the eigenvalues of the superoperator matrix :\n"; - dyn_col_vect evalsupop = evals(smat); - std::cout << disp(transpose(evalsupop)) << "\n"; - - std::cout << "their absolute values are: \n"; - for (idx i = 0; i < (idx)evalsupop.size(); ++i) - std::cout << std::abs(evalsupop(i)) << " "; - - // verification - std::cout << "\n norm difference for the superoperator action: "; - cmat rho_out2 = transpose(reshape(smat * reshape(transpose(rho_in), D * D, 1), D, D)); - std::cout << norm(rho_out - rho_out2) << "\n"; +// std::vector Kperps = choi2kraus(choim); +// std::cout << "kraus rank of channel : " << Kperps.size() << "\n"; +// +// cmat rho_out1 = clara::apply(rho_in, Kperps); +// // verification norm difference +// std::cout << "norm difference ouput states: " << norm(rho_out1 - rho_out) << "\n"; +// +// std::cout << "superoperator matrix:\n"; +// cmat smat = kraus2super(Ks); +// std::cout << disp(smat) << "\n"; +// +// std::cout << "the eigenvalues of the superoperator matrix :\n"; +// dyn_col_vect evalsupop = evals(smat); +// std::cout << disp(transpose(evalsupop)) << "\n"; +// +// std::cout << "their absolute values are: \n"; +// for (idx i = 0; i < (idx)evalsupop.size(); ++i) +// std::cout << std::abs(evalsupop(i)) << " "; +// +// // verification +// std::cout << "\n norm difference for the superoperator action: "; +// cmat rho_out2 = transpose(reshape(smat * reshape(transpose(rho_in), D * D, 1), D, D)); +// std::cout << norm(rho_out - rho_out2) << "\n"; }