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);
}
// 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));