GiNaC 1.8.10
remember.h
Go to the documentation of this file.
1
6/*
7 * GiNaC Copyright (C) 1999-2026 Johannes Gutenberg University Mainz, Germany
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
23#ifndef GINAC_REMEMBER_H
24#define GINAC_REMEMBER_H
25
26#include <iosfwd>
27#include <list>
28#include <vector>
29
30namespace GiNaC {
31
32class function;
33class ex;
34
40public:
41 remember_table_entry(function const & f, ex const & r);
42 bool is_equal(function const & f) const;
43 ex get_result() const { return result; }
44 unsigned long get_last_access() const { return last_access; }
45 unsigned long get_successful_hits() const { return successful_hits; };
46
47protected:
48 unsigned hashvalue;
51 mutable unsigned long last_access;
52 mutable unsigned successful_hits;
53 static unsigned long access_counter;
54};
55
58class remember_table_list : public std::list<remember_table_entry> {
59public:
60 remember_table_list(unsigned as, unsigned strat);
61 void add_entry(function const & f, ex const & result);
62 bool lookup_entry(function const & f, ex & result) const;
63protected:
66};
67
82class remember_table : public std::vector<remember_table_list> {
83public:
85 remember_table(unsigned s, unsigned as, unsigned strat);
86 bool lookup_entry(function const & f, ex & result) const;
87 void add_entry(function const & f, ex const & result);
88 void clear_all_entries();
89 void show_statistics(std::ostream & os, unsigned level) const;
90 static std::vector<remember_table> & remember_tables();
91protected:
92 void init_table();
93 unsigned table_size;
96};
97
98} // namespace GiNaC
99
100#endif // ndef GINAC_REMEMBER_H
Lightweight wrapper for GiNaC's symbolic objects.
Definition ex.h:72
The class function is used to implement builtin functions like sin, cos... and user defined functions...
Definition function.h:673
A single entry in the remember table of a function.
Definition remember.h:39
ex get_result() const
Definition remember.h:43
exvector seq
Definition remember.h:49
unsigned long get_last_access() const
Definition remember.h:44
bool is_equal(function const &f) const
Definition remember.cpp:42
unsigned hashvalue
Definition remember.h:48
unsigned long get_successful_hits() const
Definition remember.h:45
unsigned successful_hits
Definition remember.h:52
ex result
Definition remember.h:50
unsigned long last_access
Definition remember.h:51
static unsigned long access_counter
Definition remember.h:53
A list of entries in the remember table having some least significant bits of the hashvalue in common...
Definition remember.h:58
void add_entry(function const &f, ex const &result)
Definition remember.cpp:67
bool lookup_entry(function const &f, ex &result) const
Definition remember.cpp:121
The remember table is organized like an n-fold associative cache in a microprocessor.
Definition remember.h:82
static std::vector< remember_table > & remember_tables()
Definition remember.cpp:183
void show_statistics(std::ostream &os, unsigned level) const
unsigned max_assoc_size
Definition remember.h:94
void add_entry(function const &f, ex const &result)
Definition remember.cpp:163
unsigned remember_strategy
Definition remember.h:95
bool lookup_entry(function const &f, ex &result) const
Definition remember.cpp:156
size_t r
Definition factor.cpp:756
Definition add.cpp:35
std::vector< ex > exvector
Definition basic.h:47

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