const unsigned function_index_##NAME= \\
GiNaC::function::register_new(GiNaC::function_options(#NAME).OPT);
-#define REGISTER_FUNCTION_OLD(NAME,E,EF,D,S) \\
-const unsigned function_index_##NAME= \\
- GiNaC::function::register_new(GiNaC::function_options(#NAME). \\
- eval_func(E). \\
- evalf_func(EF). \\
- derivative_func(D). \\
- series_func(S));
-
#define BEGIN_TYPECHECK \\
bool automatic_typecheck=true;
#define TYPECHECK(VAR,TYPE) \\
-if (!is_ex_exactly_of_type(VAR,TYPE)) { \\
+if (!is_exactly_a<TYPE>(VAR)) { \\
automatic_typecheck=false; \\
} else
};
// utility functions/macros
+/** Return the object of type function handled by an ex.
+ * This is unsafe: you need to check the type first. */
inline const function &ex_to_function(const ex &e)
{
return static_cast<const function &>(*e.bp);
}
+/** Specialization of is_exactly_a<function>(obj) for objects of type function. */
+template<> inline bool is_exactly_a<function>(const basic & obj)
+{
+ return obj.tinfo()==TINFO_function;
+}
+
#define is_ex_the_function(OBJ, FUNCNAME) \\
(is_ex_exactly_of_type(OBJ, function) && static_cast<GiNaC::function *>(OBJ.bp)->get_serial() == function_index_##FUNCNAME)
if (seq.size() > 1 && !(opt.symtree.is_zero())) {
exvector v = seq;
GINAC_ASSERT(is_ex_exactly_of_type(opt.symtree, symmetry));
- int sig = canonicalize(v.begin(), ex_to_symmetry(opt.symtree));
+ int sig = canonicalize(v.begin(), ex_to<symmetry>(opt.symtree));
if (sig != INT_MAX) {
// Something has changed while sorting arguments, more evaluations later
if (sig == 0)
bool function::match(const ex & pattern, lst & repl_lst) const
{
// Serial number must match
- if (is_ex_of_type(pattern, function) && serial != ex_to_function(pattern).serial)
+ if (is_ex_of_type(pattern, function) && serial != ex_to<function>(pattern).serial)
return false;
return inherited::match(pattern, repl_lst);
}
for (unsigned i=0; i!=fcn.nops(); i++) {
arg_diff = fcn.op(i).diff(s);
if (!arg_diff.is_zero()) {
- lst new_lst = ex_to_lst(seq[1]);
+ lst new_lst = ex_to<lst>(seq[1]);
new_lst.append(i);
result += arg_diff * Derivative(fcn, new_lst);
}
int function::compare_same_type(const basic & other) const
{
GINAC_ASSERT(is_of_type(other, function));
- const function & o=static_cast<function &>(const_cast<basic &>(other));
+ const function & o = static_cast<const function &>(other);
if (serial!=o.serial) {
return serial < o.serial ? -1 : 1;
bool function::is_equal_same_type(const basic & other) const
{
GINAC_ASSERT(is_of_type(other, function));
- const function & o=static_cast<function &>(const_cast<basic &>(other));
+ const function & o = static_cast<const function &>(other);
if (serial!=o.serial) return false;
return exprseq::is_equal_same_type(o);