Macaulay2 Engine
Loading...
Searching...
No Matches
ringelement.h
Go to the documentation of this file.
1#ifndef _ringelement_h_
2# define _ringelement_h_
3
52
53# include "engine-includes.hpp"
54
55// TODO: fix this
56# if defined(__cplusplus)
57class Matrix;
58class EngineMonomial;
59class Ring;
60class RingElement;
61# else
62typedef struct Matrix Matrix;
63typedef struct EngineMonomial EngineMonomial;
64typedef struct Ring Ring;
65typedef struct RingElement RingElement;
66# endif
67
71
72# if defined(__cplusplus)
73extern "C" {
74# endif
75
76unsigned int rawRingElementHash(const RingElement *a);
77
79
80M2_string IM2_RingElement_to_string(const RingElement *f);
81
83
84const RingElement *IM2_RingElement_from_rational(const Ring *R, mpq_srcptr r);
85
87
89
91
93
95/* If the ring of a is ZZ, or ZZ/p, this returns the underlying representation.
96 Otherwise, NULL is returned, and an error is given */
97
99
101
103
105
107
108long rawDiscreteLog(const RingElement *h);
109
111
112const RingElement /* or null */ *IM2_RingElement_make_var(const Ring *R, int v);
113
115
117
119 const RingElement *b);
120
121int rawRingElementCompare(const RingElement *a, const RingElement *b);
122
123const RingElement *IM2_RingElement_promote(const Ring *S, const RingElement *f);
124/* drg: connected rawPromote*/
125
126const RingElement /* or null */ *IM2_RingElement_lift(int *success_return,
127 const Ring *S,
128 const RingElement *f);
129/* drg: connected rawLift*/
130// returns null if lifting not possible
131
132/* Is this documentation correct for promote and lift?
133 We have several ways of moving from one ring to the next:
134 R ---> R[x1..xn]
135 R ---> R/I
136 R ---> frac R
137 Z/p[x]/F(x) ---> GF(p,n)
138 R ---> local(R,I) (much later...)
139
140 Both of the following routines assume that S ---> 'this'
141 is one of these construction steps. Promote takes an element of
142 S, and maps it into 'this', while lift goes the other way.
143*/
144
146
148
149const RingElement * /* or null */ rawRingElementAntipode(const RingElement *f);
150
152/* The first component of the degree is used, unless the degree monoid is
153 trivial, in which case the degree of each variable is taken to be 1. Returns
154 lo,hi degree. If the ring is not a graded ring or a polynomial ring then
155 (0,0) is returned.
156*/
157
159 const RingElement *a,
160 int v,
161 int deg,
162 M2_arrayint wts);
163
164const RingElement /* or null */ *
166
167const RingElement /* or null */ *IM2_RingElement_term(const Ring *R,
168 const RingElement *a,
169 const EngineMonomial *m);
170/* R must be a polynomial ring, and 'a' an element of the
171 coefficient ring of R. Returns a*m, if this is a valid
172 element of R. Returns NULL if not (with an error message). */
173
174const RingElement /* or null */ *IM2_RingElement_get_terms(
175 int nvars, /* n variables in an outermost monoid */
176 const RingElement *a,
177 int lo,
178 int hi);
179/* Returns the sum of some monomials of 'a', starting at 'lo',
180 going up to 'hi'. If either of these are negative, they are indices
181 from the back of the polynomial.
182 'a' should be an element of a polynomial ring.
183*/
184
185const RingElement /* or null */ *IM2_RingElement_get_coeff(
186 const Ring *coeffRing, /* ring of the result */
187 const RingElement *a,
188 const EngineMonomial *m);
189/* Return (as an element of the coefficient ring) the coeff
190 of the monomial 'm'.
191 */
192
193const RingElement /* or null */ *IM2_RingElement_lead_coeff(
194 const Ring *coeffRing, /* ring of the result */
195 const RingElement *a);
196
198 int nvars, /* number of variables in an outermost monoid */
199 const RingElement *a);
200
202 int nvars, /* number of variables in an outermost monoid */
203 const RingElement *a);
204
206 const Ring *coeffRing, /* ring of the result coefficients */
207 const RingElement *f);
208
209engine_RawRingElementArray rawGetParts(const M2_arrayint wts,
210 const RingElement *f);
211/* Return an array of RingElement's, each having pure weight, and sorted by
212 strictly increasing weight value. The wt vector values must fit into
213 a word length integer. */
214
215/* FIXME: where to get ring_elem?
216void convolve(const PolyRing *R,
217 const VECTOR(ring_elem) & input_relems,
218 VECTOR(ring_elem) & output_relems,
219 int convolve_type);
220*/
221
222engine_RawRingElementArrayOrNull rawConvolve(engine_RawRingElementArray H,
223 int convolve_type);
224
225const RingElement /* or null */ *rawGetPart(const M2_arrayint wts,
226 const RingElement *f,
227 M2_bool lobound_given,
228 M2_bool hibound_given,
229 long lobound,
230 long hibound);
231/* Return the sum of all of the terms t of f, which satisfy: lobound <= wt.t <=
232 hibound,
233 where, if lobound_given is false, then lobound is -infinity, and if
234 hibound_given
235 is false, then hibound is infinity. */
236
238/* if f is a variable of its ring, then the index of that variable is returned.
239 If f isnot a variable, then -1 is returned. */
240
242/* The list of indices of variables which occur in f is returned. */
243
244const RingElement /* or null */ *rawAssociateDivisor(const RingElement *f);
245
246const RingElement /* or null */ *rawRingElementContent(const RingElement *f);
247// returns the content of f (as a matrix over the base coefficient ring)
248
249const RingElement /* or null */ *rawRingElementRemoveContent(
250 const RingElement *f);
251// returns the polynomial which results after division by the content
252
253const RingElement /* or null */ *rawRingElementSplitContent(
254 const RingElement *f,
255 const RingElement /* or null */ **result);
256// returns the content of f (as a matrix over the base coefficient ring)
257// result is set to the polynomial which results after division by the content
258
259const RingElement /* or null */ *IM2_RingElement_numerator(
260 const RingElement *a);
261
262const RingElement /* or null */ *IM2_RingElement_denominator(
263 const RingElement *a);
264
265const RingElement /* or null */ *IM2_RingElement_fraction(const Ring *R,
266 const RingElement *a,
267 const RingElement *b);
268
270
271const RingElement /* or null */ *rawSchurSnTensorMult(const RingElement *a,
272 const RingElement *b);
273/* the tensor multiplication function in SchurSnRing */
274
275const RingElement /* or null */ *rawSchurFromPartition(const Ring *R,
276 M2_arrayint part);
277// R should be a SchurRing2
278// part should be a partition: a weakly descending list of integers (for now,
279// non-negative)
280// if R has a limit on the size of partitions, then
281
282int rawDegree(int v, const RingElement *f);
283/* Returns -1 if 0 or not implemented for a given ring. For now, valid only for
284 * tower rings */
285
286int rawExtensionDegree(int firstvar, const Ring *R1);
287/* Currently only valid for tower rings. Others return 0. */
288
289const RingElement /* or null */ *rawDiff(int v, const RingElement *f);
290
291const RingElement /* or null */ *rawLowerP(const RingElement *f);
292
293const RingElement /* or null */ *rawPowerMod(const RingElement *f,
294 mpz_srcptr n,
295 const RingElement *g);
296
297// FIXME: there may be repetition after this line
298
299/**************************************************/
300/**** polynomial ring element routines ************/
301/**************************************************/
302
304 const RingElement *a); /* drg: connected rawIsHomogeneous*/
305
307 const RingElement *a); /* drg: connected rawMultiDegree*/
308
310 M2_arrayint wts,
311 const RingElement *a); /* drg: connected rawWeightRange*/
312/* The first component of the degree is used, unless the degree monoid is
313 trivial, in which case the degree of each variable is taken to be 1. Returns
314 lo,hi degree. If the ring is not a graded ring or a polynomial ring then
315 (0,0) is returned.
316*/
317
318const RingElement * /* or null */ rawRingElementAntipode(const RingElement *f);
319/* If the ring is not a skew commuting poly ring, this is the identity map.
320 Otherwise this returns a poly, with the signs of the coefficients possibly
321 changed, this implements the (anti-)isomorphism of the ring and its opposite
322 ring.
323*/
324
325const Matrix * /* or null */ rawHomogenizeMatrix(const Matrix *a,
326 const Matrix *b,
327 const Matrix *c);
328/* TEST dummy function!! */
329
331 const RingElement *a,
332 int v,
333 int deg,
334 M2_arrayint wts); /* drg: connected rawHomogenize*/
335
336const RingElement /* or null */ *IM2_RingElement_homogenize(
337 const RingElement *a,
338 int v,
339 M2_arrayint wts); /* drg: connected rawHomogenize*/
340
341const RingElement /* or null */ *IM2_RingElement_term(
342 const Ring *R,
343 const RingElement *a,
344 const EngineMonomial *m); /* drg: connected rawTerm*/
345/* R must be a polynomial ring, and 'a' an element of the
346 coefficient ring of R. Returns a*m, if this is a valid
347 element of R. Returns NULL if not (with an error message).
348*/
349
350const RingElement /* or null */ *IM2_RingElement_get_terms(
351 int nvars, /* n variables in an outermost monoid */
352 const RingElement *a,
353 int lo,
354 int hi); /* drg: connected rawGetTerms*/
355/* Returns the sum of some monomials of 'a', starting at 'lo',
356 going up to 'hi'. If either of these are negative, they are indices
357 from the back of the polynomial.
358 'a' should be an element of a polynomial ring.
359*/
360
361const RingElement /* or null */ *IM2_RingElement_get_coeff(
362 const Ring *coeffRing, /* ring of the result */
363 const RingElement *a,
364 const EngineMonomial *m); /* drg: connected rawCoefficient*/
365/* Return (as an element of the coefficient ring) the coeff
366 of the monomial 'm'.
367*/
368
369const RingElement /* or null */ *IM2_RingElement_lead_coeff(
370 const Ring *coeffRing, /* ring of the result */
371 const RingElement *a); /* drg: connected rawLeadCoefficient*/
372
374 int nvars, /* number of variables in an outermost monoid */
375 const RingElement *a); /* drg: connected rawLeadMonomial*/
376
378 int nvars, /* number of variables in an outermost monoid */
379 const RingElement *a); /* drg: connected rawTermCount*/
380
382 const Ring *coeffRing, /* ring of the result coefficients */
383 const RingElement *f); /* drg: connected rawPairs */
384
385engine_RawRingElementArrayOrNull rawConvolve(engine_RawRingElementArray H,
386 int convolve_type);
387/* assumes: H[0]..H[n] are in a ring.
388 returns the array determined by convolving H
389 (see def in x-relem.cpp for more info)
390*/
391
392engine_RawRingElementArray rawGetParts(const M2_arrayint wts,
393 const RingElement *f);
394/* Return an array of RingElement's, each having pure weight, and sorted by
395 strictly increasing weight value. The wt vector values must fit into
396 a word length integer. */
397
398const RingElement /* or null */ *rawGetPart(const M2_arrayint wts,
399 const RingElement *f,
400 M2_bool lobound_given,
401 M2_bool hibound_given,
402 long lobound,
403 long hibound);
404/* Return the sum of all of the terms t of f, which satisfy: lobound <= wt.t <=
405 hibound, where, if lobound_given is false, then lobound is -infinity, and if
406 hibound_given is false, then hibound is infinity. */
407
409 const RingElement *f); /* drg: connected rawIndexIfVariable */
410/* if f is a variable of its ring, then the index of that variable is returned.
411 If f is not a variable, then -1 is returned. */
412
414 const RingElement *f); /* drg: connected rawIndices */
415/* The list of indices of variables which occur in f is returned. */
416
417const RingElement /* or null */ *rawAssociateDivisor(const RingElement *f);
418/* A unit 'a' in the base coefficient ring, such that a*f is the preferred
419 associate of f. For example, if f = -9x+6 in QQ[x], then -3 is returned. If
420 the (ultimate) base ring of f is QQ, then a*f has no denominators. If the
421 base ring of f is frac(K[x]), K=ZZ,QQ, or another field, x is a set of vars
422 then a*f is in ZZ[x], or K[x].
423 If the base coefficient ring is the fraction ring of a quotient poly ring,
424 then an error is flagged, and NULL is returned.
425 */
426
428// The content of a ring element, polynomial or vector is defined to be an
429// element of the base (either a finite field, ZZ, QQ, or a fraction)
430// If base is ZZ: the result is the gcd of all of the terms appearing in the
431// polynomial or vector
432// The sign is chosen so that after division by the content the resulting
433// polynomial is monic
434// If base is QQ or frac(A): the numerator is the gcd of all of the numerators,
435// the denominator is the lcm of all of the denominators
436// If base is kk: the result is the lead coefficient. For vectors, what should
437// this mean?
439
440const RingElement /* or null */ *rawRingElementContent(
441 const RingElement *f); /* connect to rawContent */
442// returns the content of f (as a matrix over the base coefficient ring)
443
444const RingElement /* or null */ *rawRingElementRemoveContent(
445 const RingElement *f); /* connect to rawRemoveContent */
446// returns the polynomial which results after division by the content
447
448const RingElement /* or null */ *rawRingElementSplitContent(
449 const RingElement *f,
450 const RingElement /* or null */ **result); /* connect to rawSplitContent */
451// returns the content of f (as a matrix over the base coefficient ring)
452// result is set to the polynomial which results after division by the content
453
454/**************************************************/
455/**** fraction field ring element routines ********/
456/**************************************************/
457
466 const RingElement *a); /* drg: connected rawNumerator*/
467
476 const RingElement *a); /* drg: connected rawDenominator*/
477
478const RingElement /* or null */ *IM2_RingElement_fraction(
479 const Ring *R,
480 const RingElement *a,
481 const RingElement *b); /* drg: connected rawFraction*/
482
483gmp_ZZ /* or null */ rawSchurDimension(
484 const RingElement *f); /* connected rawSchurDimension */
485/* f should be a polynomial whose base ring was created using rawSchurRing
486 (otherwise NULL is returned). If so, the dimension of the corresponding
487 (virtual) GL(n) representation is returned. */
488
489const RingElement /* or null */ *rawSchurFromPartition(const Ring *R,
490 M2_arrayint part);
491/* if R is a SchurRing2, then return the element corresponding to the given
492 * partition */
493
494const RingElement /* or null */ *rawSchurSnTensorMult(const RingElement *f,
495 const RingElement *g);
496/* the tensor multiplication function in SchurSnRing */
497
498long rawDiscreteLog(const RingElement *h); /* drg: connected */
499/* returns -1 if h is 0, or if elements of the ring of h
500 are not represented as powers of a primitive element.
501 Otherwise returns an integer in the range 0..q-1 */
502
503int rawDegree(int v, const RingElement *f); /* connected to rawDegree */
504/* Returns -1 if 0 or not implemented for a given ring. For now, valid only for
505 * tower rings */
506
507int rawExtensionDegree(int v,
508 const Ring *R); /* connected to rawExtensionDegree */
509/* Currently only valid for tower rings. Others return 0. */
510
511const RingElement /* or null */ *rawDiff(int v,
512 const RingElement *f); /* connected */
513/* Currently only valid for tower rings */
514
515const RingElement /* or null */ *rawLowerP(
516 const RingElement *f); /* connected */
517/* Currently only valid for tower rings */
518
519const RingElement *rawTowerTranslatePoly(const Ring *newRing,
520 const RingElement *F);
521/* 2 cases: ring of F is a polynomial ring, and newRing is a Tower.
522 second case: ring of F is a tower, and newRing is a polynomial ring.
523 In both cases, the two rings should have the same characteristic, and the
524 same number of variables. This then translates F, returning the translated
525 poly in the ring newRing.
526*/
527
528const RingElement /* or null */ *rawPowerMod(
529 const RingElement *f,
530 mpz_srcptr n,
531 const RingElement *g); /* connected */
532/* Currently only valid for tower rings */
533
534# if defined(__cplusplus)
535}
536# endif
537
538#endif /* _ringelement_h_ */
539
540// Local Variables:
541// indent-tabs-mode: nil
542// End:
Engine-side immutable monomial value type wrapping a varpower- encoded exponent vector.
Definition monomial.hpp:61
const Ring * R
Definition relem.hpp:68
Front-end-visible "ring element" value: an engine ring_elem paired with the Ring* that gives it meani...
Definition relem.hpp:67
xxx xxx xxx
Definition ring.hpp:102
Engine-wide include prelude — a single point of truth for portability shims.
#define Matrix
Definition factory.cpp:14
VALGRIND_MAKE_MEM_DEFINED & result(result)
mpfr_srcptr gmp_RR
Definition m2-types.h:148
M2_arrayint M2_arrayintOrNull
Definition m2-types.h:99
struct gmp_CC_struct * gmp_CC
Definition m2-types.h:156
engine_RawRingElementArray engine_RawRingElementArrayOrNull
Definition m2-types.h:176
mpq_srcptr gmp_QQorNull
Definition m2-types.h:146
gmp_CCi gmp_CCiorNull
Definition m2-types.h:163
mpfr_srcptr gmp_RRorNull
Definition m2-types.h:149
char M2_bool
Definition m2-types.h:82
gmp_ZZpair gmp_ZZpairOrNull
Definition m2-types.h:211
gmp_CC gmp_CCorNull
Definition m2-types.h:157
mpfi_srcptr gmp_RRi
Definition m2-types.h:153
mpz_srcptr gmp_ZZ
Definition m2-types.h:141
mpz_srcptr gmp_ZZorNull
Definition m2-types.h:142
struct engine_RawRingElementPair_struct * engine_RawRingElementPair
Definition m2-types.h:206
engine_RawArrayPair engine_RawArrayPairOrNull
Definition m2-types.h:184
mpfi_srcptr gmp_RRiorNull
Definition m2-types.h:154
struct gmp_CCi_struct * gmp_CCi
Definition m2-types.h:162
M2_bool IM2_RingElement_is_equal(const RingElement *a, const RingElement *b)
M2_arrayint rawRingElementIndices(const RingElement *f)
int IM2_RingElement_index_if_var(const RingElement *f)
const RingElement * IM2_RingElement_denominator(const RingElement *a)
const RingElement * IM2_RingElement_get_coeff(const Ring *coeffRing, const RingElement *a, const EngineMonomial *m)
const RingElement * rawRingElementRemoveContent(const RingElement *f)
const RingElement * IM2_RingElement_term(const Ring *R, const RingElement *a, const EngineMonomial *m)
const EngineMonomial * IM2_RingElement_lead_monomial(int nvars, const RingElement *a)
M2_bool IM2_RingElement_is_zero(const RingElement *a)
const RingElement * rawLowerP(const RingElement *f)
const RingElement * IM2_RingElement_promote(const Ring *S, const RingElement *f)
gmp_QQorNull IM2_RingElement_to_rational(const RingElement *a)
engine_RawRingElementPair IM2_RingElement_divmod(const RingElement *a, const RingElement *b)
const RingElement * IM2_RingElement_from_ComplexInterval(const Ring *R, gmp_CCi z)
const RingElement * IM2_RingElement_homogenize(const RingElement *a, int v, M2_arrayint wts)
const RingElement * IM2_RingElement_from_BigComplex(const Ring *R, gmp_CC z)
const RingElement * IM2_RingElement_get_terms(int nvars, const RingElement *a, int lo, int hi)
const RingElement * IM2_RingElement_from_Integer(const Ring *R, gmp_ZZ d)
const RingElement * rawGetPart(const M2_arrayint wts, const RingElement *f, M2_bool lobound_given, M2_bool hibound_given, long lobound, long hibound)
const Ring * IM2_RingElement_ring(const RingElement *a)
const RingElement * IM2_RingElement_lead_coeff(const Ring *coeffRing, const RingElement *a)
const RingElement * IM2_RingElement_from_Interval(const Ring *R, gmp_RRi z)
gmp_ZZpairOrNull rawWeightRange(M2_arrayint wts, const RingElement *a)
const Matrix * rawHomogenizeMatrix(const Matrix *a, const Matrix *b, const Matrix *c)
int rawDegree(int v, const RingElement *f)
const RingElement * rawTowerTranslatePoly(const Ring *newRing, const RingElement *F)
Definition tower.cpp:534
unsigned int rawRingElementHash(const RingElement *a)
engine_RawRingElementArray rawGetParts(const M2_arrayint wts, const RingElement *f)
const RingElement * rawMultiplicativeGenerator(const Ring *R)
engine_RawRingElementArrayOrNull rawConvolve(engine_RawRingElementArray H, int convolve_type)
gmp_RRiorNull IM2_RingElement_to_Interval(const RingElement *a)
const RingElement * IM2_RingElement_from_rational(const Ring *R, mpq_srcptr r)
gmp_CCiorNull IM2_RingElement_to_ComplexInterval(const RingElement *a)
M2_string IM2_RingElement_to_string(const RingElement *f)
int rawRingElementCompare(const RingElement *a, const RingElement *b)
gmp_RRorNull IM2_RingElement_to_BigReal(const RingElement *a)
const RingElement * rawRingElementSplitContent(const RingElement *f, const RingElement **result)
const RingElement * rawRingElementAntipode(const RingElement *f)
const RingElement * IM2_RingElement_fraction(const Ring *R, const RingElement *a, const RingElement *b)
const RingElement * rawDiff(int v, const RingElement *f)
int IM2_RingElement_n_terms(int nvars, const RingElement *a)
const RingElement * IM2_RingElement_from_BigReal(const Ring *R, gmp_RR z)
const RingElement * rawSchurFromPartition(const Ring *R, M2_arrayint part)
M2_arrayint IM2_RingElement_multidegree(const RingElement *a)
long rawDiscreteLog(const RingElement *h)
const RingElement * IM2_RingElement_make_var(const Ring *R, int v)
const RingElement * rawSchurSnTensorMult(const RingElement *a, const RingElement *b)
engine_RawArrayPairOrNull IM2_RingElement_list_form(const Ring *coeffRing, const RingElement *f)
const RingElement * IM2_RingElement_homogenize_to_degree(const RingElement *a, int v, int deg, M2_arrayint wts)
const RingElement * rawPowerMod(const RingElement *f, mpz_srcptr n, const RingElement *g)
const RingElement * rawAssociateDivisor(const RingElement *f)
const RingElement * rawRingElementContent(const RingElement *f)
gmp_ZZorNull rawSchurDimension(const RingElement *f)
const RingElement * IM2_RingElement_lift(int *success_return, const Ring *S, const RingElement *f)
M2_bool IM2_RingElement_is_graded(const RingElement *a)
const RingElement * IM2_RingElement_numerator(const RingElement *a)
gmp_ZZorNull IM2_RingElement_to_Integer(const RingElement *a)
int rawExtensionDegree(int firstvar, const Ring *R1)
gmp_CCorNull IM2_RingElement_to_BigComplex(const RingElement *a)