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