]> www.ginac.de Git - ginac.git/blobdiff - ginac/basic.cpp
Made also ncmuls rename dummy indices.
[ginac.git] / ginac / basic.cpp
index b4e38614aaa2942306d085f68c45046f162813c3..f86483e4ec7da5b7000c258939e18cc0b6e9c4bd 100644 (file)
@@ -38,6 +38,7 @@
 #include "wildcard.h"
 #include "archive.h"
 #include "utils.h"
+#include "inifcns.h"
 
 namespace GiNaC {
 
@@ -286,13 +287,13 @@ ex & basic::operator[](size_t i)
  *  the pattern itself or one of the children 'has' it.  As a consequence
  *  (according to the definition of children) given e=x+y+z, e.has(x) is true
  *  but e.has(x+y) is false. */
-bool basic::has(const ex & pattern) const
+bool basic::has(const ex & pattern, unsigned options) const
 {
        lst repl_lst;
        if (match(pattern, repl_lst))
                return true;
        for (size_t i=0; i<nops(); i++)
-               if (op(i).has(pattern))
+               if (op(i).has(pattern, options))
                        return true;
        
        return false;
@@ -325,6 +326,12 @@ ex basic::map(map_function & f) const
                return *this;
 }
 
+/** Check whether this is a polynomial in the given variables. */
+bool basic::is_polynomial(const ex & var) const
+{
+       return !has(var) || is_equal(ex_to<basic>(var));
+}
+
 /** Return degree of highest power in object s. */
 int basic::degree(const ex & s) const
 {
@@ -705,6 +712,16 @@ ex basic::conjugate() const
        return *this;
 }
 
+ex basic::real_part() const
+{
+       return real_part_function(*this).hold();
+}
+
+ex basic::imag_part() const
+{
+       return imag_part_function(*this).hold();
+}
+
 ex basic::eval_ncmul(const exvector & v) const
 {
        return hold_ncmul(v);
@@ -775,9 +792,9 @@ unsigned basic::return_type() const
        return return_types::commutative;
 }
 
-const basic* basic::return_type_tinfo() const
+tinfo_t basic::return_type_tinfo() const
 {
-       return this;
+       return tinfo_key;
 }
 
 /** Compute the hash value of an object and if it makes sense to store it in
@@ -788,7 +805,7 @@ const basic* basic::return_type_tinfo() const
  *  would all end up with the same hashvalue. */
 unsigned basic::calchash() const
 {
-       unsigned v = golden_ratio_hash((unsigned)tinfo());
+       unsigned v = golden_ratio_hash((p_int)tinfo());
        for (size_t i=0; i<nops(); i++) {
                v = rotate_left(v);
                v ^= this->op(i).gethash();