I need to compute the scalar product of each pair of a set of states. So far, what I've been doing is
A = np.empty((n, n))
for i in range(n):
A[i, i] = assemble(Theta[i]*Theta[i]*dx)
for j in range(i+1, n):
alpha = assemble(Theta[i]*Theta[j]*dx)
A[i, j] = alpha
A[j, i] = alpha.conjugate()
The states Theta
are here organized in a Python list. The whole thing could probably be sped up by fitting Theta
in some sort of Multivector type, but if I recall correctly FEniCS doesn't support any of that.
Any other ideas of how to speed this up?