]> www.ginac.de Git - ginac.git/blob - ginac/flags.h
Added log(exp(x)) -> x for real symbols.
[ginac.git] / ginac / flags.h
1 /** @file flags.h
2  *
3  *  Collection of all flags used through the GiNaC framework. */
4
5 /*
6  *  GiNaC Copyright (C) 1999-2004 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #ifndef __GINAC_FLAGS_H__
24 #define __GINAC_FLAGS_H__
25
26 namespace GiNaC {
27
28 /** Flags to control the behavior of expand(). */
29 class expand_options {
30 public:
31         enum {
32                 expand_indexed = 0x0001,      ///< expands (a+b).i to a.i+b.i
33                 expand_function_args = 0x0002 ///< expands the arguments of functions
34         };
35 };
36
37 /** Flags to control the behavior of subs(). */
38 class subs_options {
39 public:
40         enum {
41                 no_pattern = 0x0001,             ///< disable pattern matching
42                 subs_no_pattern = 0x0001, // for backwards compatibility
43                 algebraic = 0x0002,              ///< enable algebraic substitutions
44                 subs_algebraic = 0x0002,  // for backwards compatibility
45         pattern_is_product = 0x0004,     ///< used internally by expairseq::subschildren()
46         pattern_is_not_product = 0x0008  ///< used internally by expairseq::subschildren()
47         };
48 };
49
50 /** Flags to decide how conjugate should treat a symbol */
51 class symbol_options {
52 public:
53         enum {
54                 /** Symbol is treated like a complex valued expression */
55                 complex,
56                 /** Symbol is treated like a real valued expression */
57                 real
58         };
59 };
60
61 /** Flags to control series expansion. */
62 class series_options {
63 public:
64         enum {
65                 /** Suppress branch cuts in series expansion.  Branch cuts manifest
66                  *  themselves as step functions, if this option is not passed.  If
67                  *  it is passed and expansion at a point on a cut is performed, then
68                  *  the analytic continuation of the function is expanded. */
69                 suppress_branchcut = 0x0001
70         };
71 };
72
73 /** Switch to control algorithm for determinant computation. */
74 class determinant_algo {
75 public:
76         enum {
77                 /** Let the system choose.  A heuristics is applied for automatic
78                  *  determination of a suitable algorithm. */
79                 automatic,
80                 /** Gauss elimination.  If \f$m_{i,j}^{(0)}\f$ are the entries of the
81                  *  original matrix, then the matrix is transformed into triangular
82                  *  form by applying the rules
83                  *  \f[
84                  *      m_{i,j}^{(k+1)} = m_{i,j}^{(k)} - m_{i,k}^{(k)} m_{k,j}^{(k)} / m_{k,k}^{(k)}
85                  *  \f]
86                  *  The determinant is then just the product of diagonal elements.
87                  *  Choose this algorithm only for purely numerical matrices. */
88                 gauss,
89                 /** Division-free elimination.  This is a modification of Gauss
90                  *  elimination where the division by the pivot element is not
91                  *  carried out.  If \f$m_{i,j}^{(0)}\f$ are the entries of the
92                  *  original matrix, then the matrix is transformed into triangular
93                  *  form by applying the rules
94                  *  \f[
95                  *      m_{i,j}^{(k+1)} = m_{i,j}^{(k)} m_{k,k}^{(k)} - m_{i,k}^{(k)} m_{k,j}^{(k)}
96                  *  \f]
97                  *  The determinant can later be computed by inspecting the diagonal
98                  *  elements only.  This algorithm is only there for the purpose of
99                  *  cross-checks.  It is never fast. */
100                 divfree,
101                 /** Laplace elimination.  This is plain recursive elimination along
102                  *  minors although multiple minors are avoided by the algorithm.
103                  *  Although the algorithm is exponential in complexity it is
104                  *  frequently the fastest one when the matrix is populated by
105                  *  complicated symbolic expressions. */
106                 laplace,
107                 /** Bareiss fraction-free elimination.  This is a modification of
108                  *  Gauss elimination where the division by the pivot element is
109                  *  <EM>delayed</EM> until it can be carried out without computing
110                  *  GCDs.  If \f$m_{i,j}^{(0)}\f$ are the entries of the original
111                  *  matrix, then the matrix is transformed into triangular form by
112                  *  applying the rules
113                  *  \f[
114                  *      m_{i,j}^{(k+1)} = (m_{i,j}^{(k)} m_{k,k}^{(k)} - m_{i,k}^{(k)} m_{k,j}^{(k)}) / m_{k-1,k-1}^{(k-1)}
115                  *  \f]
116                  *  (We have set \f$m_{-1,-1}^{(-1)}=1\f$ in order to avoid a case
117                  *  distinction in above formula.)  It can be shown that nothing more
118                  *  than polynomial long division is needed for carrying out the
119                  *  division.  The determinant can then be read of from the lower
120                  *  right entry.  This algorithm is rarely fast for computing
121                  *  determinants. */
122                 bareiss
123         };
124 };
125
126 /** Switch to control algorithm for linear system solving. */
127 class solve_algo {
128 public:
129         enum {
130                 /** Let the system choose.  A heuristics is applied for automatic
131                  *  determination of a suitable algorithm. */
132                 automatic,
133                 /** Gauss elimination.  If \f$m_{i,j}^{(0)}\f$ are the entries of the
134                  *  original matrix, then the matrix is transformed into triangular
135                  *  form by applying the rules
136                  *  \f[
137                  *      m_{i,j}^{(k+1)} = m_{i,j}^{(k)} - m_{i,k}^{(k)} m_{k,j}^{(k)} / m_{k,k}^{(k)}
138                  *  \f]
139                  *  This algorithm is well-suited for numerical matrices but generally
140                  *  suffers from the expensive division (and computation of GCDs) at
141                  *  each step. */
142                 gauss,
143                 /** Division-free elimination.  This is a modification of Gauss
144                  *  elimination where the division by the pivot element is not
145                  *  carried out.  If \f$m_{i,j}^{(0)}\f$ are the entries of the
146                  *  original matrix, then the matrix is transformed into triangular
147                  *  form by applying the rules
148                  *  \f[
149                  *      m_{i,j}^{(k+1)} = m_{i,j}^{(k)} m_{k,k}^{(k)} - m_{i,k}^{(k)} m_{k,j}^{(k)}
150                  *  \f]
151                  *  This algorithm is only there for the purpose of cross-checks.
152                  *  It suffers from exponential intermediate expression swell.  Use it
153                  *  only for small systems. */
154                 divfree,
155                 /** Bareiss fraction-free elimination.  This is a modification of
156                  *  Gauss elimination where the division by the pivot element is
157                  *  <EM>delayed</EM> until it can be carried out without computing
158                  *  GCDs.  If \f$m_{i,j}^{(0)}\f$ are the entries of the original
159                  *  matrix, then the matrix is transformed into triangular form by
160                  *  applying the rules
161                  *  \f[
162                  *      m_{i,j}^{(k+1)} = (m_{i,j}^{(k)} m_{k,k}^{(k)} - m_{i,k}^{(k)} m_{k,j}^{(k)}) / m_{k-1,k-1}^{(k-1)}
163                  *  \f]
164                  *  (We have set \f$m_{-1,-1}^{(-1)}=1\f$ in order to avoid a case
165                  *  distinction in above formula.)  It can be shown that nothing more
166                  *  than polynomial long division is needed for carrying out the
167                  *  division.  This is generally the fastest algorithm for solving
168                  *  linear systems.  In contrast to division-free elimination it only
169                  *  has a linear expression swell.  For two-dimensional systems, the
170                  *  two algorithms are equivalent, however. */
171                 bareiss
172         };
173 };
174
175 /** Flags to store information about the state of an object.
176  *  @see basic::flags */
177 class status_flags {
178 public:
179         enum {
180                 dynallocated    = 0x0001, ///< heap-allocated (i.e. created by new if we want to be clever and bypass the stack, @see ex::construct_from_basic() )
181                 evaluated       = 0x0002, ///< .eval() has already done its job
182                 expanded        = 0x0004, ///< .expand(0) has already done its job (other expand() options ignore this flag)
183                 hash_calculated = 0x0008, ///< .calchash() has already done its job
184                 not_shareable   = 0x0010  ///< don't share instances of this object between different expressions unless explicitly asked to (used by ex::compare())
185         };
186 };
187
188 /** Possible attributes an object can have. */
189 class info_flags {
190 public:
191         enum {
192                 // answered by class numeric
193                 numeric,
194                 real,
195                 rational,
196                 integer,
197                 crational,
198                 cinteger,
199                 positive,
200                 negative,
201                 nonnegative,
202                 posint,
203                 negint,
204                 nonnegint,
205                 even,
206                 odd,
207                 prime,
208
209                 // answered by class relation
210                 relation,
211                 relation_equal,
212                 relation_not_equal,
213                 relation_less,
214                 relation_less_or_equal,
215                 relation_greater,
216                 relation_greater_or_equal,
217
218                 // answered by class symbol
219                 symbol,
220
221                 // answered by class lst
222                 list,
223
224                 // answered by class exprseq
225                 exprseq,
226
227                 // answered by classes numeric, symbol, add, mul, power
228                 polynomial,
229                 integer_polynomial,
230                 cinteger_polynomial,
231                 rational_polynomial,
232                 crational_polynomial,
233                 rational_function,
234                 algebraic,
235
236                 // answered by class indexed
237                 indexed,      // class can carry indices
238                 has_indices,  // object has at least one index
239
240                 // answered by class idx
241                 idx
242         };
243 };
244
245 class return_types {
246 public:
247         enum {
248                 commutative,
249                 noncommutative,
250                 noncommutative_composite
251         };
252 };
253
254 /** Strategies how to clean up the function remember cache.
255  *  @see remember_table */
256 class remember_strategies {
257 public:
258         enum {
259                 delete_never,   ///< Let table grow undefinitely
260                 delete_lru,     ///< Least recently used
261                 delete_lfu,     ///< Least frequently used
262                 delete_cyclic   ///< First (oldest) one in list
263         };
264 };
265
266 } // namespace GiNaC
267
268 #endif // ndef __GINAC_FLAGS_H__