def to_matrix(self):
    'Return a numpy.array for the CRX gate.'
    half_theta = (float(self.params[0]) / 2)
    cos = numpy.cos(half_theta)
    isin = (1j * numpy.sin(half_theta))
    if self.ctrl_state:
        return numpy.array([[1, 0, 0, 0], [0, cos, 0, (- isin)], [0, 0, 1, 0], [0, (- isin), 0, cos]], dtype=complex)
    else:
        return numpy.array([[cos, 0, (- isin), 0], [0, 1, 0, 0], [(- isin), 0, cos, 0], [0, 0, 0, 1]], dtype=complex)
Return a numpy.array for the CRX gate.
def to_matrix(self):
    
    half_theta = (float(self.params[0]) / 2)
    cos = numpy.cos(half_theta)
    isin = (1j * numpy.sin(half_theta))
    if self.ctrl_state:
        return numpy.array([[1, 0, 0, 0], [0, cos, 0, (- isin)], [0, 0, 1, 0], [0, (- isin), 0, cos]], dtype=complex)
    else:
        return numpy.array([[cos, 0, (- isin), 0], [0, 1, 0, 0], [(- isin), 0, cos, 0], [0, 0, 0, 1]], dtype=complex)