[−][src]Crate qasmsim
The qasmsim
library includes a
OPENQASM 2.0
parser and interpreter, along with a statevector simulator. Compiled with
default features, the library presents a qasmsim
CLI for running programs
like the following one:
// in test.qasm
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
cx q[0], q[1];
measure q -> c;
$ qasmsim --shots 1024 test.qasm
+------+-----------+-------+
| Name | Int value | Count |
+------+-----------+-------+
| c | 0 | 503 |
| | 3 | 521 |
+------+-----------+-------+
Check the full options with:
$ qasmsim --help
qasmsim 1.0.0
A QASM interpreter and quantum simulator in Rust.
USAGE:
qasmsim [FLAGS] [OPTIONS] [source]
FLAGS:
-b, --binary Prints the binary representation of the values
-h, --help Prints help information
-x, --hexadecimal Prints the hexadecimal representation of the values
-i, --integer Prints the interger representation of the values. Default option
--probabilities Prints the probabilities vector of the simulation. Ignored if shots is set
--statevector Prints the state vector of the simulation. Ignored if shots is set
-t, --times Prints times measured for parsing and simulating
-V, --version Prints version information
-v Verbosity of the output
OPTIONS:
--out <out> Output files prefix, print in the stdout if not present. The output format of each file is
CSV. At most, three files are created with the names out.memory.csv, out.state.csv and
out.times.csv
--shots <shots> Specify the number of simulations
ARGS:
<source> QASM program file, read from stdin if not present
Re-exports
pub use crate::error::QasmSimError; |
Modules
error | Contain the error types ragarding the different tasks that QasmSim can perform. |
grammar | Contain the machinery for parsing and processing OPENQASM programs. This module is unstable. |
statevector | Contain utilities for representing the internal state of a quantum system. |
Structs
Computation | Represent the result of a simulation. |
Execution | Represent a complete execution of a program, from parsing to simulating. |
ExecutionTimes | Register the milliseconds spent in parsing the program and simulating. |
Enums
QasmType | The different types for OPENQASM values. |
Functions
parse_and_link | Return the AST of |
run | Parse and simulate the |
simulate | Perform a simulation of the parsed |
simulate_with_shots | Perform |
Type Definitions
Histogram | Map classical registers with values and number of outcomes. |