Mainly for Faustino!

I've been having a look at your script, with a view
to trying to understand what QC is all about.

I've noticed one or two (possible) minor problems -
In verb bmul,  the condition
   if. lstx = 1 *. lsty = 1 do.

should presumably bracket the left hand part. I've replaced it with if. 1 = ~.lstx, lsty do.but it's a matter of taste. There might be some more instances of this or something similar.

Your Y gate maps both 1;0 (|0>) and 1;1 (|1>) to i;1, whereas the literature suggests that |1> goes to -i|0>

Defining K11=:K1 TP K1 I find: simpl@:sqsw "1 K10,:K11

+--------+---+

|0.5j_0.5|0 1|

+--------+---+

|0.5j0.5 |1 0|

+--------+---+

+--------+---+

|0.5j_0.5|0 1|

+--------+---+

|0.5j0.5 |1 0|

+--------+---+

Whereas, as far as I can understand definitions elsewhere, eg https://en.wikipedia.org/wiki/Quantum_gate#Commonly_used_gates

it seems that K11 should be unchanged by square root swap,

I had found a neat way of programming Hd without recourse to combining executable strings together, but I mislaid it in a muddle involving the projects folder!

In "simpl" you should be able to do something like coeffs =. states +//. coeffs

states =. ~.states

though that doesn't quite seem to work correctly for the

above example with sqsw!

It might be useful to add a few more constants and utility verbs to the script, such as i =: 0j1

ei=: _12 & o.

NB. some unitary matrices, mostly nouns, such as:

MHad =: sq * 1 1,:1 _1 NB. Hadamard

MID =: 1 0,: 0 1 NB. 1-qubit identity

MX =: 0 1,: 1 0 NB. Pauli X

MY =: i * 0 _1,: 1 0 NB. Pauli Y

MZ =: 1 0,: 0 _1 NB. Pauli Z

MR =: 1 0,:0, ei NB. verb with rarg phi

...etc ...

With your approach, (using boxed pairs) I expect you'd need to unpick these matrices rather than apply them directly, but they might allow you to reduce the amount of code for the different gates. You might for example need only one generic verb to cover R, X, Y, Z, NOT, and another one for their controlled counterparts.

The boxed representation is quite neat; it allows you to mix complex and boolean types. However, have you considered ignoring the explicit identification of the bit(s) by a boolean? It appears, though my understanding is pretty hazy here, that you could replace, say, +--------+---+

|0.5j_0.5|0 1|

+--------+---+

|0.5j0.5 |1 0|

+--------+---+

by 0 0.5j_0.5 0.5j0.5 0 as coefficients for 00 01 10 and 11

This needs more complex elements, but avoids the boxed representation, and saves unboxing and reboxing in many verbs.

Sorry for a late response. Thanks for an interesting script. Perhaps I'll try to rediscover my variant for Hd

Mike


On 21/07/2015 09:58, Fausto Saporito wrote:
Hello all,

I wrote, just for fun, a basic quantum algebra package to handle
qubits and some operations.

Here's the code: https://github.com/TheFausap/qcalgebra

this is very basic j code... unfortunately with some for loops. I
tried to limit them, but I'm still Learning.

regards,
fausto
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm




---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to