[GiNaC-list] parsing of declared functions with ginac 1.5
Tony Stoecker
t.stoecker at fz-juelich.de
Wed Dec 9 17:52:58 CET 2009
Hi All:
I am happily using GiNaC since version 1.3. With version 1.5 I have the
problem that parsing of declared functions does not work anymore (the way I
am using it).
The stupid example below works fine with version 1.4 but fails with version
1.5:
terminate called after throwing an instance of 'GiNaC::parse_error'
what(): GiNaC: parse error at line 0, column 0: no function "floor" with 1
arguments
[GiNaC::ex GiNaC::parser::parse_identifier_expr()(parser/parser.cpp:66)]
Did I miss something in the declaration to introduce the new function to the
parser? Any help would be very much appreciated as I could not find the answer
in the tutorial / mailing list.
Cheers,
Tony
#include "ginac/ginac.h"
static GiNaC::ex floor_evalf(const GiNaC::ex &x){
if (!GiNaC::is_a<GiNaC::numeric>(x) ) return x;
GiNaC::ex xn = GiNaC::ex_to<GiNaC::numeric>(x);
return ((int) GiNaC::ex_to<GiNaC::numeric>(xn).to_double() );
}
DECLARE_FUNCTION_1P(floor)
REGISTER_FUNCTION(floor, evalf_func(floor_evalf))
using namespace std;
using namespace GiNaC;
int main() {
symbol x("x");
lst syms; syms.append(x);
lst nums; nums.append(1.9);
//parsing from string does not work with version 1.5
ex p("floor(x)",syms);
cout << syms << "=" << nums << " ; " << p << "="
<< evalf(p.subs(syms,nums)) << endl;
exit(0);
}
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzende des Aufsichtsrats: MinDir'in Baerbel Brumme-Bothe
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
More information about the GiNaC-list
mailing list