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