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"><<a href="mailto:varg@metalica.kh.ua">varg@metalica.kh.ua</a>></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', 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'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 'S' 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>
> #include<iostream><br>
> #include<vector><br>
> #include<sstream><br>
> #include<ginac/ginac.h><br>
> using namespace std;<br>
> using namespace GiNaC;<br>
><br>
> //Aim is to identify A_mu gamma_mu B_nu gamma_nu == A_mu B_nu delta_mu,nu<br>
> int main(){<br>
><br>
> ex metric = unit_matrix(4);<br>
> idx i(symbol("i"),4) , j(symbol("j"),4);<br>
> // Use generalised clifford gamma matrices for euclidean space<br>
> ex al_i = clifford_unit(i,metric);<br>
> ex al_j = clifford_unit(j,metric);<br>
><br>
> //Create generic 'slashed' symbols with euclidean metric<br>
><br>
> ex s1 = indexed(symbol("A"),i)*al_i;<br>
> ex s2 = indexed(symbol("B"),j)*al_j;<br>
><br>
> //Form the product<br>
> ex prod = s1*s2;<br>
><br>
> cout << s1*s2 << endl;<br>
><br>
> //Attempt to match to patterns<br>
> idx w1(wild(1),4), w2(wild(2),4);<br>
> 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>