[GiNaC-list] is_a<su3f>(e) return zero!!

Sheplyakov Alexei varg at theor.jinr.ru
Sun Mar 20 19:16:04 CET 2005


On Thu, Mar 17, 2005 at 09:03:10PM -0300, mdias at ift dot unesp dot br wrote:

> I make a struct that look at a ex e=color_f($0,$1,$2) and return
> zero. But I tried:
> 
> is_a<su3f>(e)
> is_exactly_a<su3f>(e)
> is_a<su3f>(e.op(0))
> is_a<color>(e)
> 
> but all returns zero? 

color_f(const ex&, const ex&, const ex&) returns an indexed object, so
all those results are correct.

You might try something like this:

// This hack works for me (TM)

class su3f_visitor_t : public visitor, public indexed::visitor
{
	lst res;
	public:
	su3f_visitor_t() { }
	inline lst get_result() const { return res; }
	inline void visit(const indexed &i)
	{
		if (is_a<su3f>(i.op(0)))
		  res.append(i);
	}
		
};

// look for color_f  in expression e

su3f_visitor_t su3f_v;
e.traverse(su3f_v);
lst color_lst = su3f_v.get_result();

// do whatever you need


Best regards,
  Alexei





More information about the GiNaC-list mailing list