def matrix_rep(op, basis):
 a = zeros(len(basis))
 for i in range(len(basis)):
  for j in range(len(basis)):
   a[(i, j)] = apply_operators(((Dagger(basis[i]) * op) * basis[j]))
 return a

def matrix_rep ( op , basis ) : a = zeros ( len ( basis ) ) for i in range ( len ( basis ) ) : for j in range ( len ( basis ) ) : a [ ( i , j ) ] = apply_operators ( ( ( Dagger ( basis [ i ] ) * op ) * basis [ j ] ) ) return a
find the representation of an operator in a basis .