Is there a way in numpy to test whether a matrix is Unitary
By : Ming Zhao
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further I was wondering if there is any function in numpy to determine whether a matrix is Unitary? , Let's take an obviously unitary array: code :
>>> a = 0.7
>>> b = (1a**2)**0.5
>>> m = np.array([[a,b],[b,a]])
>>> m.dot(m.conj().T)
array([[ 1., 0.],
[ 0., 1.]])
>>> is_unitary(m)
Traceback (most recent call last):
File "<ipythoninput288dc9ddb462bc>", line 1, in <module>
is_unitary(m)
File "<ipythoninput203758c2016b67>", line 5, in is_unitary
error = np.linalg.norm(np.eye(n)  matrix.dot( matrix.transpose().conjugate()))
ValueError: operands could not be broadcast together with shapes (4,4) (2,2)
>>> m.size
4
>>> np.eye(m.size)
array([[ 1., 0., 0., 0.],
[ 0., 1., 0., 0.],
[ 0., 0., 1., 0.],
[ 0., 0., 0., 1.]])
>>> is_unitary(m)
True
>>> np.allclose(np.eye(len(m)), m.dot(m.T.conj()))
True

Convert from qubit density matrix to Bloch vector
By : Dimitris Nikolaou
Date : March 29 2020, 07:55 AM
I wish this help you The conversion depends on a couple arbitrary choices: Do you want 0⟩ at the top or the bottom? Do you want the coordinate system to be righthanded or lefthanded? code :
def toBloch(matrix):
[[a, b], [c, d]] = matrix
x = complex(c + b).real
y = complex(c  b).imag
z = complex(d  a).real
return x, y, z
print(toBloch([[1, 0],
[0, 0]])) #Off, Z=1
# (0.0, 0.0, 1.0)
print(toBloch([[0, 0],
[0, 1]])) #On, Z=+1
# (0.0, 0.0, 1.0)
print(toBloch([[0.5, 0.5],
[0.5, 0.5]])) #On+Off, X=1
# (1.0, 0.0, 0.0)
print(toBloch([[0.5, 0.5j],
[0.5j, 0.5]])) #On+iOff, Y=1
# (0.0, 1.0, 0.0)
print(toBloch([[0.5, 0.0],
[0.0, 0.5]])) #maximally mixed state, X=Y=Z=0
# (0.0, 0.0, 0.0)

How to print out whole matrix from unitary simulator
By : user3588310
Date : March 29 2020, 07:55 AM
Hope this helps On Jupyter Notebook, I had simulated eight qubits quantum's circuit with Unitary_simulator. And then, I would like to print out the whole matrix, but what I get is matrix from unitary simulator. The code that I used is: , The output is a 2D array, so you could print it as code :
for row in unitary:
print(row)

How to make a parity check matrix from nonsystematic to systematic in Matlab? thanks
By : vinu
Date : March 29 2020, 07:55 AM
wish helps you I am trying to make a parity check matrix from nonsystematic to systematic. Hence, I am attaching my code below. Somewhat it is correct, but there are some problems. It would be really great if someone could help me in this. Subject: Information theory and coding. I am working on LDPC coding and decoding. Please check the code below , Here is how I'd do it (using GaussJordan elimination):

Diagonalizing sparse unitary matrix
By : Rayhan
Date : March 29 2020, 07:55 AM
I wish did fix the issue. The following code eventually defines pdeig which returns the eigenvalues of a matrix which is a pdmatrix i.e. a product of a permutation and diagonal matrix, or in other words a matrix like the question describes. Calculating the eigenvectors quickly is also possible (they have an explicit formula):

