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

This class is the ABC (abstract base class) of GiNaC's class hierarchy. More...

#include <basic.h>

Inheritance diagram for GiNaC::basic:
GiNaC::refcounted GiNaC::constant GiNaC::container< C > GiNaC::expairseq GiNaC::fail GiNaC::idx GiNaC::integral GiNaC::matrix GiNaC::numeric GiNaC::power GiNaC::pseries GiNaC::relational GiNaC::structure< T, ComparisonPolicy > GiNaC::symbol GiNaC::symmetry GiNaC::tensor GiNaC::wildcard

List of all members.

Public Member Functions

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

Protected Member Functions

 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.
virtual ex derivative (const symbol &s) const
 Default implementation of ex::diff().
virtual int compare_same_type (const basic &other) const
 Returns order relation between two objects of same type.
virtual bool is_equal_same_type (const basic &other) const
 Returns true if two objects of same type are equal.
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.
void ensure_if_modifiable () const
 Ensure the object may be modified without hurting others, throws if this is not the case.
void do_print (const print_context &c, unsigned level) const
 Default output to stream.
void do_print_tree (const print_tree &c, unsigned level) const
 Tree output to stream.
void do_print_python_repr (const print_python_repr &c, unsigned level) const
 Python parsable output to stream.

Protected Attributes

unsigned flags
 of type status_flags
unsigned hashvalue
 hash value

Friends

class ex

Detailed Description

This class is the ABC (abstract base class) of GiNaC's class hierarchy.

Definition at line 104 of file basic.h.


Constructor & Destructor Documentation

GiNaC::basic::basic ( ) [inline, protected]

Definition at line 112 of file basic.h.

Referenced by duplicate().

virtual GiNaC::basic::~basic ( ) [inline, virtual]

basic destructor, virtual because class ex will delete objects of derived classes via a basic*.

Definition at line 117 of file basic.h.

References GiNaC::status_flags::dynallocated, flags, GiNaC::refcounted::get_refcount(), and GINAC_ASSERT.

GiNaC::basic::basic ( const basic other)

Member Function Documentation

const basic & GiNaC::basic::operator= ( const basic other)

basic assignment operator: the other object might be of a derived class.

Definition at line 64 of file basic.cpp.

References GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, flags, GiNaC::status_flags::hash_calculated, hashvalue, and GiNaC::refcounted::set_refcount().

virtual basic* GiNaC::basic::duplicate ( ) const [inline, virtual]

Create a clone of this object on the heap.

One can think of this as simulating a virtual copy constructor which is needed for instance by the refcounted construction of an ex from a basic.

Reimplemented in GiNaC::possymbol, and GiNaC::realsymbol.

Definition at line 131 of file basic.h.

References basic().

Referenced by GiNaC::ex::construct_from_basic(), GiNaC::idx::map(), map(), GiNaC::idx::replace_dim(), GiNaC::idx::subs(), subs(), GiNaC::spinidx::toggle_dot(), GiNaC::varidx::toggle_variance(), and GiNaC::spinidx::toggle_variance_dot().

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

Evaluate sums, products and integer powers of matrices.

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, GiNaC::matrix, GiNaC::ncmul, GiNaC::power, GiNaC::pseries, GiNaC::mul, and GiNaC::add.

Definition at line 450 of file basic.cpp.

References map(), GiNaC::map_evalm, and nops().

ex GiNaC::basic::eval_integ ( ) const [virtual]

Evaluate integrals, if result is known.

Reimplemented in GiNaC::pseries, and GiNaC::integral.

Definition at line 464 of file basic.cpp.

References map(), GiNaC::map_eval_integ, and nops().

ex GiNaC::basic::eval_ncmul ( const exvector v) const [protected, virtual]
ex GiNaC::basic::eval_indexed ( const basic i) const [virtual]

Perform automatic symbolic evaluations on indexed expression that contains this object as the base expression.

Reimplemented in GiNaC::tensepsilon, GiNaC::spinmetric, GiNaC::structure< T, ComparisonPolicy >, GiNaC::su3d, GiNaC::matrix, GiNaC::su3f, GiNaC::minkmetric, GiNaC::tensmetric, and GiNaC::tensdelta.

Definition at line 474 of file basic.cpp.

Referenced by GiNaC::indexed::eval().

void GiNaC::basic::print ( const print_context c,
unsigned  level = 0 
) const [virtual]

Output to stream.

This performs double dispatch on the dynamic type of *this and the dynamic type of the supplied print context.

Parameters:
cprint context object that describes the output formatting
levelvalue that is used to identify the precedence or indentation level for placing parentheses and formatting

Reimplemented in GiNaC::function, GiNaC::structure< T, ComparisonPolicy >, and GiNaC::fderivative.

Definition at line 116 of file basic.cpp.

References print_dispatch().

Referenced by dbgprint(), dbgprinttree(), GiNaC::expairseq::is_equal_same_type(), GiNaC::add::print_add(), GiNaC::mul::print_overall_coeff(), GiNaC::pseries::print_series(), and GiNaC::print_sym_pow().

void GiNaC::basic::dbgprint ( ) const [virtual]

Little wrapper around print to be called within a debugger.

This is needed because you cannot call foo.print(cout) from within the debugger because it might not know what cout is. This method can be invoked with no argument and it will simply print to stdout.

See also:
basic::print
basic::dbgprinttree

Definition at line 199 of file basic.cpp.

References print().

void GiNaC::basic::dbgprinttree ( ) const [virtual]

Little wrapper around printtree to be called within a debugger.

See also:
basic::dbgprint

Definition at line 208 of file basic.cpp.

References print().

unsigned GiNaC::basic::precedence ( ) const [virtual]
bool GiNaC::basic::info ( unsigned  inf) const [virtual]
size_t GiNaC::basic::nops ( ) const [virtual]
ex GiNaC::basic::op ( size_t  i) const [virtual]
ex GiNaC::basic::operator[] ( const ex index) const [virtual]

Reimplemented in GiNaC::structure< T, ComparisonPolicy >.

Definition at line 250 of file basic.cpp.

References op(), and GiNaC::to_int().

ex GiNaC::basic::operator[] ( size_t  i) const [virtual]

Reimplemented in GiNaC::structure< T, ComparisonPolicy >.

Definition at line 258 of file basic.cpp.

References op().

ex & GiNaC::basic::let_op ( size_t  i) [virtual]

Return modifyable operand/member at position i.

Reimplemented in GiNaC::container< C >, GiNaC::structure< T, ComparisonPolicy >, GiNaC::matrix, GiNaC::clifford, and GiNaC::integral.

Definition at line 244 of file basic.cpp.

References ensure_if_modifiable().

Referenced by map(), operator[](), and subs().

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

Reimplemented in GiNaC::structure< T, ComparisonPolicy >.

Definition at line 263 of file basic.cpp.

References let_op(), and GiNaC::to_int().

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

Reimplemented in GiNaC::structure< T, ComparisonPolicy >.

Definition at line 271 of file basic.cpp.

References let_op().

bool GiNaC::basic::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 in GiNaC::structure< T, ComparisonPolicy >, GiNaC::numeric, GiNaC::power, and GiNaC::mul.

Definition at line 280 of file basic.cpp.

References GiNaC::ex::has(), match(), nops(), and op().

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

bool GiNaC::basic::match ( const ex pattern,
exmap repl_lst 
) const [virtual]

Check whether the expression matches a given pattern.

For every wildcard object in the pattern, a pair with the wildcard as a key and matching expression as a value is added to repl_lst.

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, GiNaC::expairseq, and GiNaC::wildcard.

Definition at line 528 of file basic.cpp.

References is_equal(), is_equal_same_type(), GiNaC::ex::match(), match_same_type(), GiNaC::ex::nops(), nops(), GiNaC::ex::op(), and op().

Referenced by has(), and subs_one_level().

bool GiNaC::basic::match_same_type ( const basic other) const [protected, virtual]

Returns true if the attributes of two objects are similar enough for a match.

This function must not match subexpressions (this is already done by basic::match()). Only attributes not accessible by op() should be compared. This is also the reason why this function doesn't take the wildcard replacement list from match() as an argument: only subexpressions are subject to wildcard matches. Also, this function only needs to be implemented for container classes because is_equal_same_type() is automatically used instead of match_same_type() if nops() == 0.

See also:
basic::match

Reimplemented in GiNaC::function, GiNaC::spinidx, GiNaC::structure< T, ComparisonPolicy >, GiNaC::matrix, GiNaC::varidx, GiNaC::fderivative, GiNaC::relational, GiNaC::idx, GiNaC::clifford, and GiNaC::color.

Definition at line 756 of file basic.cpp.

Referenced by match().

ex GiNaC::basic::subs ( const exmap m,
unsigned  options = 0 
) const [virtual]
ex GiNaC::basic::map ( map_function f) const [virtual]

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

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, GiNaC::expairseq, GiNaC::relational, GiNaC::power, and GiNaC::idx.

Definition at line 294 of file basic.cpp.

References GiNaC::are_ex_trivially_equal(), clearflag(), duplicate(), GiNaC::status_flags::dynallocated, GiNaC::status_flags::expanded, GiNaC::status_flags::hash_calculated, let_op(), n, nops(), op(), and setflag().

Referenced by derivative(), eval_integ(), evalf(), evalm(), expand(), and normal().

virtual void GiNaC::basic::accept ( GiNaC::visitor v) const [inline, virtual]

Definition at line 175 of file basic.h.

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

Check whether this is a polynomial in the given variables.

Reimplemented in GiNaC::numeric, GiNaC::symbol, GiNaC::power, GiNaC::constant, GiNaC::mul, and GiNaC::add.

Definition at line 320 of file basic.cpp.

References has(), and is_equal().

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

Return degree of highest power in object s.

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, GiNaC::numeric, GiNaC::ncmul, GiNaC::power, GiNaC::mul, GiNaC::add, GiNaC::pseries, and GiNaC::integral.

Definition at line 326 of file basic.cpp.

References is_equal().

Referenced by collect().

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

Return degree of lowest power in object s.

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, GiNaC::numeric, GiNaC::ncmul, GiNaC::power, GiNaC::mul, GiNaC::add, GiNaC::pseries, and GiNaC::integral.

Definition at line 332 of file basic.cpp.

References is_equal().

Referenced by collect().

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

Return coefficient of degree n in object s.

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, GiNaC::numeric, GiNaC::ncmul, GiNaC::power, GiNaC::mul, GiNaC::add, and GiNaC::pseries.

Definition at line 338 of file basic.cpp.

References GiNaC::_ex0, GiNaC::_ex1, and is_equal().

Referenced by collect(), GiNaC::expairseq::read_archive(), series(), and GiNaC::sqrfree_parfrac().

ex GiNaC::basic::expand ( unsigned  options = 0) const [virtual]

Expand expression, i.e.

multiply it out and return the result as a new expression.

Reimplemented in GiNaC::function, GiNaC::structure< T, ComparisonPolicy >, GiNaC::indexed, GiNaC::expairseq, GiNaC::mul, GiNaC::power, GiNaC::add, GiNaC::ncmul, GiNaC::pseries, and GiNaC::integral.

Definition at line 808 of file basic.cpp.

References GiNaC::status_flags::expanded, map(), nops(), and setflag().

Referenced by collect(), GiNaC::expand(), GiNaC::matrix::fraction_free_elimination(), and GiNaC::matrix::pivot().

ex GiNaC::basic::collect ( const ex s,
bool  distributed = false 
) const [virtual]

Sort expanded expression in terms of powers of some object(s).

Parameters:
sobject(s) to sort in
distributedrecursive or distributed form (only used when s is a list)

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, and GiNaC::pseries.

Definition at line 349 of file basic.cpp.

References GiNaC::_ex0, GiNaC::_ex1, GiNaC::ex::begin(), GiNaC::container< C >::begin(), GiNaC::ex::coeff(), coeff(), GiNaC::ex::collect(), GiNaC::ex::degree(), degree(), GiNaC::status_flags::dynallocated, GiNaC::ex::end(), GiNaC::container< C >::end(), expand(), ldegree(), n, GiNaC::ex::nops(), GiNaC::ex::op(), GiNaC::pow(), and x.

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

Default implementation of ex::diff().

It maps the operation on the operands (or returns 0 when the object has no operands).

See also:
ex::diff

Reimplemented in GiNaC::function, GiNaC::structure< T, ComparisonPolicy >, GiNaC::indexed, GiNaC::numeric, GiNaC::power, GiNaC::ncmul, GiNaC::fderivative, GiNaC::mul, GiNaC::pseries, GiNaC::add, GiNaC::symbol, GiNaC::integral, GiNaC::constant, and GiNaC::idx.

Definition at line 716 of file basic.cpp.

References GiNaC::_ex0, map(), and nops().

Referenced by diff().

ex GiNaC::basic::series ( const relational r,
int  order,
unsigned  options = 0 
) const [virtual]
ex GiNaC::basic::normal ( exmap repl,
exmap rev_lookup,
int  level = 0 
) const [virtual]

Default implementation of ex::normal().

It normalizes the children and replaces the object with a temporary symbol.

See also:
ex::normal

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, GiNaC::numeric, GiNaC::power, GiNaC::mul, GiNaC::add, GiNaC::pseries, and GiNaC::symbol.

Definition at line 2056 of file normal.cpp.

References GiNaC::_ex1, GiNaC::status_flags::dynallocated, map(), GiNaC::max_recursion_level, nops(), and GiNaC::replace_with_symbol().

Referenced by GiNaC::matrix::determinant(), and GiNaC::matrix::solve().

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

Default implementation of ex::to_rational().

This replaces the object with a temporary symbol.

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, GiNaC::numeric, GiNaC::expairseq, GiNaC::power, and GiNaC::symbol.

Definition at line 2479 of file normal.cpp.

References GiNaC::replace_with_symbol().

ex GiNaC::basic::to_polynomial ( exmap repl) const [virtual]
numeric GiNaC::basic::integer_content ( ) const [virtual]

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, GiNaC::numeric, GiNaC::mul, and GiNaC::add.

Definition at line 312 of file normal.cpp.

References GiNaC::_num1_p.

ex GiNaC::basic::smod ( const numeric xi) const [virtual]

Apply symmetric modular homomorphism to an expanded multivariate polynomial.

This function is usually used internally by heur_gcd().

Parameters:
ximodulus
Returns:
mapped polynomial
See also:
heur_gcd

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, GiNaC::numeric, GiNaC::mul, and GiNaC::add.

Definition at line 1204 of file normal.cpp.

numeric GiNaC::basic::max_coefficient ( ) const [virtual]

Implementation ex::max_coefficient().

See also:
heur_gcd

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, GiNaC::numeric, GiNaC::mul, and GiNaC::add.

Definition at line 1156 of file normal.cpp.

References GiNaC::_num1_p.

exvector GiNaC::basic::get_free_indices ( ) const [virtual]

Return a vector containing the free indices of an expression.

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, GiNaC::indexed, GiNaC::mul, GiNaC::ncmul, GiNaC::add, and GiNaC::integral.

Definition at line 678 of file basic.cpp.

ex GiNaC::basic::add_indexed ( const ex self,
const ex other 
) const [virtual]

Add two indexed expressions.

They are guaranteed to be of class indexed (or a subclass) and their indices are compatible. This function is used internally by simplify_indexed().

Parameters:
selfFirst indexed expression; its base object is *this
otherSecond indexed expression
Returns:
sum of self and other
See also:
ex::simplify_indexed()

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, and GiNaC::matrix.

Definition at line 490 of file basic.cpp.

ex GiNaC::basic::scalar_mul_indexed ( const ex self,
const numeric other 
) const [virtual]

Multiply an indexed expression with a scalar.

This function is used internally by simplify_indexed().

Parameters:
selfIndexed expression; its base object is *this
otherNumeric value
Returns:
product of self and other
See also:
ex::simplify_indexed()

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, and GiNaC::matrix.

Definition at line 502 of file basic.cpp.

bool GiNaC::basic::contract_with ( exvector::iterator  self,
exvector::iterator  other,
exvector v 
) const [virtual]

Try to contract two indexed expressions that appear in the same product.

If a contraction exists, the function overwrites one or both of the expressions and returns true. Otherwise it returns false. It is guaranteed that both expressions are of class indexed (or a subclass) and that at least one dummy index has been found. This functions is used internally by simplify_indexed().

Parameters:
selfPointer to first indexed expression; its base object is *this
otherPointer to second indexed expression
vThe complete vector of factors
Returns:
true if the contraction was successful, false otherwise
See also:
ex::simplify_indexed()

Reimplemented in GiNaC::structure< T, ComparisonPolicy >, GiNaC::tensepsilon, GiNaC::spinmetric, GiNaC::su3d, GiNaC::diracgamma, GiNaC::matrix, GiNaC::su3f, GiNaC::cliffordunit, GiNaC::su3t, GiNaC::tensmetric, and GiNaC::tensdelta.

Definition at line 519 of file basic.cpp.

unsigned GiNaC::basic::return_type ( ) const [virtual]
return_type_t GiNaC::basic::return_type_tinfo ( ) const [virtual]
ex GiNaC::basic::conjugate ( ) const [virtual]
ex GiNaC::basic::real_part ( ) const [virtual]
ex GiNaC::basic::imag_part ( ) const [virtual]
int GiNaC::basic::compare_same_type ( const basic other) const [protected, virtual]

Returns order relation between two objects of same type.

This needs to be implemented by each class. It may never return anything else than 0, signalling equality, or +1 and -1 signalling inequality and determining the canonical ordering. (Perl hackers will wonder why C++ doesn't feature the spaceship operator <=> for denoting just this.)

Definition at line 731 of file basic.cpp.

References GiNaC::compare_pointers().

Referenced by compare(), GiNaC::symbol::derivative(), and is_equal_same_type().

bool GiNaC::basic::is_equal_same_type ( const basic other) const [protected, virtual]

Returns true if two objects of same type are equal.

Normally needs not be reimplemented as long as it wasn't overwritten by some parent class, since it just calls compare_same_type(). The reason why this function exists is that sometimes it is easier to determine equality than an order relation and then it can be overridden.

Reimplemented in GiNaC::function, GiNaC::container< C >, GiNaC::structure< T, ComparisonPolicy >, GiNaC::numeric, GiNaC::expairseq, GiNaC::fderivative, GiNaC::symbol, and GiNaC::constant.

Definition at line 741 of file basic.cpp.

References compare_same_type().

Referenced by is_equal(), and match().

unsigned GiNaC::basic::calchash ( ) const [protected, virtual]

Compute the hash value of an object and if it makes sense to store it in the objects status_flags, do so.

The method inherited from class basic computes a hash value based on the type and hash values of possible members. For this reason it is well suited for container classes but atomic classes should override this implementation because otherwise they would all end up with the same hashvalue.

Reimplemented in GiNaC::function, GiNaC::structure< T, ComparisonPolicy >, GiNaC::numeric, GiNaC::expairseq, GiNaC::symmetry, GiNaC::relational, GiNaC::symbol, GiNaC::constant, GiNaC::idx, and GiNaC::wildcard.

Definition at line 782 of file basic.cpp.

References GiNaC::status_flags::evaluated, flags, GiNaC::ex::gethash(), GiNaC::status_flags::hash_calculated, hashvalue, GiNaC::make_hash_seed(), nops(), op(), GiNaC::rotate_left(), and setflag().

Referenced by gethash().

template<class T >
void GiNaC::basic::print_dispatch ( const print_context c,
unsigned  level 
) const [inline]

Like print(), but dispatch to the specified class.

Can be used by implementations of print methods to dispatch to the method of the superclass.

See also:
basic::print

Definition at line 237 of file basic.h.

Referenced by print().

void GiNaC::basic::print_dispatch ( const registered_class_info ri,
const print_context c,
unsigned  level 
) const

Like print(), but dispatch to the specified class.

Can be used by implementations of print methods to dispatch to the method of the superclass.

See also:
basic::print

Definition at line 126 of file basic.cpp.

References c, GiNaC::class_info< OPT >::get_parent(), and GiNaC::class_info< OPT >::options.

void GiNaC::basic::archive ( archive_node n) const [virtual]

Save (serialize) the object into archive node.

Archive the object.

Losely speaking, this method turns an expression into a byte stream (which can be saved and restored later on, or sent via network, etc.)

Reimplemented in GiNaC::function, GiNaC::container< C >, GiNaC::spinidx, GiNaC::tensepsilon, GiNaC::indexed, GiNaC::varidx, GiNaC::matrix, GiNaC::numeric, GiNaC::minkmetric, GiNaC::expairseq, GiNaC::symmetry, GiNaC::power, GiNaC::fderivative, GiNaC::pseries, GiNaC::relational, GiNaC::symbol, GiNaC::integral, GiNaC::constant, GiNaC::idx, GiNaC::clifford, GiNaC::color, and GiNaC::wildcard.

Definition at line 100 of file basic.cpp.

References GiNaC::archive_node::add_string().

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

Load (deserialize) the object from an archive node.

Construct object from archive_node.

Note:
This method is essentially a constructor. However, constructors can't be virtual. So, if unarchiving routines are implemented as constructors one would need to define such a constructor in every class, even if all it does is simply calling constructor of a superclass.

Reimplemented in GiNaC::function, GiNaC::container< C >, GiNaC::spinidx, GiNaC::tensepsilon, GiNaC::indexed, GiNaC::matrix, GiNaC::varidx, GiNaC::numeric, GiNaC::minkmetric, GiNaC::expairseq, GiNaC::symmetry, GiNaC::power, GiNaC::fderivative, GiNaC::pseries, GiNaC::relational, GiNaC::symbol, GiNaC::integral, GiNaC::constant, GiNaC::idx, GiNaC::clifford, GiNaC::color, and GiNaC::wildcard.

Definition at line 96 of file basic.cpp.

ex GiNaC::basic::subs_one_level ( const exmap m,
unsigned  options 
) const

Helper function for subs().

Does not recurse into subexpressions.

Definition at line 594 of file basic.cpp.

References GiNaC::ex::find(), match(), GiNaC::subs_options::no_pattern, and GiNaC::ex::subs().

Referenced by GiNaC::symbol::subs(), GiNaC::relational::subs(), GiNaC::power::subs(), GiNaC::expairseq::subs(), GiNaC::numeric::subs(), and subs().

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

Default interface of nth derivative ex::diff(s, n).

It should be called instead of ::derivative(s) for first derivatives and for nth derivatives it just recurses down.

Parameters:
ssymbol to differentiate in
nthorder of differentiation
See also:
ex::diff

Definition at line 658 of file basic.cpp.

References derivative(), GiNaC::ex::diff(), GiNaC::status_flags::evaluated, ex, flags, and GiNaC::ex::is_zero().

Referenced by GiNaC::mul::derivative(), and GiNaC::function::derivative().

int GiNaC::basic::compare ( const basic other) const

Compare objects syntactically to establish canonical ordering.

All compare functions return: -1 for *this less than other, 0 equal, 1 greater.

Definition at line 828 of file basic.cpp.

References compare_same_type(), and gethash().

Referenced by GiNaC::pseries::coeff().

bool GiNaC::basic::is_equal ( const basic other) const

Test for syntactic equality.

This is only a quick test, meaning objects should be in the same domain. You might have to .expand(), .normal() objects first, depending on the domain of your computation, to get a more reliable answer.

See also:
is_equal_same_type

Definition at line 875 of file basic.cpp.

References gethash(), and is_equal_same_type().

Referenced by GiNaC::power::coeff(), GiNaC::ncmul::coeff(), coeff(), GiNaC::power::degree(), GiNaC::ncmul::degree(), degree(), is_polynomial(), GiNaC::power::ldegree(), GiNaC::ncmul::ldegree(), ldegree(), GiNaC::wildcard::match(), and match().

const basic & GiNaC::basic::hold ( ) const

Stop further evaluation.

See also:
basic::eval

Definition at line 899 of file basic.cpp.

References GiNaC::status_flags::evaluated, and setflag().

Referenced by GiNaC::abs_eval(), GiNaC::abs_evalf(), GiNaC::abs_power(), GiNaC::abs_real_part(), GiNaC::acos_conjugate(), GiNaC::acos_eval(), GiNaC::acos_evalf(), GiNaC::acosh_conjugate(), GiNaC::acosh_eval(), GiNaC::acosh_evalf(), GiNaC::asin_conjugate(), GiNaC::asin_eval(), GiNaC::asin_evalf(), GiNaC::asinh_conjugate(), GiNaC::asinh_eval(), GiNaC::asinh_evalf(), GiNaC::atan2_eval(), GiNaC::atan_conjugate(), GiNaC::atan_eval(), GiNaC::atan_evalf(), GiNaC::atanh_conjugate(), GiNaC::atanh_eval(), GiNaC::atanh_evalf(), GiNaC::binomial_conjugate(), GiNaC::binomial_eval(), GiNaC::binomial_evalf(), GiNaC::binomial_real_part(), GiNaC::binomial_sym(), GiNaC::cos_eval(), GiNaC::cos_evalf(), GiNaC::cosh_eval(), GiNaC::cosh_evalf(), GiNaC::csgn_power(), GiNaC::epsilon_tensor(), GiNaC::eta_imag_part(), GiNaC::integral::eval(), GiNaC::pseries::eval(), GiNaC::add::eval(), GiNaC::relational::eval(), GiNaC::power::eval(), GiNaC::fderivative::eval(), GiNaC::expairseq::eval(), GiNaC::numeric::eval(), GiNaC::structure< T, ComparisonPolicy >::eval(), eval(), GiNaC::function::eval(), GiNaC::tensmetric::eval_indexed(), GiNaC::matrix::eval_indexed(), GiNaC::structure< T, ComparisonPolicy >::eval_indexed(), GiNaC::spinmetric::eval_indexed(), GiNaC::tensepsilon::eval_indexed(), GiNaC::function::evalf(), GiNaC::exp_eval(), GiNaC::exp_evalf(), GiNaC::power::expand(), GiNaC::factorial_conjugate(), GiNaC::factorial_eval(), GiNaC::factorial_evalf(), GiNaC::factorial_real_part(), GiNaC::G2_eval(), GiNaC::G2_evalf(), GiNaC::G3_eval(), GiNaC::G3_evalf(), GiNaC::Li2_conjugate(), GiNaC::Li2_eval(), GiNaC::Li2_evalf(), GiNaC::Li_eval(), GiNaC::Li_evalf(), GiNaC::log_conjugate(), GiNaC::log_eval(), GiNaC::log_evalf(), GiNaC::log_real_part(), GiNaC::lorentz_eps(), GiNaC::psi1_eval(), GiNaC::psi1_evalf(), GiNaC::psi2_eval(), GiNaC::psi2_evalf(), GiNaC::sin_eval(), GiNaC::sin_evalf(), GiNaC::sinh_eval(), GiNaC::sinh_evalf(), GiNaC::step_conjugate(), GiNaC::step_eval(), GiNaC::step_evalf(), GiNaC::step_real_part(), GiNaC::tan_eval(), GiNaC::tan_evalf(), GiNaC::tanh_eval(), GiNaC::tanh_evalf(), GiNaC::zeta1_eval(), GiNaC::zeta1_evalf(), GiNaC::zeta2_eval(), GiNaC::zeta2_evalf(), and GiNaC::zetaderiv_eval().

unsigned GiNaC::basic::gethash ( ) const [inline]

Definition at line 267 of file basic.h.

References calchash(), flags, GiNaC::status_flags::hash_calculated, and hashvalue.

Referenced by compare(), and is_equal().

const basic& GiNaC::basic::setflag ( unsigned  f) const [inline]

Set some status_flags.

Definition at line 283 of file basic.h.

References flags.

Referenced by GiNaC::numeric::add_dyn(), GiNaC::wildcard::calchash(), GiNaC::constant::calchash(), GiNaC::idx::calchash(), GiNaC::symbol::calchash(), GiNaC::relational::calchash(), GiNaC::symmetry::calchash(), GiNaC::expairseq::calchash(), GiNaC::numeric::calchash(), calchash(), GiNaC::function::calchash(), GiNaC::ncmul::coeff(), GiNaC::add::combine_ex_with_coeff_to_pair(), GiNaC::integral::conjugate(), GiNaC::pseries::conjugate(), GiNaC::ncmul::conjugate(), GiNaC::constant::constant(), GiNaC::ex::construct_from_basic(), GiNaC::ex::construct_from_double(), GiNaC::ex::construct_from_int(), GiNaC::ex::construct_from_long(), GiNaC::ex::construct_from_uint(), GiNaC::ex::construct_from_ulong(), GiNaC::container< C >::container(), GiNaC::add::derivative(), GiNaC::ncmul::derivative(), GiNaC::diag_matrix(), GiNaC::numeric::div_dyn(), GiNaC::integral::eval(), GiNaC::add::eval(), GiNaC::power::eval(), GiNaC::ncmul::eval(), GiNaC::expairseq::eval(), GiNaC::mul::evalm(), GiNaC::ncmul::evalm(), GiNaC::integral::expand(), GiNaC::ncmul::expand(), GiNaC::add::expand(), GiNaC::power::expand(), GiNaC::expairseq::expand(), expand(), GiNaC::function::expand(), GiNaC::power::expand_add(), GiNaC::power::expand_add_2(), GiNaC::power::expand_mul(), hold(), GiNaC::pseries::imag_part(), GiNaC::add::imag_part(), GiNaC::power::info(), GiNaC::expairseq::info(), GiNaC::lst_to_matrix(), GiNaC::idx::map(), map(), GiNaC::matrix::matrix(), GiNaC::numeric::mul_dyn(), GiNaC::pseries::mul_series(), GiNaC::multiply_lcm(), GiNaC::mul::normal(), GiNaC::power::normal(), GiNaC::numeric::numeric(), GiNaC::numeric::power_dyn(), GiNaC::wildcard::read_archive(), GiNaC::symbol::read_archive(), GiNaC::numeric::read_archive(), GiNaC::container< C >::read_archive(), GiNaC::pseries::real_part(), GiNaC::add::real_part(), GiNaC::add::recombine_pair_to_ex(), GiNaC::reduced_matrix(), GiNaC::idx::replace_dim(), GiNaC::integral::series(), GiNaC::mul::smod(), GiNaC::add::split_ex_to_pair(), GiNaC::numeric::sub_dyn(), GiNaC::sub_matrix(), GiNaC::idx::subs(), GiNaC::pseries::subs(), subs(), GiNaC::symbol::symbol(), GiNaC::symbolic_matrix(), GiNaC::symmetry::symmetry(), GiNaC::spinidx::toggle_dot(), GiNaC::varidx::toggle_variance(), GiNaC::spinidx::toggle_variance_dot(), GiNaC::unit_matrix(), and GiNaC::wildcard::wildcard().

const basic& GiNaC::basic::clearflag ( unsigned  f) const [inline]
void GiNaC::basic::ensure_if_modifiable ( ) const [protected]
void GiNaC::basic::do_print ( const print_context c,
unsigned  level 
) const [protected]
void GiNaC::basic::do_print_tree ( const print_tree c,
unsigned  level 
) const [protected]
void GiNaC::basic::do_print_python_repr ( const print_python_repr c,
unsigned  level 
) const [protected]

Friends And Related Function Documentation

friend class ex [friend]

Member Data Documentation

unsigned GiNaC::basic::flags [mutable, protected]
unsigned GiNaC::basic::hashvalue [mutable, 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.