StationQ / Liquid

The Language-Integrated Quantum Operations (LIQUi|>) Simulator
http://StationQ.github.io/Liquid
Other
440 stars 97 forks source link

Ket Bra operations #38

Closed EnginSahinCE closed 7 years ago

EnginSahinCE commented 7 years ago

I am new F# and Liquid. my doctorate thesis is about quantum computing. i want to use Liquid for studies. i have a few questions about liquid.

1) for ket state (|0>, |1> or |psi>) liquid have that

let ket = Ket(1) let q = ket.Qubits

my first question: is there anything for bra state (<0|, <1| or <psi|)?

how can i do this operation: |0><0| |psi> or |a>|b><c|

2) let's say we have |a> and |b> states

let ket = Ket(1) let a = ket.Qubits let ket2 = Ket(1) let b = ket2.Qubits

my second question: how can i get (|a> + |b>) or (|a>⊗|b>) as c or d that is a new qubit state

let ket3 = Ket(1) let c = ket3.Qubits let ket4 = Ket(2) let d = ket4.Qubits c = a + b ?? or d = a ⊗ b ??

Thank you for your interest.

dbwz8 commented 7 years ago

LIQUi|> was not designed to do arbitrary state vector manipulations. It is intended for simulating unitary quantum operations and measurements. I would suggest using something like Sage (http://www.sagemath.org/) which will give you an online (Python notebook based) tool for manipulating general state arithmetic. This is how I debug new gates that I’m working on. Here a few examples:

I1=identity_matrix(2)
I2=identity_matrix(4)
I3=identity_matrix(8)
S=matrix(2,2,[1,0,0,i]); S
X=matrix(2,2,[0,1,1,0]); X
Y=matrix(2,2,[0,-i,i,0]); Y
Z=matrix(2,2,[1,0,0,-1]); Z
H=matrix(2,2,[1,1,1,-1])/sqrt(2.0); H
CNOT=matrix(4,4,[1,0,0,0,0,1,0,0,0,0,0,1,0,0,1,0]); CNOT
def R(k):
  phi = 2*pi/(2^k)
  phiR= cos(phi)
  phiI= sin(phi)
  return matrix(2,2,[1,0,0,phiR+i*phiI])
R(5)
Z.tensor_product(Z)*i

Sample output from SAGE: https://1drv.ms/i/s!AszgA-iYgA_omOApynXqCTdYjhuyGg