source: git/libpolys/polys/ext_fields/transext.h @ 06df101

Last change on this file since 06df101 was 06df101, checked in by Frank Seelisch <seelisch@…>, 12 years ago
handled nested fractions (when over Q), found bug in (see coeffs_test.h:507)
  • Property mode set to 100644
File size: 6.7 KB
1#ifndef TRANSEXT_H
2#define TRANSEXT_H
4*  Computer Algebra System SINGULAR     *
6/* $Id$ */
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 living in the
12*           polynomial ring K[t_1, .., t_s] represented by cf->extring.
14*           An element of K(t_1, .., t_s) may have numerous representations,
15*           due to the possibility of common polynomial factors in the
16*           numerator and denominator. This problem is handled by a
17*           cancellation heuristic: Each number "knows" its complexity
18*           which is 0 if and only if common factors have definitely been
19*           cancelled, and some positive integer otherwise.
20*           Each arithmetic operation of two numbers with complexities c1
21*           and c2 will result in a number of complexity c1 + c2 + some
22*           penalty (specific for each arithmetic operation; see constants
23*           in the *.h file). Whenever the resulting complexity exceeds a
24*           certain threshold (see constant in the *.h file), then the
25*           cancellation heuristic will call 'factory' to compute the gcd
26*           and cancel it out in the given number. (This definite cancel-
27*           lation will also be performed at the beginning of ntWrite,
28*           ensuring that any output is free of common factors.
29*           For the special case of K = Q (i.e., when computing over the
30*           rationals), this definite cancellation procedure will also take
31*           care of nested fractions: If there are fractional coefficients
32*           in the numerator or denominator of a number, then this number
33*           is being replaced by a quotient of two polynomials over Z, or
34*           - if the denominator is a constant - by a polynomial over Q.
37#include <coeffs/coeffs.h>
39struct ip_sring;
40typedef struct ip_sring * ring;
42struct sip_sideal;
43typedef struct sip_sideal * ideal;
45struct spolyrec;
46typedef struct spolyrec polyrec;
47typedef polyrec * poly;
49/// struct for passing initialization parameters to naInitChar
50typedef struct { ring r; } TransExtInfo;
52/* a number in K(t_1, .., t_s) is represented by either NULL
53   (representing the zero number), or a pointer to a fraction which contains
54   the numerator polynomial and the denominator polynomial in K[t_1, .., t_s];
55   if the denominator is 1, the member 'denominator' is NULL;
56   as a consequence of the above we get: if some number n is not NULL, then
57   n->numerator cannot be NULL;
58   The member 'complexity' attempts to capture the complexity of any given
59   number n, i.e., starting with a bunch of numbers n_i that have their gcd's
60   cancelled out, n may be constructed from the n_i's by using field
61   arithmetics (+, -, *, /). If we never cancel out gcd's during this process,
62   n will become rather complex. The larger the attribute 'complexity' of n
63   is, the more likely it is that n contains some non-trivial gcd. Thus, this
64   attribute will be used by a heuristic method to cancel out gcd's from time
65   to time. (This heuristic may be set up such that cancellation can be
66   enforced after each arithmetic operation, or such that it will never take
67   place.) Moreover, the 'complexity' of n is zero iff the gcd in n (that is,
68   the gcd of its numerator and denominator) is trivial. */
69struct fractionObject
71  poly numerator;
72  poly denominator;
73  int complexity;
75typedef struct fractionObject * fraction;
77/* constants for controlling the complexity of numbers */
78#define ADD_COMPLEXITY 1   /**< complexity increase due to + and - */
79#define MULT_COMPLEXITY 2   /**< complexity increase due to * and / */
80#define BOUND_COMPLEXITY 10   /**< maximum complexity of a number */
82/* some useful accessors for fractions: */
83#define IS0(f) (f == NULL) /**< TRUE iff n represents 0 in K(t_1, .., t_s) */
84#define NUM(f) f->numerator
85#define DEN(f) f->denominator
86#define DENIS1(f) (f->denominator == NULL) /**< TRUE iff den. represents 1 */
87#define NUMIS1(f) (p_IsConstant(f->numerator, cf->extRing) && \
88                   n_IsOne(p_GetCoeff(f->numerator, cf->extRing), \
89                           cf->extRing->cf))
90                   /**< TRUE iff num. represents 1 */
91#define COM(f) f->complexity
93/// Get a mapping function from src into the domain of this type (n_transExt)
94nMapFunc ntSetMap(const coeffs src, const coeffs dst);
96/// Initialize the coeffs object
97BOOLEAN  ntInitChar(coeffs cf, void* infoStruct);
99/* Private hidden interface
100BOOLEAN  ntGreaterZero(number a, const coeffs cf);
101BOOLEAN  ntGreater(number a, number b, const coeffs cf);
102BOOLEAN  ntEqual(number a, number b, const coeffs cf);
103BOOLEAN  ntIsOne(number a, const coeffs cf);
104BOOLEAN  ntIsMOne(number a, const coeffs cf);
105BOOLEAN  ntIsZero(number a, const coeffs cf);
106number   ntInit(int i, const coeffs cf);
107int      ntInt(number &a, const coeffs cf);
108number   ntNeg(number a, const coeffs cf);
109number   ntInvers(number a, const coeffs cf);
110number   ntPar(int i, const coeffs cf);
111number   ntAdd(number a, number b, const coeffs cf);
112number   ntSub(number a, number b, const coeffs cf);
113number   ntMult(number a, number b, const coeffs cf);
114number   ntDiv(number a, number b, const coeffs cf);
115void     ntPower(number a, int exp, number *b, const coeffs cf);
116number   ntCopy(number a, const coeffs cf);
117void     ntWrite(number &a, const coeffs cf);
118number   ntRePart(number a, const coeffs cf);
119number   ntImPart(number a, const coeffs cf);
120number   ntGetDenom(number &a, const coeffs cf);
121number   ntGetNumerator(number &a, const coeffs cf);
122number   ntGcd(number a, number b, const coeffs cf);
123number   ntLcm(number a, number b, const coeffs cf);
124int      ntSize(number a, const coeffs cf);
125void     ntDelete(number * a, const coeffs cf);
126void     ntCoeffWrite(const coeffs cf);
127number   ntIntDiv(number a, number b, const coeffs cf);
128const char * ntRead(const char *s, number *a, const coeffs cf);
129static BOOLEAN ntCoeffIsEqual(const coeffs cf, n_coeffType n, void * param);
132#ifdef LDEBUG
133#define ntTest(a) ntDBTest(a,__FILE__,__LINE__,cf)
134BOOLEAN  ntDBTest(number a, const char *f, const int l, const coeffs r);
136#define ntTest(a)
139/* our own type */
140#define ntID n_transExt
142/* polynomial ring in which the numerators and denominators of our
143   numbers live */
144#define ntRing cf->extRing
146/* coeffs object in which the coefficients of our numbers live;
147 * methods attached to ntCoeffs may be used to compute with the
148 * coefficients of our numbers, e.g., use ntCoeffs->nAdd to add
149 * coefficients of our numbers */
150#define ntCoeffs cf->extRing->cf
153/* TRANSEXT_H */
Note: See TracBrowser for help on using the repository browser.