GiNaC  1.8.0
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
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::integration_kernel GiNaC::matrix GiNaC::numeric GiNaC::power GiNaC::pseries GiNaC::relational GiNaC::symbol GiNaC::symmetry GiNaC::tensor GiNaC::wildcard

Public Member Functions

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

 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...
 

Protected Attributes

unsigned flags
 of type status_flags More...
 
unsigned hashvalue
 hash value More...
 

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

◆ basic() [1/2]

GiNaC::basic::basic ( )
inlineprotected

Definition at line 112 of file basic.h.

Referenced by duplicate().

◆ ~basic()

virtual GiNaC::basic::~basic ( )
inlinevirtual

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.

◆ basic() [2/2]

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

Member Function Documentation

◆ operator=()

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 flags, and hashvalue.

◆ duplicate()

virtual basic* GiNaC::basic::duplicate ( ) const
inlinevirtual

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(), GiNaC::status_flags::dynallocated, and setflag().

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

◆ eval()

ex GiNaC::basic::eval ( ) const
virtual

Perform automatic non-interruptive term rewriting rules.

Reimplemented in GiNaC::symbol, GiNaC::pseries, GiNaC::power, GiNaC::numeric, GiNaC::ncmul, GiNaC::mul, GiNaC::integral, GiNaC::indexed, GiNaC::function, GiNaC::fderivative, GiNaC::expairseq, and GiNaC::add.

Definition at line 413 of file basic.cpp.

Referenced by GiNaC::ex::construct_from_basic().

◆ evalf()

ex GiNaC::basic::evalf ( ) const
virtual

◆ evalm()

ex GiNaC::basic::evalm ( ) const
virtual

Evaluate sums, products and integer powers of matrices.

Reimplemented in GiNaC::pseries, GiNaC::power, GiNaC::ncmul, GiNaC::mul, GiNaC::matrix, and GiNaC::add.

Definition at line 441 of file basic.cpp.

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

◆ eval_integ()

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

Evaluate integrals, if result is known.

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

Definition at line 455 of file basic.cpp.

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

◆ eval_ncmul()

ex GiNaC::basic::eval_ncmul ( const exvector v) const
protectedvirtual

◆ eval_indexed()

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::minkmetric, GiNaC::tensmetric, GiNaC::tensdelta, GiNaC::matrix, GiNaC::su3d, and GiNaC::su3f.

Definition at line 465 of file basic.cpp.

◆ print()

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, and GiNaC::fderivative.

Definition at line 116 of file basic.cpp.

References c.

Referenced by GiNaC::fderivative::print(), GiNaC::add::print_add(), GiNaC::mul::print_overall_coeff(), and GiNaC::pseries::print_series().

◆ dbgprint()

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.

◆ dbgprinttree()

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.

◆ precedence()

unsigned GiNaC::basic::precedence ( ) const
virtual

Return relative operator precedence (for parenthezing output).

Reimplemented in GiNaC::relational, GiNaC::pseries, GiNaC::power, GiNaC::numeric, GiNaC::ncmul, GiNaC::mul, GiNaC::integral, GiNaC::indexed, GiNaC::function, GiNaC::expairseq, GiNaC::container< C >, GiNaC::clifford, and GiNaC::add.

Definition at line 214 of file basic.cpp.

◆ info()

bool GiNaC::basic::info ( unsigned  inf) const
virtual

◆ nops()

size_t GiNaC::basic::nops ( ) const
virtual

◆ op()

ex GiNaC::basic::op ( size_t  i) const
virtual

◆ operator[]() [1/4]

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

Definition at line 250 of file basic.cpp.

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

◆ operator[]() [2/4]

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

Definition at line 258 of file basic.cpp.

References GiNaC::op().

◆ let_op()

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

◆ operator[]() [3/4]

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

Definition at line 263 of file basic.cpp.

References GiNaC::to_int().

◆ operator[]() [4/4]

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

Definition at line 271 of file basic.cpp.

◆ has()

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::power, GiNaC::numeric, and GiNaC::mul.

Definition at line 280 of file basic.cpp.

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

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

◆ match()

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::wildcard, and GiNaC::expairseq.

Definition at line 519 of file basic.cpp.

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

◆ match_same_type()

bool GiNaC::basic::match_same_type ( const basic other) const
protectedvirtual

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::relational, GiNaC::matrix, GiNaC::spinidx, GiNaC::varidx, GiNaC::idx, GiNaC::function, GiNaC::fderivative, GiNaC::color, and GiNaC::clifford.

Definition at line 744 of file basic.cpp.

◆ subs()

ex GiNaC::basic::subs ( const exmap m,
unsigned  options = 0 
) const
virtual

Substitute a set of objects by arbitrary expressions.

The ex returned will already be evaluated.

Reimplemented in GiNaC::symbol, GiNaC::relational, GiNaC::pseries, GiNaC::power, GiNaC::numeric, GiNaC::matrix, GiNaC::idx, GiNaC::expairseq, GiNaC::container< C >, and GiNaC::clifford.

Definition at line 607 of file basic.cpp.

References GiNaC::are_ex_trivially_equal(), clearflag(), let_op(), m, GiNaC::nops(), GiNaC::op(), options, GiNaC::ex::subs(), and subs_one_level().

Referenced by GiNaC::tensmetric::eval_indexed().

◆ map()

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::relational, GiNaC::power, GiNaC::idx, and GiNaC::expairseq.

Definition at line 294 of file basic.cpp.

References GiNaC::are_ex_trivially_equal(), clearflag(), let_op(), n, GiNaC::nops(), and GiNaC::op().

Referenced by normal().

◆ accept()

virtual void GiNaC::basic::accept ( GiNaC::visitor v) const
inlinevirtual

Definition at line 180 of file basic.h.

◆ is_polynomial()

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

Check whether this is a polynomial in the given variables.

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

Definition at line 319 of file basic.cpp.

References GiNaC::has().

◆ degree()

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

Return degree of highest power in object s.

Reimplemented in GiNaC::pseries, GiNaC::power, GiNaC::numeric, GiNaC::ncmul, GiNaC::mul, GiNaC::integral, and GiNaC::add.

Definition at line 325 of file basic.cpp.

◆ ldegree()

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

Return degree of lowest power in object s.

Reimplemented in GiNaC::pseries, GiNaC::power, GiNaC::numeric, GiNaC::ncmul, GiNaC::mul, GiNaC::integral, and GiNaC::add.

Definition at line 331 of file basic.cpp.

◆ coeff()

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

Return coefficient of degree n in object s.

Reimplemented in GiNaC::pseries, GiNaC::power, GiNaC::numeric, GiNaC::ncmul, GiNaC::mul, and GiNaC::add.

Definition at line 337 of file basic.cpp.

References GiNaC::_ex0, GiNaC::_ex1, and n.

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

◆ expand()

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::pseries, GiNaC::power, GiNaC::ncmul, GiNaC::mul, GiNaC::integral, GiNaC::indexed, GiNaC::function, GiNaC::expairseq, and GiNaC::add.

Definition at line 796 of file basic.cpp.

References GiNaC::nops(), and options.

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

◆ collect()

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::pseries.

Definition at line 348 of file basic.cpp.

References GiNaC::_ex0, GiNaC::_ex1, GiNaC::ex::coeff(), GiNaC::coeff(), GiNaC::collect(), GiNaC::ex::degree(), GiNaC::degree(), GiNaC::expand(), GiNaC::ldegree(), n, GiNaC::ex::nops(), GiNaC::ex::op(), GiNaC::pow(), and x.

◆ derivative()

ex GiNaC::basic::derivative ( const symbol s) const
protectedvirtual

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::symbol, GiNaC::pseries, GiNaC::power, GiNaC::numeric, GiNaC::ncmul, GiNaC::mul, GiNaC::integral, GiNaC::indexed, GiNaC::idx, GiNaC::function, GiNaC::fderivative, GiNaC::constant, and GiNaC::add.

Definition at line 704 of file basic.cpp.

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

◆ series()

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

◆ normal()

ex GiNaC::basic::normal ( exmap repl,
exmap rev_lookup,
lst modifier 
) const
virtual

◆ to_rational()

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::symbol, GiNaC::power, GiNaC::numeric, and GiNaC::expairseq.

Definition at line 2609 of file normal.cpp.

References GiNaC::replace_with_symbol().

◆ to_polynomial()

ex GiNaC::basic::to_polynomial ( exmap repl) const
virtual

Reimplemented in GiNaC::symbol, GiNaC::power, GiNaC::numeric, and GiNaC::expairseq.

Definition at line 2614 of file normal.cpp.

References GiNaC::replace_with_symbol().

◆ integer_content()

numeric GiNaC::basic::integer_content ( ) const
virtual

Reimplemented in GiNaC::numeric, GiNaC::mul, and GiNaC::add.

Definition at line 323 of file normal.cpp.

References GiNaC::_num1_p.

◆ smod()

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::numeric, GiNaC::mul, and GiNaC::add.

Definition at line 1203 of file normal.cpp.

◆ max_coefficient()

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

Implementation ex::max_coefficient().

See also
heur_gcd

Reimplemented in GiNaC::numeric, GiNaC::mul, and GiNaC::add.

Definition at line 1161 of file normal.cpp.

References GiNaC::_num1_p.

◆ get_free_indices()

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

Return a vector containing the free indices of an expression.

Reimplemented in GiNaC::ncmul, GiNaC::mul, GiNaC::integral, GiNaC::indexed, and GiNaC::add.

Definition at line 666 of file basic.cpp.

◆ add_indexed()

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::matrix.

Definition at line 481 of file basic.cpp.

◆ scalar_mul_indexed()

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::matrix.

Definition at line 493 of file basic.cpp.

◆ contract_with()

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::tensepsilon, GiNaC::spinmetric, GiNaC::tensmetric, GiNaC::tensdelta, GiNaC::matrix, GiNaC::su3d, GiNaC::su3f, GiNaC::su3t, GiNaC::diracgamma, and GiNaC::cliffordunit.

Definition at line 510 of file basic.cpp.

◆ return_type()

unsigned GiNaC::basic::return_type ( ) const
virtual

◆ return_type_tinfo()

return_type_t GiNaC::basic::return_type_tinfo ( ) const
virtual

◆ conjugate()

ex GiNaC::basic::conjugate ( ) const
virtual

◆ real_part()

ex GiNaC::basic::real_part ( ) const
virtual

◆ imag_part()

ex GiNaC::basic::imag_part ( ) const
virtual

◆ compare_same_type()

int GiNaC::basic::compare_same_type ( const basic other) const
protectedvirtual

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 719 of file basic.cpp.

References GiNaC::compare_pointers().

Referenced by GiNaC::symbol::derivative().

◆ is_equal_same_type()

bool GiNaC::basic::is_equal_same_type ( const basic other) const
protectedvirtual

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::symbol, GiNaC::numeric, GiNaC::function, GiNaC::fderivative, GiNaC::expairseq, GiNaC::container< C >, and GiNaC::constant.

Definition at line 729 of file basic.cpp.

◆ calchash()

unsigned GiNaC::basic::calchash ( ) const
protectedvirtual

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::wildcard, GiNaC::symmetry, GiNaC::symbol, GiNaC::relational, GiNaC::numeric, GiNaC::idx, GiNaC::function, GiNaC::expairseq, and GiNaC::constant.

Definition at line 770 of file basic.cpp.

References GiNaC::ex::gethash(), GiNaC::make_hash_seed(), GiNaC::nops(), GiNaC::op(), and GiNaC::rotate_left().

Referenced by gethash().

◆ print_dispatch() [1/2]

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 242 of file basic.h.

References c.

◆ print_dispatch() [2/2]

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.

◆ archive()

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::wildcard, GiNaC::tensepsilon, GiNaC::minkmetric, GiNaC::symmetry, GiNaC::symbol, GiNaC::relational, GiNaC::pseries, GiNaC::power, GiNaC::numeric, GiNaC::matrix, GiNaC::integral, GiNaC::indexed, GiNaC::spinidx, GiNaC::varidx, GiNaC::idx, GiNaC::function, GiNaC::fderivative, GiNaC::expairseq, GiNaC::container< C >, GiNaC::constant, GiNaC::color, and GiNaC::clifford.

Definition at line 100 of file basic.cpp.

References n.

◆ read_archive()

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::wildcard, GiNaC::tensepsilon, GiNaC::minkmetric, GiNaC::symmetry, GiNaC::symbol, GiNaC::relational, GiNaC::pseries, GiNaC::power, GiNaC::numeric, GiNaC::matrix, GiNaC::integral, GiNaC::indexed, GiNaC::spinidx, GiNaC::varidx, GiNaC::idx, GiNaC::function, GiNaC::fderivative, GiNaC::expairseq, GiNaC::constant, GiNaC::container< C >, GiNaC::color, and GiNaC::clifford.

Definition at line 96 of file basic.cpp.

◆ subs_one_level()

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

Helper function for subs().

Does not recurse into subexpressions.

Definition at line 585 of file basic.cpp.

References m, GiNaC::match(), options, and GiNaC::ex::subs().

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

◆ diff()

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 646 of file basic.cpp.

References GiNaC::ex::diff(), and GiNaC::ex::is_zero().

Referenced by GiNaC::mul::derivative().

◆ compare()

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 816 of file basic.cpp.

References gethash().

◆ is_equal()

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 863 of file basic.cpp.

References gethash().

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

◆ hold()

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

Stop further evaluation.

See also
basic::eval

Definition at line 887 of file basic.cpp.

Referenced by GiNaC::abs_conjugate(), GiNaC::abs_eval(), GiNaC::abs_evalf(), GiNaC::abs_expand(), GiNaC::abs_power(), GiNaC::abs_real_part(), GiNaC::acos_eval(), GiNaC::acos_evalf(), GiNaC::acosh_eval(), GiNaC::acosh_evalf(), GiNaC::asin_eval(), GiNaC::asin_evalf(), GiNaC::asinh_eval(), GiNaC::asinh_evalf(), GiNaC::atan2_eval(), GiNaC::atan_eval(), GiNaC::atan_evalf(), GiNaC::atanh_eval(), GiNaC::atanh_evalf(), GiNaC::binomial_conjugate(), GiNaC::binomial_eval(), GiNaC::binomial_evalf(), GiNaC::binomial_real_part(), GiNaC::binomial_sym(), GiNaC::conjugate_expl_derivative(), GiNaC::cos_eval(), GiNaC::cos_evalf(), GiNaC::cosh_eval(), GiNaC::cosh_evalf(), GiNaC::csgn_power(), GiNaC::epsilon_tensor(), GiNaC::eta_imag_part(), GiNaC::add::eval(), GiNaC::fderivative::eval(), GiNaC::function::eval(), GiNaC::integral::eval(), GiNaC::mul::eval(), GiNaC::numeric::eval(), GiNaC::power::eval(), GiNaC::pseries::eval(), GiNaC::su3f::eval_indexed(), GiNaC::su3d::eval_indexed(), GiNaC::matrix::eval_indexed(), GiNaC::structure< T, ComparisonPolicy >::eval_indexed(), GiNaC::tensmetric::eval_indexed(), GiNaC::spinmetric::eval_indexed(), GiNaC::tensepsilon::eval_indexed(), GiNaC::function::evalf(), GiNaC::exp_eval(), GiNaC::exp_evalf(), GiNaC::exp_expand(), GiNaC::exp_power(), 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::imag_part_expl_derivative(), GiNaC::iterated_integral2_eval(), GiNaC::iterated_integral3_eval(), GiNaC::iterated_integral_evalf_impl(), GiNaC::Li2_conjugate(), GiNaC::Li2_eval(), GiNaC::Li2_evalf(), GiNaC::log_eval(), GiNaC::log_evalf(), GiNaC::log_expand(), GiNaC::log_real_part(), GiNaC::lorentz_eps(), GiNaC::psi1_eval(), GiNaC::psi1_evalf(), GiNaC::psi2_eval(), GiNaC::psi2_evalf(), GiNaC::real_part_expl_derivative(), 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().

◆ gethash()

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

Definition at line 272 of file basic.h.

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

Referenced by compare(), and is_equal().

◆ setflag()

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

◆ clearflag()

const basic& GiNaC::basic::clearflag ( unsigned  f) const
inline

◆ ensure_if_modifiable()

void GiNaC::basic::ensure_if_modifiable ( ) const
protected

◆ do_print()

void GiNaC::basic::do_print ( const print_context c,
unsigned  level 
) const
protected

Default output to stream.

Definition at line 169 of file basic.cpp.

References c.

◆ do_print_tree()

void GiNaC::basic::do_print_tree ( const print_tree c,
unsigned  level 
) const
protected

Tree output to stream.

Definition at line 175 of file basic.cpp.

References c, GiNaC::nops(), GiNaC::op(), and GiNaC::ex::print().

◆ do_print_python_repr()

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

Python parsable output to stream.

Definition at line 187 of file basic.cpp.

References c.

Friends And Related Function Documentation

◆ ex

friend class ex
friend

Member Data Documentation

◆ flags

unsigned GiNaC::basic::flags
mutableprotected

◆ hashvalue

unsigned GiNaC::basic::hashvalue
mutableprotected

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.