From 127cee88ad2ade892dbcebc218ff006d008a8371 Mon Sep 17 00:00:00 2001 From: hachem Date: Sun, 29 Sep 2024 11:03:24 +0200 Subject: start work on basic examples --- examples/README.md | 12 ++++++++++++ examples/simple_gates/Cargo.toml | 8 ++++++++ examples/simple_gates/src/main.rs | 10 ++++++++++ examples/visualizers/Cargo.toml | 8 ++++++++ examples/visualizers/src/main.rs | 1 + 5 files changed, 39 insertions(+) create mode 100644 examples/README.md create mode 100644 examples/simple_gates/Cargo.toml create mode 100644 examples/simple_gates/src/main.rs create mode 100644 examples/visualizers/Cargo.toml create mode 100644 examples/visualizers/src/main.rs (limited to 'examples') diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..47cbfd5 --- /dev/null +++ b/examples/README.md @@ -0,0 +1,12 @@ +# Examples +In this directory, you will find a series of directories providing examples on how to use all the $\psi$ libraries. Since this entire project is based on workspaces, all you have to do use the following command: +```sh +$ cargo run -p [example name] +``` + +For instance: +```sh +$ cargo run -p simple_gates +$ cargo run -p visualizers +... +``` \ No newline at end of file diff --git a/examples/simple_gates/Cargo.toml b/examples/simple_gates/Cargo.toml new file mode 100644 index 0000000..503d31c --- /dev/null +++ b/examples/simple_gates/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "simple_gates" +version = "0.1.0" +edition = "2021" + +[dependencies] +libpsi-core = { path = "../../libpsi-core" } +libpsi-visualizer = { path = "../../libpsi-visualizer" } \ No newline at end of file diff --git a/examples/simple_gates/src/main.rs b/examples/simple_gates/src/main.rs new file mode 100644 index 0000000..5c529a6 --- /dev/null +++ b/examples/simple_gates/src/main.rs @@ -0,0 +1,10 @@ +use libpsi_core::*; + +fn main() { + let mut circuit = QuantumCircuit::new(2, 2); + circuit.apply(&gates::HADAMARD, &[], &[0]); + circuit.apply(&gates::CNOT, &[0], &[1]); + + let runtime = BasicRT::new(&circuit); + runtime.execute(1024); +} diff --git a/examples/visualizers/Cargo.toml b/examples/visualizers/Cargo.toml new file mode 100644 index 0000000..ab34ffe --- /dev/null +++ b/examples/visualizers/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "visualizers" +version = "0.1.0" +edition = "2021" + +[dependencies] +libpsi-core = { path = "../../libpsi-core" } +libpsi-visualizer = { path = "../../libpsi-visualizer" } \ No newline at end of file diff --git a/examples/visualizers/src/main.rs b/examples/visualizers/src/main.rs new file mode 100644 index 0000000..f328e4d --- /dev/null +++ b/examples/visualizers/src/main.rs @@ -0,0 +1 @@ +fn main() {} -- cgit v1.3