|
![]() |
![]() Project Q-ACTA (IST-1999-10596) |
||||||
| QuaSi2 | XML-based file format | Links |
|
IAKS-Homepage Simulator QuaSi : About QuaSi User Documentation Screenshots Applet-Version EISS-Report Simulator QuaSi2 : Improvements Screenshots User documentation XML file format Applet-Version Full-Version |
The XML-based file formatXML (Extensible Markup Language) is a subset of SGML (Standard Generalized Markup Language) and a parent of HTML (Hypertext Markup Language).It provides a general way to describe structured information. The main difference to SGML or HTML is that XML documents must be well-formed, i.e., either end tags are required (<Tag> ...</Tag>) or the tag has to be written like <Tag/>. In addition it is necessary to write all parameters within quotation marks. Main structureThe main structure of an XML file in QuaSi2 is:<Circuit numberofqubits="10"> ... </Circuit> The first and last tag must be Circuit. In the first tag the number of qubits in the circuit has to be given in the parameter numberofqubits. The gates and containers, described in the following sections, can be used between the Circuit tags. Setting statesThe following line sets an amplitude of the state.<Prep number="..." value="..." /> Parameters: number: number (decimal) of the amplitude to be set. value: value of the amplitude to be set. Please note that after setting all amplitudes the state will be automatically normalized. Example: <Prep number="5" value="E(5)" /> GatesOne-qubit gatesThe following gates operate only on one of the qubits.<Hadamard targetqubit="..." /> Parameters: targetqubit: target qubit of the operation in {1 ... n}. Example: <Hadamard targetqubit="2" /> <IGate targetqubit="..." /> Parameters: targetqubit: target qubit of the operation in {1 ... n}. Example: <IGate targetqubit="3" /> <SigmaX targetqubit="..." /> Parameters: targetqubit: target qubit of the operation in {1 ... n}. Example: <SigmaX targetqubit="4" /> <SigmaY targetqubit="..." /> Parameters: targetqubit: target qubit of the operation in {1 ... n}. Example: <SigmaY targetqubit="4" /> <SigmaZ targetqubit="..." /> Parameters: targetqubit: target qubit of the operation in {1 ... n}. Example: <SigmaZ targetqubit="4" /> Controlled one-qubit gatesControl qubits can be specified using the gates described in the following section. The matrix is only applied to those basis states in which the control qubit has the appropriate value and is not applied to the other states,<CNot targetqubit="..." controlqubit="..." /> Parameters: targetqubit: target qubit of the operation in {1 ... n}. controlqubit: control qubit, regarding |1>, in {1 ... n}. Example: <CNot targetqubit="1" controlqubit="2" /> <CCNot targetqubit="..." controlqubit1="..." controlqubit2="..." /> Parameters: targetqubit: target qubit of the operation in {1 ... n}. controlqubit1, controlqubit2: control qubits, regarding |1>, in {1 ... n}. Example: <CCNot targetqubit="1" controlqubit1="2" controlqubit2="4" /> <SpecialGate targetqubit="..." factor="..." controlledbyone="..." controlledbyzero="..." style="..." name="..."> <Row>a b </Row> <Row>c d </Row> </SpecialGate> Parameters: targetqubit: target qubit of the operation in {1 ... n}. controlledbyone: control qubits, regarding |1>, in {1 ... n}, separated by spaces (optional). controlledbyzero: control qubits, regarding |0>, in {1 ... n}, separated by spaces (optional). a,b,c,d: matrix entries as complex numbers, either written like p+qi or in the GAP format. The GAP format ist used in the computer algebra system GAP (Groups, Algorithms and Programming) and any complex number is described as a linear combination (with fractions) of powers of primitive n-th roots of unity. The primitive n-th root of unity has to be written like E(n). A number in the GAP format is for example: 1/2*E(8)-1/2*E(8)^3-1/4*E(37740)^7227-1/5*E(1887)^56 The GAP format is included in QuaSi2 for better exchange with the computer algebra system GAP. factor: scaling factor of the matrix as a real number (optional, if not given = 1.0). style: draw style in {0,1} 0: NOT symbol 1: Box name: name of the gate (for labelling). Example: <SpecialGate targetqubit="1" factor="0.707" controlledbyone="2 3" style="0" name="H2"> <Row> E(2)^0 E(2)^0</Row> <Row> E(2)^0 E(2)^1</Row> </SpecialGate> Controlled two or more qubit gates<MatrixGate targetqubits="..." factor="..."controlledbyone="..." controlledbyzero="..." name="..."> <Row> a b c ... </Row> <Row> ... </Row> ... <Row> ... </Row> </MatrixGate> Parameters: targetqubits: target qubits of the operation in {1 ... n}. controlledbyone: control qubits, regarding |1>, in {1 ... n}, separated by spaces (optional). controlledbyzero: control qubits, regarding |0>, in {1 ... n}, separated by spaces (optional). a b c ... : matrix entries as complex numbers, either written like p+qi or in the GAP format. The matrix must have a size of 2^k x 2^k if k is the number of targetqubits. factor: scaling factor of the matrix as a real number (optional, if not given = 1.0). name: name of the gate (for labelling, optional). Example: <MatrixGate targetqubits="2 1 3" factor="0.3535" controlledbyone="5 6" controlledbyzero="4" > <Row> E(8)^0 E(8)^0 E(8)^0 E(8)^0 E(8)^0 E(8)^0 E(8)^0 E(8)^0 </Row> <Row> E(8)^0 E(8)^1 E(8)^2 E(8)^3 E(8)^4 E(8)^5 E(8)^6 E(8)^7 </Row> <Row> E(8)^0 E(8)^2 E(8)^4 E(8)^6 E(8)^8 E(8)^10 E(8)^12 E(8)^14 </Row> <Row> E(8)^0 E(8)^3 E(8)^6 E(8)^9 E(8)^12 E(8)^15 E(8)^18 E(8)^21 </Row> <Row> E(8)^0 E(8)^4 E(8)^8 E(8)^12 E(8)^16 E(8)^20 E(8)^24 E(8)^28 </Row> <Row> E(8)^0 E(8)^5 E(8)^10 E(8)^15 E(8)^20 E(8)^25 E(8)^30 E(8)^35 </Row> <Row> E(8)^0 E(8)^6 E(8)^12 E(8)^18 E(8)\textasciicircum 24 E(8)^30 E(8)^36 E(8)^42 </Row> <Row> E(8)^0 E(8)^7 E(8)^14 E(8)^21 E(8)^28 E(8)^35 E(8)^42 E(8)^49 </Row> </MatrixGate> Measuring and setting qubits<Measure targetqubit="..." />}Measuring a qubit. Parameters: targetqubit: qubit to be measured in {1 ... n}. Example: <Measure targetqubit="7" /> <SetTo0 targetqubit="..." /> Setting a qubit to |0>. Parameters: targetqubit: qubit to be set in {1 ... n}. Example: <SetTo0 targetqubit="5" /> <SetTo1 targetqubit="..." /> Setting a qubit to |1>. Parameters: \texttt{targetqubit}: qubit to be set in {1 ... n}. Example: <SetTo1 targetqubit="5" //> Permutation and function gates<Permutation permutation="..." />Permutation of the qubit wires. Parameters: permutation: permutation, notation: p(1) p(2) ... p(n). Example: <Permutation permutation="1 3 2" /> <Function xbits="..." ybits="..." values="..." /> Evaluates a function like f: |x,y> -> |x,y (+) f(x)> Parameters: xbits: qubits in the x-register, in {1 ... n}. ybits: qubits in the y-register, in {1 ... n}. values: values of f, notation f(0) f(1) ... , separated by spaces. If k is the number of qubits in the x-register, 2^k values have to be given (each value as a natural number). Example: <Function xbits="1 3" ybits="2 4" values="1 3 8 5" /> ContainersMerging gates to a container is done using the <Container> tag.<Container name="..."> ... </Container>The parameter name can be any explicit name for the container. Containers can be arbitrarily nested. Example:
<Container name="Macro1">
<Hadamard targetqubit="2" \>
<CNot targetqubit="1" controlqubit="2" \>
<Container name="Makro2">
<SigmaX targetqubit="1">
<SigmaY targetqubit="2">
</Container>
</Container>
Define and reuse of containersIt is also possible to define a reusable container.Define ContainersThe definition of a reusable container is done analogically to a normal container, except that <defContainer> has to be used.<defContainer name="..."> ... </defContainer> Reuse containersA container already defined by means of<defContainer> can be reused using the <useContainer> tag. <useContainer name="..." qubits="..." />The parameter name must be the same name used in the definiton of the container. The parameter qubits can be used to do any desired permutation on the qubit wires before inserting the gates inside the container. This can be used to define a operation on the first qubit wires but actually use it on other wires. Example: <defContainer name="Macro"> <Hadamard targetqubit="2" /> <Hadamard targetqubit="1" /> </defContainer> <useContainer name="Macro" qubits="1 2 3 4 5 6 7 8 9 10" /> <useContainer name="Macro" qubits="10 7 9 4 2 3 8 1 5 6" / > ExamplesPlease note that the following circuits are only destined to illustrate the XML format.First Example
<Circuit numberofqubits="10">
<Hadamard targetqubit="1" />
<SetTo0 targetqubit="8" />
<SetTo1 targetqubit="3" />
<Measure targetqubit="3" />
<Container name="H">
<Hadamard targetqubit="4" />
<Hadamard targetqubit="3" />
</Container>
<Permutation permutation="2 3 4 5 6 7 8 9 10 1" />
<CNot targetqubit="4" controlqubit="1" />
<Container name="Set">
<SetTo0 targetqubit="3" />
<SetTo1 targetqubit="7" />
</Container>
<CNot targetqubit="3" controlqubit="2" />
<Hadamard targetqubit="3" />
<SetTo1 targetqubit="3" />
<CCNot targetqubit="9" controlqubit1="8" controlqubit2="5" />
<Function xbits="1 2" ybits="5 6" values="1 2 3 4" />
</Circuit>
Second Example
<Circuit numberofqubits="6">
<defContainer name="Set1">
<SetTo1 targetqubit="1" />
<SetTo1 targetqubit="2" />
<SetTo1 targetqubit="3" />
</defContainer>
<Hadamard targetqubit="1" />
<Hadamard targetqubit="2" />
<Hadamard targetqubit="3" />
<SpecialGate targetqubit="1" factor="0.707"
controlledbyzero="4 2" name="T" style="1">
<Row> E(2)^0 E(2)^0 </Row>
<Row> E(2)^0 E(2)^1 </Row>
</SpecialGate>
<useContainer name="Set1" qubits="4 5 6 1 2 3">
</Circuit>
Quantum Computer Simulators |
Maintained by Julia Wallace |
| Matthias Eck (udqo@rz.uni-karlsruhe.de), Pawel Wocjan (wocjan@ira.uka.de), Robert Michael Zeier (zeier@ira.uka.de) |