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
ex imag_part() const override
Definition: constant.cpp:180
void do_print(const print_context &c, unsigned level) const
Definition: constant.cpp:114
exset syms
Definition: factor.cpp:2434
evalffunctype ef
Definition: constant.h:74
bool is_equal_same_type(const basic &other) const override
Returns true if two objects of same type are equal.
Definition: constant.cpp:208
Definition: add.cpp:38
bool info(unsigned inf) const override
Information about the object.
Definition: constant.cpp:139
static unsigned next_serial
Definition: constant.h:77
Archiving of GiNaC expressions.
This class is the ABC (abstract base class) of GiNaC&#39;s class hierarchy.
Definition: basic.h:104
Context for python-parsable output.
Definition: print.h:138
This class holds constants, symbols with specific numerical value.
Definition: constant.h:40
ex conjugate() const override
Definition: constant.cpp:166
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
Domain of an object.
Definition: flags.h:66
This class is a wrapper around CLN-numbers within the GiNaC class hierarchy.
Definition: numeric.h:81
Context for latex-parsable output.
Definition: print.h:122
void archive(archive_node &n) const override
Save (serialize) the object into archive node.
Definition: constant.cpp:102
void do_print_python_repr(const print_python_repr &c, unsigned level) const
Definition: constant.cpp:131
const constant Euler("Euler", EulerEvalf, "\amma_E", domain::positive)
Euler&#39;s constant.
Definition: constant.h:84
void do_print_tree(const print_tree &c, unsigned level) const
Definition: constant.cpp:119
void read_archive(const archive_node &n, lst &syms) override
Load (deserialize) the object from an archive node.
Definition: constant.cpp:83
ex real_part() const override
Definition: constant.cpp:173
bool is_polynomial(const ex &var) const override
Check whether this is a polynomial in the given variables.
Definition: constant.cpp:161
size_t n
Definition: factor.cpp:1463
Interface to GiNaC&#39;s light-weight expression handles.
Base class for print_contexts.
Definition: print.h:102
ex(* evalffunctype)()
Definition: constant.h:34
Interface to GiNaC&#39;s ABC.
std::string TeX_name
LaTeX name.
Definition: constant.h:73
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
Definition: archive.h:48
Lightweight wrapper for GiNaC&#39;s symbolic objects.
Definition: ex.h:72
ex number
numerical value this constant evalf()s to
Definition: constant.h:75
const constant Pi("Pi", PiEvalf, "\i", domain::positive)
Pi.
Definition: constant.h:82
std::string name
printname of this constant
Definition: constant.h:72
unsigned serial
unique serial number for comparison
Definition: constant.h:76
Basic CAS symbol.
Definition: symbol.h:38
Wrapper template for making GiNaC classes out of STL containers.
Definition: container.h:73
#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the declaration of each registered class.
Definition: registrar.h:153
ex evalf() const override
Evaluate object numerically.
Definition: constant.cpp:151
ex derivative(const symbol &s) const override
Implementation of ex::diff() for a constant always returns 0.
Definition: constant.cpp:192
GINAC_DECLARE_UNARCHIVER(add)
constant(const std::string &initname, evalffunctype efun=nullptr, const std::string &texname=std::string(), unsigned domain=domain::complex)
Definition: constant.cpp:59
const constant Catalan("Catalan", CatalanEvalf, "G", domain::positive)
Catalan&#39;s constant.
Definition: constant.h:83
size_t c
Definition: factor.cpp:770
Context for tree-like output for debugging.
Definition: print.h:146
unsigned domain
numerical value this constant evalf()s to
Definition: constant.h:78
void do_print_latex(const print_latex &c, unsigned level) const
Definition: constant.cpp:126

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