1 | #ifndef TRANSEXT_H |
---|
2 | #define TRANSEXT_H |
---|
3 | /**************************************** |
---|
4 | * Computer Algebra System SINGULAR * |
---|
5 | ****************************************/ |
---|
6 | /* $Id$ */ |
---|
7 | /* |
---|
8 | * ABSTRACT: numbers in a rational function field K(t_1, .., t_s) with |
---|
9 | * transcendental variables t_1, ..., t_s, where s >= 1. |
---|
10 | * Denoting the implemented coeffs object by cf, then these numbers |
---|
11 | * are represented as quotients of polynomials in the polynomial |
---|
12 | * ring K[t_1, .., t_s] represented by cf->extring. |
---|
13 | */ |
---|
14 | |
---|
15 | #include <coeffs/coeffs.h> |
---|
16 | |
---|
17 | struct ip_sring; |
---|
18 | typedef struct ip_sring * ring; |
---|
19 | |
---|
20 | struct sip_sideal; |
---|
21 | typedef struct sip_sideal * ideal; |
---|
22 | |
---|
23 | struct spolyrec; |
---|
24 | typedef struct spolyrec polyrec; |
---|
25 | typedef polyrec * poly; |
---|
26 | |
---|
27 | /// struct for passing initialization parameters to naInitChar |
---|
28 | typedef struct { ring r; } TransExtInfo; |
---|
29 | |
---|
30 | /* a number in K(t_1, .., t_s) is represented by either NULL |
---|
31 | (representing the zero number), or a pointer to a fraction which contains |
---|
32 | the numerator polynomial and the denominator polynomial in K[t_1, .., t_s]; |
---|
33 | if the denominator is 1, the member 'denominator' is NULL; |
---|
34 | as a consequence of the above we get: if some number n is not NULL, then |
---|
35 | n->numerator cannot be NULL; |
---|
36 | The member 'complexity' attempts to capture the complexity of any given |
---|
37 | number n, i.e., starting with a bunch of numbers n_i that have their gcd's |
---|
38 | cancelled out, n may be constructed from the n_i's by using field |
---|
39 | arithmetics (+, -, *, /). If we never cancel out gcd's during this process, |
---|
40 | n will become rather complex. The larger the attribute 'complexity' of n |
---|
41 | is, the more likely it is that n contains some non-trivial gcd. Thus, this |
---|
42 | attribute will be used by a heuristic method to cancel out gcd's from time |
---|
43 | to time. (This heuristic may be set up such that cancellation can be |
---|
44 | enforced after each arithmetic operation, or such that it will never take |
---|
45 | place.) Moreover, the 'complexity' of n is zero iff the gcd in n (that is, |
---|
46 | the gcd of its numerator and denominator) is trivial. */ |
---|
47 | struct fractionObject |
---|
48 | { |
---|
49 | poly numerator; |
---|
50 | poly denominator; |
---|
51 | int complexity; |
---|
52 | }; |
---|
53 | typedef struct fractionObject * fraction; |
---|
54 | |
---|
55 | /* constants for controlling the complexity of numbers */ |
---|
56 | #define ADD_COMPLEXITY 1 /**< complexity increase due to + and - */ |
---|
57 | #define MULT_COMPLEXITY 2 /**< complexity increase due to * and / */ |
---|
58 | #define BOUND_COMPLEXITY 10 /**< maximum complexity of a number */ |
---|
59 | |
---|
60 | /* some useful accessors for fractions: */ |
---|
61 | #define IS0(f) (f == NULL) /**< TRUE iff n represents 0 in K(t_1, .., t_s) */ |
---|
62 | #define NUM(f) f->numerator |
---|
63 | #define DEN(f) f->denominator |
---|
64 | #define DENIS1(f) (f->denominator == NULL) /**< TRUE iff den. represents 1 */ |
---|
65 | #define NUMIS1(f) (p_IsConstant(f->numerator, cf->extRing) && \ |
---|
66 | n_IsOne(p_GetCoeff(f->numerator, cf->extRing), \ |
---|
67 | cf->extRing->cf)) |
---|
68 | /**< TRUE iff num. represents 1 */ |
---|
69 | #define COM(f) f->complexity |
---|
70 | |
---|
71 | /// Get a mapping function from src into the domain of this type (n_transExt) |
---|
72 | nMapFunc ntSetMap(const coeffs src, const coeffs dst); |
---|
73 | |
---|
74 | /// Initialize the coeffs object |
---|
75 | BOOLEAN ntInitChar(coeffs cf, void* infoStruct); |
---|
76 | |
---|
77 | /* Private hidden interface |
---|
78 | BOOLEAN ntGreaterZero(number a, const coeffs cf); |
---|
79 | BOOLEAN ntGreater(number a, number b, const coeffs cf); |
---|
80 | BOOLEAN ntEqual(number a, number b, const coeffs cf); |
---|
81 | BOOLEAN ntIsOne(number a, const coeffs cf); |
---|
82 | BOOLEAN ntIsMOne(number a, const coeffs cf); |
---|
83 | BOOLEAN ntIsZero(number a, const coeffs cf); |
---|
84 | number ntInit(int i, const coeffs cf); |
---|
85 | int ntInt(number &a, const coeffs cf); |
---|
86 | number ntNeg(number a, const coeffs cf); |
---|
87 | number ntInvers(number a, const coeffs cf); |
---|
88 | number ntPar(int i, const coeffs cf); |
---|
89 | number ntAdd(number a, number b, const coeffs cf); |
---|
90 | number ntSub(number a, number b, const coeffs cf); |
---|
91 | number ntMult(number a, number b, const coeffs cf); |
---|
92 | number ntDiv(number a, number b, const coeffs cf); |
---|
93 | void ntPower(number a, int exp, number *b, const coeffs cf); |
---|
94 | number ntCopy(number a, const coeffs cf); |
---|
95 | void ntWrite(number &a, const coeffs cf); |
---|
96 | number ntRePart(number a, const coeffs cf); |
---|
97 | number ntImPart(number a, const coeffs cf); |
---|
98 | number ntGetDenom(number &a, const coeffs cf); |
---|
99 | number ntGetNumerator(number &a, const coeffs cf); |
---|
100 | number ntGcd(number a, number b, const coeffs cf); |
---|
101 | number ntLcm(number a, number b, const coeffs cf); |
---|
102 | int ntSize(number a, const coeffs cf); |
---|
103 | void ntDelete(number * a, const coeffs cf); |
---|
104 | void ntCoeffWrite(const coeffs cf); |
---|
105 | number ntIntDiv(number a, number b, const coeffs cf); |
---|
106 | const char * ntRead(const char *s, number *a, const coeffs cf); |
---|
107 | static BOOLEAN ntCoeffIsEqual(const coeffs cf, n_coeffType n, void * param); |
---|
108 | */ |
---|
109 | |
---|
110 | #ifdef LDEBUG |
---|
111 | #define ntTest(a) ntDBTest(a,__FILE__,__LINE__,cf) |
---|
112 | BOOLEAN ntDBTest(number a, const char *f, const int l, const coeffs r); |
---|
113 | #else |
---|
114 | #define ntTest(a) |
---|
115 | #endif |
---|
116 | |
---|
117 | /* our own type */ |
---|
118 | #define ntID n_transExt |
---|
119 | |
---|
120 | /* polynomial ring in which the numerators and denominators of our |
---|
121 | numbers live */ |
---|
122 | #define ntRing cf->extRing |
---|
123 | |
---|
124 | /* coeffs object in which the coefficients of our numbers live; |
---|
125 | * methods attached to ntCoeffs may be used to compute with the |
---|
126 | * coefficients of our numbers, e.g., use ntCoeffs->nAdd to add |
---|
127 | * coefficients of our numbers */ |
---|
128 | #define ntCoeffs cf->extRing->cf |
---|
129 | |
---|
130 | #endif |
---|
131 | /* TRANSEXT_H */ |
---|