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

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