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