quipper-0.7: An embedded, scalable functional programming language for quantum computing.

Safe HaskellNone

Quipper.Printing

Contents

Description

Pretty-printing of low-level quantum circuits.

Synopsis

ASCII representation of circuits

ascii_of_bcircuit :: BCircuit -> StringSource

Generate an ASCII representation of a low-level boxed quantum circuit.

print_dbcircuit_ascii :: ErrMsg -> DBCircuit a -> IO ()Source

Interactively output a DBCircuit to standard output. This supports dynamic lifting by prompting the user for bit values when a dynamic lifting operation is encountered. Effectively the user is asked to behave like a quantum device.

getBit :: IO BoolSource

Interactively read a bit (either 0 or 1) from standard input. This is intended for interactive user input, so it skips white space until a 0 or 1 is encountered. In case the first non-whitespace character isn't 0 or 1 or '#', the rest of the line is ignored and the user is prompted to try again.

However, this also works for non-interactive input, so that the input can be redirected from a file. In this case, the characters 0 and 1 and whitespace, including newlines, can be interspersed freely. '#' starts a comment that extends until the end of the line.

Gate counts

print_gatecounts_bcircuit :: BCircuit -> IO ()Source

Print gate counts for a boxed circuit: first the simple gate count for each subroutine separately, then the aggregated count for the whole circuit.

Graphical representation of circuits

render_dbcircuit :: FormatStyle -> ErrMsg -> DBCircuit a -> Document ()Source

Render a low-level dynamic quantum circuit as a graphical Document. If there are subroutines, each of them is placed on a separate page. If the circuit uses dynamic lifting, an error is produced.

Previewing

preview_bcircuit :: BCircuit -> IO ()Source

Display the circuit directly in Acrobat Reader. This may not be portable. It requires the external program "acroread" to be installed.

Printing to multiple formats

data Format Source

Available output formats.

Constructors

EPS

Encapsulated PostScript graphics.

PDF

Portable Document Format. One circuit per page.

PS

PostScript. One circuit per page.

ASCII

A textual representation of circuits.

Preview

Don't print anything, but preview directly on screen (requires the external program acroread).

GateCount

Print statistics on gate counts.

CustomStyle FormatStyle 

Instances

data FormatStyle Source

A data type that holds all the customizable parameters.

Constructors

FormatStyle 

Fields

renderformat :: RenderFormat

The RenderFormat to use.

backgroundcolor :: Color

The color of the background.

foregroundcolor :: Color

The color of the foreground (e.g. wires and gates).

linewidth :: Double

Line width.

coffs :: Double

Gap for double line representing classical bit.

dotradius :: Double

Radius of dots for "controlled" gates.

oplusradius :: Double

Radius of oplus for "not" gate.

xoff :: Double

Horizontal column width.

gatepad :: Double

Difference between width of box and width of label.

gateheight :: Double

Height of labelled box.

crossradius :: Double

Width and height of "cross" for swap gate.

stringbase :: Double

Vertical shift for text labels.

barwidth :: Double

Width of "bar" bar.

barheight :: Double

Height of "bar" bar.

dwidth :: Double

Width of "D" symbol.

dheight :: Double

Height of "D" symbol.

maxgatelabelwidth :: Double

Maximal width of a gate label.

maxlabelwidth :: Double

Maximal width of a wire label.

maxnumberwidth :: Double

Maximal width of a wire number.

gatefont :: Font

Font to use for labels on gates.

commentfont :: Font

Font to use for comments.

commentcolor :: Color

Color to use for comments.

labelfont :: Font

Font to use for labels.

labelcolor :: Color

Color to use for labels.

numberfont :: Font

Font to use for numbers.

numbercolor :: Color

Color to use for numbers.

subroutineshape :: Bool

Whether to label each subroutine call with shape parameters

Instances

pdf :: FormatStyleSource

The default PDF Style.

eps :: FormatStyleSource

The default EPS Style.

ps :: FormatStyleSource

The default PS Style.

format_enum :: [(String, Format)]Source

A mapping from lower-case strings (to be used, e.g., with command line options) to available formats.

print_dbcircuit :: Format -> ErrMsg -> DBCircuit a -> IO ()Source

Print a low-level quantum circuit directly to the IO monad, using the specified format.

print_of_document :: Format -> Document a -> IO aSource

Print a document to the requested format, which must be one of PS, PDF, EPS, or Preview.

print_of_document_custom :: Custom -> Format -> Document a -> IO aSource

Like print_of_document, but also takes a Custom data structure.

Generic printing

print_unary :: QCData qa => Format -> (qa -> Circ b) -> qa -> IO ()Source

Print a circuit generating function to the specified format; this requires a shape parameter.

print_generic :: (QCData qa, QCurry qfun qa b, Curry fun qa (IO ())) => Format -> qfun -> funSource

Print a circuit generating function to the specified format. Unlike print_unary, this can be applied to a circuit-generating function in curried form with n arguments, for any n >= 0. It then requires n shape parameters.

The type of this heavily overloaded function is difficult to read. In more readable form, it has all of the following types:

 print_generic :: Format -> Circ qa -> IO ()
 print_generic :: (QCData qa) => Format -> (qa -> Circ qb) -> a -> IO ()
 print_generic :: (QCData qa, QCData qb) => Format -> (qa -> qb -> Circ qc) -> a -> b -> IO ()

and so forth.

print_simple :: (QCData qa, QCurry qfun qa b, Curry fun qa (IO ()), QCData_Simple qa) => Format -> qfun -> IO ()Source

Like print_generic, but only works at simple types, and therefore requires no shape parameters.