source: git/libpolys/coeffs/numbers.h @ fb0a699

fieker-DuValspielwiese
Last change on this file since fb0a699 was 35eaf8, checked in by Mohamed Barakat <mohamed.barakat@…>, 13 years ago
- update the build system to build p_Procs.inc - change macros to static inline functions in p_Numbers.h - p_Procs_Generate was changed to add "__T" suffix for template labels - todo: add __T to the macro-invocations in the files p_*__T.cc (cf. for_future_ref)
  • Property mode set to 100644
File size: 3.9 KB
Line 
1#ifndef NUMBERS_H
2#define NUMBERS_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* $Id$ */
7/*
8* ABSTRACT: interface to coefficient aritmetics
9*/
10#include <coeffs/coeffs.h>
11
12#define SHORT_REAL_LENGTH 6 // use short reals for real <= 6 digits
13
14/* the dummy routines: */
15void nDummy1(number* d);
16void ndDelete(number* d, const coeffs r);
17number ndGcd(number a, number b, const coeffs);
18number ndCopy(number a, const coeffs r);
19number ndCopyMap(number a, const coeffs src, const coeffs dst);
20int ndSize(number a, const coeffs r);
21char * ndName(number n, const coeffs r);
22number ndPar(int i, const coeffs r);
23int    ndParDeg(number n, const coeffs r);
24number ndGetDenom(number &n, const coeffs r);
25number ndGetNumerator(number &a,const coeffs r);
26number ndReturn0(number n, const coeffs r);
27number ndIntMod(number a, number b, const coeffs r);
28
29void   ndInpMult(number &a, number b, const coeffs r);
30void   ndInpAdd(number &a, number b, const coeffs r);
31
32#ifdef LDEBUG
33void nDBDummy1(number* d,char *f, int l);
34BOOLEAN ndDBTest(number a, const char *f, const int l, const coeffs r);
35#endif
36
37#define nDivBy0 "div by 0"
38
39// dummy routines
40void   ndNormalize(number& d, const coeffs); // nNormalize...
41
42// Tests:
43static inline BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
44{ return (r->ringtype == 1); }
45
46static inline BOOLEAN nCoeff_is_Ring_ModN(const coeffs r)
47{ return (r->ringtype == 2); }
48
49static inline BOOLEAN nCoeff_is_Ring_PtoM(const coeffs r)
50{ return (r->ringtype == 3); }
51
52static inline BOOLEAN nCoeff_is_Ring_Z(const coeffs r)
53{ return (r->ringtype == 4); }
54
55static inline BOOLEAN nCoeff_is_Ring(const coeffs r)
56{ return (r->ringtype != 0); }
57
58static inline BOOLEAN nCoeff_is_Domain(const coeffs r)
59{ return (r->ringtype == 4 || r->ringtype == 0); }
60
61static inline BOOLEAN nCoeff_has_Units(const coeffs r)
62{ return ((r->ringtype == 1) || (r->ringtype == 2) || (r->ringtype == 3)); }
63
64static inline BOOLEAN nCoeff_is_Zp(const coeffs r)
65{ return getCoeffType(r)==n_Zp; }
66
67static inline BOOLEAN nCoeff_is_Zp(const coeffs r, int p)
68{ return (getCoeffType(r)  && (r->ch == ABS(p))); }
69
70static inline BOOLEAN nCoeff_is_Q(const coeffs r)
71{ return getCoeffType(r)==n_Q; }
72
73static inline BOOLEAN nCoeff_is_numeric(const coeffs r) /* R, long R, long C */
74{  return (getCoeffType(r)==n_R) || (getCoeffType(r)==n_long_R) || (getCoeffType(r)==n_long_C); }
75
76static inline BOOLEAN nCoeff_is_R(const coeffs r)
77{ return getCoeffType(r)==n_R; }
78
79static inline BOOLEAN nCoeff_is_GF(const coeffs r)
80{ return getCoeffType(r)==n_GF; }
81
82static inline BOOLEAN nCoeff_is_GF(const coeffs r, int q)
83{ return (getCoeffType(r)==n_GF) && (r->ch == q); }
84
85static inline BOOLEAN nCoeff_is_Zp_a(const coeffs r)
86{ return (r->ringtype == 0) && (r->ch < -1); }
87
88static inline BOOLEAN nCoeff_is_Zp_a(const coeffs r, int p)
89{ return (r->ringtype == 0) && (r->ch < -1 ) && (-(r->ch) == ABS(p)); }
90
91static inline BOOLEAN nCoeff_is_Q_a(const coeffs r)
92{ return (r->ringtype == 0) && (r->ch == 1); }
93
94static inline BOOLEAN nCoeff_is_long_R(const coeffs r)
95{ return getCoeffType(r)==n_long_R; }
96
97static inline BOOLEAN nCoeff_is_long_C(const coeffs r)
98{ return getCoeffType(r)==n_long_C; }
99
100static inline BOOLEAN nCoeff_is_CF(const coeffs r)
101{ return getCoeffType(r)==n_CF; }
102
103static inline BOOLEAN nCoeff_has_simple_inverse(const coeffs r)
104{ return r->has_simple_Inverse; }
105/* Z/2^n, Z/p, GF(p,n), R, long_R, long_C*/
106
107static inline BOOLEAN nCoeff_has_simple_Alloc(const coeffs r)
108{ return r->has_simple_Alloc; }
109/* Z/p, GF(p,n), R, Ring_2toM: nCopy, nNew, nDelete are dummies*/
110
111static inline BOOLEAN nCoeff_is_Extension(const coeffs r)
112{ return (nCoeff_is_Q_a(r)) || (nCoeff_is_Zp_a(r)); } /* Z/p(a) and Q(a)*/
113
114/// initialize an object of type coeff, return FALSE in case of success
115typedef BOOLEAN (*cfInitCharProc)(coeffs, void *);
116n_coeffType nRegister(n_coeffType n, cfInitCharProc p);
117
118#endif
Note: See TracBrowser for help on using the repository browser.