14#if __FLINT_RELEASE >= 20503
23BOOLEAN convSingRFlintR(fmpq_mpoly_ctx_t ctx,
const ring r)
27 fmpq_mpoly_ctx_init(ctx,r->N,ORD_DEGREVLEX);
32 fmpq_mpoly_ctx_init(ctx,r->N,ORD_DEGLEX);
37 fmpq_mpoly_ctx_init(ctx,r->N,ORD_LEX);
43BOOLEAN convSingRFlintR(nmod_mpoly_ctx_t ctx,
const ring r)
47 nmod_mpoly_ctx_init(ctx,r->N,ORD_DEGREVLEX,r->cf->ch);
52 nmod_mpoly_ctx_init(ctx,r->N,ORD_DEGLEX,r->cf->ch);
57 nmod_mpoly_ctx_init(ctx,r->N,ORD_LEX,r->cf->ch);
63BOOLEAN convSingRFlintR(fmpz_mpoly_ctx_t ctx,
const ring r)
67 fmpz_mpoly_ctx_init(ctx,r->N,ORD_DEGREVLEX);
72 fmpz_mpoly_ctx_init(ctx,r->N,ORD_DEGLEX);
77 fmpz_mpoly_ctx_init(ctx,r->N,ORD_LEX);
95static void _fmpq_mpoly_clear_readonly_sing(fmpq_mpoly_t a, fmpq_mpoly_ctx_t ctx)
97 fmpq_mpoly_clear(a, ctx);
100void convSingPFlintMP(fmpq_mpoly_t
res, fmpq_mpoly_ctx_t ctx, poly
p,
int lp,
const ring r)
102 fmpq_mpoly_init2(
res, lp, ctx);
103 ulong*
exp=(ulong*)
omAlloc((r->N+1)*
sizeof(ulong));
111 fmpq_mpoly_push_term_fmpq_ui(
res, c,
exp, ctx);
114 fmpq_mpoly_push_term_fmpq_ui(
res, c, &(
exp[1]), ctx);
119 fmpq_mpoly_reduce(
res, ctx);
123poly convFlintMPSingP(fmpq_mpoly_t
f, fmpq_mpoly_ctx_t ctx,
const ring r)
125 int d=fmpq_mpoly_length(
f,ctx)-1;
127 ulong*
exp=(ulong*)
omAlloc0((r->N+1)*
sizeof(ulong));
130 for(
int i=d;
i>=0;
i--)
132 fmpq_mpoly_get_term_coeff_fmpq(c,
f,
i,ctx);
135 fmpq_mpoly_get_term_exp_ui(
exp,
f,
i,ctx);
138 fmpq_mpoly_get_term_exp_ui(&(
exp[1]),
f,
i,ctx);
153void convSingPFlintMP(fmpz_mpoly_t
res, fmpz_mpoly_ctx_t ctx, poly
p,
int lp,
const ring r)
155 fmpz_mpoly_init2(
res, lp, ctx);
156 ulong*
exp=(ulong*)
omAlloc((r->N+1)*
sizeof(ulong));
164 fmpz_mpoly_push_term_fmpz_ui(
res, c,
exp, ctx);
167 fmpz_mpoly_push_term_fmpz_ui(
res, c, &(
exp[1]), ctx);
175poly convFlintMPSingP(fmpz_mpoly_t
f, fmpz_mpoly_ctx_t ctx,
const ring r)
177 int d=fmpz_mpoly_length(
f,ctx)-1;
179 ulong*
exp=(ulong*)
omAlloc0((r->N+1)*
sizeof(ulong));
182 for(
int i=d;
i>=0;
i--)
184 fmpz_mpoly_get_term_coeff_fmpz(c,
f,
i,ctx);
187 fmpz_mpoly_get_term_exp_ui(
exp,
f,
i,ctx);
190 fmpz_mpoly_get_term_exp_ui(&(
exp[1]),
f,
i,ctx);
205poly convFlintMPSingP(nmod_mpoly_t
f, nmod_mpoly_ctx_t ctx,
const ring r)
207 int d=nmod_mpoly_length(
f,ctx)-1;
209 ulong*
exp=(ulong*)
omAlloc0((r->N+1)*
sizeof(ulong));
210 for(
int i=d;
i>=0;
i--)
212 ulong c=nmod_mpoly_get_term_coeff_ui(
f,
i,ctx);
215 nmod_mpoly_get_term_exp_ui(
exp,
f,
i,ctx);
218 nmod_mpoly_get_term_exp_ui(&(
exp[1]),
f,
i,ctx);
231void convSingPFlintMP(nmod_mpoly_t
res, nmod_mpoly_ctx_t ctx, poly
p,
int lp,
const ring r)
233 nmod_mpoly_init2(
res, lp, ctx);
234 ulong*
exp=(ulong*)
omAlloc((r->N+1)*
sizeof(ulong));
240 nmod_mpoly_push_term_ui_ui(
res, (ulong)n,
exp, ctx);
243 nmod_mpoly_push_term_ui_ui(
res, (ulong)n, &(
exp[1]), ctx);
252poly Flint_Mult_MP(poly
p,
int lp, poly q,
int lq, fmpq_mpoly_ctx_t ctx,
const ring r)
254 fmpq_mpoly_t
pp,qq,
res;
255 convSingPFlintMP(
pp,ctx,
p,lp,r);
256 convSingPFlintMP(qq,ctx,q,
lq,r);
257 fmpq_mpoly_init(
res,ctx);
258 fmpq_mpoly_mul(
res,
pp,qq,ctx);
259 poly pres=convFlintMPSingP(
res,ctx,r);
260 fmpq_mpoly_clear(
res,ctx);
261 _fmpq_mpoly_clear_readonly_sing(
pp,ctx);
262 _fmpq_mpoly_clear_readonly_sing(qq,ctx);
263 fmpq_mpoly_ctx_clear(ctx);
268poly Flint_Mult_MP(poly
p,
int lp, poly q,
int lq, nmod_mpoly_ctx_t ctx,
const ring r)
270 nmod_mpoly_t
pp,qq,
res;
271 convSingPFlintMP(
pp,ctx,
p,lp,r);
272 convSingPFlintMP(qq,ctx,q,
lq,r);
273 nmod_mpoly_init(
res,ctx);
274 nmod_mpoly_mul(
res,
pp,qq,ctx);
275 poly pres=convFlintMPSingP(
res,ctx,r);
276 nmod_mpoly_clear(
res,ctx);
277 nmod_mpoly_clear(
pp,ctx);
278 nmod_mpoly_clear(qq,ctx);
279 nmod_mpoly_ctx_clear(ctx);
284poly Flint_Mult_MP(poly
p,
int lp, poly q,
int lq, fmpz_mpoly_ctx_t ctx,
const ring r)
286 fmpz_mpoly_t
pp,qq,
res;
287 convSingPFlintMP(
pp,ctx,
p,lp,r);
288 convSingPFlintMP(qq,ctx,q,
lq,r);
289 fmpz_mpoly_init(
res,ctx);
290 fmpz_mpoly_mul(
res,
pp,qq,ctx);
291 poly pres=convFlintMPSingP(
res,ctx,r);
292 fmpz_mpoly_clear(
res,ctx);
293 fmpz_mpoly_clear(
pp,ctx);
294 fmpz_mpoly_clear(qq,ctx);
295 fmpz_mpoly_ctx_clear(ctx);
301poly Flint_Divide_MP(poly
p,
int lp, poly q,
int lq, fmpq_mpoly_ctx_t ctx,
const ring r)
303 fmpq_mpoly_t
pp,qq,
res;
304 convSingPFlintMP(
pp,ctx,
p,lp,r);
305 convSingPFlintMP(qq,ctx,q,
lq,r);
306 fmpq_mpoly_init(
res,ctx);
307 fmpq_mpoly_divides(
res,
pp,qq,ctx);
308 poly pres = convFlintMPSingP(
res,ctx,r);
309 fmpq_mpoly_clear(
res,ctx);
310 _fmpq_mpoly_clear_readonly_sing(
pp,ctx);
311 _fmpq_mpoly_clear_readonly_sing(qq,ctx);
312 fmpq_mpoly_ctx_clear(ctx);
317poly Flint_Divide_MP(poly
p,
int lp, poly q,
int lq, nmod_mpoly_ctx_t ctx,
const ring r)
319 nmod_mpoly_t
pp,qq,
res;
320 convSingPFlintMP(
pp,ctx,
p,lp,r);
321 convSingPFlintMP(qq,ctx,q,
lq,r);
322 nmod_mpoly_init(
res,ctx);
323 nmod_mpoly_divides(
res,
pp,qq,ctx);
324 poly pres=convFlintMPSingP(
res,ctx,r);
325 nmod_mpoly_clear(
res,ctx);
326 nmod_mpoly_clear(
pp,ctx);
327 nmod_mpoly_clear(qq,ctx);
328 nmod_mpoly_ctx_clear(ctx);
333poly Flint_GCD_MP(poly
p,
int lp,poly q,
int lq,nmod_mpoly_ctx_t ctx,
const ring r)
335 nmod_mpoly_t
pp,qq,
res;
336 convSingPFlintMP(
pp,ctx,
p,lp,r);
337 convSingPFlintMP(qq,ctx,q,
lq,r);
338 nmod_mpoly_init(
res,ctx);
339 int ok=nmod_mpoly_gcd(
res,
pp,qq,ctx);
343 pres=convFlintMPSingP(
res,ctx,r);
350 nmod_mpoly_clear(
res,ctx);
351 nmod_mpoly_clear(
pp,ctx);
352 nmod_mpoly_clear(qq,ctx);
353 nmod_mpoly_ctx_clear(ctx);
357poly Flint_GCD_MP(poly
p,
int lp,poly q,
int lq,fmpq_mpoly_ctx_t ctx,
const ring r)
359 fmpq_mpoly_t
pp,qq,
res;
360 convSingPFlintMP(
pp,ctx,
p,lp,r);
361 convSingPFlintMP(qq,ctx,q,
lq,r);
362 fmpq_mpoly_init(
res,ctx);
363 int ok=fmpq_mpoly_gcd(
res,
pp,qq,ctx);
369 if (!fmpq_mpoly_is_zero(
res, ctx))
377 pres=convFlintMPSingP(
res,ctx,r);
384 fmpq_mpoly_clear(
res,ctx);
385 _fmpq_mpoly_clear_readonly_sing(
pp,ctx);
386 _fmpq_mpoly_clear_readonly_sing(qq,ctx);
387 fmpq_mpoly_ctx_clear(ctx);
391poly Flint_GCD_MP(poly
p,
int lp,poly q,
int lq,fmpz_mpoly_ctx_t ctx,
const ring r)
393 fmpz_mpoly_t
pp,qq,
res;
394 convSingPFlintMP(
pp,ctx,
p,lp,r);
395 convSingPFlintMP(qq,ctx,q,
lq,r);
396 fmpz_mpoly_init(
res,ctx);
397 int ok=fmpz_mpoly_gcd(
res,
pp,qq,ctx);
402 pres=convFlintMPSingP(
res,ctx,r);
409 fmpz_mpoly_clear(
res,ctx);
410 fmpz_mpoly_clear(
pp,ctx);
411 fmpz_mpoly_clear(qq,ctx);
412 fmpz_mpoly_ctx_clear(ctx);
Coefficient rings, fields and other domains suitable for Singular polynomials.
This file is work in progress and currently not part of the official Singular.
void convSingNFlintN(fmpz_t f, mpz_t z)
void convSingNFlintN_QQ(fmpq_t f, number n)
void convFlintNSingN(mpz_t z, fmpz_t f)
number convFlintNSingN_QQ(fmpq_t f, const coeffs cf)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
gmp_float exp(const gmp_float &a)
#define omFreeSize(addr, size)
static void p_SetExpVL(poly p, int64 *ev, const ring r)
static void p_SetExpV(poly p, int *ev, const ring r)
static void p_Setm(poly p, const ring r)
static void p_GetExpVL(poly p, int64 *ev, const ring r)
static void p_GetExpV(poly p, int *ev, const ring r)
static poly p_Init(const ring r, omBin bin)
BOOLEAN rRing_ord_pure_Dp(const ring r)
BOOLEAN rRing_ord_pure_dp(const ring r)
BOOLEAN rRing_ord_pure_lp(const ring r)