#include "debugmsg.h"
#include "utils.h"
-#ifndef NO_GINAC_NAMESPACE
+#ifndef NO_NAMESPACE_GINAC
namespace GiNaC {
-#endif // ndef NO_GINAC_NAMESPACE
+#endif // ndef NO_NAMESPACE_GINAC
GINAC_IMPLEMENT_REGISTERED_CLASS(symbol, basic)
symbol::symbol() : inherited(TINFO_symbol)
{
debugmsg("symbol default constructor", LOGLEVEL_CONSTRUCT);
- serial=next_serial++;
- name=autoname_prefix()+ToString(serial);
- asexinfop=new assigned_ex_info;
+ serial = next_serial++;
+ name = autoname_prefix()+ToString(serial);
+ asexinfop = new assigned_ex_info;
setflag(status_flags::evaluated);
}
void symbol::copy(const symbol & other)
{
inherited::copy(other);
- name=other.name;
- serial=other.serial;
- asexinfop=other.asexinfop;
+ name = other.name;
+ serial = other.serial;
+ asexinfop = other.asexinfop;
++asexinfop->refcount;
}
symbol::symbol(const string & initname) : inherited(TINFO_symbol)
{
debugmsg("symbol constructor from string", LOGLEVEL_CONSTRUCT);
- name=initname;
- serial=next_serial++;
- asexinfop=new assigned_ex_info;
+ name = initname;
+ serial = next_serial++;
+ asexinfop = new assigned_ex_info;
setflag(status_flags::evaluated);
}
ex s = (new symbol(n, sym_lst))->setflag(status_flags::dynallocated);
// If symbol is in sym_lst, return the existing symbol
- for (int i=0; i<sym_lst.nops(); i++) {
+ for (unsigned i=0; i<sym_lst.nops(); i++) {
if (is_ex_of_type(sym_lst.op(i), symbol) && (ex_to_symbol(sym_lst.op(i)).name == ex_to_symbol(s).name))
return sym_lst.op(i);
}
// protected
+/** Implementation of ex::diff() for single differentiation of a symbol.
+ * It returns 1 or 0.
+ *
+ * @see ex::diff */
+ex symbol::derivative(const symbol & s) const
+{
+ if (compare_same_type(s)) {
+ return _ex0();
+ } else {
+ return _ex1();
+ }
+}
+
int symbol::compare_same_type(const basic & other) const
{
GINAC_ASSERT(is_of_type(other,symbol));
{
}
-#ifndef NO_GINAC_NAMESPACE
+#ifndef NO_NAMESPACE_GINAC
} // namespace GiNaC
-#endif // ndef NO_GINAC_NAMESPACE
+#endif // ndef NO_NAMESPACE_GINAC