Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from import a,b
from sympy import Matrix, pprint
from itertools import product
from sympy.physics.quantum import TensorProduct
# A \otimes \rho_{d}
def orderedTensorProduct(d):
dDegreeMonomials = monomialDegrees(d)
xyz = monomialDegrees(1)
retVal = []
for x in xyz:
retVal.extend([ (a[0] + b[0], a[1] + b[1], a[2] + b[2]) for (a, b) in product([x], dDegreeMonomials) ])
return retVal
# sort monomials in x & y above those that contain a z. Within these two groups sort lexically and by degree.
def homogenousMonomialOrdering(monomials,d):
return sorted(monomials, key=lambda x: (x[2], x[1]))
def monomialDegrees(d):
retVal =[]
for (i,j,k) in product(list(range(d+1)), repeat=3):
if( i + j + k == d):
return homogenousMonomialOrdering(retVal,d)
def makeProjection(pd_basis, quotient_basis):
retVal = []
for hm in pd_basis:
retVal.append([1 if tup == hm else 0 for tup in quotient_basis])
return Matrix(retVal)
def makeEmbedding(pd_basis, quotient_basis):
retVal = []
qb_length = len(quotient_basis)
for hm in pd_basis:
ret = []
count = 0
for idx in range(qb_length-1,-1,-1):
if (count == 0 and quotient_basis[idx] == hm):
count += 1
return Matrix(retVal).transpose()
def produceProjectionAndEmbedding(degree):
pd_basis = monomialDegrees(degree)
quotient_basis = orderedTensorProduct(degree - 1)
return makeProjection(pd_basis, quotient_basis), makeEmbedding(pd_basis, quotient_basis)
def representationOfSO3(A, degree):
rho = A
if (degree == 1):
return A
for i in range(2,degree+1):
S, E = produceProjectionAndEmbedding(i)
rho = S * TensorProduct(A,rho) * E
return rho
def main():
A = Matrix([[a, -b, 0],
[b, a, 0],
[0, 0, 1]])
rho2 = representationOfSO3(A,2)
rho3 = representationOfSO3(A,3)
if __name__ == '__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment