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;
}
// public
-symbol::symbol(const string & initname) : inherited(TINFO_symbol)
+symbol::symbol(const std::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);
}
void symbol::printtree(ostream & os, unsigned indent) const
{
debugmsg("symbol printtree",LOGLEVEL_PRINT);
- os << string(indent,' ') << name << " (symbol): "
+ os << std::string(indent,' ') << name << " (symbol): "
<< "serial=" << serial
<< ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
<< ", flags=" << flags << endl;
// 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));
// private
-string & symbol::autoname_prefix(void)
+std::string & symbol::autoname_prefix(void)
{
- static string * s=new string("symbol");
+ static std::string * s=new std::string("symbol");
return *s;
}