1 #ifndef TRANSEXT_H 2 #define TRANSEXT_H 3 /**************************************** 4 * Computer Algebra System SINGULAR * 5 ****************************************/ 6 /* 7 * ABSTRACT: numbers in a rational function field K(t_1, .., t_s) with 8 * transcendental variables t_1, ..., t_s, where s >= 1. 9 * Denoting the implemented coeffs object by cf, then these numbers 10 * are represented as quotients of polynomials living in the 11 * polynomial ring K[t_1, .., t_s] represented by cf->extring. 12 * 13 * An element of K(t_1, .., t_s) may have numerous representations, 14 * due to the possibility of common polynomial factors in the 15 * numerator and denominator. This problem is handled by a 16 * cancellation heuristic: Each number "knows" its complexity 17 * which is 0 if and only if common factors have definitely been 18 * cancelled, and some positive integer otherwise. 19 * Each arithmetic operation of two numbers with complexities c1 20 * and c2 will result in a number of complexity c1 + c2 + some 21 * penalty (specific for each arithmetic operation; see constants 22 * in the *.h file). Whenever the resulting complexity exceeds a 23 * certain threshold (see constant in the *.h file), then the 24 * cancellation heuristic will call 'factory' to compute the gcd 25 * and cancel it out in the given number. (This definite cancel- 26 * lation will also be performed at the beginning of ntWrite, 27 * ensuring that any output is free of common factors. 28 * For the special case of K = Q (i.e., when computing over the 29 * rationals), this definite cancellation procedure will also take 30 * care of nested fractions: If there are fractional coefficients 31 * in the numerator or denominator of a number, then this number 32 * is being replaced by a quotient of two polynomials over Z, or 33 * - if the denominator is a constant - by a polynomial over Q. 34 */ 35 36 #include "coeffs/coeffs.h" 37 #include "polys/monomials/ring.h" 38 39 // restrict access to the internal represention as much as possible: 40 #ifdef TRANSEXT_PRIVATES 41 42 /** a number in K(t_1, .., t_s) is represented by either NULL 43 (representing the zero number), or a pointer to a fraction which contains 44 the numerator polynomial and the denominator polynomial in K[t_1, .., t_s]; 45 if the denominator is 1, the member 'denominator' is NULL; 46 as a consequence of the above we get: if some number n is not NULL, then 47 n->numerator cannot be NULL; 48 The member 'complexity' attempts to capture the complexity of any given 49 number n, i.e., starting with a bunch of numbers n_i that have their gcd's 50 cancelled out, n may be constructed from the n_i's by using field 51 arithmetics (+, -, *, /). If we never cancel out gcd's during this process, 52 n will become rather complex. The larger the attribute 'complexity' of n 53 is, the more likely it is that n contains some non-trivial gcd. Thus, this 54 attribute will be used by a heuristic method to cancel out gcd's from time 55 to time. (This heuristic may be set up such that cancellation can be 56 enforced after each arithmetic operation, or such that it will never take 57 place.) Moreover, the 'complexity' of n is zero iff the gcd in n (that is, 58 the gcd of its numerator and denominator) is trivial. 59 */ 60 struct fractionObject 61 { 62 poly numerator; 63 poly denominator; 64 int complexity; 65 }; 66 67 typedef struct fractionObject * fraction; 68 69 70 #define NUM(f) ((f)->numerator) 71 #define DEN(f) ((f)->denominator) 72 73 /* some useful accessors for fractions: */ 74 #define IS0(f) (f == NULL) 75 /**< TRUE iff n represents 0 in K(t_1, .., t_s) */ 76 77 #define DENIS1(f) (DEN(f) == NULL) 78 /**< TRUE iff den. represents 1 */ 79 80 /// takes over p! 81 number ntInit(poly p, const coeffs cf); 82 83 #endif 84 85 86 87 /// struct for passing initialization parameters to naInitChar 88 typedef struct { ring r; } TransExtInfo; 89 90 /// Get a mapping function from src into the domain of this type (n_transExt) 91 nMapFunc ntSetMap(const coeffs src, const coeffs dst); 92 93 /// Initialize the coeffs object 94 BOOLEAN ntInitChar(coeffs cf, void* infoStruct); 95 96 number ntDiff(number a, number d, const coeffs cf); 97 98 /* Private hidden interface 99 BOOLEAN ntGreaterZero(number a, const coeffs cf); 100 BOOLEAN ntGreater(number a, number b, const coeffs cf); 101 BOOLEAN ntEqual(number a, number b, const coeffs cf); 102 BOOLEAN ntIsOne(number a, const coeffs cf); 103 BOOLEAN ntIsMOne(number a, const coeffs cf); 104 BOOLEAN ntIsZero(number a, const coeffs cf); 105 number ntInit(long i, const coeffs cf); 106 int ntInt(number &a, const coeffs cf); 107 number ntNeg(number a, const coeffs cf); 108 number ntInvers(number a, const coeffs cf); 109 number ntAdd(number a, number b, const coeffs cf); 110 number ntSub(number a, number b, const coeffs cf); 111 number ntMult(number a, number b, const coeffs cf); 112 number ntDiv(number a, number b, const coeffs cf); 113 void ntPower(number a, int exp, number *b, const coeffs cf); 114 number ntCopy(number a, const coeffs cf); 115 void ntWrite(number &a, const coeffs cf); 116 number ntRePart(number a, const coeffs cf); 117 number ntImPart(number a, const coeffs cf); 118 number ntGetDenom(number &a, const coeffs cf); 119 number ntGetNumerator(number &a, const coeffs cf); 120 number ntGcd(number a, number b, const coeffs cf); 121 number ntLcm(number a, number b, const coeffs cf); 122 int ntSize(number a, const coeffs cf); 123 void ntDelete(number * a, const coeffs cf); 124 void ntCoeffWrite(const coeffs cf, BOOLEAN details); 125 const char * ntRead(const char *s, number *a, const coeffs cf); 126 static BOOLEAN ntCoeffIsEqual(const coeffs cf, n_coeffType n, void * param); 127 */ 128 129 /// if m == var(i)/1 => return i, 130 int ntIsParam(number, const coeffs); 131 132 /// helper routine for calling singclap_gcd_r 133 poly gcd_over_Q ( poly f, poly g, const ring r); 134 #endif 135 /* TRANSEXT_H */ 136