I am trying to solve a problem in computational algebra using python.
Basically given two sets, say A={a,b} and B={e}, I need to compute the element by element tensor products and get a final set say C={a\tensor{e},b\tensor{e}} containing these products of elements.
I can do an element by element multiplication using arrays with numbers but I can't do an element by element tensor multiplication of letters instead of numbers.
解决方案
Not sure if I understood correctly, this below code multiplies each letter of one set with each letter of the the other set
def getProduct(A,B):
prod=[]
for a in A:
for b in B:
prod.append(a+b)
return prod
A=['a','b']
B=['e']
print(getProduct(A,B))
Output: ['ae', 'be']