{"action":"created","issue":{"url":"https://api.github.com/repos/msr-quarc/Liquid/issues/9","labels_url":"https://api.github.com/repos/msr-quarc/Liquid/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/msr-quarc/Liquid/issues/9/comments","events_url":"https://api.github.com/repos/msr-quarc/Liquid/issues/9/events","html_url":"https://github.com/msr-quarc/Liquid/issues/9","id":129987538,"number":9,"title":"Hamiltonian Gates","user":{"login":"rumschuettel","id":16973848,"avatar_url":"https://avatars.githubusercontent.com/u/16973848?v=3","gravatar_id":"","url":"https://api.github.com/users/rumschuettel","html_url":"https://github.com/rumschuettel","followers_url":"https://api.github.com/users/rumschuettel/followers","following_url":"https://api.github.com/users/rumschuettel/following{/other_user}","gists_url":"https://api.github.com/users/rumschuettel/gists{/gist_id}","starred_url":"https://api.github.com/users/rumschuettel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rumschuettel/subscriptions","organizations_url":"https://api.github.com/users/rumschuettel/orgs","repos_url":"https://api.github.com/users/rumschuettel/repos","events_url":"https://api.github.com/users/rumschuettel/events{/privacy}","received_events_url":"https://api.github.com/users/rumschuettel/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-30T13:42:31Z","updated_at":"2016-01-31T01:00:20Z","closed_at":"2016-01-31T01:00:20Z","body":"Hi! Brief question: in Hamiltonian mode, one can use gates such as ZR or ZZR to couple spins. What if I want to use a coupling that's Hermitian but not necessarily unitary, e.g. a projector? I tried creating a projector on |11> for the first 2 qubits out of 4 by defining a custom gate with a diagonal matrix with 1s in the corresponding entry and 0 everywhere, which is not unitary - the simulation somewhat works, but the normalization is now totally off:\r\n`\r\n0:0000.0/Ket of 4 qubits:\r\n0:0000.0/=== KetPart[ 0]:\r\n0:0000.0/Qubits (High to Low): 0 1 2 3\r\n0:0000.0/0x00000000:   2.1601667977e-05\r\n0:0000.0/0x00000001:   2.1601667977e-05\r\n0:0000.0/0x00000002:   2.1601667977e-05\r\n0:0000.0/0x00000003:   2.1601667977e-05\r\n0:0000.0/0x00000004:  1.14743224743e-05\r\n0:0000.0/0x00000005:  1.14743224743e-05\r\n0:0000.0/0x00000006:  1.14743224743e-05\r\n0:0000.0/0x00000007:  1.14743224743e-05\r\n0:0000.0/0x00000008:  1.14743224743e-05\r\n0:0000.0/0x00000009:  1.14743224743e-05\r\n0:0000.0/0x0000000a:  1.14743224743e-05\r\n0:0000.0/0x0000000b:  1.14743224743e-05\r\n0:0000.0/0x0000000c:  1.48433500775e-10\r\n0:0000.0/0x0000000d:  1.48433500775e-10\r\n0:0000.0/0x0000000e:  1.48433500775e-10\r\n0:0000.0/0x0000000f:  1.48433500775e-10\r\n`\r\nSo one can see that indeed the states with 1100, 1101, 1110 and 1111 have the least amplitude (as expected), but the overall probabilities don't add up to 1.\r\n\r\nAny hint would be appreciated.\r\nThanks!\r\nJ."},"comment":{"url":"https://api.github.com/repos/msr-quarc/Liquid/issues/comments/177351732","html_url":"https://github.com/msr-quarc/Liquid/issues/9#issuecomment-177351732","issue_url":"https://api.github.com/repos/msr-quarc/Liquid/issues/9","id":177351732,"user":{"login":"dbwz8","id":10551465,"avatar_url":"https://avatars.githubusercontent.com/u/10551465?v=3","gravatar_id":"","url":"https://api.github.com/users/dbwz8","html_url":"https://github.com/dbwz8","followers_url":"https://api.github.com/users/dbwz8/followers","following_url":"https://api.github.com/users/dbwz8/following{/other_user}","gists_url":"https://api.github.com/users/dbwz8/gists{/gist_id}","starred_url":"https://api.github.com/users/dbwz8/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbwz8/subscriptions","organizations_url":"https://api.github.com/users/dbwz8/orgs","repos_url":"https://api.github.com/users/dbwz8/repos","events_url":"https://api.github.com/users/dbwz8/events{/privacy}","received_events_url":"https://api.github.com/users/dbwz8/received_events","type":"User","site_admin":false},"created_at":"2016-01-31T01:00:20Z","updated_at":"2016-01-31T01:00:20Z","body":"This isn't *really* supported... but if you do a non-unitary gate, you will need to normalize the state vector yourself. First call ```let vec = ket.Single()``` which will pull any separate pieces of your state vector (ket) together into a single one and more importantly, will give you a handle to the actual state vector instance (vec). Then you can normalize it with ```vec.Normalize()```.  No guarantees, but I'd try this first and see if it gives you what you want.\r\n\r\nNote that this will only work in function mode. If you compile to a circuit (Circuit.Compile) you will have no way to do the normalization (not strictly true... but let's first try to get it working the simple way ;)"}}