Devon and all:
Many thanks for the feedback and apologies what seemed like a redundant
query.

The matrices operations I need are not only for swapping purposes, I'm
actually evaluating J as a potential platform for a quantum computer
simulators. There are several characteristics that make J attractive for
this: (1)  the parallel processing concepts of J seem very similar to
what quantum computers may some day do, (2) J is great to define new
languages/syntaxes that I see as necessary for quantum programming, and
(3) J natively works with complex numbers.

For quantum computers, the low level operations are "quantum gates"
(unitary transformation) that are applied to quantum bits or "qubits" (a
pair of complex numbers in a column vector). When designing quantum
circuits, you patch together quantum gates (2x2, 4x4, 8x8 matrices) that
operate on a subset of a "register", a collection of qubits (2xN
matrix). I have designed an XML specification to describe quantum
circuits and I'm now developing XSL transformations to "compile" the
circuit for various simulation platforms. One that I'm targeting is J so
I have a XSL transform that basically aims at turning quantum circuits
XML into J code for simulation. I'll need to present preliminary results
in about 3 weeks (therefore my query...)

For the story, I used to program in APL (many years ago) and looking up
array programming languages on Wikipedia lead me to discover J that I
find quite fascinating. The leaning curve is certainly a bit steep but
the capabilities seem endless.

best
Pascal


Devon McCormick wrote:
> Pascal - at first glance, this does look a lot like your earlier query.
>
> However,
>
>   dot =: 4 : ' x +/ . * y'
>   qb0 =: ,. 1 0
>   qb1 =: ,. 0 1
>   pauliX =: 2 2 $ (0 1 1 0)
>   pauliX dot qb0 NB. Works
> 0
> 1
>   pauliX dot qb1 NB. Also works
> 1
> 0
>   pauliX dot qb0,.qb1 NB. Also works
> 0 1
> 1 0
>   NB. Selecting columns:
>   ]m =: 2 5 $ i. 10
> 0 1 2 3 4
> 5 6 7 8 9
>   2 3{"1 m
> 2 3
> 7 8
>   pauliX dot m
> 5 6 7 8 9
> 0 1 2 3 4
>
>   NB. Updating columns:
>   ix=. 2 3 NB. Arbitrary columns to update
>   pauliX dot ix{"1 m
> 7 8
> 2 3
>   ]m=. (pauliX dot ix{"1 m) ix}"1 m
> 0 1 7 8 4
> 5 6 2 3 9
>
>   NB. This is functionally the same as
>   m=. i. 2 5
>   ]m=. (|.ix{"1 m) ix}"1 m
> 0 1 7 8 4
> 5 6 2 3 9
>
> Is matrix multiplication simply used to swap elements around like this
> all
> the time in your problems?  Or are there more general uses of it?
>
> I'm asking because I've seen this sort of structural re-arrangement done
> with matrix multiply by booleans before.  I'm wondering if this is
> because
> there's no direct way to re-position elements of an array in conventional
> mathematics, so we resort to this kind of "trick" to accomplish it, or is
> there another reason?
>
-- 
Chaos is inherent in all compounded things. Strive on with diligence.
-- Buddha
www.quotator.net

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

Reply via email to