|
GiNaC
1.6.2
|
This class holds constants, symbols with specific numerical value. More...
#include <constant.h>
Public Member Functions | |
| constant (const std::string &initname, evalffunctype efun=0, const std::string &texname=std::string(), unsigned domain=domain::complex) | |
| constant (const std::string &initname, const numeric &initnumber, const std::string &texname=std::string(), unsigned domain=domain::complex) | |
| bool | info (unsigned inf) const |
| Information about the object. | |
| ex | evalf (int level=0) const |
| Evaluate object numerically. | |
| bool | is_polynomial (const ex &var) const |
| Check whether this is a polynomial in the given variables. | |
| ex | conjugate () const |
| ex | real_part () const |
| ex | imag_part () const |
| void | archive (archive_node &n) const |
| Save (serialize) the object into archive node. | |
| void | read_archive (const archive_node &n, lst &syms) |
| Load (deserialize) the object from an archive node. | |
Protected Member Functions | |
| ex | derivative (const symbol &s) const |
| Implementation of ex::diff() for a constant always returns 0. | |
| bool | is_equal_same_type (const basic &other) const |
| Returns true if two objects of same type are equal. | |
| 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 | 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_latex (const print_latex &c, unsigned level) const |
| void | do_print_python_repr (const print_python_repr &c, unsigned level) const |
| Python parsable output to stream. | |
Private Attributes | |
| std::string | name |
| printname of this constant | |
| std::string | TeX_name |
| LaTeX name. | |
| evalffunctype | ef |
| ex | number |
| numerical value this constant evalf()s to | |
| unsigned | serial |
| unique serial number for comparison | |
| unsigned | domain |
| numerical value this constant evalf()s to | |
Static Private Attributes | |
| static unsigned | next_serial = 0 |
This class holds constants, symbols with specific numerical value.
Each object of this class must either provide their own function to evaluate it to class numeric or provide the constant as a numeric (if it's an exact number).
Definition at line 40 of file constant.h.
| GiNaC::constant::constant | ( | const std::string & | initname, |
| evalffunctype | efun = 0, |
||
| const std::string & | texname = std::string(), |
||
| unsigned | domain = domain::complex |
||
| ) |
Definition at line 59 of file constant.cpp.
References GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, name, GiNaC::basic::setflag(), and TeX_name.
| GiNaC::constant::constant | ( | const std::string & | initname, |
| const numeric & | initnumber, | ||
| const std::string & | texname = std::string(), |
||
| unsigned | domain = domain::complex |
||
| ) |
Definition at line 69 of file constant.cpp.
References GiNaC::status_flags::evaluated, GiNaC::status_flags::expanded, name, GiNaC::basic::setflag(), and TeX_name.
| bool GiNaC::constant::info | ( | unsigned | inf | ) | const [virtual] |
Information about the object.
Reimplemented from GiNaC::basic.
Definition at line 139 of file constant.cpp.
References GiNaC::info_flags::nonnegative, GiNaC::info_flags::polynomial, GiNaC::domain::positive, GiNaC::info_flags::positive, GiNaC::domain::real, and GiNaC::info_flags::real.
| ex GiNaC::constant::evalf | ( | int | level = 0 | ) | const [virtual] |
Evaluate object numerically.
Reimplemented from GiNaC::basic.
Definition at line 151 of file constant.cpp.
References ef, GiNaC::ex::evalf(), and number.
| bool GiNaC::constant::is_polynomial | ( | const ex & | var | ) | const [virtual] |
Check whether this is a polynomial in the given variables.
Reimplemented from GiNaC::basic.
Definition at line 161 of file constant.cpp.
| ex GiNaC::constant::conjugate | ( | ) | const [virtual] |
Reimplemented from GiNaC::basic.
Definition at line 166 of file constant.cpp.
References GiNaC::domain::positive, and GiNaC::domain::real.
| ex GiNaC::constant::real_part | ( | ) | const [virtual] |
Reimplemented from GiNaC::basic.
Definition at line 173 of file constant.cpp.
References GiNaC::domain::positive, and GiNaC::domain::real.
| ex GiNaC::constant::imag_part | ( | ) | const [virtual] |
Reimplemented from GiNaC::basic.
Definition at line 180 of file constant.cpp.
References GiNaC::domain::positive, and GiNaC::domain::real.
| void GiNaC::constant::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 from GiNaC::basic.
Definition at line 102 of file constant.cpp.
References GiNaC::archive_node::add_string(), and name.
| void GiNaC::constant::read_archive | ( | const archive_node & | n, |
| lst & | syms | ||
| ) | [virtual] |
Load (deserialize) the object from an archive node.
Construct object from archive_node.
Reimplemented from GiNaC::basic.
Definition at line 83 of file constant.cpp.
References GiNaC::Catalan, GiNaC::Euler, GiNaC::archive_node::find_string(), name, and GiNaC::Pi.
Implementation of ex::diff() for a constant always returns 0.
Reimplemented from GiNaC::basic.
Definition at line 192 of file constant.cpp.
References GiNaC::_ex0.
| bool GiNaC::constant::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 from GiNaC::basic.
Definition at line 208 of file constant.cpp.
References GINAC_ASSERT, and serial.
| unsigned GiNaC::constant::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 from GiNaC::basic.
Definition at line 216 of file constant.cpp.
References GiNaC::golden_ratio_hash(), GiNaC::status_flags::hash_calculated, GiNaC::basic::hashvalue, serial, and GiNaC::basic::setflag().
| void GiNaC::constant::do_print | ( | const print_context & | c, |
| unsigned | level | ||
| ) | const [protected] |
Default output to stream.
Reimplemented from GiNaC::basic.
Definition at line 114 of file constant.cpp.
References name, and GiNaC::print_context::s.
| void GiNaC::constant::do_print_tree | ( | const print_tree & | c, |
| unsigned | level | ||
| ) | const [protected] |
Tree output to stream.
Reimplemented from GiNaC::basic.
Definition at line 119 of file constant.cpp.
References GiNaC::basic::flags, GiNaC::basic::hashvalue, name, and GiNaC::print_context::s.
| void GiNaC::constant::do_print_latex | ( | const print_latex & | c, |
| unsigned | level | ||
| ) | const [protected] |
Definition at line 126 of file constant.cpp.
References GiNaC::print_context::s, and TeX_name.
| void GiNaC::constant::do_print_python_repr | ( | const print_python_repr & | c, |
| unsigned | level | ||
| ) | const [protected] |
Python parsable output to stream.
Reimplemented from GiNaC::basic.
Definition at line 131 of file constant.cpp.
References name, GiNaC::print_context::s, and TeX_name.
std::string GiNaC::constant::name [private] |
printname of this constant
Definition at line 72 of file constant.h.
Referenced by archive(), constant(), do_print(), do_print_python_repr(), do_print_tree(), and read_archive().
std::string GiNaC::constant::TeX_name [private] |
LaTeX name.
Definition at line 73 of file constant.h.
Referenced by constant(), do_print_latex(), and do_print_python_repr().
evalffunctype GiNaC::constant::ef [private] |
Definition at line 74 of file constant.h.
Referenced by evalf().
ex GiNaC::constant::number [private] |
numerical value this constant evalf()s to
Definition at line 75 of file constant.h.
Referenced by evalf().
unsigned GiNaC::constant::serial [private] |
unique serial number for comparison
Definition at line 76 of file constant.h.
Referenced by calchash(), and is_equal_same_type().
unsigned GiNaC::constant::next_serial = 0 [static, private] |
Definition at line 77 of file constant.h.
unsigned GiNaC::constant::domain [private] |
numerical value this constant evalf()s to
Definition at line 78 of file constant.h.