GiNaC Match Documentation
I have been encountering problems with the GiNaC function match. Basically I can not understand the documentation. I wanted to detail my story in the hope that perhaps my problems are solved and in the future someone else can avoid my pitfalls. The documentation informs me that I need an associative array. I can not find how to construct such an array elsewhere in the documentation so I assume that I am supposed to use exhashmap. That was a point of confusion for me. Then I designed the following code snipet, symbol x("x"), y("y"); ex tmp=x+y; exhashmap <ex> array; tmp.match(wild(1)+y); which apparently works fine. Now I wish to fill 'array' with the replacement table. So I modified to, tmp.match(wild(1)+y,array); which returned the following compiler messages, momentum_integration.cpp: In function ‘GiNaC::ex bring_to_parameterisable_form(GiNaC::ex)’: momentum_integration.cpp:13:33: error: no matching function for call to ‘GiNaC::ex::match(const GiNaC::ex, GiNaC::exhashmap<GiNaC::ex>&)’ momentum_integration.cpp:13:33: note: candidates are: In file included from /usr/include/ginac/ginac.h:30:0, from momentum_integration.h:14, from momentum_integration.cpp:1: /usr/include/ginac/ex.h:150:7: note: bool GiNaC::ex::match(const GiNaC::ex&) const /usr/include/ginac/ex.h:150:7: note: candidate expects 1 argument, 2 provided /usr/include/ginac/ex.h:151:7: note: bool GiNaC::ex::match(const GiNaC::ex&, GiNaC::exmap&) const /usr/include/ginac/ex.h:151:7: note: no known conversion for argument 2 from ‘GiNaC::exhashmap<GiNaC::ex>’ to ‘GiNaC::exmap& {aka std::map<GiNaC::ex, GiNaC::ex, GiNaC::ex_is_less>&}’ make: *** [momentum_integration.o] Error 1 I attempted to use the command exmap but I can not find anything on that in the documentation. I tried several permutations around, exmap <ex,ex> array; which made the compiler return, momentum_integration.cpp: In function ‘GiNaC::ex bring_to_parameterisable_form(GiNaC::ex)’: momentum_integration.cpp:11:8: error: ‘GiNaC::exmap {aka std::map<GiNaC::ex, GiNaC::ex, GiNaC::ex_is_less>}’ is not a template make: *** [momentum_integration.o] Error 1 At which point it is unclear to me what else I should try. The code was ran on a 64-bit Linux Mint-Debian distribution with ginac-1.6.2.
Hi Mark, On 08/13/2013 11:35 AM, Mark Round wrote:
I have been encountering problems with the GiNaC function match. Basically I can not understand the documentation. I wanted to detail my story in the hope that perhaps my problems are solved and in the future someone else can avoid my pitfalls.
The documentation informs me that I need an associative array. I can not find how to construct such an array elsewhere in the documentation so I assume that I am supposed to use exhashmap. That was a point of confusion for me. Then I designed the following code snipet,
symbol x("x"), y("y"); ex tmp=x+y; exhashmap <ex> array;
tmp.match(wild(1)+y);
which apparently works fine. Now I wish to fill 'array' with the replacement table. So I modified to,
tmp.match(wild(1)+y,array);
which returned the following compiler messages,
Make array an object of type exmap, instead of type exhashmap<ex> and it compiles. This is documented in section "Matching expressions". -richy.
participants (2)
-
Mark Round
-
Richard B. Kreckel