]> www.ginac.de Git - ginac.git/blobdiff - ginac/symbol.cpp
- info(info_flags::has_indices) now works for sums and products. It
[ginac.git] / ginac / symbol.cpp
index 59dda652a133f3e71b0c0930696beb41139947d1..b68fed87fe5f7a8d36485859485d863f843fe2c7 100644 (file)
@@ -3,7 +3,7 @@
  *  Implementation of GiNaC's symbolic objects. */
 
 /*
- *  GiNaC Copyright (C) 1999-2006 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2007 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -57,6 +57,13 @@ realsymbol::realsymbol()
        domain = domain::real;
 }
 
+// possymbol
+
+possymbol::possymbol()
+{
+       domain = domain::positive;
+}
+
 //////////
 // other constructors
 //////////
@@ -103,6 +110,20 @@ realsymbol::realsymbol(const std::string & initname, unsigned rt, tinfo_t rtt, u
 realsymbol::realsymbol(const std::string & initname, const std::string & texname, unsigned rt, tinfo_t rtt, unsigned domain)
  : symbol(initname, texname, rt, rtt, domain) { }
 
+// possymbol
+       
+possymbol::possymbol(const std::string & initname, unsigned domain)
+ : symbol(initname, domain) { }
+
+possymbol::possymbol(const std::string & initname, const std::string & texname, unsigned domain)
+ : symbol(initname, texname, domain) { }
+
+possymbol::possymbol(const std::string & initname, unsigned rt, tinfo_t rtt, unsigned domain)
+ : symbol(initname, rt, rtt, domain) { }
+
+possymbol::possymbol(const std::string & initname, const std::string & texname, unsigned rt, tinfo_t rtt, unsigned domain)
+ : symbol(initname, texname, rt, rtt, domain) { }
+
 //////////
 // archiving
 //////////
@@ -186,19 +207,25 @@ void symbol::do_print_python_repr(const print_python_repr & c, unsigned level) c
 
 bool symbol::info(unsigned inf) const
 {
-       if (inf == info_flags::symbol)
-               return true;
-       if (inf == info_flags::polynomial ||
-           inf == info_flags::integer_polynomial ||
-           inf == info_flags::cinteger_polynomial ||
-           inf == info_flags::rational_polynomial ||
-           inf == info_flags::crational_polynomial ||
-           inf == info_flags::rational_function)
-               return true;
-       if (inf == info_flags::real)
-               return domain == domain::real;
-       else
-               return inherited::info(inf);
+       switch (inf) {
+               case info_flags::symbol:
+               case info_flags::polynomial:
+               case info_flags::integer_polynomial: 
+               case info_flags::cinteger_polynomial: 
+               case info_flags::rational_polynomial: 
+               case info_flags::crational_polynomial: 
+               case info_flags::rational_function: 
+               case info_flags::expanded:
+                       return true;
+               case info_flags::real:
+                       return domain == domain::real || domain == domain::positive;
+               case info_flags::positive:
+               case info_flags::nonnegative:
+                       return domain == domain::positive;
+               case info_flags::has_indices:
+                       return false;
+       }
+       return inherited::info(inf);
 }
 
 ex symbol::eval(int level) const
@@ -228,14 +255,14 @@ ex symbol::conjugate() const
 
 ex symbol::real_part() const
 {
-       if (domain == domain::real)
+       if (domain==domain::real || domain==domain::positive)
                return *this;
        return real_part_function(*this).hold();
 }
 
 ex symbol::imag_part() const
 {
-       if (domain == domain::real)
+       if (domain==domain::real || domain==domain::positive)
                return 0;
        return imag_part_function(*this).hold();
 }