[GiNaC-list] retrieving wildcard replacements on C++
Chris Dams
Chris.Dams at mi.infn.it
Thu Feb 1 11:25:57 CET 2007
Dear Charlls,
On Wed, 31 Jan 2007, Charlls Quarra wrote:
> symbol x("x");
> ex foo = A*pow(x,2) + B*x;
> lst ocurrences;
> foo.find( wild(1)*x , ocurrences ); //the wildcard
> replacement is B
>
> how would you retrieve the wildcard replacement in
> this case?
In this simple case I would simply divide a list element by x ;-).
In general it is a bit more difficult, but you could use
cout << "list of wild(1)-replacements:" << endl;
for (int i=0; i<ocurrences.nops(); ++i)
{ lst repls;
ocurrences.op(i).match(wild(1)*x, repls);
cout << wild(1).subs(repls, subs_options::no_pattern) << endl;
}
Best wishes,
Chris
More information about the GiNaC-list
mailing list