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