GiNaC  1.8.0
constant.h
Go to the documentation of this file.
1 
5 /*
6  * GiNaC Copyright (C) 1999-2020 Johannes Gutenberg University Mainz, Germany
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef GINAC_CONSTANT_H
24 #define GINAC_CONSTANT_H
25 
26 #include "basic.h"
27 #include "ex.h"
28 #include "archive.h"
29 
30 #include <string>
31 
32 namespace GiNaC {
33 
34 typedef ex (*evalffunctype)();
35 
40 class constant : public basic
41 {
43  // other constructors
44 public:
45  constant(const std::string & initname, evalffunctype efun = nullptr, const std::string & texname = std::string(), unsigned domain = domain::complex);
46  constant(const std::string & initname, const numeric & initnumber, const std::string & texname = std::string(), unsigned domain = domain::complex);
47 
48  // functions overriding virtual functions from base classes
49 public:
50  bool info(unsigned inf) const override;
51  ex evalf() const override;
52  bool is_polynomial(const ex & var) const override;
53  ex conjugate() const override;
54  ex real_part() const override;
55  ex imag_part() const override;
56  void archive(archive_node& n) const override;
57  void read_archive(const archive_node& n, lst& syms) override;
58 protected:
59  ex derivative(const symbol & s) const override;
60  bool is_equal_same_type(const basic & other) const override;
61  unsigned calchash() const override;
62 
63  // non-virtual functions in this class
64 protected:
65  void do_print(const print_context & c, unsigned level) const;
66  void do_print_tree(const print_tree & c, unsigned level) const;
67  void do_print_latex(const print_latex & c, unsigned level) const;
68  void do_print_python_repr(const print_python_repr & c, unsigned level) const;
69 
70 // member variables
71 private:
72  std::string name;
73  std::string TeX_name;
76  unsigned serial;
77  static unsigned next_serial;
78  unsigned domain;
79 };
81 
82 extern const constant Pi;
83 extern const constant Catalan;
84 extern const constant Euler;
85 
86 } // namespace GiNaC
87 
88 #endif // ndef GINAC_CONSTANT_H
GiNaC::print_python_repr
Context for python-parsable output.
Definition: print.h:139
GiNaC::constant::derivative
ex derivative(const symbol &s) const override
Implementation of ex::diff() for a constant always returns 0.
Definition: constant.cpp:192
GiNaC::constant::do_print_latex
void do_print_latex(const print_latex &c, unsigned level) const
Definition: constant.cpp:126
GiNaC::constant::imag_part
ex imag_part() const override
Definition: constant.cpp:180
GiNaC::domain::complex
@ complex
Definition: flags.h:69
GiNaC::constant::conjugate
ex conjugate() const override
Definition: constant.cpp:166
GiNaC::print_context
Base class for print_contexts.
Definition: print.h:103
GiNaC::constant::do_print
void do_print(const print_context &c, unsigned level) const
Definition: constant.cpp:114
GiNaC::constant::info
bool info(unsigned inf) const override
Information about the object.
Definition: constant.cpp:139
GiNaC::constant::archive
void archive(archive_node &n) const override
Save (serialize) the object into archive node.
Definition: constant.cpp:102
GiNaC::archive_node
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
Definition: archive.h:49
GiNaC::GINAC_DECLARE_UNARCHIVER
GINAC_DECLARE_UNARCHIVER(add)
GiNaC::constant::is_equal_same_type
bool is_equal_same_type(const basic &other) const override
Returns true if two objects of same type are equal.
Definition: constant.cpp:208
GiNaC::constant::ef
evalffunctype ef
Definition: constant.h:74
GiNaC
Definition: add.cpp:38
syms
exset syms
Definition: factor.cpp:2434
GiNaC::domain
Domain of an object.
Definition: flags.h:66
GiNaC::constant::next_serial
static unsigned next_serial
Definition: constant.h:77
GINAC_DECLARE_REGISTERED_CLASS
#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the declaration of each registered class.
Definition: registrar.h:153
GiNaC::ex
Lightweight wrapper for GiNaC's symbolic objects.
Definition: ex.h:72
GiNaC::constant::is_polynomial
bool is_polynomial(const ex &var) const override
Check whether this is a polynomial in the given variables.
Definition: constant.cpp:161
GiNaC::constant::read_archive
void read_archive(const archive_node &n, lst &syms) override
Load (deserialize) the object from an archive node.
Definition: constant.cpp:83
GiNaC::evalffunctype
ex(* evalffunctype)()
Definition: constant.h:34
GiNaC::constant::real_part
ex real_part() const override
Definition: constant.cpp:173
ex.h
Interface to GiNaC's light-weight expression handles.
GiNaC::constant::calchash
unsigned calchash() const override
Compute the hash value of an object and if it makes sense to store it in the objects status_flags,...
Definition: constant.cpp:216
GiNaC::print_latex
Context for latex-parsable output.
Definition: print.h:123
GiNaC::constant::do_print_python_repr
void do_print_python_repr(const print_python_repr &c, unsigned level) const
Definition: constant.cpp:131
GiNaC::constant::number
ex number
numerical value this constant evalf()s to
Definition: constant.h:75
GiNaC::constant::do_print_tree
void do_print_tree(const print_tree &c, unsigned level) const
Definition: constant.cpp:119
GiNaC::print_tree
Context for tree-like output for debugging.
Definition: print.h:147
GiNaC::constant::name
std::string name
printname of this constant
Definition: constant.h:72
GiNaC::Pi
const constant Pi("Pi", PiEvalf, "\\pi", domain::positive)
Pi.
Definition: constant.h:82
GiNaC::container
Wrapper template for making GiNaC classes out of STL containers.
Definition: container.h:73
c
size_t c
Definition: factor.cpp:770
archive.h
Archiving of GiNaC expressions.
basic.h
Interface to GiNaC's ABC.
GiNaC::symbol
Basic CAS symbol.
Definition: symbol.h:39
n
size_t n
Definition: factor.cpp:1463
GiNaC::Euler
const constant Euler("Euler", EulerEvalf, "\\gamma_E", domain::positive)
Euler's constant.
Definition: constant.h:84
GiNaC::constant::domain
unsigned domain
numerical value this constant evalf()s to
Definition: constant.h:78
GiNaC::basic
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
Definition: basic.h:105
GiNaC::constant::TeX_name
std::string TeX_name
LaTeX name.
Definition: constant.h:73
GiNaC::constant::evalf
ex evalf() const override
Evaluate object numerically.
Definition: constant.cpp:151
GiNaC::constant::constant
constant(const std::string &initname, evalffunctype efun=nullptr, const std::string &texname=std::string(), unsigned domain=domain::complex)
Definition: constant.cpp:59
GiNaC::constant::serial
unsigned serial
unique serial number for comparison
Definition: constant.h:76
GiNaC::numeric
This class is a wrapper around CLN-numbers within the GiNaC class hierarchy.
Definition: numeric.h:82
GiNaC::constant
This class holds constants, symbols with specific numerical value.
Definition: constant.h:41
GiNaC::Catalan
const constant Catalan("Catalan", CatalanEvalf, "G", domain::positive)
Catalan's constant.
Definition: constant.h:83

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.