[GiNaC-list] table and exhashmap
jgmbenoit at mailsnare.net
Sun Feb 18 18:58:10 CET 2007
thanks for the quick reply.
I am afraid I have to specify my request:
by function I meant GiNaC function
(the one declared with DECLARE_FUNCTION_<N>P).
As the object exmap (or exhashmap<T>) is no an ex object,
it cannot be returned by such a function.
If I would like to return list,
there would be no trouble as lst are well defined (are ex object).
My question is rather a GiNaC question than a C++ question.
Sheplyakov Alexei wrote:
> 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).
> For example,
> #include <iostream>
> #include <ginac/ginac.h>
> using namespace std;
> using namespace GiNaC;
> exmap foo(const ex& x, const ex& y)
> exmap something;
> something[x] = x + y/2;
> something[y] = cos(x);
> return something;
> int main(int argc, char** argv)
> symbol x("x"), y("y");
> exmap tbl;
> 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
> return 0;
> Best regards,
More information about the GiNaC-list