qasmsim library includes a
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; creg c; h q; cx q, q; 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.2.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: --info <info> Show gate-related information --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
Contain the error types ragarding the different tasks that QasmSim can perform.
Contain the machinery for parsing and processing OPENQASM programs. This module is unstable.
Contain utilities for representing the internal state of a quantum system.
Represent the result of a simulation.
Represent a complete execution of a program, from parsing to simulating.
Register the milliseconds spent in parsing the program and simulating.
The different types for OPENQASM values.
Return the signature and documentation of the gate
gate_name if it is
defined in the source code
Return the AST of
input and link external sources with
Parse and simulate the
input OPENQASM program with optional
Perform a simulation of the parsed
shots number of simulations of the parsed proram
Map classical registers with values and number of outcomes.