diff options
author | nratan <narenratan@gmail.com> | 2020-07-09 22:20:36 +0100 |
---|---|---|
committer | nratan <narenratan@gmail.com> | 2020-07-09 22:20:36 +0100 |
commit | 6d55f41a87a6546105a85ef7e153957f1d9bad13 (patch) | |
tree | a796a183f30609cb67e6c91f4ab6a858a082cc3d /weyl_brauer.apl | |
download | Weyl-Brauer-6d55f41a87a6546105a85ef7e153957f1d9bad13.tar.gz |
Diffstat (limited to 'weyl_brauer.apl')
-rw-r--r-- | weyl_brauer.apl | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/weyl_brauer.apl b/weyl_brauer.apl new file mode 100644 index 0000000..0ded3cd --- /dev/null +++ b/weyl_brauer.apl @@ -0,0 +1,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! + +⎕IO←0⋄⎕PW←210 ⍝ Set index origin, console width + +a←2 2⍴1 0 0 1 ⍝ Identity matrix +b←2 2⍴1 0 0 ¯1 ⍝ Pauli matrices +p←2 2⍴0 1 1 0 +q←2 2⍴0 0J1 0J¯1 0 + +v←p q b ⍝ Vector of Pauli matrices +e←v∘.(+.×)v ⍝ Products of Pauli matrices +e+⍉e ⍝ Anticommutators of Pauli matrices + +n←3 ⍝ 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 2⍴a b)[;u+2×⍉u] ⍝ Weyl-Brauer matrices +e←v∘.(+.×)v ⍝ Products of Weyl-Brauer matrices +0 0⍉e ⍝ Check matrices square to the identity +e+⍉e ⍝ Anticommutators of Weyl-Brauer matrices + +I←+.×/v ⍝ Pseudo-scalar I +m←2*n +n m +II←⊃I+.×I +((⍳m)∘.=⍳m)≡II ⍝ I squares to identity for even n +((⍳m)∘.=⍳m)≡-II ⍝ or -identity for odd n |