Safe Haskell | None |
---|
Quipper.Printing
Contents
Description
Pretty-printing of low-level quantum circuits.
- ascii_of_bcircuit :: BCircuit -> String
- print_dbcircuit_ascii :: ErrMsg -> DBCircuit a -> IO ()
- getBit :: IO Bool
- print_gatecounts_bcircuit :: BCircuit -> IO ()
- render_dbcircuit :: FormatStyle -> ErrMsg -> DBCircuit a -> Document ()
- preview_bcircuit :: BCircuit -> IO ()
- data Format
- = EPS
- | PS
- | ASCII
- | Preview
- | GateCount
- | CustomStyle FormatStyle
- data FormatStyle = FormatStyle {
- renderformat :: RenderFormat
- backgroundcolor :: Color
- foregroundcolor :: Color
- linewidth :: Double
- coffs :: Double
- dotradius :: Double
- oplusradius :: Double
- xoff :: Double
- gatepad :: Double
- gateheight :: Double
- crossradius :: Double
- stringbase :: Double
- barwidth :: Double
- barheight :: Double
- dwidth :: Double
- dheight :: Double
- maxgatelabelwidth :: Double
- maxlabelwidth :: Double
- maxnumberwidth :: Double
- gatefont :: Font
- commentfont :: Font
- commentcolor :: Color
- labelfont :: Font
- labelcolor :: Color
- numberfont :: Font
- numbercolor :: Color
- subroutineshape :: Bool
- pdf :: FormatStyle
- eps :: FormatStyle
- ps :: FormatStyle
- format_enum :: [(String, Format)]
- print_dbcircuit :: Format -> ErrMsg -> DBCircuit a -> IO ()
- print_of_document :: Format -> Document a -> IO a
- print_of_document_custom :: Custom -> Format -> Document a -> IO a
- print_unary :: QCData qa => Format -> (qa -> Circ b) -> qa -> IO ()
- print_generic :: (QCData qa, QCurry qfun qa b, Curry fun qa (IO ())) => Format -> qfun -> fun
- print_simple :: (QCData qa, QCurry qfun qa b, Curry fun qa (IO ()), QCData_Simple qa) => Format -> qfun -> IO ()
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.
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
Available output formats.
Constructors
EPS | Encapsulated PostScript graphics. |
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 |
data FormatStyle Source
A data type that holds all the customizable parameters.
Constructors
FormatStyle | |
Fields
|
Instances
The default PDF Style.
The default EPS Style.
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_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.