about summary refs log tree commit diff stats
path: root/weyl_brauer.apl
blob: 0ded3cdc4be31b502ea110d690babb10b16ef4e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
⍝ WEYL-BRAUER MATRICES IN APL

⍝ Weyl-Brauer matrices are higher dimensional versions of Pauli spin matrices.
⍝ They can be built up using the Pauli spin matrices as blocks. The building up
⍝ can be done by making a mega-array of Pauli matrices then collapsing it down
⍝ by taking the outer/Kronecker product along one of its dimensions - perfect
⍝ for APL!

⎕IO0⎕PW210                   ⍝ Set index origin, console width

a2 21 0 0 1                   ⍝ Identity matrix
b2 21 0 0 ¯1                  ⍝ Pauli matrices
p2 20 1 1 0
q2 20 0J1 0J¯1 0

vp q b                         ⍝ Vector of Pauli matrices
ev∘.(+.×)v                     ⍝ Products of Pauli matrices
e+⍉e                            ⍝ Anticommutators of Pauli matrices

n3                             ⍝ Number of vector space dimensions is 2×n
                                ⍝ Dimension of matrices is 2 2*n

u(n)∘.>⍳n                     ⍝ Upper triangular matrix of ones

k{⊃⍪/,/∘.×⊂}                 ⍝ Kronecker product of matrices

v,k/((p q),2 2a b)[;u+2×⍉u]   ⍝ Weyl-Brauer matrices
ev∘.(+.×)v                     ⍝ Products of Weyl-Brauer matrices
0 0e                           ⍝ Check matrices square to the identity
e+⍉e                            ⍝ Anticommutators of Weyl-Brauer matrices

I+.×/v                         ⍝ Pseudo-scalar I
m2*n
n m
III+.×I
((m)∘.=⍳m)II                  ⍝ I squares to identity for even n
((m)∘.=⍳m)≡-II                 ⍝ or -identity for odd n