[GiNaC-list] Two remarks.

Jens Vollinga vollinga at thep.physik.uni-mainz.de
Wed Apr 20 20:41:12 CEST 2005


Hi Chris,

On Tue, Mar 22, 2005 at 05:31:35PM +0100, Chris Dams wrote:
> (2) Could somebody explain why there is a non-trivial method
> idx::match_same_type? This method makes it impossible to match
> varidx(mu,4-delta) using the pattern varidx(wild(1),wild(2)), which could
> be useful sometimes.

the existence of this method makes sense to me, because you don't want
to match

    varidx mu(symbol("mu"), 4-D)

with

    expr.has(varidx(wild(1), 4))

for example. But I see your point. Changing idx::match_same_type() by
inserting

   if (is_a<wildcard>(dim) || is_a<wildcard>(o.dim)) {
       return true;
   }

before the 'return' statement would give the desired behavior. Then you
could match with

    expr.has(varidx(wild(1), wild(2)))

for example. But this is probably just a dirty hack, because you could
also match with 
	
    expr.has(varidx(wild(1), wild(1)))

which shouldn't happen.

The problem, I think, lies with the design of the wildcard mechanism,
but I don't know how to improve it right now.

Another (not directly connected) example for what I mean: things like

    expr.subs(MyFunc(wild(1),wild(2)) == delta_tensor(wild(1), wild(2)))

don't work, because 'delta_tensor' checks the arguments to be of class
'idx' and since 'delta_tensor' is an ordinary C++ function with no way
to hold back the evaluation ...

Regards,
Jens




More information about the GiNaC-list mailing list