[GiNaC-list] table and exhashmap
varg at theor.jinr.ru
Sun Feb 18 18:38:23 CET 2007
On Mon, Feb 19, 2007 at 12:29:55AM +0800, Jerome BENOIT wrote:
> I am new in GiNaC and in C++ (but very familiar with another CAS and C).
> I would like to implement a function which returns table.
> Unless I missed something, there is no ready to use table object
> in GiNaC.
I guess you want to use GiNaC::exmap (and [re-]read your favourite C++
textbook, at least the chapter which describes STL containers, in
particular associative arrays).
using namespace std;
using namespace GiNaC;
exmap foo(const ex& x, const ex& y)
something[x] = x + y/2;
something[y] = cos(x);
int main(int argc, char** argv)
symbol x("x"), y("y");
tbl = foo(x-y, 2*y);
for (exmap::const_iterator i=tbl.begin(); i!=tbl.end(); ++i)
cout << i->first << " => " << i->second << endl;
// will print something like:
// 2*y => cos(-y+x)
// -y+x => x
All science is either physics or stamp collecting.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 827 bytes
Desc: Digital signature
Url : http://www.cebix.net/pipermail/ginac-list/attachments/20070218/c80a6d0d/attachment.pgp
More information about the GiNaC-list