diff --git a/src/extractor/extract.cpp b/src/extractor/extract.cpp index 2ee2a37f..ef3f09e8 100644 --- a/src/extractor/extract.cpp +++ b/src/extractor/extract.cpp @@ -81,7 +81,7 @@ void Extractor::initialize(bool from_empty_qcir) { } print_frontier(spdlog::level::level_enum::trace); print_neighbors(spdlog::level::level_enum::trace); - _graph->print_vertices_by_qubits(spdlog::level::level_enum::trace); + _graph->print_vertices_by_rows(spdlog::level::level_enum::trace); _logical_circuit->print_circuit_diagram(spdlog::level::level_enum::trace); } @@ -105,12 +105,12 @@ QCir* Extractor::extract() { spdlog::info("Finished Extracting!"); _logical_circuit->print_circuit_diagram(spdlog::level::level_enum::trace); - _graph->print_vertices_by_qubits(spdlog::level::level_enum::trace); + _graph->print_vertices_by_rows(spdlog::level::level_enum::trace); if (PERMUTE_QUBITS) { permute_qubits(); _logical_circuit->print_circuit_diagram(spdlog::level::level_enum::trace); - _graph->print_vertices_by_qubits(spdlog::level::level_enum::trace); + _graph->print_vertices_by_rows(spdlog::level::level_enum::trace); } return _logical_circuit; @@ -133,7 +133,7 @@ bool Extractor::extraction_loop(std::optional max_iter) { if (remove_gadget()) { spdlog::debug("Gadget(s) are removed."); print_frontier(spdlog::level::level_enum::trace); - _graph->print_vertices_by_qubits(spdlog::level::level_enum::trace); + _graph->print_vertices_by_rows(spdlog::level::level_enum::trace); _logical_circuit->print_circuit_diagram(spdlog::level::level_enum::trace); continue; } @@ -156,7 +156,7 @@ bool Extractor::extraction_loop(std::optional max_iter) { print_frontier(spdlog::level::level_enum::trace); print_neighbors(spdlog::level::level_enum::trace); - _graph->print_vertices_by_qubits(spdlog::level::level_enum::trace); + _graph->print_vertices_by_rows(spdlog::level::level_enum::trace); _logical_circuit->print_circuit_diagram(spdlog::level::level_enum::trace); if (max_iter.has_value()) (*max_iter)--; @@ -199,7 +199,7 @@ void Extractor::extract_singles() { _graph->remove_edge(s, t, EdgeType::hadamard); } _logical_circuit->print_circuit_diagram(spdlog::level::level_enum::trace); - _graph->print_vertices_by_qubits(spdlog::level::level_enum::trace); + _graph->print_vertices_by_rows(spdlog::level::level_enum::trace); } /** @@ -245,7 +245,7 @@ bool Extractor::extract_czs(bool check) { prepend_series_gates(ops); } _logical_circuit->print_circuit_diagram(spdlog::level::level_enum::trace); - _graph->print_vertices_by_qubits(spdlog::level::level_enum::trace); + _graph->print_vertices_by_rows(spdlog::level::level_enum::trace); return true; } diff --git a/src/zx/zx_cmd.cpp b/src/zx/zx_cmd.cpp index e7b5e411..3043b505 100644 --- a/src/zx/zx_cmd.cpp +++ b/src/zx/zx_cmd.cpp @@ -184,9 +184,9 @@ Command zxgraph_print_cmd(ZXGraphMgr const& zxgraph_mgr) { mutex.add_argument("-e", "--edges") .action(store_true) .help("print the edges info of ZXGraph"); - mutex.add_argument("-q", "--qubits") + mutex.add_argument("-r", "--rows") .nargs(NArgsOption::zero_or_more) - .help("print the vertices of ZXGraph by their qubits"); + .help("print the vertices of ZXGraph row by row"); mutex.add_argument("-n", "--neighbors") .constraint(valid_zxvertex_id(zxgraph_mgr)) .help("print the neighbor info of ZXGraph"); @@ -218,9 +218,9 @@ Command zxgraph_print_cmd(ZXGraphMgr const& zxgraph_mgr) { zxgraph_mgr.get()->print_vertices(vids); } else if (parser.parsed("--edges")) { zxgraph_mgr.get()->print_edges(); - } else if (parser.parsed("--qubits")) { - auto qids = parser.get>("--qubits"); - zxgraph_mgr.get()->print_vertices_by_qubits(spdlog::level::level_enum::off, qids); + } else if (parser.parsed("--rows")) { + auto qids = parser.get>("--rows"); + zxgraph_mgr.get()->print_vertices_by_rows(spdlog::level::level_enum::off, qids); } else if (parser.parsed("--neighbors")) { auto v = zxgraph_mgr.get()->find_vertex_by_id(parser.get("--neighbors")); v->print_vertex(); diff --git a/src/zx/zx_io.cpp b/src/zx/zx_io.cpp index d0f63b6b..903bc452 100644 --- a/src/zx/zx_io.cpp +++ b/src/zx/zx_io.cpp @@ -22,6 +22,7 @@ #include "./zxgraph.hpp" #include "util/sysdep.hpp" #include "util/tmp_files.hpp" +#include "util/util.hpp" namespace qsyn::zx { @@ -30,7 +31,8 @@ namespace detail { struct VertexInfo { char type = 'Z'; QubitIdType qubit = 0; - float column = 0.0f; + float row = 0.f; + float column = 0.f; std::vector> neighbors; Phase phase; }; @@ -39,26 +41,22 @@ using StorageType = dvlab::utils::ordered_hashmap; class ZXFileParser { public: - ZXFileParser() {} - std::optional parse(std::istream& f); static constexpr std::string_view supported_vertex_type = "IOZXH"; static constexpr std::string_view supported_edge_type = "SH"; private: - unsigned _line_no = 1; + size_t _line_no = 1; std::unordered_set _taken_input_qubits; std::unordered_set _taken_output_qubits; // parsing subroutines bool _tokenize(std::string const& line, std::vector& tokens); - std::optional> _parse_type_and_id(StorageType const& storage, std::string const& token); - bool _is_valid_tokens_for_boundary_vertex(std::vector const& tokens); - bool _is_valid_tokens_for_h_box(std::vector const& tokens); + std::optional> _parse_type_and_id(StorageType const& storage, std::string const& token); - bool _parse_qubit(std::string const& token, char const& type, int& qubit); + bool _parse_row(std::string const& token, float& row); bool _parse_column(std::string const& token, float& column); bool _parse_neighbors(std::string const& token, std::pair& neighbor); @@ -77,12 +75,17 @@ class ZXFileParser { */ std::optional ZXFileParser::parse(std::istream& f) { // each line should be in the format of - // [()] [NeighborString...] [Phase phase] + // [()] [<...] [size_t qubit_id] + // [()] [<...] [Phase phase] auto storage = StorageType{}; _taken_input_qubits.clear(); _taken_output_qubits.clear(); _line_no = 1; - for (std::string line; getline(f, line); _line_no++) { + + QubitIdType max_input_qubit_id = 0; + QubitIdType max_output_qubit_id = 0; + + for (std::string line; std::getline(f, line); _line_no++) { line = dvlab::str::trim_spaces(dvlab::str::trim_comments(line)); if (line.empty()) continue; @@ -92,36 +95,67 @@ std::optional ZXFileParser::parse(std::istream& f) { VertexInfo info; auto const type_and_id = _parse_type_and_id(storage, tokens[0]); - if (!type_and_id.has_value()) return std::nullopt; + if (!type_and_id) return std::nullopt; - info.type = type_and_id.value().first; - auto id = type_and_id.value().second; + info.type = type_and_id->first; + auto id = type_and_id->second; - if (info.type == 'I' || info.type == 'O') { - if (!_is_valid_tokens_for_boundary_vertex(tokens)) return std::nullopt; - } - if (info.type == 'H') { - if (!_is_valid_tokens_for_h_box(tokens)) return std::nullopt; - info.phase = Phase(1); + if (info.type == 'H') info.phase = Phase(1); + + switch (info.type) { + case 'I': { + if (auto const qubit = dvlab::str::from_string(tokens.back()); qubit.has_value() && tokens.size() > 3) { + tokens.pop_back(); + info.qubit = qubit.value(); + max_input_qubit_id = std::max(max_input_qubit_id, info.qubit); + } else { + info.qubit = max_input_qubit_id++; + } + if (_taken_input_qubits.contains(info.qubit)) { + _print_failed_at_line_no(); + spdlog::error("duplicated input qubit ID ({})!!", info.qubit); + return std::nullopt; + } + _taken_input_qubits.insert(info.qubit); + info.row = static_cast(info.qubit); + break; + } + case 'O': { + if (auto const qubit = dvlab::str::from_string(tokens.back()); qubit.has_value() && tokens.size() > 3) { + tokens.pop_back(); + info.qubit = qubit.value(); + max_output_qubit_id = std::max(max_output_qubit_id, info.qubit); + } else { + info.qubit = max_output_qubit_id++; + } + if (_taken_output_qubits.contains(info.qubit)) { + _print_failed_at_line_no(); + spdlog::error("duplicated output qubit ID ({})!!", info.qubit); + return std::nullopt; + } + info.row = static_cast(info.qubit); + break; + } + default: { + if (auto const phase = Phase::from_string(tokens.back()); phase.has_value() && tokens.size() > 3) { + tokens.pop_back(); + info.phase = phase.value(); + } + info.row = 0; + break; + } } - if (!_parse_qubit(tokens[1], info.type, info.qubit)) return std::nullopt; + if (!_parse_row(tokens[1], info.row)) return std::nullopt; if (!_parse_column(tokens[2], info.column)) return std::nullopt; - if (tokens.size() > 3) { - if (auto phase = Phase::from_string(tokens.back()); phase.has_value()) { - tokens.pop_back(); - info.phase = phase.value(); - } - - std::pair neighbor; - for (size_t i = 3; i < tokens.size(); ++i) { - if (!_parse_neighbors(tokens[i], neighbor)) return std::nullopt; - info.neighbors.emplace_back(neighbor); - } + std::pair neighbor; + for (size_t i = 3; i < tokens.size(); ++i) { + if (!_parse_neighbors(tokens[i], neighbor)) return std::nullopt; + info.neighbors.emplace_back(neighbor); } - storage[id] = info; + storage.emplace(id, info); } return storage; @@ -154,14 +188,14 @@ bool ZXFileParser::_tokenize(std::string const& line, std::vector& auto const left_paren_pos = line.find_first_of('(', pos); auto const right_paren_pos = line.find_first_of(')', left_paren_pos == std::string::npos ? 0 : left_paren_pos); - auto const parenthesis_case = [&]() -> ParenthesisCase { + auto const parenthesis_case = std::invoke([&]() -> ParenthesisCase { auto const has_left_parenthesis = (left_paren_pos != std::string::npos); auto const has_right_parenthesis = (right_paren_pos != std::string::npos); if (has_left_parenthesis && has_right_parenthesis) return ParenthesisCase::both; if (has_left_parenthesis && !has_right_parenthesis) return ParenthesisCase::left; if (!has_left_parenthesis && has_right_parenthesis) return ParenthesisCase::right; return ParenthesisCase::none; - }(); + }); switch (parenthesis_case) { case ParenthesisCase::none: @@ -230,7 +264,7 @@ bool ZXFileParser::_tokenize(std::string const& line, std::vector& * @return true * @return false */ -std::optional> ZXFileParser::_parse_type_and_id(StorageType const& storage, std::string const& token) { +std::optional> ZXFileParser::_parse_type_and_id(StorageType const& storage, std::string const& token) { auto type = dvlab::str::toupper(token[0]); if (type == 'G') { @@ -253,7 +287,7 @@ std::optional> ZXFileParser::_parse_type_and_id(Storag return std::nullopt; } - auto id = dvlab::str::from_string(id_string); + auto id = dvlab::str::from_string(id_string); if (!id) { _print_failed_at_line_no(); @@ -267,49 +301,7 @@ std::optional> ZXFileParser::_parse_type_and_id(Storag return std::nullopt; } - return std::make_optional>({type, id.value()}); -} - -/** - * @brief Check the tokens are valid for boundary vertices - * - * @param tokens - * @return true - * @return false - */ -bool ZXFileParser::_is_valid_tokens_for_boundary_vertex(std::vector const& tokens) { - if (tokens[1] == "-") { - _print_failed_at_line_no(); - spdlog::error("please specify the qubit ID to boundary vertex!!"); - return false; - } - - if (tokens.size() <= 3) return true; - - if (Phase::from_string(tokens.back()).has_value()) { - _print_failed_at_line_no(); - spdlog::error("cannot assign phase to boundary vertex!!"); - return false; - } - return true; -} - -/** - * @brief Check the tokens are valid for H boxes - * - * @param tokens - * @return true - * @return false - */ -bool ZXFileParser::_is_valid_tokens_for_h_box(std::vector const& tokens) { - if (tokens.size() <= 3) return true; - - if (Phase::from_string(tokens.back()).has_value()) { - _print_failed_at_line_no(); - spdlog::error("cannot assign phase to H-box!!"); - return false; - } - return true; + return std::make_optional>({type, id.value()}); } /** @@ -321,36 +313,17 @@ bool ZXFileParser::_is_valid_tokens_for_h_box(std::vector const& to * @return true * @return false */ -bool ZXFileParser::_parse_qubit(std::string const& token, char const& type, int& qubit) { +bool ZXFileParser::_parse_row(std::string const& token, float& row) { if (token == "-") { - qubit = 0; return true; } - if (!dvlab::str::str_to_i(token, qubit)) { + if (!dvlab::str::str_to_f(token, row)) { _print_failed_at_line_no(); - spdlog::error("qubit ID ({}) is not an integer!!", token); + spdlog::error("row ({}) is not an floating-point number!!", token); return false; } - if (type == 'I') { - if (_taken_input_qubits.contains(qubit)) { - _print_failed_at_line_no(); - spdlog::error("duplicated input qubit ID ({})!!", qubit); - return false; - } - _taken_input_qubits.insert(qubit); - } - - if (type == 'O') { - if (_taken_output_qubits.contains(qubit)) { - _print_failed_at_line_no(); - spdlog::error("duplicated output qubit ID ({})!!", qubit); - return false; - } - _taken_output_qubits.insert(qubit); - } - return true; } @@ -370,7 +343,7 @@ bool ZXFileParser::_parse_column(std::string const& token, float& column) { if (!dvlab::str::str_to_f(token, column)) { _print_failed_at_line_no(); - spdlog::error("column ID ({}) is not an unsigned integer!!", token); + spdlog::error("column ({}) is not an floating-point number!!", token); return false; } @@ -422,15 +395,15 @@ std::optional build_graph_from_parser_storage(StorageType const& storag [&info = info, &graph]() { switch (info.type) { case 'I': - return graph.add_input(info.qubit, info.column); + return graph.add_input(info.qubit, info.row, info.column); case 'O': - return graph.add_output(info.qubit, info.column); + return graph.add_output(info.qubit, info.row, info.column); case 'Z': - return graph.add_vertex(VertexType::z, info.phase, static_cast(info.qubit), info.column); + return graph.add_vertex(VertexType::z, info.phase, info.row, info.column); case 'X': - return graph.add_vertex(VertexType::x, info.phase, static_cast(info.qubit), info.column); + return graph.add_vertex(VertexType::x, info.phase, info.row, info.column); case 'H': - return graph.add_vertex(VertexType::h_box, info.phase, static_cast(info.qubit), info.column); + return graph.add_vertex(VertexType::h_box, info.phase, info.row, info.column); default: DVLAB_UNREACHABLE("unsupported vertex type"); } diff --git a/src/zx/zxgraph.cpp b/src/zx/zxgraph.cpp index ba314326..f3dc5c73 100644 --- a/src/zx/zxgraph.cpp +++ b/src/zx/zxgraph.cpp @@ -14,6 +14,7 @@ #include #include "./zx_def.hpp" +#include "qsyn/qsyn_type.hpp" #include "tl/enumerate.hpp" #include "util/boolean_matrix.hpp" @@ -207,17 +208,14 @@ double ZXGraph::density() { /* class ZXGraph Add functions */ /*****************************************************/ -/** - * @brief Add input to the ZXGraph - * - * @param qubit - * @param col - * @return ZXVertex* - */ ZXVertex* ZXGraph::add_input(QubitIdType qubit, float col) { + return add_input(qubit, static_cast(qubit), col); +} + +ZXVertex* ZXGraph::add_input(QubitIdType qubit, float row, float col) { assert(!is_input_qubit(qubit)); - auto v = new ZXVertex(_next_v_id, qubit, VertexType::boundary, Phase(), static_cast(qubit), col); + auto v = new ZXVertex(_next_v_id, qubit, VertexType::boundary, Phase(), row, col); _inputs.emplace(v); _input_list.emplace(qubit, v); _vertices.emplace(v); @@ -225,16 +223,14 @@ ZXVertex* ZXGraph::add_input(QubitIdType qubit, float col) { return v; } -/** - * @brief Add output to the ZXGraph - * - * @param qubit - * @return ZXVertex* - */ ZXVertex* ZXGraph::add_output(QubitIdType qubit, float col) { + return add_output(qubit, static_cast(qubit), col); +} + +ZXVertex* ZXGraph::add_output(QubitIdType qubit, float row, float col) { assert(!is_output_qubit(qubit)); - auto v = new ZXVertex(_next_v_id, qubit, VertexType::boundary, Phase(), static_cast(qubit), col); + auto v = new ZXVertex(_next_v_id, qubit, VertexType::boundary, Phase(), row, col); _outputs.emplace(v); _output_list.emplace(qubit, v); _vertices.emplace(v); @@ -465,7 +461,7 @@ void ZXGraph::adjoint() { * @param phase */ void ZXGraph::assign_vertex_to_boundary(QubitIdType qubit, bool is_input, VertexType vtype, Phase phase) { - ZXVertex* v = add_vertex(vtype, phase, static_cast(qubit)); + ZXVertex* v = add_vertex(vtype, phase, gsl::narrow(qubit)); ZXVertex* boundary = is_input ? _input_list[qubit] : _output_list[qubit]; for (auto& [nb, etype] : this->get_neighbors(boundary)) { add_edge(v, nb, etype); diff --git a/src/zx/zxgraph.hpp b/src/zx/zxgraph.hpp index 89753e2f..f3b2c6ba 100644 --- a/src/zx/zxgraph.hpp +++ b/src/zx/zxgraph.hpp @@ -198,7 +198,9 @@ class ZXGraph { // NOLINT(cppcoreguidelines-special-member-functions) : copy-sw // Add and Remove ZXVertex* add_input(QubitIdType qubit, float col = 0.f); + ZXVertex* add_input(QubitIdType qubit, float row, float col); ZXVertex* add_output(QubitIdType qubit, float col = 0.f); + ZXVertex* add_output(QubitIdType qubit, float row, float col); ZXVertex* add_vertex(VertexType vt, Phase phase = Phase(), float row = 0.f, float col = 0.f); void add_edge(ZXVertex* vs, ZXVertex* vt, EdgeType et); @@ -243,7 +245,7 @@ class ZXGraph { // NOLINT(cppcoreguidelines-special-member-functions) : copy-sw void print_io() const; void print_vertices(spdlog::level::level_enum lvl = spdlog::level::level_enum::off) const; void print_vertices(std::vector cand) const; - void print_vertices_by_qubits(spdlog::level::level_enum lvl = spdlog::level::level_enum::off, QubitIdList cand = {}) const; + void print_vertices_by_rows(spdlog::level::level_enum lvl = spdlog::level::level_enum::off, std::vector cand = {}) const; void print_edges() const; void print_difference(ZXGraph* other) const; diff --git a/src/zx/zxgraph_action.cpp b/src/zx/zxgraph_action.cpp index f5fcec15..0241cce9 100644 --- a/src/zx/zxgraph_action.cpp +++ b/src/zx/zxgraph_action.cpp @@ -98,7 +98,7 @@ ZXGraph& ZXGraph::compose(ZXGraph const& target) { // Update `_col` of copiedGraph to make them unique to the original graph for (auto const& v : copied_graph.get_vertices()) { - v->set_col(v->get_col() + max_col + 1); + v->set_col(v->get_col() + static_cast(max_col) + 1); } // Sort ori-output and copy-input diff --git a/src/zx/zxgraph_print.cpp b/src/zx/zxgraph_print.cpp index c7d3b237..3c7c167c 100644 --- a/src/zx/zxgraph_print.cpp +++ b/src/zx/zxgraph_print.cpp @@ -89,7 +89,7 @@ void ZXGraph::print_vertices(std::vector cand) const { * * @param cand */ -void ZXGraph::print_vertices_by_qubits(spdlog::level::level_enum lvl, QubitIdList cand) const { +void ZXGraph::print_vertices_by_rows(spdlog::level::level_enum lvl, std::vector cand) const { std::map> q2_vmap; for (auto const& v : _vertices) { if (!q2_vmap.contains(v->get_row())) { diff --git a/tests/conversion/zx2qc/dof/extractStep.dof b/tests/conversion/zx2qc/dof/extractStep.dof index c0306819..4c10dcc2 100644 --- a/tests/conversion/zx2qc/dof/extractStep.dof +++ b/tests/conversion/zx2qc/dof/extractStep.dof @@ -7,7 +7,7 @@ zx copy 1 qcir new qcir qubit add 3 qcir -zx print -q +zx print -r extract print --frontier extract print --neighbors extract print --axels @@ -32,5 +32,5 @@ qc2zx zx adjoint zx compose 0 zx optimize --full -zx print -q +zx print -r quit -f diff --git a/tests/conversion/zx2qc/dof/extractTof2.dof b/tests/conversion/zx2qc/dof/extractTof2.dof index 8b0d5526..68181945 100644 --- a/tests/conversion/zx2qc/dof/extractTof2.dof +++ b/tests/conversion/zx2qc/dof/extractTof2.dof @@ -2,7 +2,7 @@ extract config --optimize-level 1 zx read benchmark/zx/tof3.zx zx2ts zx optimize --full -zx print -q +zx print -r logger debug zx2qc logger warn @@ -10,7 +10,7 @@ qc2zx zx adjoint zx compose 0 zx optimize --full -zx print -q +zx print -r qcir print qcir print --diagram zx test --identity diff --git a/tests/conversion/zx2qc/ref/extractStep.log b/tests/conversion/zx2qc/ref/extractStep.log index da6c0bfa..582bd494 100644 --- a/tests/conversion/zx2qc/ref/extractStep.log +++ b/tests/conversion/zx2qc/ref/extractStep.log @@ -19,7 +19,7 @@ qsyn> qcir -> #QCir: 2 -> Now focused on: QCir 1 -qsyn> zx print -q +qsyn> zx print -r ID: 15 (Z, π/4) (Qubit, Col): (-2, 5) #Neighbors: 1 (16, H) ID: 17 (Z, -π/4) (Qubit, Col): (-2, 15) #Neighbors: 1 (18, H) @@ -169,7 +169,7 @@ qsyn> zx compose 0 qsyn> zx optimize --full -qsyn> zx print -q +qsyn> zx print -r ID: 102 (Z, π/4) (Qubit, Col): (-2, 69) #Neighbors: 1 (103, H) ID: 104 (Z, -π/4) (Qubit, Col): (-2, 79) #Neighbors: 1 (105, H) diff --git a/tests/conversion/zx2qc/ref/extractTof2.log b/tests/conversion/zx2qc/ref/extractTof2.log index 47f4d151..0ade12c1 100644 --- a/tests/conversion/zx2qc/ref/extractTof2.log +++ b/tests/conversion/zx2qc/ref/extractTof2.log @@ -6,7 +6,7 @@ qsyn> zx2ts qsyn> zx optimize --full -qsyn> zx print -q +qsyn> zx print -r ID: 27 (Z, -π/4) (Qubit, Col): (-2, 3) #Neighbors: 1 (28, H) ID: 29 (Z, -π/4) (Qubit, Col): (-2, 7) #Neighbors: 1 (30, H) @@ -181,7 +181,7 @@ qsyn> zx compose 0 qsyn> zx optimize --full -qsyn> zx print -q +qsyn> zx print -r ID: 1 (●, 0) (Qubit, Col): (0, 0) #Neighbors: 1 (50, -) ID: 50 (●, 0) (Qubit, Col): (0, 38) #Neighbors: 1 (1, -) diff --git a/tests/qcir/qcir/dof/mcp.dof b/tests/qcir/qcir/dof/mcp.dof index 9552ff9a..a1ff3577 100644 --- a/tests/qcir/qcir/dof/mcp.dof +++ b/tests/qcir/qcir/dof/mcp.dof @@ -4,9 +4,9 @@ qcir print --diagram qcir print --gate 0 qc2ts qc2zx -zx print -q +zx print -r zx optimize --full -zx print -q +zx print -r zx2ts tensor equiv 0 1 qcir delete --all diff --git a/tests/qcir/qcir/dof/mcpx.dof b/tests/qcir/qcir/dof/mcpx.dof index 2824cb8b..6d36c5bb 100644 --- a/tests/qcir/qcir/dof/mcpx.dof +++ b/tests/qcir/qcir/dof/mcpx.dof @@ -4,9 +4,9 @@ qcir print --diagram qcir print --gate 0 qc2ts qc2zx -zx print -q +zx print -r zx optimize --full -zx print -q +zx print -r zx2ts tensor equiv 0 1 qcir delete --all diff --git a/tests/qcir/qcir/ref/mcp.log b/tests/qcir/qcir/ref/mcp.log index f5fe6bff..36f8682a 100644 --- a/tests/qcir/qcir/ref/mcp.log +++ b/tests/qcir/qcir/ref/mcp.log @@ -14,7 +14,7 @@ qsyn> qc2ts qsyn> qc2zx -qsyn> zx print -q +qsyn> zx print -r ID: 7 (Z, -π/6) (Qubit, Col): (-2, 2) #Neighbors: 1 (6, H) @@ -34,7 +34,7 @@ ID: 5 (Z, π/6) (Qubit, Col): (1, 2) #Neighbors: 3 (2, -) (3 qsyn> zx optimize --full -qsyn> zx print -q +qsyn> zx print -r ID: 7 (Z, -π/6) (Qubit, Col): (-2, 2) #Neighbors: 1 (6, H) diff --git a/tests/qcir/qcir/ref/mcpx.log b/tests/qcir/qcir/ref/mcpx.log index b8fdae63..ce4db5b3 100644 --- a/tests/qcir/qcir/ref/mcpx.log +++ b/tests/qcir/qcir/ref/mcpx.log @@ -14,7 +14,7 @@ qsyn> qc2ts qsyn> qc2zx -qsyn> zx print -q +qsyn> zx print -r ID: 0 (●, 0) (Qubit, Col): (0, 0) #Neighbors: 1 (4, -) ID: 1 (●, 0) (Qubit, Col): (0, 3) #Neighbors: 1 (4, -) @@ -28,7 +28,7 @@ ID: 5 (X, 0) (Qubit, Col): (1, 2) #Neighbors: 3 (2, -) (3, qsyn> zx optimize --full -qsyn> zx print -q +qsyn> zx print -r ID: 0 (●, 0) (Qubit, Col): (0, 0) #Neighbors: 1 (4, -) ID: 1 (●, 0) (Qubit, Col): (0, 3) #Neighbors: 1 (4, -) diff --git a/tests/zx/graph/dof/print.dof b/tests/zx/graph/dof/print.dof index 05a0ef04..2b46c65a 100644 --- a/tests/zx/graph/dof/print.dof +++ b/tests/zx/graph/dof/print.dof @@ -1,7 +1,7 @@ zx read benchmark/zx/cnot.zx zx print -v 1 0 zx print -v 1 0 d 9 -zx print -q 1 2 +zx print -r 1 2 zx read benchmark/zx/cnot.zx zx print -v zx diff --git a/tests/zx/graph/ref/print.log b/tests/zx/graph/ref/print.log index 1c6d67c3..b1f3ec81 100644 --- a/tests/zx/graph/ref/print.log +++ b/tests/zx/graph/ref/print.log @@ -9,7 +9,7 @@ ID: 0 (●, 0) (Qubit, Col): (0, 0) #Neighbors: 1 (2, -) qsyn> Error: invalid size_t value "d" for argument "-v"!! zx print -v 1 0 d 9 -qsyn> zx print -q 1 2 +qsyn> zx print -r 1 2 ID: 1 (●, 0) (Qubit, Col): (1, 0) #Neighbors: 1 (3, -) ID: 3 (X, 0) (Qubit, Col): (1, 1) #Neighbors: 3 (1, -) (2, -) (5, -) diff --git a/tests/zxrules/full_reduce/dof/rd32-v1_68.dof b/tests/zxrules/full_reduce/dof/rd32-v1_68.dof index 5dd3cad6..7d68ce09 100644 --- a/tests/zxrules/full_reduce/dof/rd32-v1_68.dof +++ b/tests/zxrules/full_reduce/dof/rd32-v1_68.dof @@ -1,8 +1,8 @@ qcir read ./benchmark/SABRE/small/rd32-v1_68.qasm qc2zx -zx print -q +zx print -r logger info zx optimize --full logger warn -zx print -q +zx print -r quit -f diff --git a/tests/zxrules/full_reduce/ref/rd32-v1_68.log b/tests/zxrules/full_reduce/ref/rd32-v1_68.log index 9d411263..6eb29f0c 100644 --- a/tests/zxrules/full_reduce/ref/rd32-v1_68.log +++ b/tests/zxrules/full_reduce/ref/rd32-v1_68.log @@ -2,7 +2,7 @@ qsyn> qcir read ./benchmark/SABRE/small/rd32-v1_68.qasm qsyn> qc2zx -qsyn> zx print -q +qsyn> zx print -r ID: 0 (●, 0) (Qubit, Col): (0, 0) #Neighbors: 1 (8, -) ID: 1 (●, 0) (Qubit, Col): (0, 37) #Neighbors: 1 (35, -) @@ -90,7 +90,7 @@ qsyn> zx optimize --full qsyn> logger warn -qsyn> zx print -q +qsyn> zx print -r ID: 61 (Z, -π/4) (Qubit, Col): (-2, 6) #Neighbors: 1 (62, H) ID: 67 (Z, -π/4) (Qubit, Col): (-2, 28) #Neighbors: 1 (68, H)