|
GiNaC
1.6.2
|
00001 00005 /* 00006 * GiNaC Copyright (C) 1999-2011 Johannes Gutenberg University Mainz, Germany 00007 * 00008 * This program is free software; you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation; either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * This program is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00023 #ifndef GINAC_SYMBOL_H 00024 #define GINAC_SYMBOL_H 00025 00026 #include "basic.h" 00027 #include "ex.h" 00028 #include "ptr.h" 00029 #include "archive.h" 00030 00031 #include <string> 00032 #include <typeinfo> 00033 00034 namespace GiNaC { 00035 00038 class symbol : public basic 00039 { 00040 GINAC_DECLARE_REGISTERED_CLASS(symbol, basic) 00041 // other constructors 00042 public: 00043 explicit symbol(const std::string & initname); 00044 symbol(const std::string & initname, const std::string & texname); 00045 00046 // functions overriding virtual functions from base classes 00047 public: 00048 bool info(unsigned inf) const; 00049 ex eval(int level = 0) const { return *this; } // for performance reasons 00050 ex evalf(int level = 0) const { return *this; } // overwrites basic::evalf() for performance reasons 00051 ex series(const relational & s, int order, unsigned options = 0) const; 00052 ex subs(const exmap & m, unsigned options = 0) const { return subs_one_level(m, options); } // overwrites basic::subs() for performance reasons 00053 ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const; 00054 ex to_rational(exmap & repl) const; 00055 ex to_polynomial(exmap & repl) const; 00056 ex conjugate() const; 00057 ex real_part() const; 00058 ex imag_part() const; 00059 bool is_polynomial(const ex & var) const; 00061 void archive(archive_node& n) const; 00063 void read_archive(const archive_node& n, lst& syms); 00064 protected: 00065 ex derivative(const symbol & s) const; 00066 bool is_equal_same_type(const basic & other) const; 00067 unsigned calchash() const; 00068 00069 // non-virtual functions in this class 00070 public: 00071 void set_name(const std::string & n) { name = n; } 00072 std::string get_name() const; 00073 virtual unsigned get_domain() const { return domain::complex; } 00074 protected: 00075 void do_print(const print_context & c, unsigned level) const; 00076 void do_print_latex(const print_latex & c, unsigned level) const; 00077 void do_print_tree(const print_tree & c, unsigned level) const; 00078 void do_print_python_repr(const print_python_repr & c, unsigned level) const; 00079 00080 // member variables 00081 00082 protected: 00083 unsigned serial; 00084 mutable std::string name; 00085 std::string TeX_name; 00086 private: 00087 static unsigned next_serial; 00088 }; 00089 GINAC_DECLARE_UNARCHIVER(symbol); 00090 00091 00093 class realsymbol : public symbol 00094 { 00095 public: 00096 realsymbol(); 00097 explicit realsymbol(const std::string & initname); 00098 realsymbol(const std::string & initname, const std::string & texname); 00099 00100 unsigned get_domain() const { return domain::real; } 00101 00102 ex conjugate() const { return *this; } 00103 ex real_part() const { return *this; } 00104 ex imag_part() const { return 0; } 00105 00106 realsymbol* duplicate() const { return new realsymbol(*this); } 00107 }; 00108 GINAC_DECLARE_UNARCHIVER(realsymbol); 00109 00110 00112 class possymbol : public realsymbol 00113 { 00114 public: 00115 possymbol(); 00116 explicit possymbol(const std::string & initname); 00117 possymbol(const std::string & initname, const std::string & texname); 00118 00119 unsigned get_domain() const { return domain::positive; } 00120 00121 possymbol* duplicate() const { return new possymbol(*this); } 00122 }; 00123 GINAC_DECLARE_UNARCHIVER(possymbol); 00124 00125 } // namespace GiNaC 00126 00127 #endif // ndef GINAC_SYMBOL_H