source: git/kernel/longrat.h @ fec53d

fieker-DuValspielwiese
Last change on this file since fec53d was 2a9ae7, checked in by Hans Schoenemann <hannes@…>, 14 years ago
fix include git-svn-id: file:///usr/local/Singular/svn/trunk@13123 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.0 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 <kernel/structs.h>
11
12#include <kernel/si_gmp.h>
13
14#define SR_HDL(A) ((long)(A))
15
16#define SR_INT    1L
17#define INT_TO_SR(INT)  ((number) (((long)INT << 2) + SR_INT))
18#define SR_TO_INT(SR)   (((long)SR) >> 2)
19
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);
48LINLINE number   nlInit(int i, const ring r);
49number nlRInit (int i);
50LINLINE BOOLEAN  nlIsOne(number a);
51LINLINE BOOLEAN  nlIsZero(number za);
52LINLINE number   nlCopy(number a);
53LINLINE void     nlDelete(number *a, const ring r);
54LINLINE number   nlNeg(number za);
55LINLINE number   nlAdd(number la, number li);
56LINLINE number   nlSub(number la, number li);
57LINLINE number   nlMult(number a, number b);
58
59number   nlInit2 (int i, int j);
60number   nlInit2gmp (mpz_t i, mpz_t j);
61number   nlGcd(number a, number b, const ring r);
62number   nlLcm(number a, number b, const ring r);   /*special routine !*/
63BOOLEAN  nlGreater(number a, number b);
64BOOLEAN  nlIsMOne(number a);
65int      nlInt(number &n, const ring r);
66number   nlBigInt(number &n);
67#ifdef HAVE_RINGS
68void     nlGMP(number &i, number n);
69#endif
70BOOLEAN  nlGreaterZero(number za);
71number   nlInvers(number a);
72void     nlNormalize(number &x);
73number   nlDiv(number a, number b);
74number   nlExactDiv(number a, number b);
75number   nlIntDiv(number a, number b);
76number   nlIntMod(number a, number b);
77void     nlPower(number x, int exp, number *lu);
78const char *   nlRead (const char *s, number *a);
79void     nlWrite(number &a, const ring r);
80int      nlModP(number n, int p);
81int      nlSize(number n);
82number   nlGetDenom(number &n, const ring r);
83number   nlGetNumerator(number &n, const ring r);
84number   nlChineseRemainder(number *x, number *q,int rl);
85#ifdef LDEBUG
86BOOLEAN  nlDBTest(number a, const char *f, const int l);
87#endif
88extern number nlOne;
89
90nMapFunc nlSetMap(const ring src, const ring dst);
91#ifdef HAVE_RINGS
92number nlMapGMP(number from);
93#endif
94
95extern omBin rnumber_bin;
96
97// in-place operations
98void nlInpGcd(number &a, number b, const ring r);
99void nlInpIntDiv(number &a, number b, const ring r);
100void nlInpAdd_(number &a, number b, const ring r);
101LINLINE number   nlInpAdd(number la, number li, const ring r);
102void nlInpMult(number &a, number b, ring r);
103
104number nlFarey(number nP, number nN);
105
106#ifdef LDEBUG
107#define nlTest(a) nlDBTest(a,__FILE__,__LINE__)
108BOOLEAN nlDBTest(number a, char *f,int l);
109#else
110#define nlTest(a) ((void)0)
111#endif
112
113#endif
114
115
Note: See TracBrowser for help on using the repository browser.