#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)
destroy(0);
}
-symbol::symbol(symbol const & other)
+symbol::symbol(const symbol & other)
{
debugmsg("symbol copy constructor", LOGLEVEL_CONSTRUCT);
copy(other);
}
-void symbol::copy(symbol const & other)
+void symbol::copy(const symbol & other)
{
inherited::copy(other);
name=other.name;
// public
-symbol::symbol(string const & initname) : inherited(TINFO_symbol)
+symbol::symbol(const string & initname) : inherited(TINFO_symbol)
{
debugmsg("symbol constructor from string", LOGLEVEL_CONSTRUCT);
name=initname;
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);
}
return this->hold();
}
-bool symbol::has(ex const & other) const
+bool symbol::has(const ex & other) const
{
if (is_equal(*other.bp)) return true;
return false;
}
-int symbol::degree(symbol const & s) const
+int symbol::degree(const symbol & s) const
{
return compare_same_type(s)==0 ? 1 : 0;
}
-int symbol::ldegree(symbol const & s) const
+int symbol::ldegree(const symbol & s) const
{
return compare_same_type(s)==0 ? 1 : 0;
}
-ex symbol::coeff(symbol const & s, int const n) const
+ex symbol::coeff(const symbol & s, int n) const
{
if (compare_same_type(s)==0) {
return n==1 ? _ex1() : _ex0();
}
}
-ex symbol::subs(lst const & ls, lst const & lr) const
+ex symbol::subs(const lst & ls, const lst & lr) const
{
GINAC_ASSERT(ls.nops()==lr.nops());
#ifdef DO_GINAC_ASSERT
// protected
-int symbol::compare_same_type(basic const & other) const
+/** 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));
const symbol *o = static_cast<const symbol *>(&other);
return serial < o->serial ? -1 : 1;
}
-bool symbol::is_equal_same_type(basic const & other) const
+bool symbol::is_equal_same_type(const basic & other) const
{
GINAC_ASSERT(is_of_type(other,symbol));
const symbol *o = static_cast<const symbol *>(&other);
// public
-void symbol::assign(ex const & value)
+void symbol::assign(const ex & value)
{
asexinfop->is_assigned=1;
asexinfop->assigned_expression=value;
//////////
const symbol some_symbol;
-type_info const & typeid_symbol=typeid(some_symbol);
+const type_info & typeid_symbol=typeid(some_symbol);
//////////
// subclass assigned_ex_info
{
}
-#ifndef NO_GINAC_NAMESPACE
+#ifndef NO_NAMESPACE_GINAC
} // namespace GiNaC
-#endif // ndef NO_GINAC_NAMESPACE
+#endif // ndef NO_NAMESPACE_GINAC