GiNaC  1.6.2
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends
GiNaC::ex Class Reference

Lightweight wrapper for GiNaC's symbolic objects. More...

#include <ex.h>

List of all members.

Public Member Functions

 ex () throw ()
 ex (const basic &other)
 ex (int i)
 ex (unsigned int i)
 ex (long i)
 ex (unsigned long i)
 ex (double const d)
 ex (const std::string &s, const ex &l)
 Construct ex from string and a list of symbols.
void swap (ex &other) throw ()
 Efficiently swap the contents of two expressions.
const_iterator begin () const throw ()
const_iterator end () const throw ()
const_preorder_iterator preorder_begin () const
const_preorder_iterator preorder_end () const throw ()
const_postorder_iterator postorder_begin () const
const_postorder_iterator postorder_end () const throw ()
ex eval (int level=0) const
ex evalf (int level=0) const
ex evalm () const
ex eval_ncmul (const exvector &v) const
ex eval_integ () const
void print (const print_context &c, unsigned level=0) const
 Print expression to stream.
void dbgprint () const
 Little wrapper arount print to be called within a debugger.
void dbgprinttree () const
 Little wrapper arount printtree to be called within a debugger.
bool info (unsigned inf) const
size_t nops () const
ex op (size_t i) const
ex operator[] (const ex &index) const
ex operator[] (size_t i) const
exlet_op (size_t i)
 Return modifyable operand/member at position i.
exoperator[] (const ex &index)
exoperator[] (size_t i)
ex lhs () const
 Left hand side of relational expression.
ex rhs () const
 Right hand side of relational expression.
ex conjugate () const
ex real_part () const
ex imag_part () const
bool has (const ex &pattern, unsigned options=0) const
bool find (const ex &pattern, exset &found) const
 Find all occurrences of a pattern.
bool match (const ex &pattern) const
 Check whether expression matches a specified pattern.
bool match (const ex &pattern, exmap &repls) const
ex subs (const exmap &m, unsigned options=0) const
ex subs (const lst &ls, const lst &lr, unsigned options=0) const
 Substitute objects in an expression (syntactic substitution) and return the result as a new expression.
ex subs (const ex &e, unsigned options=0) const
 Substitute objects in an expression (syntactic substitution) and return the result as a new expression.
ex map (map_function &f) const
ex map (ex(*f)(const ex &e)) const
void accept (visitor &v) const
void traverse_preorder (visitor &v) const
 Traverse expression tree with given visitor, preorder traversal.
void traverse_postorder (visitor &v) const
 Traverse expression tree with given visitor, postorder traversal.
void traverse (visitor &v) const
bool is_polynomial (const ex &vars) const
 Check whether expression is a polynomial.
int degree (const ex &s) const
int ldegree (const ex &s) const
ex coeff (const ex &s, int n=1) const
ex lcoeff (const ex &s) const
ex tcoeff (const ex &s) const
ex expand (unsigned options=0) const
ex collect (const ex &s, bool distributed=false) const
ex diff (const symbol &s, unsigned nth=1) const
 Compute partial derivative of an expression.
ex series (const ex &r, int order, unsigned options=0) const
 Compute the truncated series expansion of an expression.
ex normal (int level=0) const
 Normalization of rational functions.
ex to_rational (exmap &repl) const
 Rationalization of non-rational functions.
ex to_rational (lst &repl_lst) const
ex to_polynomial (exmap &repl) const
ex to_polynomial (lst &repl_lst) const
ex numer () const
 Get numerator of an expression.
ex denom () const
 Get denominator of an expression.
ex numer_denom () const
 Get numerator and denominator of an expression.
ex unit (const ex &x) const
 Compute unit part (= sign of leading coefficient) of a multivariate polynomial in Q[x].
ex content (const ex &x) const
 Compute content part (= unit normal GCD of all coefficients) of a multivariate polynomial in Q[x].
numeric integer_content () const
 Compute the integer content (= GCD of all numeric coefficients) of an expanded polynomial.
ex primpart (const ex &x) const
 Compute primitive part of a multivariate polynomial in Q[x].
ex primpart (const ex &x, const ex &cont) const
 Compute primitive part of a multivariate polynomial in Q[x] when the content part is already known.
void unitcontprim (const ex &x, ex &u, ex &c, ex &p) const
 Compute unit part, content part, and primitive part of a multivariate polynomial in Q[x].
ex smod (const numeric &xi) const
numeric max_coefficient () const
 Return maximum (absolute value) coefficient of a polynomial.
exvector get_free_indices () const
ex simplify_indexed (unsigned options=0) const
 Simplify/canonicalize expression containing indexed objects.
ex simplify_indexed (const scalar_products &sp, unsigned options=0) const
 Simplify/canonicalize expression containing indexed objects.
int compare (const ex &other) const
bool is_equal (const ex &other) const
bool is_zero () const
bool is_zero_matrix () const
 Check whether expression is zero or zero matrix.
ex symmetrize () const
 Symmetrize expression over its free indices.
ex symmetrize (const lst &l) const
 Symmetrize expression over a list of objects (symbols, indices).
ex antisymmetrize () const
 Antisymmetrize expression over its free indices.
ex antisymmetrize (const lst &l) const
 Antisymmetrize expression over a list of objects (symbols, indices).
ex symmetrize_cyclic () const
 Symmetrize expression by cyclic permutation over its free indices.
ex symmetrize_cyclic (const lst &l) const
 Symmetrize expression by cyclic permutation over a list of objects (symbols, indices).
unsigned return_type () const
return_type_t return_type_tinfo () const
unsigned gethash () const

Private Member Functions

void makewriteable ()
 Make this ex writable (if more than one ex handle the same basic) by unlinking the object and creating an unshared copy of it.
void share (const ex &other) const
 Share equal objects between expressions.

Static Private Member Functions

static ptr< basicconstruct_from_basic (const basic &other)
 Helper function for the ex-from-basic constructor.
static basicconstruct_from_int (int i)
static basicconstruct_from_uint (unsigned int i)
static basicconstruct_from_long (long i)
static basicconstruct_from_ulong (unsigned long i)
static basicconstruct_from_double (double d)
static ptr< basicconstruct_from_string_and_lst (const std::string &s, const ex &l)

Private Attributes

ptr< basicbp
 pointer to basic object managed by this

Friends

class archive_node
bool are_ex_trivially_equal (const ex &, const ex &)
 Compare two objects of class quickly without doing a deep tree traversal.
template<class T >
const T & ex_to (const ex &)
 Return a reference to the basic-derived class T object embedded in an expression.
template<class T >
bool is_a (const ex &)
 Check if ex is a handle to a T, including base classes.
template<class T >
bool is_exactly_a (const ex &)
 Check if ex is a handle to a T, not including base classes.

Detailed Description

Lightweight wrapper for GiNaC's symbolic objects.

It holds a pointer to the other object in order to do garbage collection by the method of reference counting. I.e., it is a smart pointer. Also, the constructor ex::ex(const basic & other) calls the methods that do automatic evaluation. E.g., x-x turns automatically into 0.

Definition at line 71 of file ex.h.


Constructor & Destructor Documentation

GiNaC::ex::ex ( ) throw () [inline]

Definition at line 259 of file ex.h.

References bp, GiNaC::status_flags::dynallocated, and GINAC_ASSERT.

GiNaC::ex::ex ( const basic other) [inline]

Definition at line 265 of file ex.h.

References bp, GiNaC::status_flags::dynallocated, and GINAC_ASSERT.

GiNaC::ex::ex ( int  i) [inline]

Definition at line 271 of file ex.h.

References bp, GiNaC::status_flags::dynallocated, and GINAC_ASSERT.

GiNaC::ex::ex ( unsigned int  i) [inline]

Definition at line 277 of file ex.h.

References bp, GiNaC::status_flags::dynallocated, and GINAC_ASSERT.

GiNaC::ex::ex ( long  i) [inline]

Definition at line 283 of file ex.h.

References bp, GiNaC::status_flags::dynallocated, and GINAC_ASSERT.

GiNaC::ex::ex ( unsigned long  i) [inline]

Definition at line 289 of file ex.h.

References bp, GiNaC::status_flags::dynallocated, and GINAC_ASSERT.

GiNaC::ex::ex ( double const  d) [inline]

Definition at line 295 of file ex.h.

References bp, GiNaC::status_flags::dynallocated, and GINAC_ASSERT.

GiNaC::ex::ex ( const std::string &  s,
const ex l 
) [inline]

Construct ex from string and a list of symbols.

The input grammar is similar to the GiNaC output format. All symbols and indices to be used in the expression must be specified in a lst in the second argument. Undefined symbols and other parser errors will throw an exception.

Definition at line 301 of file ex.h.

References bp, GiNaC::status_flags::dynallocated, and GINAC_ASSERT.


Member Function Documentation

void GiNaC::ex::swap ( ex other) throw () [inline]
const_iterator GiNaC::ex::begin ( ) const throw () [inline]
const_iterator GiNaC::ex::end ( ) const throw () [inline]

Definition at line 637 of file ex.h.

References nops().

Referenced by GiNaC::basic::collect(), GiNaC::divide_in_z(), and subs().

const_preorder_iterator GiNaC::ex::preorder_begin ( ) const [inline]

Definition at line 642 of file ex.h.

References nops().

const_preorder_iterator GiNaC::ex::preorder_end ( ) const throw () [inline]

Definition at line 647 of file ex.h.

const_postorder_iterator GiNaC::ex::postorder_begin ( ) const [inline]

Definition at line 652 of file ex.h.

References nops().

const_postorder_iterator GiNaC::ex::postorder_end ( ) const throw () [inline]

Definition at line 657 of file ex.h.

ex GiNaC::ex::eval ( int  level = 0) const [inline]
ex GiNaC::ex::evalf ( int  level = 0) const [inline]
ex GiNaC::ex::evalm ( ) const [inline]

Definition at line 119 of file ex.h.

References bp.

Referenced by GiNaC::add::evalm(), GiNaC::pseries::evalm(), GiNaC::power::evalm(), GiNaC::evalm(), and is_zero_matrix().

ex GiNaC::ex::eval_ncmul ( const exvector v) const [inline]

Definition at line 120 of file ex.h.

References bp.

Referenced by GiNaC::integral::eval_ncmul(), and GiNaC::relational::eval_ncmul().

ex GiNaC::ex::eval_integ ( ) const [inline]

Definition at line 121 of file ex.h.

References bp.

Referenced by GiNaC::integral::eval_integ(), GiNaC::pseries::eval_integ(), and GiNaC::eval_integ().

void GiNaC::ex::print ( const print_context c,
unsigned  level = 0 
) const

Print expression to stream.

The formatting of the output is determined by the kind of print_context object that is passed. Possible formattings include ginsh-parsable output (the default), tree-like output for debugging, and C++ source.

See also:
print_context

Definition at line 56 of file ex.cpp.

References bp.

Referenced by GiNaC::abs_print_csrc_float(), GiNaC::abs_print_latex(), GiNaC::conjugate_print_latex(), GiNaC::integral::do_print(), GiNaC::relational::do_print(), GiNaC::mul::do_print(), GiNaC::add::do_print_csrc(), GiNaC::power::do_print_csrc(), GiNaC::mul::do_print_csrc(), GiNaC::idx::do_print_csrc(), GiNaC::power::do_print_csrc_cl_N(), GiNaC::power::do_print_dflt(), GiNaC::integral::do_print_latex(), GiNaC::power::do_print_latex(), GiNaC::relational::do_print_python_repr(), GiNaC::add::do_print_python_repr(), GiNaC::power::do_print_python_repr(), GiNaC::mul::do_print_python_repr(), GiNaC::pseries::do_print_python_repr(), GiNaC::idx::do_print_tree(), GiNaC::pseries::do_print_tree(), GiNaC::expairseq::do_print_tree(), GiNaC::varidx::do_print_tree(), GiNaC::spinidx::do_print_tree(), GiNaC::basic::do_print_tree(), GiNaC::factorial_print_dflt_latex(), GiNaC::H_print_latex(), GiNaC::imag_part_print_latex(), GiNaC::operator<<(), GiNaC::expair::print(), GiNaC::add::print_add(), GiNaC::idx::print_index(), GiNaC::power::print_power(), GiNaC::pseries::print_series(), GiNaC::expairseq::printpair(), GiNaC::expairseq::printseq(), GiNaC::real_part_print_latex(), GiNaC::S_print_latex(), and GiNaC::zeta1_print_latex().

void GiNaC::ex::dbgprint ( ) const

Little wrapper arount print to be called within a debugger.

Definition at line 62 of file ex.cpp.

References bp.

void GiNaC::ex::dbgprinttree ( ) const

Little wrapper arount printtree to be called within a debugger.

Definition at line 68 of file ex.cpp.

References bp.

bool GiNaC::ex::info ( unsigned  inf) const [inline]

Definition at line 129 of file ex.h.

References bp.

Referenced by GiNaC::abs_eval(), GiNaC::acos_eval(), GiNaC::acosh_eval(), GiNaC::asin_eval(), GiNaC::asinh_conjugate(), GiNaC::asinh_eval(), GiNaC::atan2_eval(), GiNaC::atan_conjugate(), GiNaC::atan_eval(), GiNaC::atanh_eval(), GiNaC::beta_eval(), GiNaC::beta_series(), GiNaC::mul::can_be_further_expanded(), GiNaC::pseries::conjugate(), GiNaC::power::conjugate(), GiNaC::expairseq::construct_from_2_ex(), content(), GiNaC::cos_eval(), GiNaC::cosh_eval(), GiNaC::csgn_power(), GiNaC::csgn_series(), GiNaC::matrix::determinant(), GiNaC::divide(), GiNaC::divide_in_z(), GiNaC::add::do_print_csrc(), GiNaC::power::do_print_csrc(), GiNaC::idx::do_print_csrc(), GiNaC::eta_eval(), GiNaC::eta_evalf(), GiNaC::eta_series(), GiNaC::power::eval(), GiNaC::exp_eval(), GiNaC::power::expand(), GiNaC::factor(), GiNaC::G2_eval(), GiNaC::G2_evalf(), GiNaC::G3_eval(), GiNaC::G3_evalf(), GiNaC::gcd(), GiNaC::H_eval(), GiNaC::H_evalf(), GiNaC::power::has(), GiNaC::heur_gcd(), GiNaC::idx::idx(), GiNaC::pseries::imag_part(), GiNaC::power::imag_part(), GiNaC::add::info(), GiNaC::mul::info(), GiNaC::power::info(), GiNaC::power::is_polynomial(), GiNaC::lcm(), GiNaC::lcmcoeff(), GiNaC::lgamma_conjugate(), GiNaC::lgamma_eval(), GiNaC::lgamma_series(), GiNaC::Li2_conjugate(), GiNaC::Li2_eval(), GiNaC::Li2_series(), GiNaC::Li_eval(), GiNaC::Li_evalf(), GiNaC::Li_series(), GiNaC::log_conjugate(), GiNaC::log_eval(), GiNaC::log_imag_part(), GiNaC::log_real_part(), GiNaC::log_series(), GiNaC::lsolve(), GiNaC::power::normal(), GiNaC::Order_imag_part(), GiNaC::matrix::pow(), GiNaC::prem(), GiNaC::psi1_eval(), GiNaC::psi1_series(), GiNaC::psi2_eval(), GiNaC::psi2_series(), GiNaC::quo(), GiNaC::pseries::real_part(), GiNaC::power::real_part(), GiNaC::rem(), GiNaC::resultant(), GiNaC::S_eval(), GiNaC::S_evalf(), GiNaC::S_series(), GiNaC::mul::series(), GiNaC::power::series(), GiNaC::sin_eval(), GiNaC::sinh_eval(), GiNaC::sprem(), GiNaC::step_series(), subs(), GiNaC::tan_eval(), GiNaC::tanh_eval(), GiNaC::tgamma_eval(), GiNaC::tgamma_series(), GiNaC::power::to_polynomial(), GiNaC::expairseq::to_polynomial(), GiNaC::power::to_rational(), GiNaC::expairseq::to_rational(), GiNaC::matrix::trace(), GiNaC::tryfactsubs(), unit(), unitcontprim(), GiNaC::zeta1_eval(), GiNaC::zeta2_deriv(), GiNaC::zeta2_eval(), and GiNaC::zetaderiv_eval().

size_t GiNaC::ex::nops ( ) const [inline]
ex GiNaC::ex::op ( size_t  i) const [inline]

Definition at line 133 of file ex.h.

References bp.

Referenced by GiNaC::matrix::add_indexed(), GiNaC::algebraic_match_mul_with_mul(), GiNaC::ncmul::append_factors(), GiNaC::atan_series(), GiNaC::atanh_series(), GiNaC::mul::can_be_further_expanded(), GiNaC::basic::collect(), GiNaC::collect_symbols(), GiNaC::cos_eval(), GiNaC::cosh_eval(), GiNaC::ncmul::count_factors(), GiNaC::csgn_eval(), GiNaC::decomp_rational(), denom(), GiNaC::const_postorder_iterator::descend(), GiNaC::divide(), GiNaC::divide_in_z(), GiNaC::epsilon_tensor(), GiNaC::power::eval(), GiNaC::indexed::eval(), GiNaC::integral::eval_integ(), GiNaC::exp_eval(), GiNaC::integral::expand(), GiNaC::mul::expand(), GiNaC::indexed::expand(), GiNaC::expand_dummy_sum(), GiNaC::factor(), find(), GiNaC::find_common_factor(), GiNaC::matrix::fraction_free_elimination(), GiNaC::gcd_pf_mul(), GiNaC::gcd_pf_pow(), GiNaC::gcd_pf_pow_pow(), GiNaC::get_all_dummy_indices_safely(), GiNaC::get_first_symbol(), GiNaC::clifford::get_metric(), GiNaC::H_evalf(), GiNaC::power::has(), GiNaC::hasindex(), GiNaC::haswild(), GiNaC::const_preorder_iterator::increment(), GiNaC::lcmcoeff(), GiNaC::Li2_series(), GiNaC::Li_deriv(), GiNaC::log_eval(), GiNaC::lorentz_eps(), GiNaC::lsolve(), GiNaC::expairseq::match(), GiNaC::basic::match(), GiNaC::multiply_lcm(), GiNaC::add::normal(), GiNaC::mul::normal(), GiNaC::power::normal(), normal(), numer(), GiNaC::op(), GiNaC::op0_is_equal::operator()(), GiNaC::ex_base_is_less::operator()(), GiNaC::const_iterator::operator*(), GiNaC::const_iterator::operator[](), GiNaC::product_to_exvector(), GiNaC::reposition_dummy_indices(), GiNaC::clifford::same_metric(), GiNaC::matrix::scalar_mul_indexed(), GiNaC::simplify_indexed(), GiNaC::sin_eval(), GiNaC::sinh_eval(), GiNaC::spmapkey::spmapkey(), GiNaC::sqrfree_parfrac(), GiNaC::step_eval(), subs(), GiNaC::symminfo::symminfo(), GiNaC::tan_eval(), GiNaC::tanh_eval(), traverse_postorder(), traverse_preorder(), GiNaC::tryfactsubs(), GiNaC::zeta1_eval(), and GiNaC::zeta2_deriv().

ex GiNaC::ex::operator[] ( const ex index) const [inline]

Definition at line 134 of file ex.h.

References bp.

ex GiNaC::ex::operator[] ( size_t  i) const [inline]

Definition at line 135 of file ex.h.

References bp.

ex & GiNaC::ex::let_op ( size_t  i)

Return modifyable operand/member at position i.

Definition at line 207 of file ex.cpp.

References bp, and makewriteable().

ex & GiNaC::ex::operator[] ( const ex index)

Definition at line 213 of file ex.cpp.

References bp, and makewriteable().

ex & GiNaC::ex::operator[] ( size_t  i)

Definition at line 219 of file ex.cpp.

References bp, and makewriteable().

ex GiNaC::ex::lhs ( ) const

Left hand side of relational expression.

Definition at line 226 of file ex.cpp.

References bp.

Referenced by GiNaC::fsolve(), GiNaC::lhs(), and GiNaC::pseries::pseries().

ex GiNaC::ex::rhs ( ) const

Right hand side of relational expression.

Definition at line 234 of file ex.cpp.

References bp.

Referenced by GiNaC::fsolve(), GiNaC::pseries::pseries(), and GiNaC::rhs().

ex GiNaC::ex::conjugate ( ) const [inline]
ex GiNaC::ex::real_part ( ) const [inline]
ex GiNaC::ex::imag_part ( ) const [inline]
bool GiNaC::ex::has ( const ex pattern,
unsigned  options = 0 
) const [inline]
bool GiNaC::ex::find ( const ex pattern,
exset found 
) const

Find all occurrences of a pattern.

The found matches are appended to the "found" list. If the expression itself matches the pattern, the children are not further examined. This function returns true when any matches were found.

Definition at line 105 of file ex.cpp.

References find(), match(), nops(), and op().

Referenced by GiNaC::divide_in_z(), find(), GiNaC::find(), GiNaC::replace_with_symbol(), GiNaC::idx::subs(), and GiNaC::basic::subs_one_level().

bool GiNaC::ex::match ( const ex pattern) const

Check whether expression matches a specified pattern.

Definition at line 95 of file ex.cpp.

References bp.

Referenced by find(), GiNaC::power::has(), GiNaC::basic::match(), GiNaC::match(), and GiNaC::tryfactsubs().

bool GiNaC::ex::match ( const ex pattern,
exmap repls 
) const [inline]

Definition at line 151 of file ex.h.

References bp.

ex GiNaC::ex::subs ( const exmap m,
unsigned  options = 0 
) const [inline]
ex GiNaC::ex::subs ( const lst ls,
const lst lr,
unsigned  options = 0 
) const

Substitute objects in an expression (syntactic substitution) and return the result as a new expression.

Definition at line 120 of file ex.cpp.

References GiNaC::container< C >::begin(), bp, GiNaC::container< C >::end(), GINAC_ASSERT, m, GiNaC::container< C >::nops(), GiNaC::subs_options::pattern_is_not_product, and GiNaC::subs_options::pattern_is_product.

ex GiNaC::ex::subs ( const ex e,
unsigned  options = 0 
) const

Substitute objects in an expression (syntactic substitution) and return the result as a new expression.

There are two valid types of replacement arguments: 1) a relational like object==ex and 2) a list of relationals lst(object1==ex1,object2==ex2,...).

Definition at line 144 of file ex.cpp.

References begin(), bp, end(), GINAC_ASSERT, info(), GiNaC::info_flags::list, m, op(), GiNaC::subs_options::pattern_is_not_product, GiNaC::subs_options::pattern_is_product, r, and GiNaC::info_flags::relation_equal.

ex GiNaC::ex::map ( map_function f) const [inline]

Definition at line 159 of file ex.h.

References bp.

Referenced by GiNaC::expand_dummy_sum().

ex GiNaC::ex::map ( ex(*)(const ex &e)  f) const
void GiNaC::ex::accept ( visitor v) const [inline]

Definition at line 163 of file ex.h.

References bp.

Referenced by traverse_postorder(), and traverse_preorder().

void GiNaC::ex::traverse_preorder ( visitor v) const

Traverse expression tree with given visitor, preorder traversal.

Definition at line 187 of file ex.cpp.

References accept(), n, nops(), op(), and traverse_preorder().

Referenced by traverse(), and traverse_preorder().

void GiNaC::ex::traverse_postorder ( visitor v) const

Traverse expression tree with given visitor, postorder traversal.

Definition at line 197 of file ex.cpp.

References accept(), n, nops(), op(), and traverse_postorder().

Referenced by traverse_postorder().

void GiNaC::ex::traverse ( visitor v) const [inline]

Definition at line 166 of file ex.h.

References traverse_preorder().

bool GiNaC::ex::is_polynomial ( const ex vars) const

Check whether expression is a polynomial.

Definition at line 242 of file ex.cpp.

References GiNaC::container< C >::begin(), bp, and GiNaC::container< C >::end().

Referenced by GiNaC::power::is_polynomial(), and GiNaC::is_polynomial().

int GiNaC::ex::degree ( const ex s) const [inline]
int GiNaC::ex::ldegree ( const ex s) const [inline]
ex GiNaC::ex::coeff ( const ex s,
int  n = 1 
) const [inline]
ex GiNaC::ex::lcoeff ( const ex s) const [inline]

Definition at line 173 of file ex.h.

References coeff(), and degree().

Referenced by content(), GiNaC::get_symbol_stats(), GiNaC::sr_gcd(), and unit().

ex GiNaC::ex::tcoeff ( const ex s) const [inline]

Definition at line 174 of file ex.h.

References coeff(), and ldegree().

ex GiNaC::ex::expand ( unsigned  options = 0) const
ex GiNaC::ex::collect ( const ex s,
bool  distributed = false 
) const [inline]

Definition at line 178 of file ex.h.

References bp.

Referenced by GiNaC::matrix::charpoly(), GiNaC::basic::collect(), and GiNaC::collect().

ex GiNaC::ex::diff ( const symbol s,
unsigned  nth = 1 
) const

Compute partial derivative of an expression.

Parameters:
ssymbol by which the expression is derived
nthorder of derivative (default 1)
Returns:
partial derivative as a new expression

Definition at line 86 of file ex.cpp.

References bp.

Referenced by GiNaC::integral::derivative(), GiNaC::power::derivative(), GiNaC::basic::diff(), GiNaC::diff(), GiNaC::fsolve(), GiNaC::basic::series(), and GiNaC::sqrfree_yun().

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

Compute the truncated series expansion of an expression.

This function returns an expression containing an object of class pseries to represent the series. If the series does not terminate within the given truncation order, the last term of the series will be an order term.

Parameters:
rexpansion relation, lhs holds variable and rhs holds point
ordertruncation order of series calculations
optionsof class series_options
Returns:
an expression holding a pseries object

Definition at line 1292 of file pseries.cpp.

References GiNaC::_ex0, bp, and r.

Referenced by GiNaC::Li2_series(), GiNaC::Li_series(), GiNaC::log_series(), GiNaC::S_series(), GiNaC::pseries::series(), GiNaC::add::series(), GiNaC::mul::series(), GiNaC::integral::series(), GiNaC::power::series(), and GiNaC::series().

ex GiNaC::ex::normal ( int  level = 0) const

Normalization of rational functions.

This function converts an expression to its normal form "numerator/denominator", where numerator and denominator are (relatively prime) polynomials. Any subexpressions which are not rational functions (like non-rational numbers, non-integer powers or functions like sin(), cos() etc.) are replaced by temporary symbols which are re-substituted by the (normalized) subexpressions before normal() returns (this way, any expression can be treated as a rational function). normal() is applied recursively to arguments of functions etc.

Parameters:
levelmaximum depth of recursion
Returns:
normalized expression

Definition at line 2342 of file normal.cpp.

References bp, GINAC_ASSERT, GiNaC::subs_options::no_pattern, op(), and subs().

Referenced by GiNaC::matrix::determinant(), GiNaC::matrix::fraction_free_elimination(), GiNaC::matrix::gauss_elimination(), GiNaC::pseries::normal(), GiNaC::normal(), and GiNaC::matrix::trace().

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

Rationalization of non-rational functions.

This function converts a general expression to a rational function by replacing all non-rational subexpressions (like non-rational numbers, non-integer powers or functions like sin(), cos() etc.) to temporary symbols. This makes it possible to use functions like gcd() and divide() on non-rational functions by applying to_rational() on the arguments, calling the desired function and re-substituting the temporary symbols in the result. To make the last step possible, all temporary symbols and their associated expressions are collected in the map specified by the repl parameter, ready to be passed as an argument to ex::subs().

Parameters:
replcollects all temporary symbols and their replacements
Returns:
rationalized expression

Definition at line 2431 of file normal.cpp.

References bp.

Referenced by GiNaC::matrix::determinant(), GiNaC::matrix::fraction_free_elimination(), GiNaC::power::to_polynomial(), GiNaC::power::to_rational(), GiNaC::expairseq::to_rational(), and GiNaC::to_rational().

ex GiNaC::ex::to_rational ( lst repl_lst) const
ex GiNaC::ex::to_polynomial ( exmap repl) const
ex GiNaC::ex::to_polynomial ( lst repl_lst) const
ex GiNaC::ex::numer ( ) const

Get numerator of an expression.

If the expression is not of the normal form "numerator/denominator", it is first converted to this form and then the numerator is returned.

See also:
ex::normal
Returns:
numerator

Definition at line 2363 of file normal.cpp.

References bp, GINAC_ASSERT, GiNaC::subs_options::no_pattern, op(), and subs().

Referenced by GiNaC::numer().

ex GiNaC::ex::denom ( ) const

Get denominator of an expression.

If the expression is not of the normal form "numerator/denominator", it is first converted to this form and then the denominator is returned.

See also:
ex::normal
Returns:
denominator

Definition at line 2383 of file normal.cpp.

References bp, GINAC_ASSERT, GiNaC::subs_options::no_pattern, op(), and subs().

Referenced by GiNaC::denom().

ex GiNaC::ex::numer_denom ( ) const

Get numerator and denominator of an expression.

If the expresison is not of the normal form "numerator/denominator", it is first converted to this form and then a list [numerator, denominator] is returned.

See also:
ex::normal
Returns:
a list [numerator, denominator]

Definition at line 2403 of file normal.cpp.

References bp, GINAC_ASSERT, GiNaC::subs_options::no_pattern, and subs().

Referenced by GiNaC::matrix::fraction_free_elimination(), and GiNaC::numer_denom().

ex GiNaC::ex::unit ( const ex x) const

Compute unit part (= sign of leading coefficient) of a multivariate polynomial in Q[x].

The product of unit part, content part, and primitive part is the polynomial itself.

Parameters:
xmain variable
Returns:
unit part
See also:
ex::content, ex::primpart, ex::unitcontprim

Definition at line 918 of file normal.cpp.

References GiNaC::_ex1, GiNaC::_ex_1, c, expand(), GiNaC::get_first_symbol(), info(), lcoeff(), GiNaC::info_flags::negative, and unit().

Referenced by content(), GiNaC::frac_cancel(), primpart(), unit(), and unitcontprim().

ex GiNaC::ex::content ( const ex x) const

Compute content part (= unit normal GCD of all coefficients) of a multivariate polynomial in Q[x].

The product of unit part, content part, and primitive part is the polynomial itself.

Parameters:
xmain variable
Returns:
content part
See also:
ex::unit, ex::primpart, ex::unitcontprim

Definition at line 940 of file normal.cpp.

References GiNaC::_ex0, c, coeff(), degree(), expand(), GiNaC::gcd(), info(), GiNaC::info_flags::integer, integer_content(), is_zero(), lcoeff(), ldegree(), GiNaC::info_flags::negative, r, and unit().

Referenced by GiNaC::sr_gcd(), and unitcontprim().

numeric GiNaC::ex::integer_content ( ) const

Compute the integer content (= GCD of all numeric coefficients) of an expanded polynomial.

For a polynomial with rational coefficients, this returns g/l where g is the GCD of the coefficients' numerators and l is the LCM of the coefficients' denominators.

Returns:
integer content

Definition at line 307 of file normal.cpp.

References bp.

Referenced by content(), GiNaC::power::eval(), GiNaC::gcd(), and GiNaC::heur_gcd_z().

ex GiNaC::ex::primpart ( const ex x) const

Compute primitive part of a multivariate polynomial in Q[x].

The result will be a unit-normal polynomial with a content part of 1. The product of unit part, content part, and primitive part is the polynomial itself.

Parameters:
xmain variable
Returns:
primitive part
See also:
ex::unit, ex::content, ex::unitcontprim

Definition at line 976 of file normal.cpp.

References c, and unitcontprim().

Referenced by GiNaC::sr_gcd().

ex GiNaC::ex::primpart ( const ex x,
const ex c 
) const

Compute primitive part of a multivariate polynomial in Q[x] when the content part is already known.

This function is faster in computing the primitive part than the previous function.

Parameters:
xmain variable
cpreviously computed content part
Returns:
primitive part

Definition at line 992 of file normal.cpp.

References GiNaC::_ex0, GiNaC::_ex1, is_zero(), GiNaC::quo(), and unit().

void GiNaC::ex::unitcontprim ( const ex x,
ex u,
ex c,
ex p 
) const

Compute unit part, content part, and primitive part of a multivariate polynomial in Q[x].

The product of the three parts is the polynomial itself.

Parameters:
xmain variable
uunit part (returned)
ccontent part (returned)
pprimitive part (returned)
See also:
ex::unit, ex::content, ex::primpart

Definition at line 1017 of file normal.cpp.

References GiNaC::_ex0, GiNaC::_ex1, GiNaC::_ex_1, GiNaC::abs(), content(), expand(), info(), is_zero(), GiNaC::info_flags::negative, GiNaC::quo(), and unit().

Referenced by GiNaC::gcd(), and primpart().

ex GiNaC::ex::smod ( const numeric xi) const [inline]

Definition at line 201 of file ex.h.

References bp.

Referenced by GiNaC::interpolate().

numeric GiNaC::ex::max_coefficient ( ) const

Return maximum (absolute value) coefficient of a polynomial.

This function is used internally by heur_gcd().

Returns:
maximum coefficient
See also:
heur_gcd

Definition at line 1149 of file normal.cpp.

References bp.

Referenced by GiNaC::heur_gcd_z().

exvector GiNaC::ex::get_free_indices ( ) const [inline]
ex GiNaC::ex::simplify_indexed ( unsigned  options = 0) const

Simplify/canonicalize expression containing indexed objects.

This performs contraction of dummy indices where possible and checks whether the free indices in sums are consistent.

Parameters:
optionsSimplification options (currently unused)
Returns:
simplified expression

Definition at line 1257 of file indexed.cpp.

Referenced by simplify_indexed(), and GiNaC::simplify_indexed().

ex GiNaC::ex::simplify_indexed ( const scalar_products sp,
unsigned  options = 0 
) const

Simplify/canonicalize expression containing indexed objects.

This performs contraction of dummy indices where possible, checks whether the free indices in sums are consistent, and automatically replaces scalar products by known values if desired.

Parameters:
spScalar products to be replaced automatically
optionsSimplification options (currently unused)
Returns:
simplified expression

Definition at line 1272 of file indexed.cpp.

References simplify_indexed().

int GiNaC::ex::compare ( const ex other) const [inline]
bool GiNaC::ex::is_equal ( const ex other) const [inline]

Definition at line 330 of file ex.h.

References bp, and share().

Referenced by GiNaC::abs_power(), GiNaC::acos_eval(), GiNaC::acosh_eval(), GiNaC::matrix::add_indexed(), GiNaC::asin_eval(), GiNaC::atan2_eval(), GiNaC::atan_eval(), GiNaC::atanh_eval(), GiNaC::atanh_series(), GiNaC::beta_eval(), GiNaC::pseries::coeff(), GiNaC::power::coeff(), GiNaC::add::combine_ex_with_coeff_to_pair(), GiNaC::mul::combine_ex_with_coeff_to_pair(), GiNaC::mul::combine_pair_with_coeff_to_pair(), GiNaC::mul::conjugate(), GiNaC::pseries::degree(), GiNaC::power::degree(), GiNaC::divide(), GiNaC::divide_in_z(), GiNaC::add::do_print_csrc(), GiNaC::power::do_print_csrc(), GiNaC::mul::do_print_csrc(), GiNaC::power::do_print_csrc_cl_N(), GiNaC::power::do_print_dflt(), GiNaC::power::do_print_latex(), GiNaC::expairseq::do_print_tree(), GiNaC::epsilon_tensor(), GiNaC::power::eval(), GiNaC::tensdelta::eval_indexed(), GiNaC::tensmetric::eval_indexed(), GiNaC::matrix::eval_indexed(), GiNaC::mul::expand(), GiNaC::power::expand_add_2(), GiNaC::find_common_factor(), GiNaC::frac_cancel(), GiNaC::gcd(), GiNaC::gcd_pf_pow(), GiNaC::gcd_pf_pow_pow(), GiNaC::make_flat_inserter::handle_factor(), GiNaC::expair::is_canonical_numeric(), GiNaC::pseries::is_compatible_to(), GiNaC::idx::is_dummy_pair_same_type(), GiNaC::expair::is_equal(), GiNaC::expairseq::is_equal_same_type(), is_zero(), GiNaC::pseries::ldegree(), GiNaC::power::ldegree(), GiNaC::Li2_eval(), GiNaC::Li2_series(), GiNaC::Li_eval(), GiNaC::log_eval(), GiNaC::lorentz_eps(), GiNaC::expairseq::map(), GiNaC::expairseq::match(), GiNaC::idx::match_same_type(), GiNaC::minimal_dim(), GiNaC::expairseq::nops(), GiNaC::power::normal(), GiNaC::expairseq::op(), GiNaC::idx_is_equal_ignore_dim::operator()(), GiNaC::ex_is_equal::operator()(), GiNaC::op0_is_equal::operator()(), GiNaC::spmapkey::operator==(), GiNaC::expairseq::printseq(), GiNaC::product_to_exvector(), GiNaC::psi2_eval(), GiNaC::quo(), GiNaC::rem(), GiNaC::clifford::same_metric(), GiNaC::pseries::series(), GiNaC::power::series(), GiNaC::simplify_indexed(), and GiNaC::sqrfree_yun().

bool GiNaC::ex::is_zero ( ) const [inline]

Definition at line 212 of file ex.h.

References GiNaC::_ex0, and is_equal().

Referenced by GiNaC::acos_conjugate(), GiNaC::acos_eval(), GiNaC::acosh_conjugate(), GiNaC::acosh_eval(), GiNaC::pseries::add_series(), GiNaC::asin_conjugate(), GiNaC::asin_eval(), GiNaC::asinh_eval(), GiNaC::atan2_eval(), GiNaC::atan_eval(), GiNaC::atanh_conjugate(), GiNaC::atanh_eval(), GiNaC::add::coeff(), GiNaC::mul::coeff(), GiNaC::ncmul::coeff(), content(), GiNaC::cosh_eval(), GiNaC::add::degree(), GiNaC::pseries::derivative(), GiNaC::fderivative::derivative(), GiNaC::function::derivative(), GiNaC::matrix::determinant(), GiNaC::basic::diff(), GiNaC::divide(), GiNaC::divide_in_z(), GiNaC::add::do_print_csrc(), GiNaC::add::eval(), GiNaC::power::eval(), GiNaC::indexed::eval(), GiNaC::function::eval(), GiNaC::pseries::evalm(), GiNaC::exp_eval(), GiNaC::pseries::expand(), GiNaC::mul::expand(), GiNaC::power::expand_add_2(), GiNaC::mul::find_real_imag(), GiNaC::frac_cancel(), GiNaC::gcd(), GiNaC::heur_gcd_z(), GiNaC::add::imag_part(), GiNaC::add::info(), GiNaC::interpolate(), GiNaC::is_zero(), is_zero_matrix(), GiNaC::add::ldegree(), GiNaC::lgamma_conjugate(), GiNaC::Li2_conjugate(), GiNaC::Li2_eval(), GiNaC::Li2_series(), GiNaC::Li3_eval(), GiNaC::Li_series(), GiNaC::log_conjugate(), GiNaC::log_eval(), GiNaC::log_series(), GiNaC::pseries::mul_series(), GiNaC::pseries::normal(), GiNaC::Order_eval(), GiNaC::prem(), primpart(), GiNaC::add::print_add(), GiNaC::pseries::print_series(), GiNaC::psi2_eval(), GiNaC::quo(), GiNaC::add::real_part(), GiNaC::rem(), GiNaC::S_eval(), GiNaC::S_series(), GiNaC::symbol::series(), GiNaC::power::series(), GiNaC::basic::series(), GiNaC::simplify_indexed(), GiNaC::simplify_indexed_product(), GiNaC::sinh_eval(), GiNaC::sprem(), GiNaC::sqrfree_yun(), GiNaC::sr_gcd(), GiNaC::tanh_eval(), unitcontprim(), GiNaC::indexed::validate(), and GiNaC::zetaderiv_eval().

bool GiNaC::ex::is_zero_matrix ( ) const

Check whether expression is zero or zero matrix.

Definition at line 256 of file ex.cpp.

References evalm(), and is_zero().

ex GiNaC::ex::symmetrize ( ) const

Symmetrize expression over its free indices.

Definition at line 1279 of file indexed.cpp.

References get_free_indices().

Referenced by GiNaC::symmetrize().

ex GiNaC::ex::symmetrize ( const lst l) const

Symmetrize expression over a list of objects (symbols, indices).

Definition at line 565 of file symmetry.cpp.

References GiNaC::container< C >::begin(), GiNaC::container< C >::end(), and GiNaC::symm().

ex GiNaC::ex::antisymmetrize ( ) const

Antisymmetrize expression over its free indices.

Definition at line 1285 of file indexed.cpp.

References get_free_indices().

Referenced by GiNaC::antisymmetrize().

ex GiNaC::ex::antisymmetrize ( const lst l) const

Antisymmetrize expression over a list of objects (symbols, indices).

Definition at line 572 of file symmetry.cpp.

References GiNaC::container< C >::begin(), GiNaC::container< C >::end(), and GiNaC::symm().

ex GiNaC::ex::symmetrize_cyclic ( ) const

Symmetrize expression by cyclic permutation over its free indices.

Definition at line 1291 of file indexed.cpp.

References get_free_indices().

Referenced by symmetrize_cyclic(), and GiNaC::symmetrize_cyclic().

ex GiNaC::ex::symmetrize_cyclic ( const lst l) const

Symmetrize expression by cyclic permutation over a list of objects (symbols, indices).

Definition at line 580 of file symmetry.cpp.

References GiNaC::container< C >::begin(), GiNaC::container< C >::end(), and symmetrize_cyclic().

unsigned GiNaC::ex::return_type ( ) const [inline]
return_type_t GiNaC::ex::return_type_tinfo ( ) const [inline]
unsigned GiNaC::ex::gethash ( ) const [inline]
ptr< basic > GiNaC::ex::construct_from_basic ( const basic other) [static, private]

Helper function for the ex-from-basic constructor.

This is where GiNaC's automatic evaluator and memory management are implemented.

See also:
ex::ex(const basic &)

Definition at line 293 of file ex.cpp.

References bp, GiNaC::basic::duplicate(), GiNaC::status_flags::dynallocated, GiNaC::basic::eval(), GiNaC::status_flags::evaluated, GiNaC::basic::flags, GiNaC::refcounted::get_refcount(), GINAC_ASSERT, and GiNaC::basic::setflag().

basic & GiNaC::ex::construct_from_int ( int  i) [static, private]
basic & GiNaC::ex::construct_from_uint ( unsigned int  i) [static, private]
basic & GiNaC::ex::construct_from_long ( long  i) [static, private]
basic & GiNaC::ex::construct_from_ulong ( unsigned long  i) [static, private]
basic & GiNaC::ex::construct_from_double ( double  d) [static, private]
static ptr<basic> GiNaC::ex::construct_from_string_and_lst ( const std::string &  s,
const ex l 
) [static, private]
void GiNaC::ex::makewriteable ( ) [private]

Make this ex writable (if more than one ex handle the same basic) by unlinking the object and creating an unshared copy of it.

Definition at line 270 of file ex.cpp.

References bp, GiNaC::status_flags::dynallocated, GINAC_ASSERT, and GiNaC::ptr< T >::makewritable().

Referenced by let_op(), and operator[]().

void GiNaC::ex::share ( const ex other) const [private]

Share equal objects between expressions.

See also:
ex::compare(const ex &)

Definition at line 279 of file ex.cpp.

References bp, and GiNaC::status_flags::not_shareable.

Referenced by compare(), and is_equal().


Friends And Related Function Documentation

friend class archive_node [friend]

Definition at line 72 of file ex.h.

bool are_ex_trivially_equal ( const ex e1,
const ex e2 
) [friend]

Compare two objects of class quickly without doing a deep tree traversal.

Returns:
"true" if they are equal "false" if equality cannot be established quickly (e1 and e2 may still be equal, in this case.

Definition at line 669 of file ex.h.

template<class T >
const T& ex_to ( const ex e) [friend]

Return a reference to the basic-derived class T object embedded in an expression.

This is fast but unsafe: the result is undefined if the expression does not contain a T object at its top level. Hence, you should generally check the type of e first. Also, you shouldn't cache the returned reference because GiNaC's garbage collector may destroy the referenced object any time it's used in another expression.

Parameters:
eexpression
Returns:
reference to object of class T
See also:
is_exactly_a<class T>()

Definition at line 953 of file ex.h.

template<class T >
bool is_a ( const ex obj) [friend]

Check if ex is a handle to a T, including base classes.

Definition at line 930 of file ex.h.

template<class T >
bool is_exactly_a ( const ex obj) [friend]

Check if ex is a handle to a T, not including base classes.

Definition at line 937 of file ex.h.


Member Data Documentation

ptr<basic> GiNaC::ex::bp [mutable, private]

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.