diff --git a/.swm b/.swm
deleted file mode 100644
index a6b5b4c..0000000
Binary files a/.swm and /dev/null differ
diff --git a/.swn b/.swn
deleted file mode 100644
index 27a7812..0000000
Binary files a/.swn and /dev/null differ
diff --git a/.swo b/.swo
deleted file mode 100644
index 8a8ebe7..0000000
Binary files a/.swo and /dev/null differ
diff --git a/README.md b/README.md
index 50730f3..6b66f4e 100644
--- a/README.md
+++ b/README.md
@@ -10,10 +10,6 @@ Quantum Algorithms with Java and Strange
- [Quantum Computing samples in Java](https://github.com/johanvos/quantumjava)
- [How to Install Maven on Linux (Ubuntu)](https://www.digitalocean.com/community/tutorials/install-maven-linux-ubuntu)
- [Quantum Logic Gate](https://en.wikipedia.org/wiki/Quantum_logic_gate)
-- [Quantum Key Distribution and BB84 Protocol](https://en.wikipedia.org/wiki/BB84)
-- [Deutsch–Jozsa algorithm](https://en.wikipedia.org/wiki/Grover%27s_algorithm)
-- [Grover's algorithm](https://en.wikipedia.org/wiki/Shor%27s_algorithm)
-- [Shor's Algorithm](https://en.wikipedia.org/wiki/Deutsch%E2%80%93Jozsa_algorithm)
## Instructions
@@ -342,265 +338,3 @@ Qubit | Probability: 1.0, Mesured: 1
```

-
-### BB84 Algorithm
-
-Sending a message over the network, taking advantage of the `Hadamard` gate resulting in the original Qubit if applied twice.
-
-```bash
-mvn clean javafx:run --quiet --file bb84.xml
-```
-
-The `|1001>` Qubits sent by Alice are received as `|1001>` by Bob.
-
-```bash
-Qubit | Probability: 0.9999997615814209, Mesured: 1
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.9999997615814209, Mesured: 1
-```
-
-
-
-Eve is listening on the network and randomly applies `Hadamard` gates to try to get the message. After that, retransmits the Qubit to Bob who applies the same `Hadamard` configuration that Alice randomly applied.
-
-```bash
-mvn clean javafx:run --quiet --file eavesdropping.xml
-```
-
-The `|1001>` Qubits sent by Alice are not properly received by Eve, who can not forward a message to Bob without him noticing that the message has been tampered.
-
-```bash
-Qubit | Probability: 0.9999997615814209, Mesured: 1
-Qubit | Probability: 0.49999988079071045, Mesured: 1
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.49999988079071045, Mesured: 1
-```
-
-
-
-### Deutsch Josza Algorithm
-
-Running the Deutsch Algorithm with a random Oracle that is unknown at run time:
-
-```bash
-mvn clean javafx:run --quiet --file deutschjozsa.xml
-```
-
-If the Oracle is a constant function, the measured value of the first Qubit is guaranteed to be 0.
-If the Oracle is a balanced function, the measured value of the first Qubit is guaranteed to be 1.
-
-```bash
-Qubit | Function: 0 Type: constant
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.49999991059303284, Mesured: 1
-----------------------------------------------------
-Qubit | Function: 1 Type: balanced
-Qubit | Probability: 0.9999998211860657, Mesured: 1
-Qubit | Probability: 0.49999991059303284, Mesured: 0
-----------------------------------------------------
-Qubit | Function: 0 Type: constant
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.49999991059303284, Mesured: 1
-----------------------------------------------------
-Qubit | Function: 1 Type: balanced
-Qubit | Probability: 0.9999998211860657, Mesured: 1
-Qubit | Probability: 0.49999991059303284, Mesured: 0
-----------------------------------------------------
-Qubit | Function: 1 Type: balanced
-Qubit | Probability: 0.9999998211860657, Mesured: 1
-Qubit | Probability: 0.49999991059303284, Mesured: 1
-----------------------------------------------------
-Qubit | Function: 0 Type: constant
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.49999991059303284, Mesured: 0
-----------------------------------------------------
-Qubit | Function: 0 Type: constant
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.49999991059303284, Mesured: 1
-----------------------------------------------------
-Qubit | Function: 1 Type: balanced
-Qubit | Probability: 0.9999998211860657, Mesured: 1
-Qubit | Probability: 0.49999991059303284, Mesured: 0
-----------------------------------------------------
-Qubit | Function: 0 Type: constant
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.49999991059303284, Mesured: 1
-----------------------------------------------------
-Qubit | Function: 1 Type: balanced
-Qubit | Probability: 0.9999998211860657, Mesured: 1
-Qubit | Probability: 0.49999991059303284, Mesured: 0
-```
-
-
-
-Running the Deutsch Algorithm with 2 Qubits.
-
-```bash
-mvn clean javafx:run --quiet --file deutschjozsa2.xml
-```
-
-If the Oracle is a constant function, the measured value of the first Qubit is guaranteed to be 0.
-If the Oracle is a balanced function, the measured value of the first Qubit is guaranteed to be 1.
-
-```bash
-Qubit | Function: 1 Type: balanced
-Qubit | Probability: 0.9999998211860657, Mesured: 1
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.49999991059303284, Mesured: 0
-----------------------------------------------------
-Qubit | Function: 0 Type: constant
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.49999991059303284, Mesured: 0
-----------------------------------------------------
-Qubit | Function: 0 Type: constant
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.49999991059303284, Mesured: 0
-```
-
-
-
-Running the Deutsch Algorithm with 3 Qubits.
-
-```bash
-mvn clean javafx:run --quiet --file deutschjozsa3.xml
-```
-
-If the Oracle is a constant function, the measured value of the first Qubit is guaranteed to be 0.
-If the Oracle is a balanced function, the measured value of the first Qubit is guaranteed to be 1.
-
-```bash
-Qubit | Function: 0 Type: constant
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.49999991059303284, Mesured: 0
-----------------------------------------------------
-Qubit | Function: 0 Type: constant
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.49999991059303284, Mesured: 1
-----------------------------------------------------
-Qubit | Function: 1 Type: balanced
-Qubit | Probability: 0.9999998211860657, Mesured: 1
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.49999991059303284, Mesured: 0
-```
-
-
-
-Running the Deutsch-Jozsa Algorithm with N Qubits.
-
-```bash
-mvn clean javafx:run --quiet --file deutschjozsa10.xml
-```
-
-If the Oracle is a constant function, the measured value of the first Qubit is guaranteed to be 0.
-If the Oracle is a balanced function, the measured value of the first Qubit is guaranteed to be 1.
-
-```bash
-Qubit | Function: 0 Type: constant
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.49999991059303284, Mesured: 0
-----------------------------------------------------
-Qubit | Function: 0 Type: constant
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.49999991059303284, Mesured: 0
-----------------------------------------------------
-Qubit | Function: 1 Type: balanced
-Qubit | Probability: 0.9999998211860657, Mesured: 1
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.0, Mesured: 0
-Qubit | Probability: 0.49999991059303284, Mesured: 0
-```
-
-### Grover's Search Algorithm
-
-Running the Deutsch Algorithm with a random Oracle that is unknown at run time:
-
-```bash
-mvn clean javafx:run --quiet --file grover.xml
-```
-
-The algorithm iterates multiple times applying the `Oracle` and the `Diffusor`. In each iteration, the probability of measuring the expected solution increases.
-
-In this case, there are 3 Qubits which can encode 8 values. In other words, 3 Qubits can be used to search for a match among 8 records.
-
-```bash
-Qubits | Qubits: 3 Encoded: 8 Solution: 2 Runs: 2.221441469079183
-----------------------------------------------------
-Correct Solution Probability after step 1: 0.7812497615814209
-Correct Solution Probability after step 2: 0.9453120827674866
-----------------------------------------------------
-Probability distribution at step: 1
-p: 0.031249988824129105
-p: 0.031249988824129105
-p: 0.7812497615814209
-p: 0.031249988824129105
-p: 0.031249988824129105
-p: 0.031249994412064552
-p: 0.031249988824129105
-p: 0.031249983236193657
-----------------------------------------------------
-Probability distribution at step: 2
-p: 0.007812506519258022
-p: 0.007812506519258022
-p: 0.9453120827674866
-p: 0.007812506519258022
-p: 0.007812500931322575
-p: 0.007812506519258022
-p: 0.007812500931322575
-p: 0.007812498603016138
-```
-
-
-
-Running the Deutsch Algorithm with a random Oracle that is unknown at run time:
-
-```bash
-mvn clean javafx:run --quiet --file grovern.xml
-```
-
-This time, the Grover's Search algorithm is able to search for a match among 256 records. As a conclusion, the computation increases exponentially with the amount of entangled Qubits.
-
-```bash
-Qubits | Qubits: 8 Encoded: 256.0 Solution: 2 Runs: 12.566370614359172
-----------------------------------------------------
-Correct Solution Probability after step 1: 0.03479098901152611
-Correct Solution Probability after step 2: 0.09463772177696228
-Correct Solution Probability after step 3: 0.17972062528133392
-Correct Solution Probability after step 4: 0.2847433090209961
-Correct Solution Probability after step 5: 0.40317079424858093
-Correct Solution Probability after step 6: 0.527620255947113
-Correct Solution Probability after step 7: 0.6503432393074036
-[...]
-```
diff --git a/bb84.xml b/bb84.xml
deleted file mode 100644
index 35739d7..0000000
--- a/bb84.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
- 4.0.0
- org.redfx.javaqc
- simplestrangedemo
- jar
- 1.0-SNAPSHOT
- Quantum Algorithms
- http://maven.apache.org
-
- 1.8
- 1.8
-
-
-
- org.redfx
- strange
- 0.1.1
-
-
- org.redfx
- strangefx
- 0.1.4
-
-
-
-
-
- org.openjfx
- javafx-maven-plugin
- 0.0.6
-
- Encryption
-
-
-
-
-
diff --git a/deutschjozsa.xml b/deutschjozsa.xml
deleted file mode 100644
index 6bc516d..0000000
--- a/deutschjozsa.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
- 4.0.0
- org.redfx.javaqc
- simplestrangedemo
- jar
- 1.0-SNAPSHOT
- Quantum Algorithms
- http://maven.apache.org
-
- 1.8
- 1.8
-
-
-
- org.redfx
- strange
- 0.1.1
-
-
- org.redfx
- strangefx
- 0.1.4
-
-
-
-
-
- org.openjfx
- javafx-maven-plugin
- 0.0.6
-
- DeutschJosza
-
-
-
-
-
diff --git a/deutschjozsa10.xml b/deutschjozsa10.xml
deleted file mode 100644
index 3b17c02..0000000
--- a/deutschjozsa10.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
- 4.0.0
- org.redfx.javaqc
- simplestrangedemo
- jar
- 1.0-SNAPSHOT
- Quantum Algorithms
- http://maven.apache.org
-
- 1.8
- 1.8
-
-
-
- org.redfx
- strange
- 0.1.1
-
-
- org.redfx
- strangefx
- 0.1.4
-
-
-
-
-
- org.openjfx
- javafx-maven-plugin
- 0.0.6
-
- DeutschJosza10
-
-
-
-
-
diff --git a/deutschjozsa2.xml b/deutschjozsa2.xml
deleted file mode 100644
index c0053a3..0000000
--- a/deutschjozsa2.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
- 4.0.0
- org.redfx.javaqc
- simplestrangedemo
- jar
- 1.0-SNAPSHOT
- Quantum Algorithms
- http://maven.apache.org
-
- 1.8
- 1.8
-
-
-
- org.redfx
- strange
- 0.1.1
-
-
- org.redfx
- strangefx
- 0.1.4
-
-
-
-
-
- org.openjfx
- javafx-maven-plugin
- 0.0.6
-
- DeutschJosza2
-
-
-
-
-
diff --git a/deutschjozsa3.xml b/deutschjozsa3.xml
deleted file mode 100644
index e8d63a1..0000000
--- a/deutschjozsa3.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
- 4.0.0
- org.redfx.javaqc
- simplestrangedemo
- jar
- 1.0-SNAPSHOT
- Quantum Algorithms
- http://maven.apache.org
-
- 1.8
- 1.8
-
-
-
- org.redfx
- strange
- 0.1.1
-
-
- org.redfx
- strangefx
- 0.1.4
-
-
-
-
-
- org.openjfx
- javafx-maven-plugin
- 0.0.6
-
- DeutschJosza3
-
-
-
-
-
diff --git a/eavesdropping.xml b/eavesdropping.xml
deleted file mode 100644
index 11b959d..0000000
--- a/eavesdropping.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
- 4.0.0
- org.redfx.javaqc
- simplestrangedemo
- jar
- 1.0-SNAPSHOT
- Quantum Algorithms
- http://maven.apache.org
-
- 1.8
- 1.8
-
-
-
- org.redfx
- strange
- 0.1.1
-
-
- org.redfx
- strangefx
- 0.1.4
-
-
-
-
-
- org.openjfx
- javafx-maven-plugin
- 0.0.6
-
- Eavesdropping
-
-
-
-
-
diff --git a/grover.xml b/grover.xml
deleted file mode 100644
index d6d410b..0000000
--- a/grover.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
- 4.0.0
- org.redfx.javaqc
- simplestrangedemo
- jar
- 1.0-SNAPSHOT
- Quantum Algorithms
- http://maven.apache.org
-
- 1.8
- 1.8
-
-
-
- org.redfx
- strange
- 0.1.1
-
-
- org.redfx
- strangefx
- 0.1.4
-
-
-
-
-
- org.openjfx
- javafx-maven-plugin
- 0.0.6
-
- Grover
-
-
-
-
-
diff --git a/grovern.xml b/grovern.xml
deleted file mode 100644
index c7d0bca..0000000
--- a/grovern.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
- 4.0.0
- org.redfx.javaqc
- simplestrangedemo
- jar
- 1.0-SNAPSHOT
- Quantum Algorithms
- http://maven.apache.org
-
- 1.8
- 1.8
-
-
-
- org.redfx
- strange
- 0.1.1
-
-
- org.redfx
- strangefx
- 0.1.4
-
-
-
-
-
- org.openjfx
- javafx-maven-plugin
- 0.0.6
-
- GroverN
-
-
-
-
-
diff --git a/images/bb84.png b/images/bb84.png
deleted file mode 100644
index 4586d9f..0000000
Binary files a/images/bb84.png and /dev/null differ
diff --git a/images/eavesdropping.png b/images/eavesdropping.png
deleted file mode 100644
index 8405d50..0000000
Binary files a/images/eavesdropping.png and /dev/null differ
diff --git a/images/grover.png b/images/grover.png
deleted file mode 100644
index bbba2e2..0000000
Binary files a/images/grover.png and /dev/null differ
diff --git a/images/jozsa.png b/images/jozsa.png
deleted file mode 100644
index b9c6e3e..0000000
Binary files a/images/jozsa.png and /dev/null differ
diff --git a/images/jozsa2.png b/images/jozsa2.png
deleted file mode 100644
index d919673..0000000
Binary files a/images/jozsa2.png and /dev/null differ
diff --git a/images/jozsa3.png b/images/jozsa3.png
deleted file mode 100644
index 3b6eb90..0000000
Binary files a/images/jozsa3.png and /dev/null differ
diff --git a/src/main/java/DeutschJosza.java b/src/main/java/DeutschJosza.java
deleted file mode 100644
index ea0c641..0000000
--- a/src/main/java/DeutschJosza.java
+++ /dev/null
@@ -1,125 +0,0 @@
-import org.redfx.strange.*;
-import org.redfx.strange.gate.*;
-import org.redfx.strange.local.SimpleQuantumExecutionEnvironment;
-import org.redfx.strangefx.render.Renderer;
-
-import java.util.Random;
-import java.util.Arrays;
-
-public class DeutschJosza {
-
- static final int N = 1;
- static final int RUNS = 10;
-
- public static void main(String[] args) {
- // Connecting to a local simulator.
- QuantumExecutionEnvironment simulator = new SimpleQuantumExecutionEnvironment();
-
- // Running the same program multiple times.
- for (int i = 0; i < RUNS; i++) {
- // Setting up the Quantum Program.
- Program program = new Program(N + 1);
-
- // Initilizing steps in the Quantum Program.
- Step step1 = new Step();
- Step step2 = new Step();
- Step step3 = new Step();
- Step step4 = new Step();
-
- // Adding a not gate to only the last Qubit, which
- // is the helper Qubit.
- step1.addGate(new X(N));
-
- // Adding a Hadamard gate to all the Qubits to put
- // them into a Superposition state.
- for (int j = 0; j < N+1; j++) {
- step2.addGate(new Hadamard(j));
- }
-
- // Adding a random Oracle gate to the Program, so
- // that we can test the robustness of the Deutsch-Jozsa
- // algorithm in front of randomness.
- Oracle oracle = createOracle();
- step3.addGate(oracle);
-
- // Applying a Hadamard gate to all the Qubits except
- // the last one, which is discarded, since was just a helper Qubit.
- for (int j = 0; j < N; j++) {
- step4.addGate(new Hadamard(j));
- }
-
- // Adding gates to the Quantum Program.
- program.addStep(step1);
- program.addStep(step2);
- program.addStep(step3);
- program.addStep(step4);
-
- // Running the Program.
- Result res = simulator.runProgram(program);
-
- // Measuring a single Qubit.
- Qubit[] qubits = res.getQubits();
- Arrays.asList(qubits).forEach(q -> DeutschJosza.measure(q));
-
- // Rendering circuit as an image.
- if (i == RUNS - 1) {
- Renderer.renderProgram(program);
- Renderer.showProbabilities(program, 1000);
- }
- }
-
-
- }
-
- private static void measure(Qubit q) {
- System.out.println("Qubit | Probability: "+q.getProbability()+", Mesured: "+ q.measure());
- }
-
- private static Oracle createOracle() {
- // Initializing an empty matrix of size NxN.
- int dim = 2 << N;
- int half = dim / 2;
- Complex[][] matrix = new Complex[dim][dim];
-
- // Building the Oracle based on a random Number.
- Random random = new Random();
- int choice = random.nextInt(2);
- String type = "balanced";
- if (choice == 0) {
- type = "constant";
- }
- System.out.println("----------------------------------------------------");
- System.out.println("Qubit | Function: "+ choice + " Type: " + type);
-
- // Generating a matrix that should represent the Oracle that is unknown
- // to the Program executing the Deutsch-Jozsa Algorithm.
- switch (choice) {
-
- // Building a constant function that returns 1 every time.
- case 0:
- for (int i = 0; i < dim; i ++) {
- matrix[i][i] = Complex.ONE;
- }
- return new Oracle(matrix);
-
- // Creating a balanced function that returns 1 50% of the time.
- case 1:
- for (int i = 0; i < dim; i ++) {
- if (i % 2 == 0) {
- matrix[i][i] = Complex.ONE;
- } else {
- if (i < half) {
- matrix[i][i + half] = Complex.ONE;
- } else{
- matrix[i][i - half] = Complex.ONE;
- }
- }
- }
- return new Oracle(matrix);
-
- // Invalid Oracle index.
- default:
- throw new IllegalArgumentException("Wrong index in oracle: " + choice);
- }
- }
-}
diff --git a/src/main/java/DeutschJosza10.java b/src/main/java/DeutschJosza10.java
deleted file mode 100644
index de62c47..0000000
--- a/src/main/java/DeutschJosza10.java
+++ /dev/null
@@ -1,125 +0,0 @@
-import org.redfx.strange.*;
-import org.redfx.strange.gate.*;
-import org.redfx.strange.local.SimpleQuantumExecutionEnvironment;
-import org.redfx.strangefx.render.Renderer;
-
-import java.util.Random;
-import java.util.Arrays;
-
-public class DeutschJosza10 {
-
- static final int N = 10;
- static final int RUNS = 8;
-
- public static void main(String[] args) {
- // Connecting to a local simulator.
- QuantumExecutionEnvironment simulator = new SimpleQuantumExecutionEnvironment();
-
- // Running the same program multiple times.
- for (int i = 0; i < RUNS; i++) {
- // Setting up the Quantum Program.
- Program program = new Program(N + 1);
-
- // Initilizing steps in the Quantum Program.
- Step step1 = new Step();
- Step step2 = new Step();
- Step step3 = new Step();
- Step step4 = new Step();
-
- // Adding a not gate to only the last Qubit, which
- // is the helper Qubit.
- step1.addGate(new X(N));
-
- // Adding a Hadamard gate to all the Qubits to put
- // them into a Superposition state.
- for (int j = 0; j < N+1; j++) {
- step2.addGate(new Hadamard(j));
- }
-
- // Adding a random Oracle gate to the Program, so
- // that we can test the robustness of the Deutsch-Jozsa
- // algorithm in front of randomness.
- Oracle oracle = createOracle();
- step3.addGate(oracle);
-
- // Applying a Hadamard gate to all the Qubits except
- // the last one, which is discarded, since was just a helper Qubit.
- for (int j = 0; j < N; j++) {
- step4.addGate(new Hadamard(j));
- }
-
- // Adding gates to the Quantum Program.
- program.addStep(step1);
- program.addStep(step2);
- program.addStep(step3);
- program.addStep(step4);
-
- // Running the Program.
- Result res = simulator.runProgram(program);
-
- // Measuring a single Qubit.
- Qubit[] qubits = res.getQubits();
- Arrays.asList(qubits).forEach(q -> DeutschJosza10.measure(q));
-
- // Rendering circuit as an image.
- if (i == RUNS - 1) {
- Renderer.renderProgram(program);
- Renderer.showProbabilities(program, 1000);
- }
- }
-
-
- }
-
- private static void measure(Qubit q) {
- System.out.println("Qubit | Probability: "+q.getProbability()+", Mesured: "+ q.measure());
- }
-
- private static Oracle createOracle() {
- // Initializing an empty matrix of size NxN.
- int dim = 2 << N;
- int half = dim / 2;
- Complex[][] matrix = new Complex[dim][dim];
-
- // Building the Oracle based on a random Number.
- Random random = new Random();
- int choice = random.nextInt(2);
- String type = "balanced";
- if (choice == 0) {
- type = "constant";
- }
- System.out.println("----------------------------------------------------");
- System.out.println("Qubit | Function: "+ choice + " Type: " + type);
-
- // Generating a matrix that should represent the Oracle that is unknown
- // to the Program executing the Deutsch-Jozsa Algorithm.
- switch (choice) {
-
- // Building a constant function that returns 1 every time.
- case 0:
- for (int i = 0; i < dim; i ++) {
- matrix[i][i] = Complex.ONE;
- }
- return new Oracle(matrix);
-
- // Creating a balanced function that returns 1 50% of the time.
- case 1:
- for (int i = 0; i < dim; i ++) {
- if (i % 2 == 0) {
- matrix[i][i] = Complex.ONE;
- } else {
- if (i < half) {
- matrix[i][i + half] = Complex.ONE;
- } else{
- matrix[i][i - half] = Complex.ONE;
- }
- }
- }
- return new Oracle(matrix);
-
- // Invalid Oracle index.
- default:
- throw new IllegalArgumentException("Wrong index in oracle: " + choice);
- }
- }
-}
diff --git a/src/main/java/DeutschJosza2.java b/src/main/java/DeutschJosza2.java
deleted file mode 100644
index 7d1e789..0000000
--- a/src/main/java/DeutschJosza2.java
+++ /dev/null
@@ -1,125 +0,0 @@
-import org.redfx.strange.*;
-import org.redfx.strange.gate.*;
-import org.redfx.strange.local.SimpleQuantumExecutionEnvironment;
-import org.redfx.strangefx.render.Renderer;
-
-import java.util.Random;
-import java.util.Arrays;
-
-public class DeutschJosza2 {
-
- static final int N = 2;
- static final int RUNS = 3;
-
- public static void main(String[] args) {
- // Connecting to a local simulator.
- QuantumExecutionEnvironment simulator = new SimpleQuantumExecutionEnvironment();
-
- // Running the same program multiple times.
- for (int i = 0; i < RUNS; i++) {
- // Setting up the Quantum Program.
- Program program = new Program(N + 1);
-
- // Initilizing steps in the Quantum Program.
- Step step1 = new Step();
- Step step2 = new Step();
- Step step3 = new Step();
- Step step4 = new Step();
-
- // Adding a not gate to only the last Qubit, which
- // is the helper Qubit.
- step1.addGate(new X(N));
-
- // Adding a Hadamard gate to all the Qubits to put
- // them into a Superposition state.
- for (int j = 0; j < N+1; j++) {
- step2.addGate(new Hadamard(j));
- }
-
- // Adding a random Oracle gate to the Program, so
- // that we can test the robustness of the Deutsch-Jozsa
- // algorithm in front of randomness.
- Oracle oracle = createOracle();
- step3.addGate(oracle);
-
- // Applying a Hadamard gate to all the Qubits except
- // the last one, which is discarded, since was just a helper Qubit.
- for (int j = 0; j < N; j++) {
- step4.addGate(new Hadamard(j));
- }
-
- // Adding gates to the Quantum Program.
- program.addStep(step1);
- program.addStep(step2);
- program.addStep(step3);
- program.addStep(step4);
-
- // Running the Program.
- Result res = simulator.runProgram(program);
-
- // Measuring a single Qubit.
- Qubit[] qubits = res.getQubits();
- Arrays.asList(qubits).forEach(q -> DeutschJosza2.measure(q));
-
- // Rendering circuit as an image.
- if (i == RUNS - 1) {
- Renderer.renderProgram(program);
- Renderer.showProbabilities(program, 1000);
- }
- }
-
-
- }
-
- private static void measure(Qubit q) {
- System.out.println("Qubit | Probability: "+q.getProbability()+", Mesured: "+ q.measure());
- }
-
- private static Oracle createOracle() {
- // Initializing an empty matrix of size NxN.
- int dim = 2 << N;
- int half = dim / 2;
- Complex[][] matrix = new Complex[dim][dim];
-
- // Building the Oracle based on a random Number.
- Random random = new Random();
- int choice = random.nextInt(2);
- String type = "balanced";
- if (choice == 0) {
- type = "constant";
- }
- System.out.println("----------------------------------------------------");
- System.out.println("Qubit | Function: "+ choice + " Type: " + type);
-
- // Generating a matrix that should represent the Oracle that is unknown
- // to the Program executing the Deutsch-Jozsa Algorithm.
- switch (choice) {
-
- // Building a constant function that returns 1 every time.
- case 0:
- for (int i = 0; i < dim; i ++) {
- matrix[i][i] = Complex.ONE;
- }
- return new Oracle(matrix);
-
- // Creating a balanced function that returns 1 50% of the time.
- case 1:
- for (int i = 0; i < dim; i ++) {
- if (i % 2 == 0) {
- matrix[i][i] = Complex.ONE;
- } else {
- if (i < half) {
- matrix[i][i + half] = Complex.ONE;
- } else{
- matrix[i][i - half] = Complex.ONE;
- }
- }
- }
- return new Oracle(matrix);
-
- // Invalid Oracle index.
- default:
- throw new IllegalArgumentException("Wrong index in oracle: " + choice);
- }
- }
-}
diff --git a/src/main/java/DeutschJosza3.java b/src/main/java/DeutschJosza3.java
deleted file mode 100644
index 0e0d195..0000000
--- a/src/main/java/DeutschJosza3.java
+++ /dev/null
@@ -1,125 +0,0 @@
-import org.redfx.strange.*;
-import org.redfx.strange.gate.*;
-import org.redfx.strange.local.SimpleQuantumExecutionEnvironment;
-import org.redfx.strangefx.render.Renderer;
-
-import java.util.Random;
-import java.util.Arrays;
-
-public class DeutschJosza3 {
-
- static final int N = 3;
- static final int RUNS = 3;
-
- public static void main(String[] args) {
- // Connecting to a local simulator.
- QuantumExecutionEnvironment simulator = new SimpleQuantumExecutionEnvironment();
-
- // Running the same program multiple times.
- for (int i = 0; i < RUNS; i++) {
- // Setting up the Quantum Program.
- Program program = new Program(N + 1);
-
- // Initilizing steps in the Quantum Program.
- Step step1 = new Step();
- Step step2 = new Step();
- Step step3 = new Step();
- Step step4 = new Step();
-
- // Adding a not gate to only the last Qubit, which
- // is the helper Qubit.
- step1.addGate(new X(N));
-
- // Adding a Hadamard gate to all the Qubits to put
- // them into a Superposition state.
- for (int j = 0; j < N+1; j++) {
- step2.addGate(new Hadamard(j));
- }
-
- // Adding a random Oracle gate to the Program, so
- // that we can test the robustness of the Deutsch-Jozsa
- // algorithm in front of randomness.
- Oracle oracle = createOracle();
- step3.addGate(oracle);
-
- // Applying a Hadamard gate to all the Qubits except
- // the last one, which is discarded, since was just a helper Qubit.
- for (int j = 0; j < N; j++) {
- step4.addGate(new Hadamard(j));
- }
-
- // Adding gates to the Quantum Program.
- program.addStep(step1);
- program.addStep(step2);
- program.addStep(step3);
- program.addStep(step4);
-
- // Running the Program.
- Result res = simulator.runProgram(program);
-
- // Measuring a single Qubit.
- Qubit[] qubits = res.getQubits();
- Arrays.asList(qubits).forEach(q -> DeutschJosza3.measure(q));
-
- // Rendering circuit as an image.
- if (i == RUNS - 1) {
- Renderer.renderProgram(program);
- Renderer.showProbabilities(program, 1000);
- }
- }
-
-
- }
-
- private static void measure(Qubit q) {
- System.out.println("Qubit | Probability: "+q.getProbability()+", Mesured: "+ q.measure());
- }
-
- private static Oracle createOracle() {
- // Initializing an empty matrix of size NxN.
- int dim = 2 << N;
- int half = dim / 2;
- Complex[][] matrix = new Complex[dim][dim];
-
- // Building the Oracle based on a random Number.
- Random random = new Random();
- int choice = random.nextInt(2);
- String type = "balanced";
- if (choice == 0) {
- type = "constant";
- }
- System.out.println("----------------------------------------------------");
- System.out.println("Qubit | Function: "+ choice + " Type: " + type);
-
- // Generating a matrix that should represent the Oracle that is unknown
- // to the Program executing the Deutsch-Jozsa Algorithm.
- switch (choice) {
-
- // Building a constant function that returns 1 every time.
- case 0:
- for (int i = 0; i < dim; i ++) {
- matrix[i][i] = Complex.ONE;
- }
- return new Oracle(matrix);
-
- // Creating a balanced function that returns 1 50% of the time.
- case 1:
- for (int i = 0; i < dim; i ++) {
- if (i % 2 == 0) {
- matrix[i][i] = Complex.ONE;
- } else {
- if (i < half) {
- matrix[i][i + half] = Complex.ONE;
- } else{
- matrix[i][i - half] = Complex.ONE;
- }
- }
- }
- return new Oracle(matrix);
-
- // Invalid Oracle index.
- default:
- throw new IllegalArgumentException("Wrong index in oracle: " + choice);
- }
- }
-}
diff --git a/src/main/java/Eavesdropping.java b/src/main/java/Eavesdropping.java
deleted file mode 100644
index 134893b..0000000
--- a/src/main/java/Eavesdropping.java
+++ /dev/null
@@ -1,67 +0,0 @@
-import org.redfx.strange.*;
-import org.redfx.strange.gate.*;
-import org.redfx.strange.local.SimpleQuantumExecutionEnvironment;
-import org.redfx.strangefx.render.Renderer;
-
-import java.util.Arrays;
-
-public class Eavesdropping {
-
- public static void main(String[] args) {
- // Initilizing steps in the Quantum Program.
- Step step1 = new Step();
- Step step2 = new Step();
- Step step3 = new Step();
- Step step4 = new Step();
-
- // Applying the X-Gate to 2 Qubits.
- step1.addGate(new X(0));
- step1.addGate(new X(3));
-
- // Applying the Hadamard gate once by Alice before sending the message.
- step2.addGate(new Hadamard(0));
- step2.addGate(new Hadamard(1));
-
- // Eve applies random Hadamard gates to try to get the message.
- step3.addGate(new Hadamard(0));
- step3.addGate(new Hadamard(3));
-
- // Eve measures the Qubits to get one result.
- step4.addGate(new Measurement(0));
- step4.addGate(new Measurement(1));
- step4.addGate(new Measurement(2));
- step4.addGate(new Measurement(3));
-
- // Setting up the Quantum Program.
- Program program = new Program(4);
- program.addStep(step1);
- program.addStep(step2);
- program.addStep(step3);
- program.addStep(step4);
-
- // Altering the initial value of the first Qubit.
- program.initializeQubit(0, 1);
- program.initializeQubit(1, 1);
- program.initializeQubit(2, 1);
- program.initializeQubit(3, 1);
-
- // Connecting to a local simulator.
- SimpleQuantumExecutionEnvironment sqee = new SimpleQuantumExecutionEnvironment();
-
- // Running the Program.
- Result res = sqee.runProgram(program);
-
- // Measuring a single Qubit.
- Qubit[] qubits = res.getQubits();
- Arrays.asList(qubits).forEach(q -> Eavesdropping.measure(q));
-
- // Rendering circuit as an image.
- Renderer.renderProgram(program);
- Renderer.showProbabilities(program, 1000);
-
- }
-
- private static void measure(Qubit q) {
- System.out.println("Qubit | Probability: "+q.getProbability()+", Mesured: "+ q.measure());
- }
-}
diff --git a/src/main/java/Encryption.java b/src/main/java/Encryption.java
deleted file mode 100644
index d1680fa..0000000
--- a/src/main/java/Encryption.java
+++ /dev/null
@@ -1,62 +0,0 @@
-import org.redfx.strange.*;
-import org.redfx.strange.gate.*;
-import org.redfx.strange.local.SimpleQuantumExecutionEnvironment;
-import org.redfx.strangefx.render.Renderer;
-
-import java.util.Arrays;
-
-public class Encryption {
-
- public static void main(String[] args) {
- // Initilizing steps in the Quantum Program.
- Step step1 = new Step();
- Step step2 = new Step();
- Step step3 = new Step();
-
- // Applying the X-Gate to 2 Qubits.
- step1.addGate(new X(0));
- step1.addGate(new X(3));
-
- // Applying the Hadamard gate once by Alice before sending the message.
- step2.addGate(new Hadamard(0));
- step2.addGate(new Hadamard(1));
- step2.addGate(new Hadamard(2));
- step2.addGate(new Hadamard(3));
-
- // Applying the Hadamard gate once by Bob before after the message.
- step3.addGate(new Hadamard(0));
- step3.addGate(new Hadamard(1));
- step3.addGate(new Hadamard(2));
- step3.addGate(new Hadamard(3));
-
- // Setting up the Quantum Program.
- Program program = new Program(4);
- program.addStep(step1);
- program.addStep(step2);
- program.addStep(step3);
-
- // Altering the initial value of the first Qubit.
- program.initializeQubit(0, 1);
- program.initializeQubit(1, 1);
- program.initializeQubit(2, 1);
- program.initializeQubit(3, 1);
-
- // Connecting to a local simulator.
- SimpleQuantumExecutionEnvironment sqee = new SimpleQuantumExecutionEnvironment();
-
- // Running the Program.
- Result res = sqee.runProgram(program);
-
- // Measuring a single Qubit.
- Qubit[] qubits = res.getQubits();
- Arrays.asList(qubits).forEach(q -> Encryption.measure(q));
-
- // Rendering circuit as an image.
- Renderer.renderProgram(program);
- Renderer.showProbabilities(program, 1000);
- }
-
- private static void measure(Qubit q) {
- System.out.println("Qubit | Probability: "+q.getProbability()+", Mesured: "+ q.measure());
- }
-}
diff --git a/src/main/java/Grover.java b/src/main/java/Grover.java
deleted file mode 100644
index 05516e4..0000000
--- a/src/main/java/Grover.java
+++ /dev/null
@@ -1,113 +0,0 @@
-import org.redfx.strange.*;
-import org.redfx.strange.gate.*;
-import org.redfx.strange.local.SimpleQuantumExecutionEnvironment;
-import org.redfx.strangefx.render.Renderer;
-
-import java.util.Random;
-import java.util.Arrays;
-
-public class Grover {
-
- static final int DIMENSIONS = 3;
- static final int SOLUTION = 2;
-
- // Connecting to a local simulator.
- static QuantumExecutionEnvironment simulator = new SimpleQuantumExecutionEnvironment();
-
- public static void main(String[] args) {
-
- // Estimating the optimal amount of iterations.
- int N = 1 << DIMENSIONS;
- double runs = Math.PI * Math.sqrt(N) / 4;
- System.out.println("Qubits | Qubits: " + DIMENSIONS + " Encoded: " + Math.pow(2, DIMENSIONS) + " Solution: " + SOLUTION + " Runs: " + runs);
-
- // Initializing a Quantum Program.
- Program p = new Program(DIMENSIONS);
-
- // Applying a Hadamard gate to all the Qubits.
- Step s0 = new Step();
- for (int i = 0; i < DIMENSIONS; i++) {
- s0.addGate(new Hadamard(i));
- }
- p.addStep(s0);
-
- // Creating an unknown Oracle.
- Oracle oracle = createOracle();
- oracle.setCaption("O");
-
- // Creating a Diffusor Oracle.
- Oracle difOracle = createDiffusor();
- difOracle.setCaption("D");
-
- // Applying the Oracle and Diffusor multiple times.
- for (int i = 1; i < runs; i++) {
- Step s1 = new Step("Oracle " + i);
- s1.addGate(oracle);
- Step s2 = new Step("Diffusion " + i);
- s2.addGate(difOracle);
- Step s3 = new Step("Prob " + i);
- s3.addGate(new ProbabilitiesGate(0));
- p.addStep(s1);
- p.addStep(s2);
- p.addStep(s3);
- }
-
- // Initializing a Quantum Program.
- Result res = simulator.runProgram(p);
-
- // Measuring the probability distribution at the end.
- Complex[] probability = res.getProbability();
-
- // Measuring the probability distribution in the middle.
- System.out.println("----------------------------------------------------");
- for (int i = 1; i < runs; i++) {
- Complex[] ip0 = res.getIntermediateProbability(3 * i);
- System.out.println("Correct Solution Probability after step " + i + ": " + ip0[SOLUTION].abssqr());
- }
- System.out.println("----------------------------------------------------");
-
- // Measuring the probability distribution in the middle.
- for (int i = 1; i < runs; i++) {
- System.out.println("Probability distribution at step: " + i);
- Qubit[] qubits = res.getQubits();
- Complex[] ip0 = res.getIntermediateProbability(3 * i);
- Arrays.asList(ip0).forEach(q -> System.out.println("p: " + q.abssqr()));
- System.out.println("----------------------------------------------------");
- }
-
- }
-
- // Creating an unknown Oracle gate.
- private static Oracle createOracle() {
- int N = 1 << DIMENSIONS;
- Complex[][] matrix = new Complex[N][N];
- for (int i = 0; i < N;i++) {
- for (int j = 0 ; j < N; j++) {
- if (i != j) {
- matrix[i][j] = Complex.ZERO;
- } else {
- if (i == SOLUTION) {
- matrix[i][j] = Complex.ONE.mul(-1);
- } else {
- matrix[i][j] = Complex.ONE;
- }
- }
- }
- }
- return new Oracle(matrix);
- }
-
- // Creating a Diffusor Oracle that interferes the probability
- // distribution with the optimal solution of the problem.
- private static Oracle createDiffusor() {
- int N = 1 << DIMENSIONS;
- double N2 = 2./N;
- Complex[][] matrix = new Complex[N][N];
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < N; j++) {
- matrix[i][j] = (i == j ? new Complex(N2 - 1) : new Complex(N2));
- }
- }
- return new Oracle(matrix);
- }
-}
diff --git a/src/main/java/GroverN.java b/src/main/java/GroverN.java
deleted file mode 100644
index 5d61158..0000000
--- a/src/main/java/GroverN.java
+++ /dev/null
@@ -1,113 +0,0 @@
-import org.redfx.strange.*;
-import org.redfx.strange.gate.*;
-import org.redfx.strange.local.SimpleQuantumExecutionEnvironment;
-import org.redfx.strangefx.render.Renderer;
-
-import java.util.Random;
-import java.util.Arrays;
-
-public class GroverN {
-
- static final int DIMENSIONS = 8;
- static final int SOLUTION = 2;
-
- // Connecting to a local simulator.
- static QuantumExecutionEnvironment simulator = new SimpleQuantumExecutionEnvironment();
-
- public static void main(String[] args) {
-
- // Estimating the optimal amount of iterations.
- int N = 1 << DIMENSIONS;
- double runs = Math.PI * Math.sqrt(N) / 4;
- System.out.println("Qubits | Qubits: " + DIMENSIONS + " Encoded: " + Math.pow(2, DIMENSIONS) + " Solution: " + SOLUTION + " Runs: " + runs);
-
- // Initializing a Quantum Program.
- Program p = new Program(DIMENSIONS);
-
- // Applying a Hadamard gate to all the Qubits.
- Step s0 = new Step();
- for (int i = 0; i < DIMENSIONS; i++) {
- s0.addGate(new Hadamard(i));
- }
- p.addStep(s0);
-
- // Creating an unknown Oracle.
- Oracle oracle = createOracle();
- oracle.setCaption("O");
-
- // Creating a Diffusor Oracle.
- Oracle difOracle = createDiffusor();
- difOracle.setCaption("D");
-
- // Applying the Oracle and Diffusor multiple times.
- for (int i = 1; i < runs; i++) {
- Step s1 = new Step("Oracle " + i);
- s1.addGate(oracle);
- Step s2 = new Step("Diffusion " + i);
- s2.addGate(difOracle);
- Step s3 = new Step("Prob " + i);
- s3.addGate(new ProbabilitiesGate(0));
- p.addStep(s1);
- p.addStep(s2);
- p.addStep(s3);
- }
-
- // Initializing a Quantum Program.
- Result res = simulator.runProgram(p);
-
- // Measuring the probability distribution at the end.
- Complex[] probability = res.getProbability();
-
- // Measuring the probability distribution in the middle.
- System.out.println("----------------------------------------------------");
- for (int i = 1; i < runs; i++) {
- Complex[] ip0 = res.getIntermediateProbability(3 * i);
- System.out.println("Correct Solution Probability after step " + i + ": " + ip0[SOLUTION].abssqr());
- }
- System.out.println("----------------------------------------------------");
-
- // Measuring the probability distribution in the middle.
- for (int i = 1; i < runs; i++) {
- System.out.println("Probability distribution at step: " + i);
- Qubit[] qubits = res.getQubits();
- Complex[] ip0 = res.getIntermediateProbability(3 * i);
- Arrays.asList(ip0).forEach(q -> System.out.println("p: " + q.abssqr()));
- System.out.println("----------------------------------------------------");
- }
-
- }
-
- // Creating an unknown Oracle gate.
- private static Oracle createOracle() {
- int N = 1 << DIMENSIONS;
- Complex[][] matrix = new Complex[N][N];
- for (int i = 0; i < N;i++) {
- for (int j = 0 ; j < N; j++) {
- if (i != j) {
- matrix[i][j] = Complex.ZERO;
- } else {
- if (i == SOLUTION) {
- matrix[i][j] = Complex.ONE.mul(-1);
- } else {
- matrix[i][j] = Complex.ONE;
- }
- }
- }
- }
- return new Oracle(matrix);
- }
-
- // Creating a Diffusor Oracle that interferes the probability
- // distribution with the optimal solution of the problem.
- private static Oracle createDiffusor() {
- int N = 1 << DIMENSIONS;
- double N2 = 2./N;
- Complex[][] matrix = new Complex[N][N];
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < N; j++) {
- matrix[i][j] = (i == j ? new Complex(N2 - 1) : new Complex(N2));
- }
- }
- return new Oracle(matrix);
- }
-}
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy