package qiskit

  1. Overview
  2. Docs
Qiskit for OCaml

Install

Dune Dependency

Authors

Maintainers

Sources

v1.0.2.tar.gz
md5=4830377982b2b6a87fa9445e015e6747
sha512=485978cf181b74592f2adfb0be1f8af142c3f5ad7355226540c11ddf010cb9f57d7eda705f87edfd7e86d1a0d3ec43def91dc7324caa62ff17c1b4cebf8b03e8

Description

An OCaml wrapper for the Qiskit quantum computing toolkit

Published: 13 Mar 2024

README

Caml_qiskit

An OCaml wrapper for IBM Qiskit quantum computing toolkit.

opam install qiskit

Example

open Qiskit

(* Create the circuit *)
let qc = quantum_circuit 2 2 
  |> h 0 
  |> id 1 
  |> barrier
  |> cx 0 1
  |> barrier
  |> measure 0 0
  |> measure 1 1
  |> draw;;

(* Start a simulation *)
aer_simulator "statevector" 
  |> run qc 
  |> result 
  |> get_counts 
  |> Visualization.plot_histogram;

(* Run the circuit on real quantum hardware *)
let _ = IBMProvider.save_account "TOKEN" in
let j = IBMProvider.get_backend "ibmq_london" prov |> run qc in
Tools.Monitor.job_monitor j;
j 
  |> result 
  |> get_counts 
  |> Visualization.plot_histogram;;

Install

opam install qiskit

You also need to install these python libraries (via pip):

  • matplotlib

  • numpy

  • qiskit

  • pylatexenc

And optional for IBM quantum cloud computers:

  • qiskit_ibm_provider

License

Copyright (c) 2020-2024 Davide Gessa

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Dependencies (3)

  1. pyml >= "20220905"
  2. dune >= "3.10.0"
  3. ocaml >= "4.05.0"

Dev Dependencies (3)

  1. bisect_ppx dev & >= "2.8.3"
  2. odoc dev & >= "2.2.1"
  3. ounit with-test & >= "2.2.7"

Used by

None

Conflicts

None