[GiNaC-list] remove entry from symtab

Alexei Sheplyakov alexei.sheplyakov at gmail.com
Mon Aug 16 10:28:43 CEST 2010


Hello,

On Sun, Aug 15, 2010 at 11:10:02AM +0200, Kraus Philipp wrote:

> I'm using GiNaC 1.5.8 and have declared a GiNaC::symtab with symbols.
> How can I remove a symbole (by string name or GiNaC::symbol
> expression) from the table?

GiNaC::symtab is an associative array (std::map) which maps input strings
to variables in the (C++) code (this fact is somewhat documented in
the tutorial, see the paragraph 5.15.2, titled as `Expression input').
Therefore one can manipulate symtabs in a usual STL'ish manner:

symbol x("x"), y("y");
symtab test;
test["x"] = x;
test.insert(make_pair("y", y));
test["Funny"] = x + y;

// remove the entry containing the expression x + y
symtab::iterator i = test.begin();
while (i != test.end()) {
	// be careful to not invalidate the iterator, use post-increment	
	if (i->second->is_equal(x + y))
		test.erase(i++);
	else
		++i;
}

test.erase("x");

Best regards,
	Alexei



More information about the GiNaC-list mailing list