]> www.ginac.de Git - ginac.git/blobdiff - ginac/symbol.cpp
- The status_flags::expanded is now used on some occasions.
[ginac.git] / ginac / symbol.cpp
index 43927dc3a3192df4e2780440c9e701b7c3ec0066..7dd1c5228107dc22c5a30f8309cfd940d2cc505d 100644 (file)
@@ -43,9 +43,9 @@ 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);
 }
 
@@ -64,9 +64,9 @@ symbol::symbol(const symbol & other)
 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;
 }
 
@@ -95,9 +95,9 @@ void symbol::destroy(bool call_parent)
 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);
 }
 
@@ -259,6 +259,19 @@ ex symbol::subs(const lst & ls, const lst & lr) const
 
 // 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));