GiNaC  1.6.2
Public Member Functions | Protected Member Functions | Protected Attributes | Friends
GiNaC::power Class Reference

This class holds a two-component object, a basis and and exponent representing exponentiation. More...

#include <power.h>

Inheritance diagram for GiNaC::power:
GiNaC::basic GiNaC::refcounted

List of all members.

Public Member Functions

 power (const ex &lh, const ex &rh)
template<typename T >
 power (const ex &lh, const T &rh)
unsigned precedence () const
 Return relative operator precedence (for parenthezing output).
bool info (unsigned inf) const
 Information about the object.
size_t nops () const
 Number of operands/members.
ex op (size_t i) const
 Return operand/member at position i.
ex map (map_function &f) const
 Construct new expression by applying the specified function to all sub-expressions (one level only, not recursively).
bool is_polynomial (const ex &var) const
 Check whether this is a polynomial in the given variables.
int degree (const ex &s) const
 Return degree of highest power in object s.
int ldegree (const ex &s) const
 Return degree of lowest power in object s.
ex coeff (const ex &s, int n=1) const
 Return coefficient of degree n in object s.
ex eval (int level=0) const
 Perform automatic term rewriting rules in this class.
ex evalf (int level=0) const
 Evaluate object numerically.
ex evalm () const
 Evaluate sums, products and integer powers of matrices.
ex series (const relational &s, int order, unsigned options=0) const
 Implementation of ex::series() for powers.
ex subs (const exmap &m, unsigned options=0) const
 Substitute a set of objects by arbitrary expressions.
bool has (const ex &other, unsigned options=0) const
 Test for occurrence of a pattern.
ex normal (exmap &repl, exmap &rev_lookup, int level=0) const
 Implementation of ex::normal([B) for powers.
ex to_rational (exmap &repl) const
 Implementation of ex::to_rational() for powers.
ex to_polynomial (exmap &repl) const
 Implementation of ex::to_polynomial() for powers.
ex conjugate () const
ex real_part () const
ex imag_part () const
void archive (archive_node &n) const
 Save (a.k.a.
void read_archive (const archive_node &n, lst &syms)
 Read (a.k.a.

Protected Member Functions

ex derivative (const symbol &s) const
 Implementation of ex::diff() for a power.
ex eval_ncmul (const exvector &v) const
unsigned return_type () const
return_type_t return_type_tinfo () const
ex expand (unsigned options=0) const
 Expand expression, i.e.
void print_power (const print_context &c, const char *powersymbol, const char *openbrace, const char *closebrace, unsigned level) const
void do_print_dflt (const print_dflt &c, unsigned level) const
void do_print_latex (const print_latex &c, unsigned level) const
void do_print_csrc (const print_csrc &c, unsigned level) const
void do_print_python (const print_python &c, unsigned level) const
void do_print_python_repr (const print_python_repr &c, unsigned level) const
 Python parsable output to stream.
void do_print_csrc_cl_N (const print_csrc_cl_N &c, unsigned level) const
ex expand_add (const add &a, int n, unsigned options) const
 expand a^n where a is an add and n is a positive integer.
ex expand_add_2 (const add &a, unsigned options) const
 Special case of power::expand_add.
ex expand_mul (const mul &m, const numeric &n, unsigned options, bool from_expand=false) const
 Expand factors of m in m^n where m is a mul and n is an integer.

Protected Attributes

ex basis
ex exponent

Friends

class mul

Detailed Description

This class holds a two-component object, a basis and and exponent representing exponentiation.

Definition at line 38 of file power.h.


Constructor & Destructor Documentation

GiNaC::power::power ( const ex lh,
const ex rh 
) [inline]
template<typename T >
GiNaC::power::power ( const ex lh,
const T &  rh 
) [inline]

Definition at line 49 of file power.h.


Member Function Documentation

unsigned GiNaC::power::precedence ( ) const [inline, virtual]

Return relative operator precedence (for parenthezing output).

Reimplemented from GiNaC::basic.

Definition at line 53 of file power.h.

Referenced by print_power().

bool GiNaC::power::info ( unsigned  inf) const [virtual]
size_t GiNaC::power::nops ( ) const [virtual]

Number of operands/members.

Reimplemented from GiNaC::basic.

Definition at line 264 of file power.cpp.

ex GiNaC::power::op ( size_t  i) const [virtual]

Return operand/member at position i.

Reimplemented from GiNaC::basic.

Definition at line 269 of file power.cpp.

References basis, exponent, and GINAC_ASSERT.

ex GiNaC::power::map ( map_function f) const [virtual]

Construct new expression by applying the specified function to all sub-expressions (one level only, not recursively).

Reimplemented from GiNaC::basic.

Definition at line 276 of file power.cpp.

References GiNaC::are_ex_trivially_equal(), basis, GiNaC::status_flags::dynallocated, exponent, and power().

bool GiNaC::power::is_polynomial ( const ex var) const [virtual]

Check whether this is a polynomial in the given variables.

Reimplemented from GiNaC::basic.

Definition at line 288 of file power.cpp.

References basis, exponent, GiNaC::ex::has(), GiNaC::ex::info(), GiNaC::ex::is_polynomial(), and GiNaC::info_flags::nonnegint.

int GiNaC::power::degree ( const ex s) const [virtual]

Return degree of highest power in object s.

Reimplemented from GiNaC::basic.

Definition at line 297 of file power.cpp.

References basis, GiNaC::ex::degree(), exponent, GiNaC::ex::has(), GiNaC::ex::is_equal(), GiNaC::basic::is_equal(), GiNaC::is_integer(), and GiNaC::to_int().

int GiNaC::power::ldegree ( const ex s) const [virtual]

Return degree of lowest power in object s.

Reimplemented from GiNaC::basic.

Definition at line 312 of file power.cpp.

References basis, exponent, GiNaC::ex::has(), GiNaC::ex::is_equal(), GiNaC::basic::is_equal(), GiNaC::is_integer(), GiNaC::ex::ldegree(), and GiNaC::to_int().

ex GiNaC::power::coeff ( const ex s,
int  n = 1 
) const [virtual]

Return coefficient of degree n in object s.

Reimplemented from GiNaC::basic.

Definition at line 327 of file power.cpp.

References GiNaC::_ex0, GiNaC::_ex1, basis, exponent, GiNaC::ex::is_equal(), GiNaC::basic::is_equal(), GiNaC::is_integer(), and GiNaC::to_int().

ex GiNaC::power::eval ( int  level = 0) const [virtual]

Perform automatic term rewriting rules in this class.

In the following x, x1, x2,... stand for a symbolic variables of type ex and c, c1, c2... stand for such expressions that contain a plain number.

  • ^(x,0) -> 1 (also handles ^(0,0))
  • ^(x,1) -> x
  • ^(0,c) -> 0 or exception (depending on the real part of c)
  • ^(1,x) -> 1
  • ^(c1,c2) -> *(c1^n,c1^(c2-n)) (so that 0<(c2-n)<1, try to evaluate roots, possibly in numerator and denominator of c1)
  • ^(^(x,c1),c2) -> ^(x,c1*c2) if x is positive and c1 is real.
  • ^(^(x,c1),c2) -> ^(x,c1*c2) (c2 integer or -1 < c1 <= 1, case c1=1 should not happen, see below!)
  • ^(*(x,y,z),c) -> *(x^c,y^c,z^c) (if c integer)
  • ^(*(x,c1),c2) -> ^(x,c2)*c1^c2 (c1>0)
  • ^(*(x,c1),c2) -> ^(-x,c2)*c1^c2 (c1<0)
Parameters:
levelcut-off in recursive evaluation

Reimplemented from GiNaC::basic.

Definition at line 371 of file power.cpp.

References GiNaC::_ex0, GiNaC::_ex1, GiNaC::_ex_1, GiNaC::_num0_p, GiNaC::_num1_p, GiNaC::_num_1_p, GiNaC::abs(), GiNaC::are_ex_trivially_equal(), basis, c, GiNaC::basic::clearflag(), GiNaC::return_types::commutative, GiNaC::numeric::compare(), GiNaC::numeric::denom(), GiNaC::numeric::div(), GiNaC::status_flags::dynallocated, GiNaC::ex::eval(), GiNaC::status_flags::evaluated, expand_mul(), GiNaC::status_flags::expanded, exponent, GiNaC::basic::flags, GINAC_ASSERT, GiNaC::status_flags::hash_calculated, GiNaC::basic::hold(), GiNaC::ex::info(), GiNaC::ex::integer_content(), GiNaC::numeric::inverse(), GiNaC::iquo(), GiNaC::numeric::is_crational(), GiNaC::numeric::is_equal(), GiNaC::ex::is_equal(), GiNaC::numeric::is_integer(), GiNaC::numeric::is_negative(), GiNaC::is_negative(), GiNaC::numeric::is_pos_integer(), GiNaC::numeric::is_positive(), GiNaC::numeric::is_rational(), GiNaC::numeric::is_real(), GiNaC::numeric::is_zero(), GiNaC::ex::is_zero(), GiNaC::is_zero(), likely, m, GiNaC::max_recursion_level, mul, GiNaC::numeric::mul(), n, GiNaC::numeric::numer(), GiNaC::ex::op(), GiNaC::expairseq::overall_coeff, GiNaC::info_flags::positive, power(), GiNaC::numeric::power(), r, GiNaC::numeric::real(), GiNaC::info_flags::real, GiNaC::ex::return_type(), GiNaC::basic::setflag(), and GiNaC::numeric::to_int().

ex GiNaC::power::evalf ( int  level = 0) const [virtual]

Evaluate object numerically.

Reimplemented from GiNaC::basic.

Definition at line 579 of file power.cpp.

References basis, GiNaC::ex::evalf(), exponent, GiNaC::max_recursion_level, and power().

ex GiNaC::power::evalm ( ) const [virtual]

Evaluate sums, products and integer powers of matrices.

Reimplemented from GiNaC::basic.

Definition at line 600 of file power.cpp.

References basis, GiNaC::status_flags::dynallocated, GiNaC::ex::evalm(), exponent, GiNaC::pow(), and power().

ex GiNaC::power::series ( const relational r,
int  order,
unsigned  options = 0 
) const [virtual]
ex GiNaC::power::subs ( const exmap m,
unsigned  options = 0 
) const [virtual]

Substitute a set of objects by arbitrary expressions.

The ex returned will already be evaluated.

Reimplemented from GiNaC::basic.

Definition at line 639 of file power.cpp.

References GiNaC::subs_options::algebraic, GiNaC::are_ex_trivially_equal(), basis, exponent, GiNaC::subs_options::no_pattern, power(), GiNaC::ex::subs(), GiNaC::basic::subs_one_level(), and GiNaC::tryfactsubs().

bool GiNaC::power::has ( const ex pattern,
unsigned  options = 0 
) const [virtual]

Test for occurrence of a pattern.

An object 'has' a pattern if it matches 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.

Reimplemented from GiNaC::basic.

Definition at line 612 of file power.cpp.

References GiNaC::has_options::algebraic, basis, exponent, GiNaC::basic::has(), GiNaC::ex::info(), GiNaC::info_flags::integer, GiNaC::ex::match(), GiNaC::info_flags::negint, GiNaC::ex::op(), GiNaC::info_flags::posint, and GiNaC::to_int().

ex GiNaC::power::normal ( exmap repl,
exmap rev_lookup,
int  level = 0 
) const [virtual]

Implementation of ex::normal([B) for powers.

It normalizes the basis, distributes integer exponents to numerator and denominator, and replaces non-integer powers by temporary symbols.

See also:
ex::normal

Reimplemented from GiNaC::basic.

Definition at line 2260 of file normal.cpp.

References GiNaC::_ex1, basis, GiNaC::status_flags::dynallocated, exponent, GiNaC::ex::info(), GiNaC::info_flags::integer, GiNaC::ex::is_equal(), GiNaC::max_recursion_level, GiNaC::info_flags::negative, GiNaC::ex::op(), GiNaC::info_flags::positive, power(), GiNaC::replace_with_symbol(), and GiNaC::basic::setflag().

ex GiNaC::power::to_rational ( exmap repl) const [virtual]

Implementation of ex::to_rational() for powers.

It replaces non-integer powers by temporary symbols.

Reimplemented from GiNaC::basic.

Definition at line 2544 of file normal.cpp.

References basis, exponent, GiNaC::ex::info(), GiNaC::info_flags::integer, power(), GiNaC::replace_with_symbol(), and GiNaC::ex::to_rational().

ex GiNaC::power::to_polynomial ( exmap repl) const [virtual]

Implementation of ex::to_polynomial() for powers.

It replaces non-posint powers by temporary symbols.

Reimplemented from GiNaC::basic.

Definition at line 2554 of file normal.cpp.

References GiNaC::_ex_1, basis, GiNaC::collect_common_factors(), exponent, GiNaC::ex::info(), GiNaC::info_flags::negint, GiNaC::info_flags::posint, power(), GiNaC::replace_with_symbol(), GiNaC::ex::to_polynomial(), and GiNaC::ex::to_rational().

ex GiNaC::power::conjugate ( ) const [virtual]
ex GiNaC::power::real_part ( ) const [virtual]
ex GiNaC::power::imag_part ( ) const [virtual]
void GiNaC::power::archive ( archive_node n) const [virtual]

Save (a.k.a.

serialize) object into archive.

Reimplemented from GiNaC::basic.

Definition at line 81 of file power.cpp.

References GiNaC::archive_node::add_ex(), basis, and exponent.

void GiNaC::power::read_archive ( const archive_node n,
lst syms 
) [virtual]

Read (a.k.a.

deserialize) object from archive.

Reimplemented from GiNaC::basic.

Definition at line 74 of file power.cpp.

References basis, exponent, and GiNaC::archive_node::find_ex().

ex GiNaC::power::derivative ( const symbol s) const [protected, virtual]

Implementation of ex::diff() for a power.

See also:
ex::diff

Reimplemented from GiNaC::basic.

Definition at line 747 of file power.cpp.

References GiNaC::_ex1, GiNaC::_ex_1, basis, GiNaC::ex::diff(), exponent, GiNaC::log(), mul, and power().

ex GiNaC::power::eval_ncmul ( const exvector v) const [protected, virtual]

Reimplemented from GiNaC::basic.

Definition at line 665 of file power.cpp.

unsigned GiNaC::power::return_type ( ) const [protected, virtual]

Reimplemented from GiNaC::basic.

Definition at line 776 of file power.cpp.

References basis, and GiNaC::ex::return_type().

return_type_t GiNaC::power::return_type_tinfo ( ) const [protected, virtual]

Reimplemented from GiNaC::basic.

Definition at line 781 of file power.cpp.

References basis, and GiNaC::ex::return_type_tinfo().

ex GiNaC::power::expand ( unsigned  options = 0) const [protected, virtual]
void GiNaC::power::print_power ( const print_context c,
const char *  powersymbol,
const char *  openbrace,
const char *  closebrace,
unsigned  level 
) const [protected]
void GiNaC::power::do_print_dflt ( const print_dflt c,
unsigned  level 
) const [protected]
void GiNaC::power::do_print_latex ( const print_latex c,
unsigned  level 
) const [protected]
void GiNaC::power::do_print_csrc ( const print_csrc c,
unsigned  level 
) const [protected]
void GiNaC::power::do_print_python ( const print_python c,
unsigned  level 
) const [protected]

Definition at line 211 of file power.cpp.

References print_power().

void GiNaC::power::do_print_python_repr ( const print_python_repr c,
unsigned  level 
) const [protected]

Python parsable output to stream.

Reimplemented from GiNaC::basic.

Definition at line 216 of file power.cpp.

References basis, exponent, GiNaC::ex::print(), and GiNaC::print_context::s.

void GiNaC::power::do_print_csrc_cl_N ( const print_csrc_cl_N c,
unsigned  level 
) const [protected]
ex GiNaC::power::expand_add ( const add a,
int  n,
unsigned  options 
) const [protected]
ex GiNaC::power::expand_add_2 ( const add a,
unsigned  options 
) const [protected]
ex GiNaC::power::expand_mul ( const mul m,
const numeric n,
unsigned  options,
bool  from_expand = false 
) const [protected]

Friends And Related Function Documentation

friend class mul [friend]

Definition at line 42 of file power.h.

Referenced by derivative(), eval(), expand(), expand_add(), and expand_mul().


Member Data Documentation

ex GiNaC::power::basis [protected]

The documentation for this class was generated from the following files:

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