source: git/libpolys/coeffs/longrat.h @ 560a3d

spielwiese
Last change on this file since 560a3d was 6ce030f, checked in by Oleksandr Motsak <motsak@…>, 12 years ago
removal of the $Id$ svn tag from everywhere NOTE: the git SHA1 may be used instead (only on special places) NOTE: the libraries Singular/LIB/*.lib still contain the marker due to our current use of svn
  • Property mode set to 100644
File size: 3.8 KB
Line 
1#ifndef LONGRAT_H
2#define LONGRAT_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/*
7* ABSTRACT: computation with long rational numbers
8*/
9#include <misc/auxiliary.h>
10#include <omalloc/omalloc.h>
11
12#include <coeffs/si_gmp.h>
13#include <coeffs/coeffs.h>
14
15#define SR_HDL(A) ((long)(A))
16
17#define SR_INT    1L
18#define INT_TO_SR(INT)  ((number) (((long)INT << 2) + SR_INT))
19#define SR_TO_INT(SR)   (((long)SR) >> 2)
20
21#define MP_SMALL 1
22
23
24struct snumber;
25typedef struct snumber  *number;
26struct snumber
27{
28  mpz_t z;
29  mpz_t n;
30#if defined(LDEBUG)
31  int debug;
32#endif
33  BOOLEAN s;
34};
35
36// allow inlining only from p_Numbers.h and if ! LDEBUG
37
38#if defined(DO_LINLINE) && defined(P_NUMBERS_H) && !defined(LDEBUG)
39#define LINLINE static inline
40#else
41#define LINLINE
42#undef DO_LINLINE
43#endif // DO_LINLINE
44
45LINLINE BOOLEAN  nlEqual(number a, number b, const coeffs r);
46LINLINE number   nlInit(long i, const coeffs r);
47number nlRInit (long i);
48LINLINE BOOLEAN  nlIsOne(number a, const coeffs r);
49LINLINE BOOLEAN  nlIsZero(number za, const coeffs r);
50LINLINE number   nlCopy(number a, const coeffs r);
51LINLINE number   nl_Copy(number a, const coeffs r);
52LINLINE void     nlDelete(number *a, const coeffs r);
53LINLINE number   nlNeg(number za, const coeffs r);
54LINLINE number   nlAdd(number la, number li, const coeffs r);
55LINLINE number   nlSub(number la, number li, const coeffs r);
56LINLINE number   nlMult(number a, number b, const coeffs r);
57
58BOOLEAN nlInitChar(coeffs r, void*);
59
60number   nlInit2 (int i, int j, const coeffs r);
61number   nlInit2gmp (mpz_t i, mpz_t j);
62
63// number nlInitMPZ(mpz_t m, const coeffs r);
64// void nlMPZ(mpz_t m, number &n, const coeffs r);
65
66number   nlGcd(number a, number b, const coeffs r);
67number   nlLcm(number a, number b, const coeffs r);   /*special routine !*/
68BOOLEAN  nlGreater(number a, number b, const coeffs r);
69BOOLEAN  nlIsMOne(number a, const coeffs r);
70int      nlInt(number &n, const coeffs r);
71number   nlBigInt(number &n);
72
73#ifdef HAVE_RINGS
74number nlMapGMP(number from, const coeffs src, const coeffs dst);
75void     nlGMP(number &i, number n, const coeffs r);
76#endif
77
78BOOLEAN  nlGreaterZero(number za, const coeffs r);
79number   nlInvers(number a, const coeffs r);
80void     nlNormalize(number &x, const coeffs r);
81number   nlDiv(number a, number b, const coeffs r);
82number   nlExactDiv(number a, number b, const coeffs r);
83number   nlIntDiv(number a, number b, const coeffs r);
84number   nlIntMod(number a, number b, const coeffs r);
85void     nlPower(number x, int exp, number *lu, const coeffs r);
86const char *   nlRead (const char *s, number *a, const coeffs r);
87void     nlWrite(number &a, const coeffs r);
88
89/// Map q \in QQ \to Zp
90number nlModP(number q, const coeffs Q, const coeffs Zp);
91
92int      nlSize(number n, const coeffs r);
93number   nlGetDenom(number &n, const coeffs r);
94number   nlGetNumerator(number &n, const coeffs r);
95void     nlCoeffWrite(const coeffs r, BOOLEAN details);
96number   nlChineseRemainder(number *x, number *q,int rl, const coeffs C);
97number   nlFarey(number nN, number nP, const coeffs CF);
98
99#ifdef LDEBUG
100BOOLEAN  nlDBTest(number a, const char *f, const int l);
101#endif
102extern number nlOne;
103
104nMapFunc nlSetMap(const coeffs src, const coeffs dst);
105
106extern omBin rnumber_bin;
107
108#define FREE_RNUMBER(x) omFreeBin((void *)x, rnumber_bin)
109#define ALLOC_RNUMBER() (number)omAllocBin(rnumber_bin)
110#define ALLOC0_RNUMBER() (number)omAlloc0Bin(rnumber_bin)
111
112// in-place operations
113void nlInpGcd(number &a, number b, const coeffs r);
114void nlInpIntDiv(number &a, number b, const coeffs r);
115
116LINLINE void nlInpAdd(number &a, number b, const coeffs r);
117LINLINE void nlInpMult(number &a, number b, const coeffs r);
118
119#ifdef LDEBUG
120#define nlTest(a, r) nlDBTest(a,__FILE__,__LINE__, r)
121BOOLEAN nlDBTest(number a, char *f,int l, const coeffs r);
122#else
123#define nlTest(a, r) ((void)0)
124#endif
125
126#endif
127
128
Note: See TracBrowser for help on using the repository browser.