GiNaC 1.8.7
Public Member Functions | Protected Member Functions | Protected Attributes | Static Private Attributes | List of all members
GiNaC::symbol Class Reference

Basic CAS symbol. More...

#include <symbol.h>

Inheritance diagram for GiNaC::symbol:
GiNaC::basic GiNaC::refcounted GiNaC::realsymbol GiNaC::possymbol

Public Member Functions

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

Protected Member Functions

ex derivative (const symbol &s) const override
 Implementation of ex::diff() for single differentiation of a symbol. More...
 
bool is_equal_same_type (const basic &other) const override
 Returns true if two objects of same type are equal. More...
 
unsigned calchash () const override
 Compute the hash value of an object and if it makes sense to store it in the objects status_flags, do so. More...
 
void do_print (const print_context &c, unsigned level) const
 
void do_print_latex (const print_latex &c, unsigned level) const
 
void do_print_tree (const print_tree &c, unsigned level) const
 
void do_print_python_repr (const print_python_repr &c, unsigned level) const
 
- Protected Member Functions inherited from GiNaC::basic
 basic ()
 
virtual ex eval_ncmul (const exvector &v) const
 
virtual bool match_same_type (const basic &other) const
 Returns true if the attributes of two objects are similar enough for a match. More...
 
virtual ex derivative (const symbol &s) const
 Default implementation of ex::diff(). More...
 
virtual int compare_same_type (const basic &other) const
 Returns order relation between two objects of same type. More...
 
virtual bool is_equal_same_type (const basic &other) const
 Returns true if two objects of same type are equal. More...
 
virtual unsigned calchash () const
 Compute the hash value of an object and if it makes sense to store it in the objects status_flags, do so. More...
 
void ensure_if_modifiable () const
 Ensure the object may be modified without hurting others, throws if this is not the case. More...
 
void do_print (const print_context &c, unsigned level) const
 Default output to stream. More...
 
void do_print_tree (const print_tree &c, unsigned level) const
 Tree output to stream. More...
 
void do_print_python_repr (const print_python_repr &c, unsigned level) const
 Python parsable output to stream. More...
 

Protected Attributes

unsigned serial
 unique serial number for comparison More...
 
std::string name
 printname of this symbol More...
 
std::string TeX_name
 LaTeX name of this symbol. More...
 
- Protected Attributes inherited from GiNaC::basic
unsigned flags
 of type status_flags More...
 
unsigned hashvalue
 hash value More...
 

Static Private Attributes

static unsigned next_serial = 0
 

Detailed Description

Basic CAS symbol.

It has a name because it must know how to output itself.

Definition at line 38 of file symbol.h.

Constructor & Destructor Documentation

◆ symbol() [1/2]

GiNaC::symbol::symbol ( const std::string &  initname)
explicit

◆ symbol() [2/2]

GiNaC::symbol::symbol ( const std::string &  initname,
const std::string &  texname 
)

Member Function Documentation

◆ info()

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

◆ eval()

ex GiNaC::symbol::eval ( ) const
inlineoverridevirtual

Perform automatic non-interruptive term rewriting rules.

Reimplemented from GiNaC::basic.

Definition at line 49 of file symbol.h.

◆ evalf()

ex GiNaC::symbol::evalf ( ) const
inlineoverridevirtual

Evaluate object numerically.

Reimplemented from GiNaC::basic.

Definition at line 50 of file symbol.h.

◆ series()

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

Implementation of ex::series() for symbols.

See also
ex::series

Reimplemented from GiNaC::basic.

Definition at line 656 of file pseries.cpp.

References GiNaC::_ex0, GiNaC::_ex1, GINAC_ASSERT, is_equal_same_type(), GiNaC::ex::is_zero(), order, and r.

◆ subs()

ex GiNaC::symbol::subs ( const exmap m,
unsigned  options = 0 
) const
inlineoverridevirtual

Substitute a set of objects by arbitrary expressions.

The ex returned will already be evaluated.

Reimplemented from GiNaC::basic.

Definition at line 52 of file symbol.h.

References m, options, and GiNaC::basic::subs_one_level().

◆ normal()

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

Implementation of ex::normal() for symbols.

This returns the unmodified symbol.

See also
ex::normal

Reimplemented from GiNaC::basic.

Definition at line 2242 of file normal.cpp.

References GiNaC::_ex1.

◆ to_rational()

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

Implementation of ex::to_rational() for symbols.

This returns the unmodified symbol.

Reimplemented from GiNaC::basic.

Definition at line 2652 of file normal.cpp.

◆ to_polynomial()

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

Implementation of ex::to_polynomial() for symbols.

This returns the unmodified symbol.

Reimplemented from GiNaC::basic.

Definition at line 2659 of file normal.cpp.

◆ conjugate()

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

Reimplemented from GiNaC::basic.

Reimplemented in GiNaC::realsymbol.

Definition at line 229 of file symbol.cpp.

◆ real_part()

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

Reimplemented from GiNaC::basic.

Reimplemented in GiNaC::realsymbol.

Definition at line 234 of file symbol.cpp.

◆ imag_part()

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

Reimplemented from GiNaC::basic.

Reimplemented in GiNaC::realsymbol.

Definition at line 239 of file symbol.cpp.

◆ is_polynomial()

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

Check whether this is a polynomial in the given variables.

Reimplemented from GiNaC::basic.

Definition at line 244 of file symbol.cpp.

◆ archive()

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

Save (a.k.a.

Archive the object.

serialize) object into archive.

Reimplemented from GiNaC::basic.

Definition at line 133 of file symbol.cpp.

References n, name, and TeX_name.

◆ read_archive()

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

Read (a.k.a.

Read object from archive_node.

deserialize) object from archive.

Reimplemented from GiNaC::basic.

Definition at line 100 of file symbol.cpp.

References GiNaC::container< C >::append(), GiNaC::status_flags::dynallocated, GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, n, name, next_serial, serial, GiNaC::basic::setflag(), and TeX_name.

◆ derivative()

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

Implementation of ex::diff() for single differentiation of a symbol.

It returns 1 or 0.

See also
ex::diff

Reimplemented from GiNaC::basic.

Definition at line 255 of file symbol.cpp.

References GiNaC::_ex0, GiNaC::_ex1, and GiNaC::basic::compare_same_type().

◆ is_equal_same_type()

bool GiNaC::symbol::is_equal_same_type ( const basic other) const
overrideprotectedvirtual

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 from GiNaC::basic.

Definition at line 271 of file symbol.cpp.

References GINAC_ASSERT, and serial.

Referenced by series().

◆ calchash()

unsigned GiNaC::symbol::calchash ( ) const
overrideprotectedvirtual

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 from GiNaC::basic.

Definition at line 278 of file symbol.cpp.

References GiNaC::golden_ratio_hash(), GiNaC::status_flags::hash_calculated, GiNaC::basic::hashvalue, GiNaC::make_hash_seed(), serial, and GiNaC::basic::setflag().

◆ get_domain()

virtual unsigned GiNaC::symbol::get_domain ( ) const
inlinevirtual

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

Definition at line 71 of file symbol.h.

References GiNaC::domain::complex.

Referenced by do_print_tree(), and info().

◆ set_name()

void GiNaC::symbol::set_name ( const std::string &  n)
inline

Definition at line 75 of file symbol.h.

References n, and name.

◆ set_TeX_name()

void GiNaC::symbol::set_TeX_name ( const std::string &  n)
inline

Definition at line 76 of file symbol.h.

References n, and TeX_name.

◆ get_name()

std::string GiNaC::symbol::get_name ( ) const

Definition at line 152 of file symbol.cpp.

References name, and serial.

Referenced by do_print(), and get_TeX_name().

◆ get_TeX_name()

std::string GiNaC::symbol::get_TeX_name ( ) const

Definition at line 160 of file symbol.cpp.

References GiNaC::get_default_TeX_name(), get_name(), and TeX_name.

◆ do_print()

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

Definition at line 170 of file symbol.cpp.

References c, and get_name().

◆ do_print_latex()

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

Definition at line 175 of file symbol.cpp.

References c, GiNaC::get_default_TeX_name(), name, serial, and TeX_name.

◆ do_print_tree()

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

Definition at line 185 of file symbol.cpp.

References c, GiNaC::basic::flags, get_domain(), GiNaC::basic::hashvalue, name, and serial.

◆ do_print_python_repr()

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

Definition at line 194 of file symbol.cpp.

References c, name, serial, and TeX_name.

Member Data Documentation

◆ serial

unsigned GiNaC::symbol::serial
protected

unique serial number for comparison

Definition at line 88 of file symbol.h.

Referenced by calchash(), do_print_latex(), do_print_python_repr(), do_print_tree(), get_name(), is_equal_same_type(), and read_archive().

◆ name

std::string GiNaC::symbol::name
mutableprotected

printname of this symbol

Definition at line 89 of file symbol.h.

Referenced by archive(), do_print_latex(), do_print_python_repr(), do_print_tree(), get_name(), read_archive(), and set_name().

◆ TeX_name

std::string GiNaC::symbol::TeX_name
protected

LaTeX name of this symbol.

Definition at line 90 of file symbol.h.

Referenced by archive(), do_print_latex(), do_print_python_repr(), get_TeX_name(), read_archive(), and set_TeX_name().

◆ next_serial

unsigned GiNaC::symbol::next_serial = 0
staticprivate

Definition at line 92 of file symbol.h.

Referenced by read_archive().


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.