I have defined several symbolic function f[x],g[x,y],h[x,y,z]
etc... And I have a list made of elements which are product of these functions with different arguments; for example,
list = { f[a]f[-a], f[a]g[c,d]h[-a,-c,-d], f[c]f[-c] ,
f[d]g[a,y]h[-d,-a,-y] , f[b]f[-a] , f[-c]f[c] ,
f[d]g[a,y]h[-d,-a,-z] }
Actually, these functions are just symbolic. They do not return any value. You can think the functions' arguments as tensorial indexes.
I want to find an efficient function checkPattern[list_]
which does the following
1) Take the first element f[a]f[-a]
and find if there are others elements matching this pattern; so, for example, the third element of list
is "equal" to the first one, in the sense that f[a]f[-a]~f[c]f[-c]~f[-c]f[c]
irrespectively of the arguments. Note that the elements f[a]f[-a]
and f[b]f[-a]
are different.
2) Take the second element (which is more complicated) and does the same check as the step 1.
So the result would be
checkPattern[list]
(* {{1,3,6},{2,4},{5},{7}}*)
f[-c]f[c]
andf[a] f[-a]
could beTensorContract[TensorProduct[f, f], {{1,2}}]
andf[a]g[c,d][h[-a,-c,-d]
could beTensorContract[TensorProduct[f,g,h], {{1, 4}, {2,5}, {3, 6}}]
. This eliminates the use of dummy indices. $\endgroup$TensorProduct
prevent you from doing symbolic computations? $\endgroup$