3 * Interface to GiNaC's symbolic objects. */
6 * GiNaC Copyright (C) 1999-2008 Johannes Gutenberg University Mainz, Germany
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef __GINAC_SYMBOL_H__
24 #define __GINAC_SYMBOL_H__
34 /** Basic CAS symbol. It has a name because it must know how to output itself.
36 class symbol : public basic
38 GINAC_DECLARE_REGISTERED_CLASS(symbol, basic)
42 explicit symbol(const std::string & initname);
43 symbol(const std::string & initname, const std::string & texname);
45 // functions overriding virtual functions from base classes
47 bool info(unsigned inf) const;
48 ex eval(int level = 0) const { return *this; } // for performance reasons
49 ex evalf(int level = 0) const { return *this; } // overwrites basic::evalf() for performance reasons
50 ex series(const relational & s, int order, unsigned options = 0) const;
51 ex subs(const exmap & m, unsigned options = 0) const { return subs_one_level(m, options); } // overwrites basic::subs() for performance reasons
52 ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const;
53 ex to_rational(exmap & repl) const;
54 ex to_polynomial(exmap & repl) const;
58 bool is_polynomial(const ex & var) const;
60 ex derivative(const symbol & s) const;
61 bool is_equal_same_type(const basic & other) const;
62 unsigned calchash() const;
64 // non-virtual functions in this class
66 void set_name(const std::string & n) { name = n; }
67 std::string get_name() const { return name; }
68 virtual unsigned get_domain() const { return domain::complex; }
70 void do_print(const print_context & c, unsigned level) const;
71 void do_print_latex(const print_latex & c, unsigned level) const;
72 void do_print_tree(const print_tree & c, unsigned level) const;
73 void do_print_python_repr(const print_python_repr & c, unsigned level) const;
78 unsigned serial; ///< unique serial number for comparison
79 std::string name; ///< printname of this symbol
80 std::string TeX_name; ///< LaTeX name of this symbol
82 static unsigned next_serial;
86 /** Specialization of symbol to real domain */
87 class realsymbol : public symbol
91 explicit realsymbol(const std::string & initname);
92 realsymbol(const std::string & initname, const std::string & texname);
94 unsigned get_domain() const { return domain::real; }
96 ex conjugate() const { return *this; }
97 ex real_part() const { return *this; }
98 ex imag_part() const { return 0; }
100 realsymbol* duplicate() const { return new realsymbol(*this); }
104 /** Specialization of symbol to real domain */
105 class possymbol : public realsymbol
109 explicit possymbol(const std::string & initname);
110 possymbol(const std::string & initname, const std::string & texname);
112 unsigned get_domain() const { return domain::positive; }
114 possymbol* duplicate() const { return new possymbol(*this); }
119 #endif // ndef __GINAC_SYMBOL_H__