[GiNaC-devel] Fix for pattern matching

Matthias Dellweg dellweg at tp1.uni-duesseldorf.de
Thu Dec 5 12:11:35 CET 2013


Dear all,
while using GiNaC, I came across a strange behaviour with pattern
matching in products having more than one wildcard. The match succeeded
in a probablistic fashion. My conclusion is, that expairseq::match
dishonors the rule, that repl_lst will remain unchanged whenever false
is returned. See the attached patch, which solves the problem for me.

Anyway, I started to think about the whole matching mechanism. Wouldn't
it be much easier, if the matching was done from the patterns
perspective? A wildcard would know itself to match to anything. And it
might be possible to match a single object to a product of this
object and a global wildcard, since expairseq would know how to
handle that. See for example 'sin(phi).match(sin(wild(0))*wild(1))'.
There could be wildcards matching to everything not containing a
specified Symbol.
And in every case basic would only need to check for type equality and
matchable operands.
I think one can even implement that preserving the
current interface by calling an internal virtual match with interchanged
operands.
Any thoughts on that?

Best wishes, Matthias Dellweg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-matching-in-expairseq.patch
Type: text/x-patch
Size: 2382 bytes
Desc: not available
URL: <http://www.cebix.net/pipermail/ginac-devel/attachments/20131205/0632931e/attachment.patch>


More information about the GiNaC-devel mailing list