(self, basis, **options)
Represent this qubits in the computational basis (ZGate).
Represent this qubits in the computational basis (ZGate).
Represent this qubits in the computational basis ( ZGate ) .
def _represent_ZGate(self, basis, **options):
        """Represent this qubits in the computational basis (ZGate).
        """
        format = options.get('format', 'sympy')
        n = 1
        definite_state = 0
        for it in reversed(self.qubit_values):
            definite_state += n*it
            n = n*2
        result = [0]*(2**self.dimension)
        result[int(definite_state)] = 1
        if format == 'sympy':
            return Matrix(result)
        elif format == 'numpy':
            import numpy as np
            return np.matrix(result, dtype='complex').transpose()
        elif format == 'scipy.sparse':
            from scipy import sparse
            return sparse.csr_matrix(result, dtype='complex').transpose()
def _represent_ZGate ( self , basis , * * options ) : format = options . get ( 'format' , 'sympy' ) n = 1 definite_state = 0 for it in reversed ( self . qubit_values ) : definite_state += n * it n = n * 2 result = [ 0 ] * ( 2 ** self . dimension ) result [ int ( definite_state ) ] = 1 if format == 'sympy' : return Matrix ( result ) elif format == 'numpy' : import numpy as np return np . matrix ( result , dtype = 'complex' ) . transpose ( ) elif format == 'scipy.sparse' : from scipy import sparse return sparse . csr_matrix ( result , dtype = 'complex' ) . transpose ( )