The parser only accepts lst in the form lst(...) not {...}, though.
Function prototype can now have a argument size of 0 to indicate
functions with an arbitrary number of arguments (like lst).
{
return GiNaC::sqrt(ev[0]);
}
{
return GiNaC::sqrt(ev[0]);
}
static ex pow_reader(const exvector& ev)
{
return GiNaC::pow(ev[0], ev[1]);
}
static ex pow_reader(const exvector& ev)
{
return GiNaC::pow(ev[0], ev[1]);
}
static ex power_reader(const exvector& ev)
{
return GiNaC::power(ev[0], ev[1]);
}
static ex power_reader(const exvector& ev)
{
return GiNaC::power(ev[0], ev[1]);
}
+static ex lst_reader(const exvector& ev)
+{
+ return GiNaC::lst(ev.begin(), ev.end());
+}
+
// function::registered_functions() is protected, but we need to access it
// TODO: add a proper const method to the `function' class, so we don't
// function::registered_functions() is protected, but we need to access it
// TODO: add a proper const method to the `function' class, so we don't
reader[make_pair("sqrt", 1)] = sqrt_reader;
reader[make_pair("pow", 2)] = pow_reader;
reader[make_pair("power", 2)] = power_reader;
reader[make_pair("sqrt", 1)] = sqrt_reader;
reader[make_pair("pow", 2)] = pow_reader;
reader[make_pair("power", 2)] = power_reader;
+ reader[make_pair("lst", 0)] = lst_reader;
std::vector<function_options>::const_iterator it =
registered_functions_hack::get_registered_functions().begin();
std::vector<function_options>::const_iterator end =
std::vector<function_options>::const_iterator it =
registered_functions_hack::get_registered_functions().begin();
std::vector<function_options>::const_iterator end =
reader[make_pair("sqrt", 1)] = sqrt_reader;
reader[make_pair("pow", 2)] = pow_reader;
reader[make_pair("power", 2)] = power_reader;
reader[make_pair("sqrt", 1)] = sqrt_reader;
reader[make_pair("pow", 2)] = pow_reader;
reader[make_pair("power", 2)] = power_reader;
+ reader[make_pair("lst", 0)] = lst_reader;
* function pointer!! The unsigned has to correspond to the serial number of
* the defined GiNaC function.
*/
* function pointer!! The unsigned has to correspond to the serial number of
* the defined GiNaC function.
*/
-typedef std::map<prototype, reader_func> prototype_table;
+class PrototypeLess
+{
+public:
+ bool operator()(const prototype& p1, const prototype& p2) const
+ {
+ int s = p1.first.compare(p2.first);
+ if (s == 0) {
+ if ((p1.second == 0) || (p2.second == 0)) return false;
+ return p1.second < p2.second;
+ }
+ return s < 0;
+ }
+};
+typedef std::map<prototype, reader_func, PrototypeLess> prototype_table;
/**
* Default prototype table.
/**
* Default prototype table.