Hi Alexei,<br><br>Thank you for your reply.<br><br><div class="gmail_quote">On Wed, Aug 26, 2009 at 7:01 AM, Alexei Sheplyakov <span dir="ltr">&lt;<a href="mailto:varg@metalica.kh.ua">varg@metalica.kh.ua</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
The pattern matching operates on internal representation (in other words<br>
the matching is `syntactic&#39;, not algebraic). It tries to be smart(er) and<br>
handles sums and _commutative_ products in a special way (to account<br>
commutativity and associativity), but these tricks are not applicable to<br>
non-commutative products and/or tensors (a.k.a. indexed). Fortunately you<br>
don&#39;t need pattern matching to solve your problem. Simply choose appropriate<br>
basis (for 4-dimensional space with Minkowski metric that would be the set<br>
{1, gamma_mu, i/2 [ gamma_mu, a gamma_nu ], gamma_5, gamma_5 gamma_mu }),<br>
and operate on (commutative) coefficients.<br>
</blockquote><div><br>The larger problem i am trying to solve is to find the solution to a set of simultaneous equations involving gamma matrices and objects that can be represented by sums over products of gamma matrices. This is to be solved in Euclidean space rather than the canonical Minkowski space.<br>
<br>The equations have the form<br>S_i = a*Y + b*Y*PR*S_j + c*Y*PL*S_k<br><br>where i,j,k are indices, lower-case objects are commuting coefficients and capitalised objects are non-commuting objects that can be represented by sums over products of gamma matrices as you say. I am solving for the &#39;S&#39; objects, and PR,PL and Y are known, as are the commuting coefficients.<br>
<br>A general way of representing an object on 16 element basis of dirac matrix products and the unit matrix would be as a 16 component vector. These must be defined as non-commuting object such that the correct ordering is retained and I would also need to write code defining the product of these objects. In all it looks like I would be better off sticking to the existing clifford algebra for this more complicated problem, although it would certainly simplify the simpler problem that I posed in the previous email. <br>
 </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
&gt; #include&lt;iostream&gt;<br>
&gt; #include&lt;vector&gt;<br>
&gt; #include&lt;sstream&gt;<br>
&gt; #include&lt;ginac/ginac.h&gt;<br>
&gt; using namespace std;<br>
&gt; using namespace GiNaC;<br>
&gt;<br>
&gt; //Aim is to identify A_mu gamma_mu B_nu gamma_nu == A_mu B_nu delta_mu,nu<br>
&gt; int main(){<br>
&gt;<br>
&gt;   ex metric = unit_matrix(4);<br>
&gt;   idx i(symbol(&quot;i&quot;),4) , j(symbol(&quot;j&quot;),4);<br>
&gt;   // Use generalised clifford gamma matrices for euclidean space<br>
&gt;   ex al_i = clifford_unit(i,metric);<br>
&gt;   ex al_j = clifford_unit(j,metric);<br>
&gt;<br>
&gt;   //Create generic &#39;slashed&#39; symbols with euclidean metric<br>
&gt;<br>
&gt;   ex s1 = indexed(symbol(&quot;A&quot;),i)*al_i;<br>
&gt;   ex s2 = indexed(symbol(&quot;B&quot;),j)*al_j;<br>
&gt;<br>
&gt;   //Form the product<br>
&gt;   ex prod = s1*s2;<br>
&gt;<br>
&gt;   cout &lt;&lt; s1*s2 &lt;&lt; endl;<br>
&gt;<br>
&gt;   //Attempt to match to patterns<br>
&gt;   idx w1(wild(1),4), w2(wild(2),4);<br>
&gt;   indexed in2_w1 = indexed(wild(2),w1);<br>
<br>
Perhaps you mean wild(4) (not wild(2)) here.<br>
</blockquote><div><br>Indeed. Upon correcting this bug I find that the first set of patterns (which as you say are all ordered to the same form) now sometimes match the input.<br><br>Unfortunately there are still instances in running when neither pattern matches the input.<br>
<br>Is there some way to canonically order an expression by a set of rules rather than by the hash value such that i can find a pattern that is guaranteed to match?<br><br>Thanks,<br>Chris<br><br></div></div><br>