source: git/libpolys/coeffs/longrat.h @ f59722

spielwiese
Last change on this file since f59722 was f59722, checked in by Hans Schoenemann <hannes@…>, 13 years ago
convert to inline routine: nlInpMult
  • Property mode set to 100644
File size: 3.6 KB
Line 
1#ifndef LONGRAT_H
2#define LONGRAT_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id$ */
7/*
8* ABSTRACT: computation with long rational numbers
9*/
10#include <misc/auxiliary.h>
11#include <omalloc/omalloc.h>
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#define mpz_size1(A) (ABS((A)->_mp_size))
24//#define mpz_size1(A) mpz_size(A)
25
26struct snumber;
27typedef struct snumber  *number;
28struct snumber
29{
30  mpz_t z;
31  mpz_t n;
32#if defined(LDEBUG)
33  int debug;
34#endif
35  BOOLEAN s;
36};
37
38// allow inlining only from p_Numbers.h and if ! LDEBUG
39
40#if defined(DO_LINLINE) && defined(P_NUMBERS_H) && !defined(LDEBUG)
41#define LINLINE static inline
42#else
43#define LINLINE
44#undef DO_LINLINE
45#endif // DO_LINLINE
46
47LINLINE BOOLEAN  nlEqual(number a, number b, const coeffs r);
48LINLINE number   nlInit(int i, const coeffs r);
49number nlRInit (long i);
50LINLINE BOOLEAN  nlIsOne(number a, const coeffs r);
51LINLINE BOOLEAN  nlIsZero(number za, const coeffs r);
52LINLINE number   nlCopy(number a, const coeffs r);
53LINLINE number   nl_Copy(number a, const coeffs r);
54LINLINE void     nlDelete(number *a, const coeffs r);
55LINLINE number   nlNeg(number za, const coeffs r);
56LINLINE number   nlAdd(number la, number li, const coeffs r);
57LINLINE number   nlSub(number la, number li, const coeffs r);
58LINLINE number   nlMult(number a, number b, const coeffs r);
59
60BOOLEAN nlInitChar(coeffs r, void*);
61
62number   nlInit2 (int i, int j, const coeffs r);
63number   nlInit2gmp (mpz_t i, mpz_t j);
64number   nlGcd(number a, number b, const coeffs r);
65number   nlLcm(number a, number b, const coeffs r);   /*special routine !*/
66BOOLEAN  nlGreater(number a, number b, const coeffs r);
67BOOLEAN  nlIsMOne(number a, const coeffs r);
68int      nlInt(number &n, const coeffs r);
69number   nlBigInt(number &n);
70
71#ifdef HAVE_RINGS
72void     nlGMP(number &i, number n, const coeffs r);
73#endif
74
75BOOLEAN  nlGreaterZero(number za, const coeffs r);
76number   nlInvers(number a, const coeffs r);
77void     nlNormalize(number &x, const coeffs r);
78number   nlDiv(number a, number b, const coeffs r);
79number   nlExactDiv(number a, number b, const coeffs r);
80number   nlIntDiv(number a, number b, const coeffs r);
81number   nlIntMod(number a, number b, const coeffs r);
82void     nlPower(number x, int exp, number *lu, const coeffs r);
83const char *   nlRead (const char *s, number *a, const coeffs r);
84void     nlWrite(number &a, const coeffs r);
85int      nlModP(number n, int p, const coeffs r);
86int      nlSize(number n, const coeffs r);
87number   nlGetDenom(number &n, const coeffs r);
88number   nlGetNumerator(number &n, const coeffs r);
89void     nlCoeffWrite(const coeffs r);
90#ifdef LDEBUG
91BOOLEAN  nlDBTest(number a, const char *f, const int l);
92#endif
93extern number nlOne;
94
95nMapFunc nlSetMap(const coeffs src, const coeffs dst);
96
97extern omBin rnumber_bin;
98
99
100#define FREE_RNUMBER(x) omFreeBin((void *)x, rnumber_bin)
101#define ALLOC_RNUMBER() (number)omAllocBin(rnumber_bin)
102#define ALLOC0_RNUMBER() (number)omAlloc0Bin(rnumber_bin)
103
104// in-place operations
105void nlInpGcd(number &a, number b, const coeffs r);
106void nlInpIntDiv(number &a, number b, const coeffs r);
107
108LINLINE void nlInpAdd(number &a, number b, const coeffs r);
109LINLINE void nlInpMult(number &a, number b, const coeffs r);
110
111number nlFarey(number nP, number nN);
112
113#ifdef LDEBUG
114#define nlTest(a, r) nlDBTest(a,__FILE__,__LINE__, r)
115BOOLEAN nlDBTest(number a, char *f,int l, const coeffs r);
116#else
117#define nlTest(a, r) ((void)0)
118#endif
119
120#endif
121
122
Note: See TracBrowser for help on using the repository browser.