Strange

OpenJFX JavaFX

License

License

GroupId

GroupId

com.gluonhq
ArtifactId

ArtifactId

strange
Last Version

Last Version

0.0.13
Release Date

Release Date

Type

Type

zip
Description

Description

Strange
OpenJFX JavaFX
Project URL

Project URL

http://maven.apache.org
Source Code Management

Source Code Management

https://github.com/qcjava/strange

Download strange

Dependencies

compile (8)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-params jar 5.5.2
org.junit.jupiter : junit-jupiter-engine jar 5.5.2
org.openjfx : javafx-controls jar 11-ea+24
org.openjfx : javafx-swing jar 11-ea+24
com.gluonhq » charm-cloudlink-client jar 4.4.7
com.gluonhq : charm-down-plugin-storage-desktop jar 3.6.0
org.nd4j : nd4j-native jar 1.0.0-beta7
org.slf4j : slf4j-nop jar 1.7.26

test (1)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar 5.5.2

Project Modules

There are no modules declared in this project.

strange Build Status

Quantum Computing API for Java

This project defines a Java API that can be used to create Quantum Programs. A Quantum Program, defined by org.redfx.strange.Program can be executed on an implementation of the org.redfx.strange.QuantumExecutionEnvironment.

You can read more about Java and QuantumComputing in Quantum Computing for Java Developers

Getting Started

Strange is distributed via the traditional Java distribution channels (e.g. maven central and jcenter) and can thus easily be used leveraging maven or gradle build software.

Using gradle

A typical build.gradle file looks as follows:

plugins {
    id 'application'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.redfx:strange:0.0.16'
}

mainClassName = 'SimpleStrangeDemo'

The sample application contains a single Java file:

import org.redfx.strange.*;
import org.redfx.strange.gate.*;
import org.redfx.strange.local.SimpleQuantumExecutionEnvironment;
import java.util.Arrays;

public class SimpleStrangeDemo {

    public static void main(String[] args) {
        Program p = new Program(2);
        Gate xGate1 = new X(0); 
        Step step1 = new Step();
        step1.addGate(xGate1);
        p.addStep(step1);
        Gate hGate2 = new Hadamard(0);
        Gate xGate2 = new X(1);
        Step step2 = new Step();
        step2.addGates(hGate2, xGate2);
        p.addStep(step2);
        SimpleQuantumExecutionEnvironment sqee = new SimpleQuantumExecutionEnvironment();
        Result res = sqee.runProgram(p);
        Qubit[] qubits = res.getQubits();
        Arrays.asList(qubits).forEach(q -> System.out.println("qubit with probability on 1 = "+q.getProbability()+", measured it gives "+ q.measure()));
    }

}

This sample create a Program that requires 2 qubits. It will create 2 steps (s and t). The first step adds a Paul-X (NOT) Gate to the first qubit. The second steps adds a Hadamard Gate to the first qubit, and a NOT gate to the second qubit. Both steps are added to the Program.

In order to "run" this program, we need a QuantumExecutionEnvironment. Strange comes with a SimpleQuantumExecutionEnvironment which contains a very simple, non-optimized quantum computer simulator.

After running the program on this simulator, we inspect the state of the Qubits. As expected, there is a 50% chance the first qubit (which had an X and an H gate) will be in the 0 state, and a 50% chance it will be in the 1 state. The second qubit will always be in the 1 state.

Running this application a number of times will consistently give the same probabilities, and different measurements.

Visualisation

The Strange API's allow to create and simulate quantum programs. A companion project, StrangeFX , allows to visualise programs, and create them with a simple drag and drop interface. The sample program above rendered via StrangeFX looks as follows: StrangeFX rendering

com.gluonhq

Versions

Version
0.0.13
0.0.12
0.0.11
0.0.10
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1