diff options
| author | hachem <im@hachem.wtf> | 2024-09-29 11:03:24 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2024-09-29 11:03:24 +0200 |
| commit | 127cee88ad2ade892dbcebc218ff006d008a8371 (patch) | |
| tree | b350bee5d041262e6c7214fbef2173f8ffbbc95f | |
| parent | 2770097e25e7fb5090efe0f85340f0c638f9dd71 (diff) | |
start work on basic examples
| -rw-r--r-- | Cargo.toml | 9 | ||||
| -rw-r--r-- | examples/README.md | 12 | ||||
| -rw-r--r-- | examples/simple_gates/Cargo.toml | 8 | ||||
| -rw-r--r-- | examples/simple_gates/src/main.rs (renamed from libpsi-tester/src/main.rs) | 4 | ||||
| -rw-r--r-- | examples/visualizers/Cargo.toml | 8 | ||||
| -rw-r--r-- | examples/visualizers/src/main.rs | 1 | ||||
| -rw-r--r-- | libpsi-qasm/Cargo.toml | 6 | ||||
| -rw-r--r-- | libpsi-qasm/src/lib.rs | 14 | ||||
| -rw-r--r-- | libpsi-tester/Cargo.toml | 8 |
9 files changed, 54 insertions, 16 deletions
@@ -1,7 +1,8 @@ [workspace] resolver = "2" members = [ - "libpsi-core", - "libpsi-tester", - "libpsi-visualizer" -] + "libpsi-core", + "libpsi-qasm", + "libpsi-visualizer", + "examples/*" +]
\ No newline at end of file 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/libpsi-tester/src/main.rs b/examples/simple_gates/src/main.rs index 7941935..5c529a6 100644 --- a/libpsi-tester/src/main.rs +++ b/examples/simple_gates/src/main.rs @@ -1,14 +1,10 @@ use libpsi_core::*; -use libpsi_visualizer::*; fn main() { let mut circuit = QuantumCircuit::new(2, 2); circuit.apply(&gates::HADAMARD, &[], &[0]); circuit.apply(&gates::CNOT, &[0], &[1]); - let visualizer = HorizontalCLIVisualizer::new(&circuit); - visualizer.render(); - 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() {} diff --git a/libpsi-qasm/Cargo.toml b/libpsi-qasm/Cargo.toml new file mode 100644 index 0000000..e36f63f --- /dev/null +++ b/libpsi-qasm/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "libpsi-qasm" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/libpsi-qasm/src/lib.rs b/libpsi-qasm/src/lib.rs new file mode 100644 index 0000000..7d12d9a --- /dev/null +++ b/libpsi-qasm/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/libpsi-tester/Cargo.toml b/libpsi-tester/Cargo.toml deleted file mode 100644 index 7a026b3..0000000 --- a/libpsi-tester/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "libpsi-tester" -version = "0.1.0" -edition = "2021" - -[dependencies] -libpsi-core = { path = "../libpsi-core" } -libpsi-visualizer = { path = "../libpsi-visualizer" }
\ No newline at end of file |
