GiNaC 1.8.7
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
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

Public Member Functions

 power (const ex &lh, const ex &rh)
 
template<typename T >
 power (const ex &lh, const T &rh)
 
unsigned precedence () const override
 Return relative operator precedence (for parenthezing output). More...
 
bool info (unsigned inf) const override
 Information about the object. More...
 
size_t nops () const override
 Number of operands/members. More...
 
ex op (size_t i) const override
 Return operand/member at position i. More...
 
ex map (map_function &f) const override
 Construct new expression by applying the specified function to all sub-expressions (one level only, not recursively). More...
 
bool is_polynomial (const ex &var) const override
 Check whether this is a polynomial in the given variables. More...
 
int degree (const ex &s) const override
 Return degree of highest power in object s. More...
 
int ldegree (const ex &s) const override
 Return degree of lowest power in object s. More...
 
ex coeff (const ex &s, int n=1) const override
 Return coefficient of degree n in object s. More...
 
ex eval () const override
 Perform automatic term rewriting rules in this class. More...
 
ex evalf () const override
 Evaluate object numerically. More...
 
ex evalm () const override
 Evaluate sums, products and integer powers of matrices. More...
 
ex series (const relational &s, int order, unsigned options=0) const override
 Implementation of ex::series() for powers. More...
 
ex subs (const exmap &m, unsigned options=0) const override
 Substitute a set of objects by arbitrary expressions. More...
 
bool has (const ex &other, unsigned options=0) const override
 Test for occurrence of a pattern. More...
 
ex normal (exmap &repl, exmap &rev_lookup, lst &modifier) const override
 Implementation of ex::normal() for powers. More...
 
ex to_rational (exmap &repl) const override
 Implementation of ex::to_rational() for powers. More...
 
ex to_polynomial (exmap &repl) const override
 Implementation of ex::to_polynomial() for powers. More...
 
ex conjugate () const override
 
ex real_part () const override
 
ex imag_part () const override
 
void archive (archive_node &n) const override
 Save (a.k.a. More...
 
void read_archive (const archive_node &n, lst &syms) override
 Read (a.k.a. More...
 
- Public Member Functions inherited from GiNaC::basic
virtual ~basic ()
 basic destructor, virtual because class ex will delete objects of derived classes via a basic*. More...
 
 basic (const basic &other)
 
const basicoperator= (const basic &other)
 basic assignment operator: the other object might be of a derived class. More...
 
virtual basicduplicate () const
 Create a clone of this object on the heap. More...
 
virtual ex eval () const
 Perform automatic non-interruptive term rewriting rules. More...
 
virtual ex evalf () const
 Evaluate object numerically. More...
 
virtual ex evalm () const
 Evaluate sums, products and integer powers of matrices. More...
 
virtual ex eval_integ () const
 Evaluate integrals, if result is known. More...
 
virtual ex eval_indexed (const basic &i) const
 Perform automatic symbolic evaluations on indexed expression that contains this object as the base expression. More...
 
virtual void print (const print_context &c, unsigned level=0) const
 Output to stream. More...
 
virtual void dbgprint () const
 Little wrapper around print to be called within a debugger. More...
 
virtual void dbgprinttree () const
 Little wrapper around printtree to be called within a debugger. More...
 
virtual unsigned precedence () const
 Return relative operator precedence (for parenthezing output). More...
 
virtual bool info (unsigned inf) const
 Information about the object. More...
 
virtual size_t nops () const
 Number of operands/members. More...
 
virtual ex op (size_t i) const
 Return operand/member at position i. More...
 
virtual ex operator[] (const ex &index) const
 
virtual ex operator[] (size_t i) const
 
virtual exlet_op (size_t i)
 Return modifiable operand/member at position i. More...
 
virtual exoperator[] (const ex &index)
 
virtual exoperator[] (size_t i)
 
virtual bool has (const ex &other, unsigned options=0) const
 Test for occurrence of a pattern. More...
 
virtual bool match (const ex &pattern, exmap &repls) const
 Check whether the expression matches a given pattern. More...
 
virtual ex subs (const exmap &m, unsigned options=0) const
 Substitute a set of objects by arbitrary expressions. More...
 
virtual ex map (map_function &f) const
 Construct new expression by applying the specified function to all sub-expressions (one level only, not recursively). More...
 
virtual void accept (GiNaC::visitor &v) const
 
virtual bool is_polynomial (const ex &var) const
 Check whether this is a polynomial in the given variables. More...
 
virtual int degree (const ex &s) const
 Return degree of highest power in object s. More...
 
virtual int ldegree (const ex &s) const
 Return degree of lowest power in object s. More...
 
virtual ex coeff (const ex &s, int n=1) const
 Return coefficient of degree n in object s. More...
 
virtual ex expand (unsigned options=0) const
 Expand expression, i.e. More...
 
virtual ex collect (const ex &s, bool distributed=false) const
 Sort expanded expression in terms of powers of some object(s). More...
 
virtual ex series (const relational &r, int order, unsigned options=0) const
 Default implementation of ex::series(). More...
 
virtual ex normal (exmap &repl, exmap &rev_lookup, lst &modifier) const
 Default implementation of ex::normal(). More...
 
virtual ex to_rational (exmap &repl) const
 Default implementation of ex::to_rational(). More...
 
virtual ex to_polynomial (exmap &repl) const
 
virtual numeric integer_content () const
 
virtual ex smod (const numeric &xi) const
 Apply symmetric modular homomorphism to an expanded multivariate polynomial. More...
 
virtual numeric max_coefficient () const
 Implementation ex::max_coefficient(). More...
 
virtual exvector get_free_indices () const
 Return a vector containing the free indices of an expression. More...
 
virtual ex add_indexed (const ex &self, const ex &other) const
 Add two indexed expressions. More...
 
virtual ex scalar_mul_indexed (const ex &self, const numeric &other) const
 Multiply an indexed expression with a scalar. More...
 
virtual bool contract_with (exvector::iterator self, exvector::iterator other, exvector &v) const
 Try to contract two indexed expressions that appear in the same product. More...
 
virtual unsigned return_type () const
 
virtual return_type_t return_type_tinfo () const
 
virtual ex conjugate () const
 
virtual ex real_part () const
 
virtual ex imag_part () const
 
template<class T >
void print_dispatch (const print_context &c, unsigned level) const
 Like print(), but dispatch to the specified class. More...
 
void print_dispatch (const registered_class_info &ri, const print_context &c, unsigned level) const
 Like print(), but dispatch to the specified class. More...
 
virtual void archive (archive_node &n) const
 Save (serialize) the object into archive node. More...
 
virtual void read_archive (const archive_node &n, lst &syms)
 Load (deserialize) the object from an archive node. More...
 
ex subs_one_level (const exmap &m, unsigned options) const
 Helper function for subs(). More...
 
ex diff (const symbol &s, unsigned nth=1) const
 Default interface of nth derivative ex::diff(s, n). More...
 
int compare (const basic &other) const
 Compare objects syntactically to establish canonical ordering. More...
 
bool is_equal (const basic &other) const
 Test for syntactic equality. More...
 
const basichold () const
 Stop further evaluation. More...
 
unsigned gethash () const
 
const basicsetflag (unsigned f) const
 Set some status_flags. More...
 
const basicclearflag (unsigned f) const
 Clear some status_flags. More...
 
- Public Member Functions inherited from GiNaC::refcounted
 refcounted () noexcept
 
unsigned int add_reference () noexcept
 
unsigned int remove_reference () noexcept
 
unsigned int get_refcount () const noexcept
 
void set_refcount (unsigned int r) noexcept
 

Protected Member Functions

ex derivative (const symbol &s) const override
 Implementation of ex::diff() for a power. More...
 
ex eval_ncmul (const exvector &v) const override
 
unsigned return_type () const override
 
return_type_t return_type_tinfo () const override
 
ex expand (unsigned options=0) const override
 Expand expression, i.e. More...
 
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
 
void do_print_csrc_cl_N (const print_csrc_cl_N &c, unsigned level) const
 
- Protected Member Functions inherited from GiNaC::basic
 basic ()
 
virtual ex eval_ncmul (const exvector &v) const
 
virtual bool match_same_type (const basic &other) const
 Returns true if the attributes of two objects are similar enough for a match. More...
 
virtual ex derivative (const symbol &s) const
 Default implementation of ex::diff(). More...
 
virtual int compare_same_type (const basic &other) const
 Returns order relation between two objects of same type. More...
 
virtual bool is_equal_same_type (const basic &other) const
 Returns true if two objects of same type are equal. More...
 
virtual unsigned calchash () const
 Compute the hash value of an object and if it makes sense to store it in the objects status_flags, do so. More...
 
void ensure_if_modifiable () const
 Ensure the object may be modified without hurting others, throws if this is not the case. More...
 
void do_print (const print_context &c, unsigned level) const
 Default output to stream. More...
 
void do_print_tree (const print_tree &c, unsigned level) const
 Tree output to stream. More...
 
void do_print_python_repr (const print_python_repr &c, unsigned level) const
 Python parsable output to stream. More...
 

Static Protected Member Functions

static ex expand_add (const add &a, long n, unsigned options)
 expand a^n where a is an add and n is a positive integer. More...
 
static ex expand_add_2 (const add &a, unsigned options)
 Special case of power::expand_add. More...
 
static ex expand_mul (const mul &m, const numeric &n, unsigned options, bool from_expand=false)
 Expand factors of m in m^n where m is a mul and n is an integer. More...
 

Protected Attributes

ex basis
 
ex exponent
 
- Protected Attributes inherited from GiNaC::basic
unsigned flags
 of type status_flags More...
 
unsigned hashvalue
 hash value More...
 

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

◆ power() [1/2]

GiNaC::power::power ( const ex lh,
const ex rh 
)
inline

Definition at line 48 of file power.h.

Referenced by do_print_latex().

◆ power() [2/2]

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

Definition at line 49 of file power.h.

Member Function Documentation

◆ precedence()

unsigned GiNaC::power::precedence ( ) const
inlineoverridevirtual

Return relative operator precedence (for parenthezing output).

Reimplemented from GiNaC::basic.

Definition at line 53 of file power.h.

Referenced by print_power().

◆ info()

bool GiNaC::power::info ( unsigned  inf) const
overridevirtual

◆ nops()

size_t GiNaC::power::nops ( ) const
overridevirtual

Number of operands/members.

Reimplemented from GiNaC::basic.

Definition at line 263 of file power.cpp.

◆ op()

ex GiNaC::power::op ( size_t  i) const
overridevirtual

Return operand/member at position i.

Reimplemented from GiNaC::basic.

Definition at line 268 of file power.cpp.

References basis, exponent, and GINAC_ASSERT.

◆ map()

ex GiNaC::power::map ( map_function f) const
overridevirtual

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

Reimplemented from GiNaC::basic.

Definition at line 275 of file power.cpp.

References GiNaC::are_ex_trivially_equal(), basis, and exponent.

◆ is_polynomial()

bool GiNaC::power::is_polynomial ( const ex var) const
overridevirtual

Check whether this is a polynomial in the given variables.

Reimplemented from GiNaC::basic.

Definition at line 287 of file power.cpp.

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

◆ degree()

int GiNaC::power::degree ( const ex s) const
overridevirtual

Return degree of highest power in object s.

Reimplemented from GiNaC::basic.

Definition at line 301 of file power.cpp.

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

◆ ldegree()

int GiNaC::power::ldegree ( const ex s) const
overridevirtual

Return degree of lowest power in object s.

Reimplemented from GiNaC::basic.

Definition at line 316 of file power.cpp.

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

◆ coeff()

ex GiNaC::power::coeff ( const ex s,
int  n = 1 
) const
overridevirtual

Return coefficient of degree n in object s.

Reimplemented from GiNaC::basic.

Definition at line 331 of file power.cpp.

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

Referenced by expand(), and expand_add().

◆ eval()

ex GiNaC::power::eval ( ) const
overridevirtual

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 or (c1=-1 and c2>0), 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)

Reimplemented from GiNaC::basic.

Definition at line 374 of file power.cpp.

References GiNaC::_ex0, GiNaC::_ex1, GiNaC::_ex_1, GiNaC::_num0_p, GiNaC::_num1_p, GiNaC::_num_1_p, GiNaC::abs(), basis, c, GiNaC::basic::clearflag(), GiNaC::ex::coeff(), GiNaC::return_types::commutative, GiNaC::numeric::compare(), GiNaC::numeric::denom(), GiNaC::numeric::div(), GiNaC::status_flags::evaluated, expand_mul(), 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::ex::is_equal(), GiNaC::numeric::is_equal(), GiNaC::numeric::is_integer(), GiNaC::is_negative(), GiNaC::numeric::is_pos_integer(), GiNaC::numeric::is_positive(), GiNaC::numeric::is_rational(), GiNaC::numeric::is_real(), GiNaC::ex::is_zero(), GiNaC::numeric::is_zero(), likely, m, GiNaC::numeric::mul(), n, GiNaC::numeric::numer(), GiNaC::ex::op(), GiNaC::expairseq::overall_coeff, GiNaC::info_flags::positive, GiNaC::pow(), GiNaC::numeric::power(), r, GiNaC::info_flags::real, GiNaC::numeric::real(), GiNaC::ex::return_type(), GiNaC::expairseq::seq, GiNaC::basic::setflag(), and GiNaC::numeric::to_int().

◆ evalf()

ex GiNaC::power::evalf ( ) const
overridevirtual

Evaluate object numerically.

Reimplemented from GiNaC::basic.

Definition at line 565 of file power.cpp.

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

◆ evalm()

ex GiNaC::power::evalm ( ) const
overridevirtual

Evaluate sums, products and integer powers of matrices.

Reimplemented from GiNaC::basic.

Definition at line 578 of file power.cpp.

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

◆ series()

ex GiNaC::power::series ( const relational r,
int  order,
unsigned  options = 0 
) const
overridevirtual

◆ subs()

ex GiNaC::power::subs ( const exmap m,
unsigned  options = 0 
) const
overridevirtual

Substitute a set of objects by arbitrary expressions.

The ex returned will already be evaluated.

Reimplemented from GiNaC::basic.

Definition at line 615 of file power.cpp.

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

◆ has()

bool GiNaC::power::has ( const ex pattern,
unsigned  options = 0 
) const
overridevirtual

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 590 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(), options, and GiNaC::info_flags::posint.

◆ normal()

ex GiNaC::power::normal ( exmap repl,
exmap rev_lookup,
lst modifier 
) const
overridevirtual

Implementation of ex::normal() 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 2438 of file normal.cpp.

References GiNaC::_ex1, basis, exponent, GiNaC::ex::info(), GiNaC::info_flags::integer, GiNaC::ex::is_equal(), GiNaC::info_flags::negative, GiNaC::subs_options::no_pattern, GiNaC::container< C >::nops(), GiNaC::ex::normal(), GiNaC::ex::op(), GiNaC::container< C >::op(), GiNaC::info_flags::positive, GiNaC::pow(), GiNaC::replace_with_symbol(), and GiNaC::ex::subs().

◆ to_rational()

ex GiNaC::power::to_rational ( exmap repl) const
overridevirtual

Implementation of ex::to_rational() for powers.

It replaces non-integer powers by temporary symbols.

Reimplemented from GiNaC::basic.

Definition at line 2704 of file normal.cpp.

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

◆ to_polynomial()

ex GiNaC::power::to_polynomial ( exmap repl) const
overridevirtual

Implementation of ex::to_polynomial() for powers.

It replaces non-posint powers by temporary symbols.

Reimplemented from GiNaC::basic.

Definition at line 2714 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, GiNaC::pow(), GiNaC::replace_with_symbol(), and GiNaC::ex::to_polynomial().

◆ conjugate()

ex GiNaC::power::conjugate ( ) const
overridevirtual

◆ real_part()

ex GiNaC::power::real_part ( ) const
overridevirtual

◆ imag_part()

ex GiNaC::power::imag_part ( ) const
overridevirtual

◆ archive()

void GiNaC::power::archive ( archive_node n) const
overridevirtual

Save (a.k.a.

serialize) object into archive.

Reimplemented from GiNaC::basic.

Definition at line 80 of file power.cpp.

References basis, exponent, and n.

◆ read_archive()

void GiNaC::power::read_archive ( const archive_node n,
lst syms 
)
overridevirtual

Read (a.k.a.

deserialize) object from archive.

Reimplemented from GiNaC::basic.

Definition at line 73 of file power.cpp.

References basis, exponent, and n.

◆ derivative()

ex GiNaC::power::derivative ( const symbol s) const
overrideprotectedvirtual

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

See also
ex::diff

Reimplemented from GiNaC::basic.

Definition at line 744 of file power.cpp.

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

◆ eval_ncmul()

ex GiNaC::power::eval_ncmul ( const exvector v) const
overrideprotectedvirtual

Reimplemented from GiNaC::basic.

Definition at line 641 of file power.cpp.

◆ return_type()

unsigned GiNaC::power::return_type ( ) const
overrideprotectedvirtual

Reimplemented from GiNaC::basic.

Definition at line 768 of file power.cpp.

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

◆ return_type_tinfo()

return_type_t GiNaC::power::return_type_tinfo ( ) const
overrideprotectedvirtual

Reimplemented from GiNaC::basic.

Definition at line 773 of file power.cpp.

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

◆ expand()

ex GiNaC::power::expand ( unsigned  options = 0) const
overrideprotectedvirtual

◆ print_power()

void GiNaC::power::print_power ( const print_context c,
const char *  powersymbol,
const char *  openbrace,
const char *  closebrace,
unsigned  level 
) const
protected

Definition at line 93 of file power.cpp.

References basis, c, exponent, precedence(), and GiNaC::ex::print().

Referenced by do_print_dflt(), do_print_latex(), and do_print_python().

◆ do_print_dflt()

void GiNaC::power::do_print_dflt ( const print_dflt c,
unsigned  level 
) const
protected

◆ do_print_latex()

void GiNaC::power::do_print_latex ( const print_latex c,
unsigned  level 
) const
protected

◆ do_print_csrc()

void GiNaC::power::do_print_csrc ( const print_csrc c,
unsigned  level 
) const
protected

◆ do_print_python()

void GiNaC::power::do_print_python ( const print_python c,
unsigned  level 
) const
protected

Definition at line 210 of file power.cpp.

References c, and print_power().

◆ do_print_python_repr()

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

Definition at line 215 of file power.cpp.

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

◆ do_print_csrc_cl_N()

void GiNaC::power::do_print_csrc_cl_N ( const print_csrc_cl_N c,
unsigned  level 
) const
protected

Definition at line 164 of file power.cpp.

References GiNaC::_ex_1, basis, c, exponent, GiNaC::ex::is_equal(), and GiNaC::ex::print().

◆ expand_add()

ex GiNaC::power::expand_add ( const add a,
long  n,
unsigned  options 
)
staticprotected

◆ expand_add_2()

ex GiNaC::power::expand_add_2 ( const add a,
unsigned  options 
)
staticprotected

◆ expand_mul()

ex GiNaC::power::expand_mul ( const mul m,
const numeric n,
unsigned  options,
bool  from_expand = false 
)
staticprotected

Friends And Related Function Documentation

◆ mul

friend class mul
friend

Definition at line 42 of file power.h.

Referenced by expand_add(), and expand_add_2().

Member Data Documentation

◆ basis

ex GiNaC::power::basis
protected

◆ exponent

ex GiNaC::power::exponent
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.