GiNaC  1.6.2
power.h
Go to the documentation of this file.
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_POWER_H
00024 #define GINAC_POWER_H
00025 
00026 #include "basic.h"
00027 #include "ex.h"
00028 #include "archive.h"
00029 
00030 namespace GiNaC {
00031 
00032 class numeric;
00033 class add;
00034 class mul;
00035 
00038 class power : public basic
00039 {
00040     GINAC_DECLARE_REGISTERED_CLASS(power, basic)
00041     
00042     friend class mul;
00043     
00044 // member functions
00045     
00046     // other constructors
00047 public:
00048     power(const ex & lh, const ex & rh) :  basis(lh), exponent(rh) {}
00049     template<typename T> power(const ex & lh, const T & rh) :  basis(lh), exponent(rh) {}
00050     
00051     // functions overriding virtual functions from base classes
00052 public:
00053     unsigned precedence() const {return 60;}
00054     bool info(unsigned inf) const;
00055     size_t nops() const;
00056     ex op(size_t i) const;
00057     ex map(map_function & f) const;
00058     bool is_polynomial(const ex & var) const;
00059     int degree(const ex & s) const;
00060     int ldegree(const ex & s) const;
00061     ex coeff(const ex & s, int n = 1) const;
00062     ex eval(int level=0) const;
00063     ex evalf(int level=0) const;
00064     ex evalm() const;
00065     ex series(const relational & s, int order, unsigned options = 0) const;
00066     ex subs(const exmap & m, unsigned options = 0) const;
00067     bool has(const ex & other, unsigned options = 0) const;
00068     ex normal(exmap & repl, exmap & rev_lookup, int level = 0) const;
00069     ex to_rational(exmap & repl) const;
00070     ex to_polynomial(exmap & repl) const;
00071     ex conjugate() const;
00072     ex real_part() const;
00073     ex imag_part() const;
00075     void archive(archive_node& n) const;
00077     void read_archive(const archive_node& n, lst& syms);
00078 protected:
00079     ex derivative(const symbol & s) const;
00080     ex eval_ncmul(const exvector & v) const;
00081     unsigned return_type() const;
00082     return_type_t return_type_tinfo() const;
00083     ex expand(unsigned options = 0) const;
00084     
00085     // new virtual functions which can be overridden by derived classes
00086     // none
00087     
00088     // non-virtual functions in this class
00089 protected:
00090     void print_power(const print_context & c, const char *powersymbol, const char *openbrace, const char *closebrace, unsigned level) const;
00091     void do_print_dflt(const print_dflt & c, unsigned level) const;
00092     void do_print_latex(const print_latex & c, unsigned level) const;
00093     void do_print_csrc(const print_csrc & c, unsigned level) const;
00094     void do_print_python(const print_python & c, unsigned level) const;
00095     void do_print_python_repr(const print_python_repr & c, unsigned level) const;
00096     void do_print_csrc_cl_N(const print_csrc_cl_N & c, unsigned level) const;
00097 
00098     ex expand_add(const add & a, int n, unsigned options) const;
00099     ex expand_add_2(const add & a, unsigned options) const;
00100     ex expand_mul(const mul & m, const numeric & n, unsigned options, bool from_expand = false) const;
00101     
00102 // member variables
00103     
00104 protected:
00105     ex basis;
00106     ex exponent;
00107 };
00108 GINAC_DECLARE_UNARCHIVER(power); 
00109 
00110 // wrapper functions
00111 
00116 inline ex pow(const ex & b, const ex & e)
00117 {
00118     return power(b, e);
00119 }
00120 template<typename T1, typename T2>
00121 inline ex pow(const T1 & b, const T2 & e)
00122 {
00123     return power(ex(b), ex(e));
00124 }
00125 
00127 inline ex sqrt(const ex & a)
00128 {
00129     extern const ex _ex1_2;
00130     return power(a,_ex1_2);
00131 }
00132 
00133 } // namespace GiNaC
00134 
00135 #endif // ndef GINAC_POWER_H

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.