GiNaC 1.8.7
wildcard.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_WILDCARD_H
24#define GINAC_WILDCARD_H
25
26#include "ex.h"
27#include "archive.h"
28
29namespace GiNaC {
30
33class wildcard : public basic
34{
36
37 // other constructors
38public:
40 wildcard(unsigned label);
41
42 // functions overriding virtual functions from base classes
43public:
44 bool match(const ex & pattern, exmap& repl_lst) const override;
45
47 void archive(archive_node& n) const override;
49 void read_archive(const archive_node& n, lst& syms) override;
50protected:
51 unsigned calchash() const override;
52
53 // non-virtual functions in this class
54public:
55 unsigned get_label() const {return label;}
56
57protected:
58 void do_print(const print_context & c, unsigned level) const;
59 void do_print_tree(const print_tree & c, unsigned level) const;
60 void do_print_python_repr(const print_python_repr & c, unsigned level) const;
61
62 // member variables
63private:
64 unsigned label;
65};
67
68
69// utility functions
70
72inline ex wild(unsigned label = 0)
73{
74 return wildcard(label);
75}
76
78bool haswild(const ex & x);
79
80} // namespace GiNaC
81
82#endif // ndef GINAC_WILDCARD_H
Archiving of GiNaC expressions.
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
Wrapper template for making GiNaC classes out of STL containers.
Definition: container.h:73
Lightweight wrapper for GiNaC's symbolic objects.
Definition: ex.h:72
Base class for print_contexts.
Definition: print.h:103
Context for python-parsable output.
Definition: print.h:139
Context for tree-like output for debugging.
Definition: print.h:147
This class acts as a wildcard for subs(), match(), has() and find().
Definition: wildcard.h:34
bool match(const ex &pattern, exmap &repl_lst) const override
Check whether the expression matches a given pattern.
Definition: wildcard.cpp:116
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
Definition: wildcard.cpp:59
wildcard(unsigned label)
Construct wildcard with specified label.
Definition: wildcard.cpp:50
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: wildcard.cpp:105
void archive(archive_node &n) const override
Save (a.k.a.
Definition: wildcard.cpp:67
void do_print(const print_context &c, unsigned level) const
Definition: wildcard.cpp:88
unsigned label
Label used to distinguish different wildcards.
Definition: wildcard.h:64
void do_print_python_repr(const print_python_repr &c, unsigned level) const
Definition: wildcard.cpp:100
unsigned get_label() const
Definition: wildcard.h:55
void do_print_tree(const print_tree &c, unsigned level) const
Definition: wildcard.cpp:93
Interface to GiNaC's light-weight expression handles.
size_t n
Definition: factor.cpp:1432
size_t c
Definition: factor.cpp:757
ex x
Definition: factor.cpp:1610
exset syms
Definition: factor.cpp:2429
Definition: add.cpp:38
bool haswild(const ex &x)
Check whether x has a wildcard anywhere as a subexpression.
Definition: wildcard.cpp:124
std::map< ex, ex, ex_is_less > exmap
Definition: basic.h:50
GINAC_DECLARE_UNARCHIVER(add)
ex wild(unsigned label=0)
Create a wildcard object with the specified label.
Definition: wildcard.h:72
#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.