{"id":22903949,"url":"https://github.com/drewsilcock/quest-rs","last_synced_at":"2025-05-08T17:21:50.575Z","repository":{"id":62443443,"uuid":"250243763","full_name":"drewsilcock/quest-rs","owner":"drewsilcock","description":"Safe Rust wrapper around QuEST toolkit","archived":false,"fork":false,"pushed_at":"2020-03-27T11:30:36.000Z","size":80,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-05T01:37:44.013Z","etag":null,"topics":["api-wrapper","quantum-computing","rust","simulation"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drewsilcock.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-26T11:47:00.000Z","updated_at":"2023-04-27T22:18:46.000Z","dependencies_parsed_at":"2022-11-01T23:18:14.121Z","dependency_job_id":null,"html_url":"https://github.com/drewsilcock/quest-rs","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewsilcock%2Fquest-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewsilcock%2Fquest-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewsilcock%2Fquest-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drewsilcock%2Fquest-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drewsilcock","download_url":"https://codeload.github.com/drewsilcock/quest-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253112359,"owners_count":21856123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-wrapper","quantum-computing","rust","simulation"],"created_at":"2024-12-14T02:39:34.103Z","updated_at":"2025-05-08T17:21:50.508Z","avatar_url":"https://github.com/drewsilcock.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QuEST Rust Wrapper\n\n[![Build](https://github.com/drewsilcock/quest-rs/workflows/Build/badge.svg)](https://github.com/drewsilcock/quest-rs/actions?query=workflow%3ABuild)\n[![Docs](https://docs.rs/quest-rs/badge.svg)](https://docs.rs/quest-rs)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n## Introduction\n\nThe Quantum Exact Simulation Toolkit is a high performance simulator of\nuniversal quantum circuits, state-vectors and density matrices. QuEST is\nwritten in C, hybridises OpenMP and MPI, and can run on a GPU. Needing only\ncompilation, QuEST is easy to run both on laptops and supercomputers (in both\nC and C++), where it can take advantage of multicore, GPU-accelerated and\nnetworked machines to quickly simulate circuits on many qubits.\n\nThis library provides a safe wrapper around QuEST with an idiomatic Rust API.\n\n## Usage\n\nTo use quest-rs in your Rust codebase, first run:\n```bash\ncargo add quest-rs\n```\nor add `quest-rs` manually to your `Cargo.toml`.\n\nThe API is simple:\n```rust\nuse quest_rs::{QuestEnv, QuReg};\n\nlet env = QuestEnv::new();\nlet mut qubits = QuReg::new(2, \u0026env);\nqubits.init_plus_state().hadamard(0).controlled_not(0, 1);\nprintln!(\n    \"Probability amplitude of |11\u003e *before* measurement is: {}\",\n    qubits.probability_amplitude(0b11)\n);\nqubits.measure(1);\nprintln!(\n    \"Probability amplitude of |11\u003e *after* measurement is: {}\",\n    qubits.probability_amplitude(0b11)\n);\n```\n\nThe fluent API makes more complicated circuits easy to create:\n```rust\nuse quest_rs::{Complex, ComplexMatrix2, ComplexMatrixN, QReal, QuReg, QuestEnv, Vector};\n\nlet env = QuestEnv::new();\n\nlet mut qubits = QuReg::new(3, \u0026env);\nqubits.init_zero_state();\n\nprintln!(\"Out environment is:\");\nqubits.report_params();\nenv.report();\n\n// Set up the circuitry\n\nlet unitary_alpha = Complex::new(0.5, 0.5);\nlet unitary_beta = Complex::new(0.5, -0.5);\n\nlet unitary_matrix = ComplexMatrix2 {\n    real: [[0.5, 0.5], [0.5, 0.5]],\n    imag: [[0.5, -0.5], [-0.5, 0.5]],\n};\n\nlet mut toffoli_gate = ComplexMatrixN::new(3);\nfor i in 0..6 {\n    toffoli_gate.set_real(i, i, 1.0);\n}\ntoffoli_gate.set_real(6, 7, 1.0);\ntoffoli_gate.set_real(7, 6, 1.0);\n\nqubits\n    .hadamard(0)\n    .controlled_not(0, 1)\n    .rotate_y(2, 0.1)\n    .multi_controlled_phase_flip(vec![0, 1, 2])\n    .unitary(0, unitary_matrix)\n    .compact_unitary(1, unitary_alpha, unitary_beta)\n    .rotate_around_axis(2, (3.14 / 2.0) as QReal, Vector::new(1.0, 0.0, 0.0))\n    .controlled_compact_unitary(0, 1, unitary_alpha, unitary_beta)\n    .multi_controlled_unitary(vec![0, 1], 2, unitary_matrix)\n    .multi_qubit_unitary(vec![0, 1, 2], toffoli_gate);\n\n// Study the output\n\nprintln!(\"Circuit output:\");\nprintln!(\"---------------\");\nprintln!(\"Probability amplitude of |111\u003e is: {}\", qubits.probability_amplitude(0b111));\nprintln!(\n    \"Probability of qubit 2 being in state 1: {}\",\n    qubits.calculate_probability_of_outcome(2, 1)\n);\nprintln!(\"Qubit 0 was measured in state: {}\", qubits.measure(0));\nlet (outcome, outcome_probability) = qubits.measure_with_stats(2);\nprintln!(\n    \"Qubit 2 collapsed to {} with probability {}\",\n    outcome, outcome_probability\n);\n```\n\n## Template\n\nFor a starter template to get going with an executable project that uses this\nwrapper, see: https://github.com/drewsilcock/quest-rs-template or press this button:\n\n[![Use Template](https://img.shields.io/badge/Starter%20Template-Use-orange.svg)](https://github.com/drewsilcock/quest-rs-template/generate)\n\n## Todo\n\nThe C QuEST library has several compile-option flags which should be\nsupported using cargo features. These are:\n- what precision to operate in (single, double or quad)\n- whether to enable OpenMP, MPI, OpenMP+MPI or GPU\n\nThe documentation should also be expanded to include all the relevant info\nfrom the QuEST documentation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrewsilcock%2Fquest-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrewsilcock%2Fquest-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrewsilcock%2Fquest-rs/lists"}