nforder_elt.cc
Go to the documentation of this file.
1 #include "kernel/mod2.h" // general settings/macros
2 //#include"kernel/febase.h" // for Print, WerrorS
3 #include"Singular/ipid.h" // for SModulFunctions, leftv
4 #include"Singular/number2.h" // for SModulFunctions, leftv
5 #include<coeffs/numbers.h> // nRegister, coeffs.h
6 #include <coeffs/coeffs.h>
7 #include"Singular/blackbox.h" // blackbox type
8 #include "nforder.h"
9 #include <coeffs/bigintmat.h>
10 
12 
13 static void WriteRing(const coeffs r, BOOLEAN details)
14 {
15  ((nforder *)r->data)->Print();
16 }
17 
18 static char* CoeffString(const coeffs r)
19 {
20  return ((nforder *)r->data)->String();
21 }
22 static void EltWrite(number a, const coeffs r)
23 {
24  bigintmat * b = (bigintmat*)a;
25  if (a) {
26  bigintmat * c = b->transpose();
27  c->Write();
28  StringAppendS("^t ");
29  } else {
30  StringAppendS("(Null)\n");
31  }
32 }
33 
35 {
36  number xx;
37  if (b->rows()==1) {
38  assume(b->cols()==a->getDim());
39  xx = (number) b->transpose();
40  } else {
41  assume(b->rows() == a->getDim());
42  assume(b->cols() == 1);
43  xx = (number) new bigintmat((bigintmat*)b);
44  }
45 // Print("Created new element %lx from %lx\n", xx, b);
46  return (number) xx;
47 }
48 
49 
50 static BOOLEAN order_cmp(coeffs n, n_coeffType t, void*parameter)
51 {
52  return (t==nforder_type) && (n->data == parameter);
53 }
54 
55 static void KillChar(coeffs r) {
56  Print("KillChar %lx\n", r);
57 }
58 #ifdef LDEBUG
59  BOOLEAN EltDBTest(number, const char *, const int, const coeffs)
60 {
61  return TRUE;
62 }
63 #endif
64 
65 static void SetChar(const coeffs r)
66 {
67  Print("%s called\n", __func__);
68 }
69  // or NULL
70  // general stuff
71 static number EltMult(number a, number b, const coeffs r)
72 {
73  nforder *O = (nforder*) (r->data);
74  bigintmat *c = new bigintmat((bigintmat*)a);
75  O->elMult(c, (bigintmat*) b);
76  return (number) c;
77 }
78 static number EltSub(number a, number b, const coeffs r)
79 {
80  nforder *O = (nforder*) (r->data);
81  bigintmat *c = new bigintmat((bigintmat*)a);
82  O->elSub(c, (bigintmat*) b);
83  return (number) c;
84 }
85 static number EltAdd(number a, number b, const coeffs r)
86 {
87  nforder *O = (nforder*) (r->data);
88  bigintmat *c = new bigintmat((bigintmat*)a);
89  O->elAdd(c, (bigintmat*) b);
90  return (number) c;
91 }
92 static number EltDiv(number a, number b, const coeffs r)
93 {
94  Werror("%s called\n", __func__, a, b, r);
95  return NULL;
96 }
97 static number EltIntDiv(number a, number b, const coeffs r)
98 {
99  Werror("IntDiv called on order elts", a, b, r);
100  return NULL;
101 }
102 static number EltIntMod(number a, number b, const coeffs r)
103 {
104  Werror("IntMod called on order elts", a, b, r);
105  return NULL;
106 }
107 static number EltExactDiv(number a, number b, const coeffs r)
108 {
109  Werror("%s called\n", __func__, a, b, r);
110  return NULL;
111 }
112  /// init with an integer
113 static number EltInit(long i,const coeffs r)
114 
115 {
116  nforder * O = (nforder*) r->data;
117  if (!O) return NULL; //during init, this seems to be called with O==NULL
118  coeffs C = O->basecoeffs();
119  bigintmat * b = new bigintmat(O->getDim(), 1, C);
120  if (O->oneIsOne()) {
121  basis_elt(b, 1);
122  number I = n_Init(i, C);
123  b->skalmult(I, C);
124  n_Delete(&I, C);
125  return (number) b;
126  } else
127  return NULL;
128 }
129 
130  /// init with a GMP integer
131 static number EltInitMPZ(mpz_t i, const coeffs r)
132 
133 {
134  Werror("%s called\n", __func__);
135  return NULL;
136 }
137  /// how complicated, (0) => 0, or positive
138 static int EltSize(number n, const coeffs r)
139 
140 {
141  Werror("%s called\n", __func__);
142  return NULL;
143 }
144  /// convertion to int, 0 if impossible
145 static long EltInt(number &n, const coeffs r)
146 
147 {
148  Werror("%s called\n", __func__);
149  return NULL;
150 }
151  /// Converts a non-negative number n into a GMP number, 0 if impossible
152 static void EltMPZ(mpz_t result, number &n, const coeffs r)
153 
154 {
155  Werror("%s called\n", __func__);
156 }
157  /// changes argument inline: a:= -a
158  /// return -a! (no copy is returned)
159  /// the result should be assigned to the original argument: e.g. a = n_Neg(a,r)
160 static number EltNeg(number a, const coeffs r)
161  /// return -a
162 {
163  Werror("%s called\n", __func__);
164  return NULL;
165 }
166 static number EltInvers(number a, const coeffs r)
167  /// return 1/a
168 {
169  Werror("%s called\n", __func__);
170  return NULL;
171 }
172 static number EltCopy(number a, const coeffs r)
173 {
174  return EltCreateMat((nforder*)r->data, (bigintmat*)a);
175 }
176 
177 static const char * EltRead(const char * s, number * a, const coeffs r)
178 {
179 // Print("%s called with ->%s-<\n", __func__, s);
180  return s;
181 }
182 
183 static BOOLEAN EltEqual(number a,number b, const coeffs r)
184 {
185  Print("%s called\n", __func__, a, b, r);
186  return 0;
187 }
188 static BOOLEAN EltGreater(number a,number b, const coeffs r)
189 {
190  Print("%s called\n", __func__, a, b, r);
191  return 0;
192 }
193 static BOOLEAN EltIsOne(number a, const coeffs r)
194 {
195 // Print("%s called\n", __func__, a, r);
196  return 0;
197 }
198 static BOOLEAN EltIsMOne(number a, const coeffs r)
199 {
200 // Print("%s called\n", __func__, a, r);
201  return 0;
202 }
203 static BOOLEAN EltGreaterZero(number a, const coeffs r)
204 {
205 // Print("%s called\n", __func__, a, r);
206  return 1;
207 }
208 static BOOLEAN EltIsZero(number a, const coeffs r)
209 {
210  return (a==NULL) || ((bigintmat*)a)->isZero();
211 }
212 
213 static nMapFunc EltSetMap(const coeffs src, const coeffs dst)
214 {
215  Print("%s called\n", __func__, src, dst);
216  return NULL;
217 }
218 
219 static void EltDelete(number * a, const coeffs r)
220 {
221 // Print("Deleting %lx\n%s\n", *a, (((bigintmat*)(*a))->String()));
222 
223  delete (bigintmat*)(*a);
224  *a = NULL;
225 }
226 
227 BOOLEAN n_nfOrderInit(coeffs r, void * parameter)
228 {
230  r->nCoeffIsEqual=order_cmp;
231  r->cfKillChar = KillChar;
232  r->cfSetChar = SetChar;
233  r->cfCoeffString=CoeffString;
234  r->cfCoeffWrite=WriteRing;
235  r->cfWriteShort=EltWrite;
236  r->cfInit = EltInit;
237  r->cfMult = EltMult;
238  r->cfSub = EltSub;
239  r->cfAdd = EltAdd;
240  r->cfDiv = EltDiv;
241  r->cfExactDiv = EltExactDiv;
242  r->cfInitMPZ = EltInitMPZ;
243  r->cfSize = EltSize;
244  r->cfInt = EltInt;
245  r->cfMPZ = EltMPZ;
246  r->cfInpNeg = EltNeg;
247  r->cfInvers = EltInvers;
248  r->cfCopy = EltCopy;
249  r->data = parameter;
250 
251  r->cfWriteLong = EltWrite;
252  r->cfRead =EltRead;
253  r->cfGreater = EltGreater;
254  r->cfEqual = EltEqual;
255  r->cfIsZero = EltIsZero;
256  r->cfIsOne = EltIsOne;
257  r->cfIsMOne = EltIsMOne;
258  r->cfGreaterZero = EltGreaterZero;
259  r->cfDelete = EltDelete;
260  r->cfSetMap = EltSetMap;
261  if (parameter)
262  r->nNULL = EltInit(0, r);
263 #ifdef LDEBUG
264  r->cfDBTest = EltDBTest;
265 #endif
266  return FALSE;
267 }
268 
269 
bigintmat * transpose()
Definition: bigintmat.cc:38
const CanonicalForm int s
Definition: facAbsFact.cc:55
static BOOLEAN EltGreater(number a, number b, const coeffs r)
Definition: nforder_elt.cc:188
bool oneIsOne()
Definition: nforder.h:84
const poly a
Definition: syzextra.cc:212
#define Print
Definition: emacs.cc:83
void elAdd(bigintmat *a, bigintmat *b)
Definition: nforder.cpp:301
static number EltInitMPZ(mpz_t i, const coeffs r)
init with a GMP integer
Definition: nforder_elt.cc:131
if(0 > strat->sl)
Definition: myNF.cc:73
#define FALSE
Definition: auxiliary.h:94
static void KillChar(coeffs r)
Definition: nforder_elt.cc:55
Matrices of numbers.
Definition: bigintmat.h:51
int rows() const
Definition: bigintmat.h:146
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
static number EltCopy(number a, const coeffs r)
Definition: nforder_elt.cc:172
static number EltIntDiv(number a, number b, const coeffs r)
Definition: nforder_elt.cc:97
number EltCreateMat(nforder *a, bigintmat *b)
Definition: nforder_elt.cc:34
#define TRUE
Definition: auxiliary.h:98
BOOLEAN n_nfOrderInit(coeffs r, void *parameter)
Definition: nforder_elt.cc:227
static void EltDelete(number *a, const coeffs r)
Definition: nforder_elt.cc:219
static char * CoeffString(const coeffs r)
Definition: nforder_elt.cc:18
static BOOLEAN EltEqual(number a, number b, const coeffs r)
Definition: nforder_elt.cc:183
n_coeffType nforder_type
void Write()
IO: writes the matrix into the current internal string buffer which must be started/ allocated before...
Definition: bigintmat.cc:416
static BOOLEAN EltIsZero(number a, const coeffs r)
Definition: nforder_elt.cc:208
static long EltInt(number &n, const coeffs r)
convertion to int, 0 if impossible
Definition: nforder_elt.cc:145
const ring r
Definition: syzextra.cc:208
Coefficient rings, fields and other domains suitable for Singular polynomials.
static BOOLEAN EltGreaterZero(number a, const coeffs r)
Definition: nforder_elt.cc:203
#define assume(x)
Definition: mod2.h:394
The main handler for Singular numbers which are suitable for Singular polynomials.
static number EltDiv(number a, number b, const coeffs r)
Definition: nforder_elt.cc:92
static number EltSub(number a, number b, const coeffs r)
Definition: nforder_elt.cc:78
void StringAppendS(const char *st)
Definition: reporter.cc:107
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
bool skalmult(number b, coeffs c)
Multipliziert zur Matrix den Skalar b hinzu.
Definition: bigintmat.cc:948
static void EltWrite(number a, const coeffs r)
Definition: nforder_elt.cc:22
coeffs basecoeffs() const
Definition: nforder.h:76
static number EltIntMod(number a, number b, const coeffs r)
Definition: nforder_elt.cc:102
static BOOLEAN order_cmp(coeffs n, n_coeffType t, void *parameter)
Definition: nforder_elt.cc:50
int cols() const
Definition: bigintmat.h:145
static number EltAdd(number a, number b, const coeffs r)
Definition: nforder_elt.cc:85
static nMapFunc EltSetMap(const coeffs src, const coeffs dst)
Definition: nforder_elt.cc:213
int i
Definition: cfEzgcd.cc:123
static void SetChar(const coeffs r)
Definition: nforder_elt.cc:65
static BOOLEAN EltIsOne(number a, const coeffs r)
Definition: nforder_elt.cc:193
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
void elMult(bigintmat *a, bigintmat *b)
Definition: nforder.cpp:321
static number EltMult(number a, number b, const coeffs r)
Definition: nforder_elt.cc:71
n_coeffType
Definition: coeffs.h:27
#define NULL
Definition: omList.c:10
static number EltInit(long i, const coeffs r)
init with an integer
Definition: nforder_elt.cc:113
static int EltSize(number n, const coeffs r)
how complicated, (0) => 0, or positive
Definition: nforder_elt.cc:138
void basis_elt(bigintmat *m, int i)
Definition: nforder.cpp:422
void elSub(bigintmat *a, bigintmat *b)
Definition: nforder.cpp:311
static void EltMPZ(mpz_t result, number &n, const coeffs r)
Converts a non-negative number n into a GMP number, 0 if impossible.
Definition: nforder_elt.cc:152
static BOOLEAN EltIsMOne(number a, const coeffs r)
Definition: nforder_elt.cc:198
static number EltNeg(number a, const coeffs r)
changes argument inline: a:= -a return -a! (no copy is returned) the result should be assigned to the...
Definition: nforder_elt.cc:160
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459
BOOLEAN EltDBTest(number, const char *, const int, const coeffs)
Definition: nforder_elt.cc:59
int getDim()
Definition: nforder.cpp:235
int BOOLEAN
Definition: auxiliary.h:85
const poly b
Definition: syzextra.cc:213
static number EltInvers(number a, const coeffs r)
return 1/a
Definition: nforder_elt.cc:166
static number EltExactDiv(number a, number b, const coeffs r)
Definition: nforder_elt.cc:107
void Werror(const char *fmt,...)
Definition: reporter.cc:189
static void WriteRing(const coeffs r, BOOLEAN details)
Definition: nforder_elt.cc:13
return result
Definition: facAbsBiFact.cc:76
static const char * EltRead(const char *s, number *a, const coeffs r)
Definition: nforder_elt.cc:177