Skip to content

Commit

Permalink
merge origin/main
Browse files Browse the repository at this point in the history
  • Loading branch information
Glacialte committed Dec 27, 2024
1 parent 250f78a commit a014bc6
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 68 deletions.
12 changes: 0 additions & 12 deletions exe/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,6 @@ int main() {
std::cout << Json(gate::Pauli<double>(pauli)) << std::endl;
std::cout << Json(gate::PauliRotation<double>(pauli, 0.5)) << std::endl;

std::cout << Json(gate::OneTargetMatrix<double>(2, {0, 1, 2, 3})) << std::endl;
std::cout << Json(gate::TwoTargetMatrix<double>(
2, 3, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}))
<< std::endl;

auto probgate =
gate::Probablistic<double>({.1, .9}, {gate::X<double>(0), gate::I<double>()});
std::cout << Json(probgate) << std::endl;
Expand Down Expand Up @@ -119,13 +114,6 @@ int main() {
Gate<double> gate = j;
std::cout << gate << std::endl;
}
{
auto x = gate::OneTargetMatrix<double>(1, {2., 3., 0., 10.}, {0, 3});
Json j = x;
std::cout << j << std::endl;
Gate<double> gate = j;
std::cout << gate << std::endl;
}
{
PauliOperator<double> pauli("X 2 Y 1");
auto x = gate::PauliRotation<double>(pauli, 1.5, {0, 3});
Expand Down
2 changes: 0 additions & 2 deletions include/scaluq/gate/gate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,6 @@ class GatePtr {
else if (type == "U2") gate = get_from_json<U2GateImpl<Fp>>(j);
else if (type == "U3") gate = get_from_json<U3GateImpl<Fp>>(j);
else if (type == "Swap") gate = get_from_json<SwapGateImpl<Fp>>(j);
else if (type == "OneTargetMatrix") gate = get_from_json<OneTargetMatrixGateImpl<Fp>>(j);
else if (type == "TwoTargetMatrix") gate = get_from_json<TwoTargetMatrixGateImpl<Fp>>(j);
else if (type == "Pauli") gate = get_from_json<PauliGateImpl<Fp>>(j);
else if (type == "PauliRotation") gate = get_from_json<PauliRotationGateImpl<Fp>>(j);
else if (type == "Probablistic") gate = get_from_json<ProbablisticGateImpl<Fp>>(j);
Expand Down
49 changes: 0 additions & 49 deletions include/scaluq/gate/gate_matrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,55 +78,6 @@ using SparseMatrixGate = internal::GatePtr<internal::SparseMatrixGateImpl<Fp>>;
template <std::floating_point Fp>
using DenseMatrixGate = internal::GatePtr<internal::DenseMatrixGateImpl<Fp>>;

namespace internal {
#define DECLARE_GET_FROM_JSON_ONETARGETMATRIXGATE_WITH_TYPE(Type) \
template <> \
inline std::shared_ptr<const OneTargetMatrixGateImpl<Type>> get_from_json(const Json& j) { \
auto targets = j.at("target").get<std::vector<std::uint64_t>>(); \
auto controls = j.at("control").get<std::vector<std::uint64_t>>(); \
auto matrix = j.at("matrix").get<std::vector<std::vector<Kokkos::complex<Type>>>>(); \
return std::make_shared<const OneTargetMatrixGateImpl<Type>>( \
vector_to_mask(targets), \
vector_to_mask(controls), \
std::array<std::array<Kokkos::complex<Type>, 2>, 2>{ \
matrix[0][0], matrix[0][1], matrix[1][0], matrix[1][1]}); \
}
DECLARE_GET_FROM_JSON_ONETARGETMATRIXGATE_WITH_TYPE(double)
DECLARE_GET_FROM_JSON_ONETARGETMATRIXGATE_WITH_TYPE(float)
#undef DECLARE_GET_FROM_JSON_ONETARGETMATRIXGATE_WITH_TYPE

#define DECLARE_GET_FROM_JSON_TWOTARGETMATRIXGATE_WITH_TYPE(Type) \
template <> \
inline std::shared_ptr<const TwoTargetMatrixGateImpl<Type>> get_from_json(const Json& j) { \
auto targets = j.at("target").get<std::vector<std::uint64_t>>(); \
auto controls = j.at("control").get<std::vector<std::uint64_t>>(); \
auto matrix = j.at("matrix").get<std::vector<std::vector<Kokkos::complex<Type>>>>(); \
return std::make_shared<const TwoTargetMatrixGateImpl<Type>>( \
vector_to_mask(targets), \
vector_to_mask(controls), \
std::array<std::array<Kokkos::complex<Type>, 4>, 4>{matrix[0][0], \
matrix[0][1], \
matrix[0][2], \
matrix[0][3], \
matrix[1][0], \
matrix[1][1], \
matrix[1][2], \
matrix[1][3], \
matrix[2][0], \
matrix[2][1], \
matrix[2][2], \
matrix[2][3], \
matrix[3][0], \
matrix[3][1], \
matrix[3][2], \
matrix[3][3]}); \
}
DECLARE_GET_FROM_JSON_TWOTARGETMATRIXGATE_WITH_TYPE(double)
DECLARE_GET_FROM_JSON_TWOTARGETMATRIXGATE_WITH_TYPE(float)
#undef DECLARE_GET_FROM_JSON_TWOTARGETMATRIXGATE_WITH_TYPE

} // namespace internal

#ifdef SCALUQ_USE_NANOBIND
namespace internal {
template <std::floating_point Fp>
Expand Down
5 changes: 0 additions & 5 deletions tests/gate/gate_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,6 @@ TEST(GateTest, ApplyIBMQ) {
run_random_gate_apply_IBMQ<float>(5, make_U<float>);
}

TEST(GateTest, ApplyTwoTarget) {
run_random_gate_apply_two_target<double>(5);
run_random_gate_apply_two_target<float>(5);
}

TEST(GateTest, ApplySparseMatrixGate) {
run_random_gate_apply_sparse<double>(6);
run_random_gate_apply_sparse<float>(6);
Expand Down

0 comments on commit a014bc6

Please sign in to comment.