source: git/libpolys/polys/ext_fields/transext.h @ 1f414c8

spielwiese
Last change on this file since 1f414c8 was 1f414c8, checked in by Oleksandr Motsak <motsak@…>, 13 years ago
CHG: cleaning up Frank's code for alg./trans. extensions + hiding private details
  • Property mode set to 100644
File size: 6.0 KB
Line 
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 living in the
12*           polynomial ring K[t_1, .., t_s] represented by cf->extring.
13*
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.
35*/
36
37#include <coeffs/coeffs.h>
38
39struct ip_sring;
40typedef struct ip_sring * ring;
41
42
43// the following is only needed _here_ due to its use in clapsing.cc!
44#ifdef TRANSEXT_PRIVATES
45struct spolyrec; typedef struct spolyrec polyrec; typedef polyrec * poly;
46
47
48/** a number in K(t_1, .., t_s) is represented by either NULL
49   (representing the zero number), or a pointer to a fraction which contains
50   the numerator polynomial and the denominator polynomial in K[t_1, .., t_s];
51   if the denominator is 1, the member 'denominator' is NULL;
52   as a consequence of the above we get: if some number n is not NULL, then
53   n->numerator cannot be NULL;
54   The member 'complexity' attempts to capture the complexity of any given
55   number n, i.e., starting with a bunch of numbers n_i that have their gcd's
56   cancelled out, n may be constructed from the n_i's by using field
57   arithmetics (+, -, *, /). If we never cancel out gcd's during this process,
58   n will become rather complex. The larger the attribute 'complexity' of n
59   is, the more likely it is that n contains some non-trivial gcd. Thus, this
60   attribute will be used by a heuristic method to cancel out gcd's from time
61   to time. (This heuristic may be set up such that cancellation can be
62   enforced after each arithmetic operation, or such that it will never take
63   place.) Moreover, the 'complexity' of n is zero iff the gcd in n (that is,
64     the gcd of its numerator and denominator) is trivial.
65 */
66struct fractionObject
67{
68  poly numerator;
69  poly denominator;
70  int complexity;
71};
72
73typedef struct fractionObject * fraction;
74
75
76#define NUM(f) f->numerator
77#define DEN(f) f->denominator
78
79#endif
80
81
82/// struct for passing initialization parameters to naInitChar
83typedef struct { ring r; } TransExtInfo;
84
85/// Get a mapping function from src into the domain of this type (n_transExt)
86nMapFunc ntSetMap(const coeffs src, const coeffs dst);
87
88/// Initialize the coeffs object
89BOOLEAN  ntInitChar(coeffs cf, void* infoStruct);
90
91/* Private hidden interface
92BOOLEAN  ntGreaterZero(number a, const coeffs cf);
93BOOLEAN  ntGreater(number a, number b, const coeffs cf);
94BOOLEAN  ntEqual(number a, number b, const coeffs cf);
95BOOLEAN  ntIsOne(number a, const coeffs cf);
96BOOLEAN  ntIsMOne(number a, const coeffs cf);
97BOOLEAN  ntIsZero(number a, const coeffs cf);
98number   ntInit(int i, const coeffs cf);
99int      ntInt(number &a, const coeffs cf);
100number   ntNeg(number a, const coeffs cf);
101number   ntInvers(number a, const coeffs cf);
102number   ntAdd(number a, number b, const coeffs cf);
103number   ntSub(number a, number b, const coeffs cf);
104number   ntMult(number a, number b, const coeffs cf);
105number   ntDiv(number a, number b, const coeffs cf);
106void     ntPower(number a, int exp, number *b, const coeffs cf);
107number   ntCopy(number a, const coeffs cf);
108void     ntWrite(number &a, const coeffs cf);
109number   ntRePart(number a, const coeffs cf);
110number   ntImPart(number a, const coeffs cf);
111number   ntGetDenom(number &a, const coeffs cf);
112number   ntGetNumerator(number &a, const coeffs cf);
113number   ntGcd(number a, number b, const coeffs cf);
114number   ntLcm(number a, number b, const coeffs cf);
115int      ntSize(number a, const coeffs cf);
116void     ntDelete(number * a, const coeffs cf);
117void     ntCoeffWrite(const coeffs cf);
118number   ntIntDiv(number a, number b, const coeffs cf);
119const char * ntRead(const char *s, number *a, const coeffs cf);
120static BOOLEAN ntCoeffIsEqual(const coeffs cf, n_coeffType n, void * param);
121*/
122
123#ifdef LDEBUG
124#define ntTest(a) ntDBTest(a,__FILE__,__LINE__,cf)
125BOOLEAN  ntDBTest(number a, const char *f, const int l, const coeffs r);
126#else
127#define ntTest(a)
128#endif
129
130/* our own type */
131#define ntID n_transExt
132
133/* polynomial ring in which the numerators and denominators of our
134   numbers live */
135#define ntRing cf->extRing
136
137/* coeffs object in which the coefficients of our numbers live;
138 * methods attached to ntCoeffs may be used to compute with the
139 * coefficients of our numbers, e.g., use ntCoeffs->nAdd to add
140 * coefficients of our numbers */
141#define ntCoeffs cf->extRing->cf
142
143#endif
144/* TRANSEXT_H */
Note: See TracBrowser for help on using the repository browser.