On Thu, Oct 6, 2011 at 2:19 PM, Hans Harhoff Andersen
<[email protected]> wrote:
> I just checked that the problem persists even in newest git version.

I should mention that I don't consider this to be a bug as most people
use the word "CNOT gate" to mean the two qubit gate.

> Also I have a feature request for circuit_plot. It would be very nice
> to have a way of making circuit plot display unfilled circles for
> controls which are triggered on qubit being in 0 state instead of
> state 1 (cf. Nielsen and Chuang book for examples of this eg. page 193
> (fig. 4.16)).
> Without this feature you have to include a lot of NOTs in your circuit
> digram which makes it ugly and unreadable.

A simple subclass of CGate would accomplish this:

class AntiCGate(CGate):

    control_value = Integer(0)

    def plot_gate(self, circ_plot, gate_idx):
        min_wire = int(min(chain(self.controls, self.targets)))
        max_wire = int(max(chain(self.controls, self.targets)))
        circ_plot.control_line(gate_idx, min_wire, max_wire)
        for c in self.controls:
            circ_plot.anti_control_point(gate_idx, int(c))
        self.gate.plot_gate(circ_plot, gate_idx)

This would also require the anti_control_point method of
circuitplot.CircuitPlot:

        def anti_control_point(self, gate_idx, wire_idx):
            """Draw a control point."""
            x = self._gate_grid[gate_idx]
            y = self._wire_grid[wire_idx]
            radius = self.control_radius
            c = Circle(
                (x,y),
                radius*self.scale,
                ec='k',
                fc='k',
                fill=False,
                lw=self.linewidth
            )
            self._axes.add_patch(c)

Could you create a pull request on github with these changes?  I am
short on time right now and won't be able to get to this for a while.
If you can't create a pull request, please open an issue with this
information.

Cheers,

Brian




> Best regards, Hans
>
> On Oct 6, 9:13 pm, Hans Harhoff Andersen <[email protected]>
> wrote:
>> I suspect that this is a bug since I can get it to work by writing:
>> gate.CGate((2,1),gate.X(0))
>>
>> When I do
>> gate.CNOT((2,1),0)
>> I get:
>> TypeError: List indices must be integers, not Tuple
>>
>> On Thu, Oct 6, 2011 at 8:54 PM, Hans Harhoff Andersen
>>
>>
>>
>>
>>
>>
>>
>> <[email protected]> wrote:
>> > Hi Sympy.
>>
>> > I am trying to use circuit_plot to plot my quantum circuit. I can get
>> > CNOT and such gates working, but I can't get the Toffoli/CCNOT gate to
>> > plot. As I read the documentation I should be able to use mutiple
>> > control qubits on the CNOT gate by writing something like:
>> > gate.CNOT([2,1],0) to have qubit 1 and 2 control qubit 0. But this
>> > doesn't work with sympy 0.7.
>>
>> > Any hints or suggestions?
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/sympy?hl=en.
>
>



-- 
Brian E. Granger
Cal Poly State University, San Luis Obispo
[email protected] and [email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to