My Project
Macros | Typedefs | Functions | Variables
ring.cc File Reference
#include <cmath>
#include "misc/auxiliary.h"
#include "misc/mylimits.h"
#include "misc/options.h"
#include "misc/int64vec.h"
#include "coeffs/numbers.h"
#include "coeffs/coeffs.h"
#include "polys/monomials/p_polys.h"
#include "polys/simpleideals.h"
#include "polys/monomials/ring.h"
#include "polys/monomials/maps.h"
#include "polys/prCopy.h"
#include "polys/templates/p_Procs.h"
#include "polys/matpol.h"
#include "polys/nc/nc.h"
#include "polys/nc/sca.h"
#include "ext_fields/algext.h"
#include "ext_fields/transext.h"
#include <ctype.h>

Go to the source code of this file.

Macros

#define BITS_PER_LONG   8*SIZEOF_LONG
 
#define MYTEST   0
 
#define pFDeg_CASE(A)   if(r->pFDeg == A) PrintS( "" #A "" )
 
#define rOppVar(R, I)   (rVar(R)+1-I)
 

Typedefs

typedef char * char_ptr
 

Functions

const char * rSimpleOrdStr (int ord)
 
void rDelete (ring r)
 unconditionally deletes fields in r More...
 
static void rSetVarL (ring r)
 set r->VarL_Size, r->VarL_Offset, r->VarL_LowIndex More...
 
static unsigned long rGetDivMask (int bits)
 get r->divmask depending on bits per exponent More...
 
static void rRightAdjustVarOffset (ring r)
 right-adjust r->VarOffset More...
 
static void rOptimizeLDeg (ring r)
 
ring rDefault (const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
 
ring rDefault (int ch, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl)
 
ring rDefault (const coeffs cf, int N, char **n, const rRingOrder_t o)
 
ring rDefault (int ch, int N, char **n)
 
BOOLEAN rCheckIV (const intvec *iv)
 
int rTypeOfMatrixOrder (const intvec *order)
 
int r_IsRingVar (const char *n, char **names, int N)
 
void rWrite (ring r, BOOLEAN details)
 
rRingOrder_t rOrderName (char *ordername)
 
char * rOrdStr (ring r)
 
char * rVarStr (ring r)
 
char * rCharStr (const ring r)
 TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar. More...
 
char * rParStr (ring r)
 
char * rString (ring r)
 
int rChar (ring r)
 
ring nc_rCreateNCcomm_rCopy (ring r)
 
int rSumInternal (ring r1, ring r2, ring &sum, BOOLEAN vartest, BOOLEAN dp_dp)
 returns -1 for not compatible, 1 for compatible (and sum) dp_dp:0: block ordering, 1: dp,dp, 2: aa(...),dp vartest: check for name conflicts More...
 
int rSum (ring r1, ring r2, ring &sum)
 
ring rCopy0 (const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
 
ring rCopy0AndAddA (const ring r, int64vec *wv64, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
 
ring rCopy (ring r)
 
BOOLEAN rEqual (ring r1, ring r2, BOOLEAN qr)
 returns TRUE, if r1 equals r2 FALSE, otherwise Equality is determined componentwise, if qr == 1, then qrideal equality is tested, as well More...
 
BOOLEAN rSamePolyRep (ring r1, ring r2)
 returns TRUE, if r1 and r2 represents the monomials in the same way FALSE, otherwise this is an analogue to rEqual but not so strict More...
 
rOrderType_t rGetOrderType (ring r)
 
BOOLEAN rHas_c_Ordering (const ring r)
 
BOOLEAN rHasSimpleOrder (const ring r)
 
BOOLEAN rHasSimpleLexOrder (const ring r)
 returns TRUE, if simple lp or ls ordering More...
 
BOOLEAN rOrder_is_DegOrdering (const rRingOrder_t order)
 
BOOLEAN rOrder_is_WeightedOrdering (rRingOrder_t order)
 
BOOLEAN rHasSimpleOrderAA (ring r)
 
BOOLEAN rOrd_SetCompRequiresSetm (const ring r)
 return TRUE if p_SetComp requires p_Setm More...
 
BOOLEAN rOrd_is_Totaldegree_Ordering (const ring r)
 
BOOLEAN rOrd_is_WeightedDegree_Ordering (const ring r)
 
BOOLEAN rIsPolyVar (int v, const ring r)
 returns TRUE if var(i) belongs to p-block More...
 
BOOLEAN rDBTest (ring r, const char *fn, const int l)
 
static void rO_Align (int &place, int &bitplace)
 
static void rO_TDegree (int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct)
 
static void rO_TDegree_neg (int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct)
 
static void rO_WDegree (int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct, int *weights)
 
static void rO_WMDegree (int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct, int *weights)
 
static void rO_WDegree64 (int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct, int64 *weights)
 
static void rO_WDegree_neg (int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct, int *weights)
 
static void rO_LexVars (int &place, int &bitplace, int start, int end, int &prev_ord, long *o, int *v, int bits, int opt_var)
 
static void rO_LexVars_neg (int &place, int &bitplace, int start, int end, int &prev_ord, long *o, int *v, int bits, int opt_var)
 
static void rO_Syzcomp (int &place, int &bitplace, int &prev_ord, long *o, sro_ord &ord_struct)
 
static void rO_Syz (int &place, int &bitplace, int &prev_ord, int syz_comp, long *o, sro_ord &ord_struct)
 
static void rO_ISPrefix (int &place, int &bitplace, int &prev_ord, long *o, int, int *v, sro_ord &ord_struct)
 
static void rO_ISSuffix (int &place, int &bitplace, int &prev_ord, long *o, int N, int *v, sro_ord *tmp_typ, int &typ_i, int sgn)
 
static unsigned long rGetExpSize (unsigned long bitmask, int &bits)
 
unsigned long rGetExpSize (unsigned long bitmask, int &bits, int N)
 
ring rModifyRing (ring r, BOOLEAN omit_degree, BOOLEAN try_omit_comp, unsigned long exp_limit)
 
ring rModifyRing_Wp (ring r, int *weights)
 construct Wp, C ring More...
 
ring rModifyRing_Simple (ring r, BOOLEAN ommit_degree, BOOLEAN ommit_comp, unsigned long exp_limit, BOOLEAN &simple)
 
void rKillModifiedRing (ring r)
 
void rKillModified_Wp_Ring (ring r)
 
static void rSetOutParams (ring r)
 
static void rSetFirstWv (ring r, int i, rRingOrder_t *order, int *block1, int **wvhdl)
 
static void rSetDegStuff (ring r)
 
static void rSetNegWeight (ring r)
 
static void rSetOption (ring r)
 
static void rCheckOrdSgn (ring r, int i)
 
void p_SetGlobals (const ring r, BOOLEAN complete)
 set all properties of a new ring - also called by rComplete More...
 
static int sign (int x)
 
BOOLEAN rOrd_is_MixedDegree_Ordering (ring r)
 
BOOLEAN rComplete (ring r, int force)
 this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffset), unless they already exist with force == 1, new fields are always created (overwritten), even if they exist More...
 
void rUnComplete (ring r)
 
void rDebugPrint (const ring r)
 
void p_DebugPrint (poly p, const ring r)
 
static void m_DebugPrint (const poly p, const ring R)
 debug-print monomial poly/vector p, assuming that it lives in the ring R More...
 
void pISUpdateComponents (ideal F, const intvec *const V, const int MIN, const ring r)
 
static void rNChangeSComps (int *currComponents, long *currShiftedComponents, ring r)
 
static void rNGetSComps (int **currComponents, long **currShiftedComponents, ring r)
 
static void rDBChangeSComps (int *currComponents, long *currShiftedComponents, int length, ring r)
 
static void rDBGetSComps (int **currComponents, long **currShiftedComponents, int *length, ring r)
 
void rChangeSComps (int *currComponents, long *currShiftedComponents, int length, ring r)
 
void rGetSComps (int **currComponents, long **currShiftedComponents, int *length, ring r)
 
ring rAssure_SyzOrder (const ring r, BOOLEAN complete)
 
ring rAssure_SyzComp (const ring r, BOOLEAN complete)
 
ring rAssure_TDeg (ring r, int &pos)
 
ring rAssure_HasComp (const ring r)
 
ring rAssure_CompLastBlock (ring r, BOOLEAN complete)
 makes sure that c/C ordering is last ordering More...
 
ring rAssure_SyzComp_CompLastBlock (const ring r)
 makes sure that c/C ordering is last ordering and SyzIndex is first More...
 
static ring rAssure_Global (rRingOrder_t b1, rRingOrder_t b2, const ring r)
 
ring rAssure_InducedSchreyerOrdering (const ring r, BOOLEAN complete, int sgn)
 
ring rAssure_dp_S (const ring r)
 
ring rAssure_dp_C (const ring r)
 
ring rAssure_C_dp (const ring r)
 
ring rAssure_c_dp (const ring r)
 
int rGetISPos (const int p, const ring r)
 Finds p^th IS ordering, and returns its position in r->typ[] returns -1 if something went wrong! p - starts with 0! More...
 
BOOLEAN rSetISReference (const ring r, const ideal F, const int i, const int p)
 Changes r by setting induced ordering parameters: limit and reference leading terms F belong to r, we will DO a copy! We will use it AS IS! returns true is everything was allright! More...
 
void rSetSyzComp (int k, const ring r)
 
int rGetMaxSyzComp (int i, const ring r)
 return the max-comonent wchich has syzIndex i Assume: i<= syzIndex_limit More...
 
BOOLEAN rRing_is_Homog (const ring r)
 
BOOLEAN rRing_has_CompLastBlock (const ring r)
 
BOOLEAN rRing_ord_pure_dp (const ring r)
 
BOOLEAN rRing_ord_pure_Dp (const ring r)
 
BOOLEAN rRing_ord_pure_lp (const ring r)
 
int64rGetWeightVec (const ring r)
 
void rSetWeightVec (ring r, int64 *wv)
 
static int rRealloc1 (ring r, int size, int pos)
 
static void rOppWeight (int *w, int l)
 
ring rOpposite (ring src)
 
ring rEnvelope (ring R)
 
BOOLEAN nc_rComplete (const ring src, ring dest, bool bSetupQuotient)
 
void rModify_a_to_A (ring r)
 
poly rGetVar (const int varIndex, const ring r)
 
int n_IsParam (const number m, const ring r)
 TODO: rewrite somehow... More...
 
ring rPlusVar (const ring r, char *v, int left)
 K[x],"y" -> K[x,y] resp. K[y,x]. More...
 
ring rMinusVar (const ring r, char *v)
 undo rPlusVar More...
 

Variables

VAR omBin sip_sring_bin = omGetSpecBin(sizeof(ip_sring))
 
VAR omBin char_ptr_bin = omGetSpecBin(sizeof(char_ptr))
 
static const char *const ringorder_name []
 
VAR int pDBsyzComp =0
 

Macro Definition Documentation

◆ BITS_PER_LONG

#define BITS_PER_LONG   8*SIZEOF_LONG

Definition at line 40 of file ring.cc.

◆ MYTEST

#define MYTEST   0

Definition at line 2401 of file ring.cc.

◆ pFDeg_CASE

#define pFDeg_CASE (   A)    if(r->pFDeg == A) PrintS( "" #A "" )

◆ rOppVar

#define rOppVar (   R,
 
)    (rVar(R)+1-I)

Definition at line 5250 of file ring.cc.

Typedef Documentation

◆ char_ptr

typedef char* char_ptr

Definition at line 42 of file ring.cc.

Function Documentation

◆ m_DebugPrint()

static void m_DebugPrint ( const poly  p,
const ring  R 
)
inlinestatic

debug-print monomial poly/vector p, assuming that it lives in the ring R

Definition at line 4303 of file ring.cc.

4304 {
4305  Print("\nexp[0..%d]\n", R->ExpL_Size - 1);
4306  for(int i = 0; i < R->ExpL_Size; i++)
4307  Print("%09lx ", p->exp[i]);
4308  PrintLn();
4309  Print("v0:%9ld ", p_GetComp(p, R));
4310  for(int i = 1; i <= R->N; i++) Print(" v%d:%5ld",i, p_GetExp(p, i, R));
4311  PrintLn();
4312 }
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4080
#define Print
Definition: emacs.cc:80
#define p_GetComp(p, r)
Definition: monomials.h:64
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:469
void PrintLn()
Definition: reporter.cc:310
#define R
Definition: sirandom.c:27

◆ n_IsParam()

int n_IsParam ( const number  m,
const ring  r 
)

TODO: rewrite somehow...

if m == var(i)/1 => return i,

Definition at line 5768 of file ring.cc.

5769 {
5770  assume(r != NULL);
5771  const coeffs C = r->cf;
5772  assume(C != NULL);
5773 
5775 
5776  const n_coeffType _filed_type = getCoeffType(C);
5777 
5778  if(( _filed_type == n_algExt )||( _filed_type == n_polyExt ))
5779  return naIsParam(m, C);
5780 
5781  if( _filed_type == n_transExt )
5782  return ntIsParam(m, C);
5783 
5784  Werror("n_IsParam: IsParam is not to be used for (coeff_type = %d)",getCoeffType(C));
5785 
5786  return 0;
5787 }
int naIsParam(number m, const coeffs cf)
if m == var(i)/1 => return i,
Definition: algext.cc:1091
int m
Definition: cfEzgcd.cc:128
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition: coeffs.h:870
n_coeffType
Definition: coeffs.h:28
@ n_polyExt
used to represent polys as coeffcients
Definition: coeffs.h:35
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition: coeffs.h:36
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:39
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
#define assume(x)
Definition: mod2.h:387
The main handler for Singular numbers which are suitable for Singular polynomials.
#define NULL
Definition: omList.c:12
void Werror(const char *fmt,...)
Definition: reporter.cc:189
int ntIsParam(number m, const coeffs cf)
if m == var(i)/1 => return i,
Definition: transext.cc:2216

◆ nc_rComplete()

BOOLEAN nc_rComplete ( const ring  src,
ring  dest,
bool  bSetupQuotient 
)

Definition at line 5657 of file ring.cc.

5662 {
5663 // NOTE: Originally used only by idElimination to transfer NC structure to dest
5664 // ring created by dirty hack (without nc_CallPlural)
5665  rTest(src);
5666 
5667  assume(!rIsPluralRing(dest)); // destination must be a newly constructed commutative ring
5668 
5669  if (!rIsPluralRing(src))
5670  {
5671  return FALSE;
5672  }
5673 
5674  const int N = dest->N;
5675 
5676  assume(src->N == N);
5677 
5678 // ring save = currRing;
5679 
5680 // if (dest != save)
5681 // rChangeCurrRing(dest);
5682 
5683  const ring srcBase = src;
5684 
5685  assume( n_SetMap(srcBase->cf,dest->cf) == n_SetMap(dest->cf,dest->cf) ); // currRing is important here!
5686 
5687  matrix C = mpNew(N,N); // ring independent
5688  matrix D = mpNew(N,N);
5689 
5690  matrix C0 = src->GetNC()->C;
5691  matrix D0 = src->GetNC()->D;
5692 
5693  // map C and D into dest
5694  for (int i = 1; i < N; i++)
5695  {
5696  for (int j = i + 1; j <= N; j++)
5697  {
5698  const number n = n_Copy(p_GetCoeff(MATELEM(C0,i,j), srcBase), srcBase->cf); // src, mapping for coeffs into currRing = dest!
5699  const poly p = p_NSet(n, dest);
5700  MATELEM(C,i,j) = p;
5701  if (MATELEM(D0,i,j) != NULL)
5702  MATELEM(D,i,j) = prCopyR(MATELEM(D0,i,j), srcBase, dest); // ?
5703  }
5704  }
5705  /* One must test C and D _only_ in r->GetNC()->basering!!! not in r!!! */
5706 
5707  id_Test((ideal)C, dest);
5708  id_Test((ideal)D, dest);
5709 
5710  if (nc_CallPlural(C, D, NULL, NULL, dest, bSetupQuotient, false, true, dest)) // also takes care about quotient ideal
5711  {
5712  //WarnS("Error transferring non-commutative structure");
5713  // error message should be in the interpreter interface
5714 
5715  mp_Delete(&C, dest);
5716  mp_Delete(&D, dest);
5717 
5718 // if (currRing != save)
5719 // rChangeCurrRing(save);
5720 
5721  return TRUE;
5722  }
5723 
5724 // mp_Delete(&C, dest); // used by nc_CallPlural!
5725 // mp_Delete(&D, dest);
5726 
5727 // if (dest != save)
5728 // rChangeCurrRing(save);
5729 
5730  assume(rIsPluralRing(dest));
5731  return FALSE;
5732 }
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:452
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition: coeffs.h:723
int j
Definition: facHensel.cc:110
#define D(A)
Definition: gentable.cc:131
BOOLEAN nc_CallPlural(matrix cc, matrix dd, poly cn, poly dn, ring r, bool bSetupQuotient, bool bCopyInput, bool bBeQuiet, ring curr, bool dummy_ring=false)
returns TRUE if there were errors analyze inputs, check them for consistency detects nc_type,...
Definition: old.gring.cc:2682
void mp_Delete(matrix *a, const ring r)
Definition: matpol.cc:880
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29
#define p_GetCoeff(p, r)
Definition: monomials.h:50
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1460
poly prCopyR(poly p, ring src_r, ring dest_r)
Definition: prCopy.cc:34
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:400
#define rTest(r)
Definition: ring.h:790
#define id_Test(A, lR)
Definition: simpleideals.h:78

◆ nc_rCreateNCcomm_rCopy()

ring nc_rCreateNCcomm_rCopy ( ring  r)

Definition at line 720 of file ring.cc.

721 {
722  r = rCopy(r);
723  if (rIsPluralRing(r))
724  return r;
725 
726  matrix C = mpNew(r->N,r->N); // ring-independent!?!
727  matrix D = mpNew(r->N,r->N);
728 
729  for(int i=1; i<r->N; i++)
730  for(int j=i+1; j<=r->N; j++)
731  MATELEM(C,i,j) = p_One( r);
732 
733  if (nc_CallPlural(C, D, NULL, NULL, r, false, true, false, r/*??currRing??*/, TRUE)) // TODO: what about quotient ideal?
734  WarnS("Error initializing multiplication!"); // No reaction!???
735 
736  return r;
737 }
#define WarnS
Definition: emacs.cc:78
poly p_One(const ring r)
Definition: p_polys.cc:1308
ring rCopy(ring r)
Definition: ring.cc:1648

◆ p_DebugPrint()

void p_DebugPrint ( poly  p,
const ring  r 
)

Definition at line 4280 of file ring.cc.

4281 {
4282  int i,j;
4283  p_Write(p,r);
4284  j=2;
4285  while(p!=NULL)
4286  {
4287  Print("\nexp[0..%d]\n",r->ExpL_Size-1);
4288  for(i=0;i<r->ExpL_Size;i++)
4289  Print("%ld ",p->exp[i]);
4290  PrintLn();
4291  Print("v0:%ld ",p_GetComp(p, r));
4292  for(i=1;i<=r->N;i++) Print(" v%d:%ld",i,p_GetExp(p,i, r));
4293  PrintLn();
4294  pIter(p);
4295  j--;
4296  if (j==0) { PrintS("...\n"); break; }
4297  }
4298 }
#define pIter(p)
Definition: monomials.h:37
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:342
void PrintS(const char *s)
Definition: reporter.cc:284

◆ p_SetGlobals()

void p_SetGlobals ( const ring  r,
BOOLEAN  complete 
)

set all properties of a new ring - also called by rComplete

Definition at line 3368 of file ring.cc.

3369 {
3370 // // // if (r->ppNoether!=NULL) p_Delete(&r->ppNoether,r); // ???
3371 
3372  r->pLexOrder=r->LexOrder;
3373  if (complete)
3374  {
3376  si_opt_1 |= r->options;
3377  }
3378 }
VAR unsigned si_opt_1
Definition: options.c:5
#define TEST_RINGDEP_OPTS
Definition: options.h:99

◆ pISUpdateComponents()

void pISUpdateComponents ( ideal  F,
const intvec *const  V,
const int  MIN,
const ring  r 
)

Definition at line 4317 of file ring.cc.

4318 {
4319  assume( V != NULL );
4320  assume( MIN >= 0 );
4321 
4322  if( F == NULL )
4323  return;
4324 
4325  for( int j = (F->ncols*F->nrows) - 1; j >= 0; j-- )
4326  {
4327 #ifdef PDEBUG
4328  Print("F[%d]:", j);
4329  p_wrp(F->m[j], r);
4330 #endif
4331 
4332  for( poly p = F->m[j]; p != NULL; pIter(p) )
4333  {
4334  int c = p_GetComp(p, r);
4335 
4336  if( c > MIN )
4337  {
4338 #ifdef PDEBUG
4339  Print("gen[%d] -> gen(%d)\n", c, MIN + (*V)[ c - MIN - 1 ]);
4340 #endif
4341 
4342  p_SetComp( p, MIN + (*V)[ c - MIN - 1 ], r );
4343  }
4344  }
4345 #ifdef PDEBUG
4346  Print("new F[%d]:", j);
4347  p_Test(F->m[j], r);
4348  p_wrp(F->m[j], r);
4349 #endif
4350  }
4351 }
#define MIN(a, b)
Definition: omDebug.c:102
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
#define p_Test(p, r)
Definition: p_polys.h:162
void p_wrp(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:373

◆ r_IsRingVar()

int r_IsRingVar ( const char *  n,
char **  names,
int  N 
)

Definition at line 212 of file ring.cc.

213 {
214  if (names!=NULL)
215  {
216  for (int i=0; i<N; i++)
217  {
218  if (names[i]==NULL) return -1;
219  if (strcmp(n,names[i]) == 0) return (int)i;
220  }
221  }
222  return -1;
223 }

◆ rAssure_C_dp()

ring rAssure_C_dp ( const ring  r)

Definition at line 4935 of file ring.cc.

4936 {
4938 }
static ring rAssure_Global(rRingOrder_t b1, rRingOrder_t b2, const ring r)
Definition: ring.cc:4768
@ ringorder_C
Definition: ring.h:73
@ ringorder_dp
Definition: ring.h:78

◆ rAssure_c_dp()

ring rAssure_c_dp ( const ring  r)

Definition at line 4940 of file ring.cc.

4941 {
4943 }
@ ringorder_c
Definition: ring.h:72

◆ rAssure_CompLastBlock()

ring rAssure_CompLastBlock ( ring  r,
BOOLEAN  complete 
)

makes sure that c/C ordering is last ordering

Definition at line 4658 of file ring.cc.

4659 {
4660  int last_block = rBlocks(r) - 2;
4661  if (r->order[last_block] != ringorder_c &&
4662  r->order[last_block] != ringorder_C)
4663  {
4664  int c_pos = 0;
4665  int i;
4666 
4667  for (i=0; i< last_block; i++)
4668  {
4669  if (r->order[i] == ringorder_c || r->order[i] == ringorder_C)
4670  {
4671  c_pos = i;
4672  break;
4673  }
4674  }
4675  if (c_pos != -1)
4676  {
4677  ring new_r = rCopy0(r, FALSE, TRUE);
4678  for (i=c_pos+1; i<=last_block; i++)
4679  {
4680  new_r->order[i-1] = new_r->order[i];
4681  new_r->block0[i-1] = new_r->block0[i];
4682  new_r->block1[i-1] = new_r->block1[i];
4683  new_r->wvhdl[i-1] = new_r->wvhdl[i];
4684  }
4685  new_r->order[last_block] = r->order[c_pos];
4686  new_r->block0[last_block] = r->block0[c_pos];
4687  new_r->block1[last_block] = r->block1[c_pos];
4688  new_r->wvhdl[last_block] = r->wvhdl[c_pos];
4689  if (complete)
4690  {
4691  rComplete(new_r, 1);
4692 
4693 #ifdef HAVE_PLURAL
4694  if (rIsPluralRing(r))
4695  {
4696  if ( nc_rComplete(r, new_r, false) ) // no qideal!
4697  {
4698 #ifndef SING_NDEBUG
4699  WarnS("error in nc_rComplete"); // cleanup?// rDelete(res);// return r; // just go on..
4700 #endif
4701  }
4702  }
4703  assume(rIsPluralRing(r) == rIsPluralRing(new_r));
4704 #endif
4705  }
4706  return new_r;
4707  }
4708  }
4709  return r;
4710 }
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition: ring.cc:3403
BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient)
Definition: ring.cc:5657
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1366
static int rBlocks(ring r)
Definition: ring.h:573

◆ rAssure_dp_C()

ring rAssure_dp_C ( const ring  r)

Definition at line 4930 of file ring.cc.

4931 {
4933 }

◆ rAssure_dp_S()

ring rAssure_dp_S ( const ring  r)

Definition at line 4925 of file ring.cc.

4926 {
4928 }
@ ringorder_S
S?
Definition: ring.h:75

◆ rAssure_Global()

static ring rAssure_Global ( rRingOrder_t  b1,
rRingOrder_t  b2,
const ring  r 
)
static

Definition at line 4768 of file ring.cc.

4769 {
4770  int r_blocks = rBlocks(r);
4771 
4772  assume(b1 == ringorder_c || b1 == ringorder_C ||
4773  b2 == ringorder_c || b2 == ringorder_C ||
4774  b2 == ringorder_S);
4775  if ((r_blocks == 3) &&
4776  (r->order[0] == b1) &&
4777  (r->order[1] == b2) &&
4778  (r->order[2] == 0))
4779  return r;
4780  ring res = rCopy0(r, FALSE, FALSE);
4781  res->order = (rRingOrder_t*)omAlloc0(3*sizeof(rRingOrder_t));
4782  res->block0 = (int*)omAlloc0(3*sizeof(int));
4783  res->block1 = (int*)omAlloc0(3*sizeof(int));
4784  res->wvhdl = (int**)omAlloc0(3*sizeof(int*));
4785  res->order[0] = b1;
4786  res->order[1] = b2;
4787  if (b1 == ringorder_c || b1 == ringorder_C)
4788  {
4789  res->block0[1] = 1;
4790  res->block1[1] = r->N;
4791  }
4792  else
4793  {
4794  res->block0[0] = 1;
4795  res->block1[0] = r->N;
4796  }
4797  rComplete(res, 1);
4798  if (r->qideal!=NULL) res->qideal= idrCopyR_NoSort(r->qideal, r, res);
4799 #ifdef HAVE_PLURAL
4800  if (rIsPluralRing(r))
4801  {
4802  if ( nc_rComplete(r, res, false) ) // no qideal!
4803  {
4804 #ifndef SING_NDEBUG
4805  WarnS("error in nc_rComplete");
4806 #endif
4807  }
4808  }
4809 #endif
4810 // rChangeCurrRing(res);
4811  return res;
4812 }
CanonicalForm res
Definition: facAbsFact.cc:60
#define omAlloc0(size)
Definition: omAllocDecl.h:211
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:204
rRingOrder_t
order stuff
Definition: ring.h:68

◆ rAssure_HasComp()

ring rAssure_HasComp ( const ring  r)

Definition at line 4603 of file ring.cc.

4604 {
4605  int last_block;
4606  int i=0;
4607  do
4608  {
4609  if (r->order[i] == ringorder_c ||
4610  r->order[i] == ringorder_C) return r;
4611  if (r->order[i] == 0)
4612  break;
4613  i++;
4614  } while (1);
4615  //WarnS("re-creating ring with comps");
4616  last_block=i-1;
4617 
4618  ring new_r = rCopy0(r, FALSE, FALSE);
4619  i+=2;
4620  new_r->wvhdl=(int **)omAlloc0(i * sizeof(int *));
4621  new_r->order = (rRingOrder_t *) omAlloc0(i * sizeof(rRingOrder_t));
4622  new_r->block0 = (int *) omAlloc0(i * sizeof(int));
4623  new_r->block1 = (int *) omAlloc0(i * sizeof(int));
4624  memcpy(new_r->order,r->order,(i-1) * sizeof(rRingOrder_t));
4625  memcpy(new_r->block0,r->block0,(i-1) * sizeof(int));
4626  memcpy(new_r->block1,r->block1,(i-1) * sizeof(int));
4627  for (int j=0; j<=last_block; j++)
4628  {
4629  if (r->wvhdl[j]!=NULL)
4630  {
4631  new_r->wvhdl[j] = (int*) omMemDup(r->wvhdl[j]);
4632  }
4633  }
4634  last_block++;
4635  new_r->order[last_block]=ringorder_C;
4636  //new_r->block0[last_block]=0;
4637  //new_r->block1[last_block]=0;
4638  //new_r->wvhdl[last_block]=NULL;
4639 
4640  rComplete(new_r, 1);
4641 
4642 #ifdef HAVE_PLURAL
4643  if (rIsPluralRing(r))
4644  {
4645  if ( nc_rComplete(r, new_r, false) ) // no qideal!
4646  {
4647 #ifndef SING_NDEBUG
4648  WarnS("error in nc_rComplete"); // cleanup?// rDelete(res);// return r; // just go on..
4649 #endif
4650  }
4651  }
4652  assume(rIsPluralRing(r) == rIsPluralRing(new_r));
4653 #endif
4654 
4655  return new_r;
4656 }
#define omMemDup(s)
Definition: omAllocDecl.h:264

◆ rAssure_InducedSchreyerOrdering()

ring rAssure_InducedSchreyerOrdering ( const ring  r,
BOOLEAN  complete,
int  sgn 
)

Definition at line 4814 of file ring.cc.

4815 { // TODO: ???? Add leading Syz-comp ordering here...????
4816 
4817 #if MYTEST
4818  Print("rAssure_InducedSchreyerOrdering(r, complete = %d, sgn = %d): r: \n", complete, sgn);
4819  rWrite(r);
4820 #ifdef RDEBUG
4821  rDebugPrint(r);
4822 #endif
4823  PrintLn();
4824 #endif
4825  assume((sgn == 1) || (sgn == -1));
4826 
4827  ring res=rCopy0(r, FALSE, FALSE); // No qideal & ordering copy.
4828 
4829  int n = rBlocks(r); // Including trailing zero!
4830 
4831  // Create 2 more blocks for prefix/suffix:
4832  res->order=(rRingOrder_t *)omAlloc0((n+2)*sizeof(rRingOrder_t)); // 0 .. n+1
4833  res->block0=(int *)omAlloc0((n+2)*sizeof(int));
4834  res->block1=(int *)omAlloc0((n+2)*sizeof(int));
4835  int ** wvhdl =(int **)omAlloc0((n+2)*sizeof(int**));
4836 
4837  // Encapsulate all existing blocks between induced Schreyer ordering markers: prefix and suffix!
4838  // Note that prefix and suffix have the same ringorder marker and only differ in block[] parameters!
4839 
4840  // new 1st block
4841  int j = 0;
4842  res->order[j] = ringorder_IS; // Prefix
4843  res->block0[j] = res->block1[j] = 0;
4844  // wvhdl[j] = NULL;
4845  j++;
4846 
4847  for(int i = 0; (i <= n) && (r->order[i] != 0); i++, j++) // i = [0 .. n-1] <- non-zero old blocks
4848  {
4849  res->order [j] = r->order [i];
4850  res->block0[j] = r->block0[i];
4851  res->block1[j] = r->block1[i];
4852 
4853  if (r->wvhdl[i] != NULL)
4854  {
4855  wvhdl[j] = (int*) omMemDup(r->wvhdl[i]);
4856  } // else wvhdl[j] = NULL;
4857  }
4858 
4859  // new last block
4860  res->order [j] = ringorder_IS; // Suffix
4861  res->block0[j] = res->block1[j] = sgn; // Sign of v[o]: 1 for C, -1 for c
4862  // wvhdl[j] = NULL;
4863  j++;
4864 
4865  // res->order [j] = 0; // The End!
4866  res->wvhdl = wvhdl;
4867 
4868  // j == the last zero block now!
4869  assume(j == (n+1));
4870  assume(res->order[0]==ringorder_IS);
4871  assume(res->order[j-1]==ringorder_IS);
4872  assume(res->order[j]==0);
4873 
4874 
4875  if (complete)
4876  {
4877  rComplete(res, 1);
4878 
4879 #ifdef HAVE_PLURAL
4880  if (rIsPluralRing(r))
4881  {
4882  if ( nc_rComplete(r, res, false) ) // no qideal!
4883  {
4884 #ifndef SING_NDEBUG
4885  WarnS("error in nc_rComplete"); // cleanup?// rDelete(res);// return r; // just go on..
4886 #endif
4887  }
4888  }
4890 #endif
4891 
4892 
4893 #ifdef HAVE_PLURAL
4894  ring old_ring = r;
4895 #endif
4896 
4897  if (r->qideal!=NULL)
4898  {
4899  res->qideal= idrCopyR_NoSort(r->qideal, r, res);
4900 
4901  assume(id_RankFreeModule(res->qideal, res) == 0);
4902 
4903 #ifdef HAVE_PLURAL
4904  if( rIsPluralRing(res) )
4905  if( nc_SetupQuotient(res, r, true) )
4906  {
4907 // WarnS("error in nc_SetupQuotient"); // cleanup? rDelete(res); return r; // just go on...?
4908  }
4909 
4910 #endif
4911  assume(id_RankFreeModule(res->qideal, res) == 0);
4912  }
4913 
4914 #ifdef HAVE_PLURAL
4915  assume((res->qideal==NULL) == (old_ring->qideal==NULL));
4916  assume(rIsPluralRing(res) == rIsPluralRing(old_ring));
4917  assume(rIsSCA(res) == rIsSCA(old_ring));
4918  assume(ncRingType(res) == ncRingType(old_ring));
4919 #endif
4920  }
4921 
4922  return res;
4923 }
int sgn(const Rational &a)
Definition: GMPrat.cc:430
static bool rIsSCA(const ring r)
Definition: nc.h:190
bool nc_SetupQuotient(ring rGR, const ring rG=NULL, bool bCopy=false)
Definition: old.gring.cc:3403
static nc_type & ncRingType(nc_struct *p)
Definition: nc.h:159
void rWrite(ring r, BOOLEAN details)
Definition: ring.cc:226
void rDebugPrint(const ring r)
Definition: ring.cc:4075
@ ringorder_IS
Induced (Schreyer) ordering.
Definition: ring.h:93
long id_RankFreeModule(ideal s, ring lmRing, ring tailRing)
return the maximal component number found in any polynomial in s

◆ rAssure_SyzComp()

ring rAssure_SyzComp ( const ring  r,
BOOLEAN  complete 
)

Definition at line 4426 of file ring.cc.

4427 {
4428  if ( r->order[0] == ringorder_s ) return r;
4429 
4430  if ( r->order[0] == ringorder_IS )
4431  {
4432 #ifndef SING_NDEBUG
4433  WarnS("rAssure_SyzComp: input ring has an IS-ordering!");
4434 #endif
4435 // return r;
4436  }
4437  ring res=rCopy0(r, FALSE, FALSE);
4438  int i=rBlocks(r);
4439  int j;
4440 
4441  res->order=(rRingOrder_t *)omAlloc((i+1)*sizeof(rRingOrder_t));
4442  res->block0=(int *)omAlloc0((i+1)*sizeof(int));
4443  res->block1=(int *)omAlloc0((i+1)*sizeof(int));
4444  int ** wvhdl =(int **)omAlloc0((i+1)*sizeof(int**));
4445  for(j=i;j>0;j--)
4446  {
4447  res->order[j]=r->order[j-1];
4448  res->block0[j]=r->block0[j-1];
4449  res->block1[j]=r->block1[j-1];
4450  if (r->wvhdl[j-1] != NULL)
4451  {
4452  wvhdl[j] = (int*) omMemDup(r->wvhdl[j-1]);
4453  }
4454  }
4455  res->order[0]=ringorder_s;
4456 
4457  res->wvhdl = wvhdl;
4458 
4459  if (complete)
4460  {
4461  rComplete(res, 1);
4462 #ifdef HAVE_PLURAL
4463  if (rIsPluralRing(r))
4464  {
4465  if ( nc_rComplete(r, res, false) ) // no qideal!
4466  {
4467 #ifndef SING_NDEBUG
4468  WarnS("error in nc_rComplete"); // cleanup?// rDelete(res);// return r; // just go on..
4469 #endif
4470  }
4471  }
4473 #endif
4474 
4475 #ifdef HAVE_PLURAL
4476  ring old_ring = r;
4477 #endif
4478  if (r->qideal!=NULL)
4479  {
4480  res->qideal= idrCopyR_NoSort(r->qideal, r, res);
4481  assume(id_RankFreeModule(res->qideal, res) == 0);
4482 #ifdef HAVE_PLURAL
4483  if( rIsPluralRing(res) )
4484  {
4485  if( nc_SetupQuotient(res, r, true) )
4486  {
4487 // WarnS("error in nc_SetupQuotient"); // cleanup? rDelete(res); return r; // just go on...?
4488  }
4489  assume(id_RankFreeModule(res->qideal, res) == 0);
4490  }
4491 #endif
4492  }
4493 
4494 #ifdef HAVE_PLURAL
4495  assume((res->qideal==NULL) == (old_ring->qideal==NULL));
4496  assume(rIsPluralRing(res) == rIsPluralRing(old_ring));
4497  assume(rIsSCA(res) == rIsSCA(old_ring));
4498  assume(ncRingType(res) == ncRingType(old_ring));
4499 #endif
4500  }
4501  return res;
4502 }
#define omAlloc(size)
Definition: omAllocDecl.h:210
@ ringorder_s
s?
Definition: ring.h:76

◆ rAssure_SyzComp_CompLastBlock()

ring rAssure_SyzComp_CompLastBlock ( const ring  r)

makes sure that c/C ordering is last ordering and SyzIndex is first

? rChangeCurrRing(new_r);

Definition at line 4713 of file ring.cc.

4714 {
4715  rTest(r);
4716 
4717  ring new_r_1 = rAssure_CompLastBlock(r, FALSE); // due to this FALSE - no completion!
4718  ring new_r = rAssure_SyzComp(new_r_1, FALSE); // new_r_1 is used only here!!!
4719 
4720  if (new_r == r)
4721  return r;
4722 
4723  ring old_r = r;
4724  if (new_r_1 != new_r && new_r_1 != old_r) rDelete(new_r_1);
4725 
4726  rComplete(new_r, TRUE);
4727 #ifdef HAVE_PLURAL
4728  if (rIsPluralRing(old_r))
4729  {
4730  if ( nc_rComplete(old_r, new_r, false) ) // no qideal!
4731  {
4732 # ifndef SING_NDEBUG
4733  WarnS("error in nc_rComplete"); // cleanup? rDelete(res); return r; // just go on...?
4734 # endif
4735  }
4736  }
4737 #endif
4738 
4739 ///? rChangeCurrRing(new_r);
4740  if (old_r->qideal != NULL)
4741  {
4742  new_r->qideal = idrCopyR(old_r->qideal, old_r, new_r);
4743  }
4744 
4745 #ifdef HAVE_PLURAL
4746  if( rIsPluralRing(old_r) )
4747  if( nc_SetupQuotient(new_r, old_r, true) )
4748  {
4749 #ifndef SING_NDEBUG
4750  WarnS("error in nc_SetupQuotient"); // cleanup? rDelete(res); return r; // just go on...?
4751 #endif
4752  }
4753 #endif
4754 
4755 #ifdef HAVE_PLURAL
4756  assume((new_r->qideal==NULL) == (old_r->qideal==NULL));
4757  assume(rIsPluralRing(new_r) == rIsPluralRing(old_r));
4758  assume(rIsSCA(new_r) == rIsSCA(old_r));
4759  assume(ncRingType(new_r) == ncRingType(old_r));
4760 #endif
4761 
4762  rTest(new_r);
4763  rTest(old_r);
4764  return new_r;
4765 }
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:191
ring rAssure_SyzComp(const ring r, BOOLEAN complete)
Definition: ring.cc:4426
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:449
ring rAssure_CompLastBlock(ring r, BOOLEAN complete)
makes sure that c/C ordering is last ordering
Definition: ring.cc:4658

◆ rAssure_SyzOrder()

ring rAssure_SyzOrder ( const ring  r,
BOOLEAN  complete 
)

Definition at line 4421 of file ring.cc.

4422 {
4423  if ( r->order[0] == ringorder_c ) return r;
4424  return rAssure_SyzComp(r,complete);
4425 }

◆ rAssure_TDeg()

ring rAssure_TDeg ( ring  r,
int &  pos 
)

Definition at line 4504 of file ring.cc.

4505 {
4506  if (r->N==1) // special: dp(1)==lp(1)== no entry in typ
4507  {
4508  pos=r->VarL_LowIndex;
4509  return r;
4510  }
4511  if (r->typ!=NULL)
4512  {
4513  for(int i=r->OrdSize-1;i>=0;i--)
4514  {
4515  if ((r->typ[i].ord_typ==ro_dp)
4516  && (r->typ[i].data.dp.start==1)
4517  && (r->typ[i].data.dp.end==r->N))
4518  {
4519  pos=r->typ[i].data.dp.place;
4520  //printf("no change, pos=%d\n",pos);
4521  return r;
4522  }
4523  }
4524  }
4525 
4526 #ifdef HAVE_PLURAL
4527  nc_struct* save=r->GetNC();
4528  r->GetNC()=NULL;
4529 #endif
4530  ring res=rCopy(r);
4531  if (res->qideal!=NULL)
4532  {
4533  id_Delete(&res->qideal,r);
4534  }
4535 
4536  int i=rBlocks(r);
4537  int j;
4538 
4539  res->ExpL_Size=r->ExpL_Size+1; // one word more in each monom
4540  res->PolyBin=omGetSpecBin(POLYSIZE + (res->ExpL_Size)*sizeof(long));
4541  omFree((ADDRESS)res->ordsgn);
4542  res->ordsgn=(long *)omAlloc0(res->ExpL_Size*sizeof(long));
4543  for(j=0;j<r->CmpL_Size;j++)
4544  {
4545  res->ordsgn[j] = r->ordsgn[j];
4546  }
4547  res->OrdSize=r->OrdSize+1; // one block more for pSetm
4548  if (r->typ!=NULL)
4549  omFree((ADDRESS)res->typ);
4550  res->typ=(sro_ord*)omAlloc0(res->OrdSize*sizeof(sro_ord));
4551  if (r->typ!=NULL)
4552  memcpy(res->typ,r->typ,r->OrdSize*sizeof(sro_ord));
4553  // the additional block for pSetm: total degree at the last word
4554  // but not included in the compare part
4555  res->typ[res->OrdSize-1].ord_typ=ro_dp;
4556  res->typ[res->OrdSize-1].data.dp.start=1;
4557  res->typ[res->OrdSize-1].data.dp.end=res->N;
4558  res->typ[res->OrdSize-1].data.dp.place=res->ExpL_Size-1;
4559  pos=res->ExpL_Size-1;
4560  //res->pOrdIndex=pos; //NO: think of a(1,0),dp !
4561  extern void p_Setm_General(poly p, ring r);
4562  res->p_Setm=p_Setm_General;
4563  // ----------------------------
4564  omFree((ADDRESS)res->p_Procs);
4565  res->p_Procs = (p_Procs_s*)omAlloc(sizeof(p_Procs_s));
4566 
4567  p_ProcsSet(res, res->p_Procs);
4568 #ifdef HAVE_PLURAL
4569  r->GetNC()=save;
4570  if (rIsPluralRing(r))
4571  {
4572  if ( nc_rComplete(r, res, false) ) // no qideal!
4573  {
4574 #ifndef SING_NDEBUG
4575  WarnS("error in nc_rComplete");
4576 #endif
4577  // just go on..
4578  }
4579  }
4580 #endif
4581  if (r->qideal!=NULL)
4582  {
4583  res->qideal=idrCopyR_NoSort(r->qideal,r, res);
4584 #ifdef HAVE_PLURAL
4585  if (rIsPluralRing(res))
4586  {
4587 // nc_SetupQuotient(res, currRing);
4588  nc_SetupQuotient(res, r); // ?
4589  }
4590  assume((res->qideal==NULL) == (r->qideal==NULL));
4591 #endif
4592  }
4593 
4594 #ifdef HAVE_PLURAL
4596  assume(rIsSCA(res) == rIsSCA(r));
4597  assume(ncRingType(res) == ncRingType(r));
4598 #endif
4599 
4600  return res;
4601 }
void * ADDRESS
Definition: auxiliary.h:119
#define POLYSIZE
Definition: monomials.h:233
#define omFree(addr)
Definition: omAllocDecl.h:261
#define omGetSpecBin(size)
Definition: omBin.h:11
void p_ProcsSet(ring r, p_Procs_s *p_Procs)
Definition: p_Procs_Set.h:141
void p_Setm_General(poly p, const ring r)
Definition: p_polys.cc:157
struct p_Procs_s p_Procs_s
Definition: ring.h:23
@ ro_dp
Definition: ring.h:52
Definition: ring.h:219
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition: nc.h:68

◆ rChangeSComps()

void rChangeSComps ( int *  currComponents,
long *  currShiftedComponents,
int  length,
ring  r 
)

Definition at line 4396 of file ring.cc.

4397 {
4398 #ifdef PDEBUG
4399  rDBChangeSComps(currComponents, currShiftedComponents, length, r);
4400 #else
4401  rNChangeSComps(currComponents, currShiftedComponents, r);
4402 #endif
4403 }
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:257
static void rNChangeSComps(int *currComponents, long *currShiftedComponents, ring r)
Definition: ring.cc:4358
static void rDBChangeSComps(int *currComponents, long *currShiftedComponents, int length, ring r)
Definition: ring.cc:4374
EXTERN_VAR long * currShiftedComponents
Definition: syz.h:118

◆ rChar()

int rChar ( ring  r)

Definition at line 714 of file ring.cc.

714 { return r->cf->ch; }

◆ rCharStr()

char* rCharStr ( const ring  r)

TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.

Definition at line 648 of file ring.cc.

648 { assume( r != NULL ); return nCoeffString(r->cf); }
static FORCE_INLINE char * nCoeffString(const coeffs cf)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition: coeffs.h:983

◆ rCheckIV()

BOOLEAN rCheckIV ( const intvec iv)

Definition at line 175 of file ring.cc.

176 {
177  if ((iv->length()!=2)&&(iv->length()!=3))
178  {
179  WerrorS("weights only for orderings wp,ws,Wp,Ws,a,M");
180  return TRUE;
181  }
182  return FALSE;
183 }
int length() const
Definition: intvec.h:94
void WerrorS(const char *s)
Definition: feFopen.cc:24

◆ rCheckOrdSgn()

static void rCheckOrdSgn ( ring  r,
int  i 
)
static

Definition at line 3805 of file ring.cc.

3806 { // set r->OrdSgn, r->MixedOrder
3807  // for each variable:
3808  int nonpos=0;
3809  int nonneg=0;
3810  for(int i=1;i<=r->N;i++)
3811  {
3812  int found=0;
3813  // for all blocks:
3814  for(int j=0;(j<=b) && (found==0);j++)
3815  {
3816  // search the first block containing var(i)
3817  if ((r->block0[j]<=i)&&(r->block1[j]>=i))
3818  {
3819  // what kind if block is it?
3820  if ((r->order[j]==ringorder_ls)
3821  || (r->order[j]==ringorder_ds)
3822  || (r->order[j]==ringorder_Ds)
3823  || (r->order[j]==ringorder_ws)
3824  || (r->order[j]==ringorder_Ws)
3825  || (r->order[j]==ringorder_rs))
3826  {
3827  r->OrdSgn=-1;
3828  nonpos++;
3829  found=1;
3830  }
3831  else if((r->order[j]==ringorder_a)
3832  ||(r->order[j]==ringorder_aa))
3833  {
3834  // <0: local/mixed ordering
3835  // >0: var(i) is okay, look at other vars
3836  // ==0: look at other blocks for var(i)
3837  if(r->wvhdl[j][i-r->block0[j]]<0)
3838  {
3839  r->OrdSgn=-1;
3840  nonpos++;
3841  found=1;
3842  }
3843  else if(r->wvhdl[j][i-r->block0[j]]>0)
3844  {
3845  nonneg++;
3846  found=1;
3847  }
3848  }
3849  else if(r->order[j]==ringorder_M)
3850  {
3851  // <0: local/mixed ordering
3852  // >0: var(i) is okay, look at other vars
3853  // ==0: look at other blocks for var(i)
3854  if(r->wvhdl[j][i-r->block0[j]]<0)
3855  {
3856  r->OrdSgn=-1;
3857  nonpos++;
3858  found=1;
3859  }
3860  else if(r->wvhdl[j][i-r->block0[j]]>0)
3861  {
3862  nonneg++;
3863  found=1;
3864  }
3865  else
3866  {
3867  // very bad: try next row(s)
3868  int add=r->block1[j]-r->block0[j]+1;
3869  int max_i=r->block0[j]+add*add-add-1;
3870  while(found==0)
3871  {
3872  i+=add;
3873  if (r->wvhdl[j][i-r->block0[j]]<0)
3874  {
3875  r->OrdSgn=-1;
3876  nonpos++;
3877  found=1;
3878  }
3879  else if(r->wvhdl[j][i-r->block0[j]]>0)
3880  {
3881  nonneg++;
3882  found=1;
3883  }
3884  else if(i>max_i)
3885  {
3886  nonpos++;
3887  nonneg++;
3888  found=1;
3889  }
3890  }
3891  }
3892  }
3893  else if ((r->order[j]==ringorder_lp)
3894  || (r->order[j]==ringorder_dp)
3895  || (r->order[j]==ringorder_Dp)
3896  || (r->order[j]==ringorder_wp)
3897  || (r->order[j]==ringorder_Wp)
3898  || (r->order[j]==ringorder_rp))
3899  {
3900  found=1;
3901  nonneg++;
3902  }
3903  }
3904  }
3905  }
3906  if (nonpos>0)
3907  {
3908  r->OrdSgn=-1;
3909  if (nonneg>0) r->MixedOrder=1;
3910  }
3911  else
3912  {
3913  r->OrdSgn=1;
3914  r->MixedOrder=0;
3915  }
3916 }
CanonicalForm b
Definition: cfModGcd.cc:4105
bool found
Definition: facFactorize.cc:55
STATIC_VAR unsigned add[]
Definition: misc_ip.cc:115
@ ringorder_lp
Definition: ring.h:77
@ ringorder_a
Definition: ring.h:70
@ ringorder_rs
opposite of ls
Definition: ring.h:92
@ ringorder_ds
Definition: ring.h:84
@ ringorder_Dp
Definition: ring.h:80
@ ringorder_Ds
Definition: ring.h:85
@ ringorder_rp
Definition: ring.h:79
@ ringorder_aa
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition: ring.h:91
@ ringorder_Wp
Definition: ring.h:82
@ ringorder_ws
Definition: ring.h:86
@ ringorder_Ws
Definition: ring.h:87
@ ringorder_ls
Definition: ring.h:83
@ ringorder_wp
Definition: ring.h:81
@ ringorder_M
Definition: ring.h:74

◆ rComplete()

BOOLEAN rComplete ( ring  r,
int  force 
)

this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffset), unless they already exist with force == 1, new fields are always created (overwritten), even if they exist

Definition at line 3403 of file ring.cc.

3404 {
3405  if (r->VarOffset!=NULL && force == 0) return FALSE;
3406  rSetOutParams(r);
3407  int n=rBlocks(r)-1;
3408  int i;
3409  int bits;
3410  r->bitmask=rGetExpSize(r->wanted_maxExp,bits,r->N);
3411  r->BitsPerExp = bits;
3412  r->ExpPerLong = BIT_SIZEOF_LONG / bits;
3413  r->divmask=rGetDivMask(bits);
3414 
3415  // will be used for ordsgn:
3416  long *tmp_ordsgn=(long *)omAlloc0(3*(n+r->N)*sizeof(long));
3417  // will be used for VarOffset:
3418  int *v=(int *)omAlloc((r->N+1)*sizeof(int));
3419  for(i=r->N; i>=0 ; i--)
3420  {
3421  v[i]=-1;
3422  }
3423  sro_ord *tmp_typ=(sro_ord *)omAlloc0(3*(n+r->N)*sizeof(sro_ord));
3424  int typ_i=0;
3425  int prev_ordsgn=0;
3426 
3427  // fill in v, tmp_typ, tmp_ordsgn, determine typ_i (== ordSize)
3428  int j=0;
3429  int j_bits=BITS_PER_LONG;
3430 
3431  BOOLEAN need_to_add_comp=FALSE; // Only for ringorder_s and ringorder_S!
3432 
3433  for(i=0;i<n;i++)
3434  {
3435  tmp_typ[typ_i].order_index=i;
3436  switch (r->order[i])
3437  {
3438  case ringorder_a:
3439  case ringorder_aa:
3440  rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],
3441  r->wvhdl[i]);
3442  typ_i++;
3443  break;
3444 
3445  case ringorder_am:
3446  rO_WMDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],
3447  r->wvhdl[i]);
3448  typ_i++;
3449  break;
3450 
3451  case ringorder_a64:
3452  rO_WDegree64(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3453  tmp_typ[typ_i], (int64 *)(r->wvhdl[i]));
3454  typ_i++;
3455  break;
3456 
3457  case ringorder_c:
3458  rO_Align(j, j_bits);
3459  rO_LexVars_neg(j, j_bits, 0,0, prev_ordsgn,tmp_ordsgn,v,BITS_PER_LONG, -1);
3460  r->ComponentOrder=1;
3461  break;
3462 
3463  case ringorder_C:
3464  rO_Align(j, j_bits);
3465  rO_LexVars(j, j_bits, 0,0, prev_ordsgn,tmp_ordsgn,v,BITS_PER_LONG, -1);
3466  r->ComponentOrder=-1;
3467  break;
3468 
3469  case ringorder_M:
3470  {
3471  int k,l;
3472  k=r->block1[i]-r->block0[i]+1; // number of vars
3473  for(l=0;l<k;l++)
3474  {
3475  rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3476  tmp_typ[typ_i],
3477  r->wvhdl[i]+(r->block1[i]-r->block0[i]+1)*l);
3478  typ_i++;
3479  }
3480  break;
3481  }
3482 
3483  case ringorder_lp:
3484  rO_LexVars(j, j_bits, r->block0[i],r->block1[i], prev_ordsgn,
3485  tmp_ordsgn,v,bits, -1);
3486  break;
3487 
3488  case ringorder_ls:
3489  rO_LexVars_neg(j, j_bits, r->block0[i],r->block1[i], prev_ordsgn,
3490  tmp_ordsgn,v, bits, -1);
3491  break;
3492 
3493  case ringorder_rs:
3494  rO_LexVars_neg(j, j_bits, r->block1[i],r->block0[i], prev_ordsgn,
3495  tmp_ordsgn,v, bits, -1);
3496  break;
3497 
3498  case ringorder_rp:
3499  rO_LexVars(j, j_bits, r->block1[i],r->block0[i], prev_ordsgn,
3500  tmp_ordsgn,v, bits, -1);
3501  break;
3502 
3503  case ringorder_dp:
3504  if (r->block0[i]==r->block1[i])
3505  {
3506  rO_LexVars(j, j_bits, r->block0[i],r->block0[i], prev_ordsgn,
3507  tmp_ordsgn,v, bits, -1);
3508  }
3509  else
3510  {
3511  rO_TDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3512  tmp_typ[typ_i]);
3513  typ_i++;
3514  rO_LexVars_neg(j, j_bits, r->block1[i],r->block0[i]+1,
3515  prev_ordsgn,tmp_ordsgn,v,bits, r->block0[i]);
3516  }
3517  break;
3518 
3519  case ringorder_Dp:
3520  if (r->block0[i]==r->block1[i])
3521  {
3522  rO_LexVars(j, j_bits, r->block0[i],r->block0[i], prev_ordsgn,
3523  tmp_ordsgn,v, bits, -1);
3524  }
3525  else
3526  {
3527  rO_TDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3528  tmp_typ[typ_i]);
3529  typ_i++;
3530  rO_LexVars(j, j_bits, r->block0[i],r->block1[i]-1, prev_ordsgn,
3531  tmp_ordsgn,v, bits, r->block1[i]);
3532  }
3533  break;
3534 
3535  case ringorder_ds:
3536  if (r->block0[i]==r->block1[i])
3537  {
3538  rO_LexVars_neg(j, j_bits,r->block0[i],r->block1[i],prev_ordsgn,
3539  tmp_ordsgn,v,bits, -1);
3540  }
3541  else
3542  {
3543  rO_TDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3544  tmp_typ[typ_i]);
3545  typ_i++;
3546  rO_LexVars_neg(j, j_bits, r->block1[i],r->block0[i]+1,
3547  prev_ordsgn,tmp_ordsgn,v,bits, r->block0[i]);
3548  }
3549  break;
3550 
3551  case ringorder_Ds:
3552  if (r->block0[i]==r->block1[i])
3553  {
3554  rO_LexVars_neg(j, j_bits, r->block0[i],r->block0[i],prev_ordsgn,
3555  tmp_ordsgn,v, bits, -1);
3556  }
3557  else
3558  {
3559  rO_TDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3560  tmp_typ[typ_i]);
3561  typ_i++;
3562  rO_LexVars(j, j_bits, r->block0[i],r->block1[i]-1, prev_ordsgn,
3563  tmp_ordsgn,v, bits, r->block1[i]);
3564  }
3565  break;
3566 
3567  case ringorder_wp:
3568  rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3569  tmp_typ[typ_i], r->wvhdl[i]);
3570  typ_i++;
3571  { // check for weights <=0
3572  int jj;
3573  BOOLEAN have_bad_weights=FALSE;
3574  for(jj=r->block1[i]-r->block0[i];jj>=0; jj--)
3575  {
3576  if (r->wvhdl[i][jj]<=0) have_bad_weights=TRUE;
3577  }
3578  if (have_bad_weights)
3579  {
3580  rO_TDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3581  tmp_typ[typ_i]);
3582  typ_i++;
3583  }
3584  }
3585  if (r->block1[i]!=r->block0[i])
3586  {
3587  rO_LexVars_neg(j, j_bits,r->block1[i],r->block0[i]+1, prev_ordsgn,
3588  tmp_ordsgn, v,bits, r->block0[i]);
3589  }
3590  break;
3591 
3592  case ringorder_Wp:
3593  rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3594  tmp_typ[typ_i], r->wvhdl[i]);
3595  typ_i++;
3596  { // check for weights <=0
3597  int jj;
3598  BOOLEAN have_bad_weights=FALSE;
3599  for(jj=r->block1[i]-r->block0[i];jj>=0; jj--)
3600  {
3601  if (r->wvhdl[i][jj]<=0) have_bad_weights=TRUE;
3602  }
3603  if (have_bad_weights)
3604  {
3605  rO_TDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3606  tmp_typ[typ_i]);
3607  typ_i++;
3608  }
3609  }
3610  if (r->block1[i]!=r->block0[i])
3611  {
3612  rO_LexVars(j, j_bits,r->block0[i],r->block1[i]-1, prev_ordsgn,
3613  tmp_ordsgn,v, bits, r->block1[i]);
3614  }
3615  break;
3616 
3617  case ringorder_ws:
3618  rO_WDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3619  tmp_typ[typ_i], r->wvhdl[i]);
3620  typ_i++;
3621  if (r->block1[i]!=r->block0[i])
3622  {
3623  rO_LexVars_neg(j, j_bits,r->block1[i],r->block0[i]+1, prev_ordsgn,
3624  tmp_ordsgn, v,bits, r->block0[i]);
3625  }
3626  break;
3627 
3628  case ringorder_Ws:
3629  rO_WDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3630  tmp_typ[typ_i], r->wvhdl[i]);
3631  typ_i++;
3632  if (r->block1[i]!=r->block0[i])
3633  {
3634  rO_LexVars(j, j_bits,r->block0[i],r->block1[i]-1, prev_ordsgn,
3635  tmp_ordsgn,v, bits, r->block1[i]);
3636  }
3637  break;
3638 
3639  case ringorder_S:
3640  assume(typ_i == 1); // For LaScala3 only: on the 2nd place ([1])!
3641  // TODO: for K[x]: it is 0...?!
3642  rO_Syzcomp(j, j_bits,prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]);
3643  need_to_add_comp=TRUE;
3644  r->ComponentOrder=-1;
3645  typ_i++;
3646  break;
3647 
3648  case ringorder_s:
3649  assume(typ_i == 0 && j == 0);
3650  rO_Syz(j, j_bits, prev_ordsgn, r->block0[i], tmp_ordsgn, tmp_typ[typ_i]); // set syz-limit?
3651  need_to_add_comp=TRUE;
3652  r->ComponentOrder=-1;
3653  typ_i++;
3654  break;
3655 
3656  case ringorder_IS:
3657  {
3658 
3659  assume( r->block0[i] == r->block1[i] );
3660  const int s = r->block0[i];
3661  assume( -2 < s && s < 2);
3662 
3663  if(s == 0) // Prefix IS
3664  rO_ISPrefix(j, j_bits, prev_ordsgn, tmp_ordsgn, r->N, v, tmp_typ[typ_i++]); // What about prev_ordsgn?
3665  else // s = +1 or -1 // Note: typ_i might be incrimented here inside!
3666  {
3667  rO_ISSuffix(j, j_bits, prev_ordsgn, tmp_ordsgn, r->N, v, tmp_typ, typ_i, s); // Suffix.
3668  need_to_add_comp=FALSE;
3669  }
3670 
3671  break;
3672  }
3673  case ringorder_unspec:
3674  case ringorder_no:
3675  default:
3676  dReportError("undef. ringorder used\n");
3677  break;
3678  }
3679  }
3680  rCheckOrdSgn(r,n-1);
3681 
3682  int j0=j; // save j
3683  int j_bits0=j_bits; // save jbits
3684  rO_Align(j,j_bits);
3685  r->CmpL_Size = j;
3686 
3687  j_bits=j_bits0; j=j0;
3688 
3689  // fill in some empty slots with variables not already covered
3690  // v0 is special, is therefore normally already covered
3691  // now we do have rings without comp...
3692  if((need_to_add_comp) && (v[0]== -1))
3693  {
3694  if (prev_ordsgn==1)
3695  {
3696  rO_Align(j, j_bits);
3697  rO_LexVars(j, j_bits, 0,0, prev_ordsgn,tmp_ordsgn,v,BITS_PER_LONG, -1);
3698  }
3699  else
3700  {
3701  rO_Align(j, j_bits);
3702  rO_LexVars_neg(j, j_bits, 0,0, prev_ordsgn,tmp_ordsgn,v,BITS_PER_LONG, -1);
3703  }
3704  }
3705  // the variables
3706  for(i=1 ; i<=r->N ; i++)
3707  {
3708  if(v[i]==(-1))
3709  {
3710  if (prev_ordsgn==1)
3711  {
3712  rO_LexVars(j, j_bits, i,i, prev_ordsgn,tmp_ordsgn,v,bits, -1);
3713  }
3714  else
3715  {
3716  rO_LexVars_neg(j,j_bits,i,i, prev_ordsgn,tmp_ordsgn,v,bits, -1);
3717  }
3718  }
3719  }
3720 
3721  rO_Align(j,j_bits);
3722  // ----------------------------
3723  // finished with constructing the monomial, computing sizes:
3724 
3725  r->ExpL_Size=j;
3726  r->PolyBin = omGetSpecBin(POLYSIZE + (r->ExpL_Size)*sizeof(long));
3727  assume(r->PolyBin != NULL);
3728 
3729  // ----------------------------
3730  // indices and ordsgn vector for comparison
3731  //
3732  // r->pCompHighIndex already set
3733  r->ordsgn=(long *)omAlloc0(r->ExpL_Size*sizeof(long));
3734 
3735  for(j=0;j<r->CmpL_Size;j++)
3736  {
3737  r->ordsgn[j] = tmp_ordsgn[j];
3738  }
3739 
3740  omFreeSize((ADDRESS)tmp_ordsgn,(3*(n+r->N)*sizeof(long)));
3741 
3742  // ----------------------------
3743  // description of orderings for setm:
3744  //
3745  r->OrdSize=typ_i;
3746  if (typ_i==0) r->typ=NULL;
3747  else
3748  {
3749  r->typ=(sro_ord*)omAlloc(typ_i*sizeof(sro_ord));
3750  memcpy(r->typ,tmp_typ,typ_i*sizeof(sro_ord));
3751  }
3752  omFreeSize((ADDRESS)tmp_typ,(3*(n+r->N)*sizeof(sro_ord)));
3753 
3754  // ----------------------------
3755  // indices for (first copy of ) variable entries in exp.e vector (VarOffset):
3756  r->VarOffset=v;
3757 
3758  // ----------------------------
3759  // other indicies
3760  r->pCompIndex=(r->VarOffset[0] & 0xffff); //r->VarOffset[0];
3761  i=0; // position
3762  j=0; // index in r->typ
3763  if (i==r->pCompIndex) i++; // IS???
3764  while ((j < r->OrdSize)
3765  && ((r->typ[j].ord_typ==ro_syzcomp) ||
3766  (r->typ[j].ord_typ==ro_syz) || (r->typ[j].ord_typ==ro_isTemp) || (r->typ[j].ord_typ==ro_is) ||
3767  (r->order[r->typ[j].order_index] == ringorder_aa)))
3768  {
3769  i++; j++;
3770  }
3771 
3772  if (i==r->pCompIndex) i++;
3773  r->pOrdIndex=i;
3774 
3775  // ----------------------------
3776  rSetDegStuff(r); // OrdSgn etc already set
3777  rSetOption(r);
3778  // ----------------------------
3779  // r->p_Setm
3780  r->p_Setm = p_GetSetmProc(r);
3781 
3782  // ----------------------------
3783  // set VarL_*
3784  rSetVarL(r);
3785 
3786  // ----------------------------
3787  // right-adjust VarOffset
3789 
3790  // ----------------------------
3791  // set NegWeightL*
3792  rSetNegWeight(r);
3793 
3794  // ----------------------------
3795  // p_Procs: call AFTER NegWeightL
3796  r->p_Procs = (p_Procs_s*)omAlloc(sizeof(p_Procs_s));
3797  p_ProcsSet(r, r->p_Procs);
3798 
3799  // use totaldegree on crazy oderings:
3800  if ((r->pFDeg==p_WTotaldegree) && rOrd_is_MixedDegree_Ordering(r))
3801  r->pFDeg = p_Totaldegree;
3802  return FALSE;
3803 }
long int64
Definition: auxiliary.h:68
#define BIT_SIZEOF_LONG
Definition: auxiliary.h:80
int BOOLEAN
Definition: auxiliary.h:87
int l
Definition: cfEzgcd.cc:100
int k
Definition: cfEzgcd.cc:99
const CanonicalForm int s
Definition: facAbsFact.cc:51
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
int dReportError(const char *fmt,...)
Definition: dError.cc:43
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
long p_WTotaldegree(poly p, const ring r)
Definition: p_polys.cc:608
p_SetmProc p_GetSetmProc(const ring r)
Definition: p_polys.cc:555
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1467
static void rSetNegWeight(ring r)
Definition: ring.cc:3300
static void rO_ISSuffix(int &place, int &bitplace, int &prev_ord, long *o, int N, int *v, sro_ord *tmp_typ, int &typ_i, int sgn)
Definition: ring.cc:2422
static void rSetOption(ring r)
Definition: ring.cc:3337
#define BITS_PER_LONG
Definition: ring.cc:40
static void rO_WDegree64(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct, int64 *weights)
Definition: ring.cc:2243
static void rSetVarL(ring r)
set r->VarL_Size, r->VarL_Offset, r->VarL_LowIndex
Definition: ring.cc:3980
static void rO_LexVars(int &place, int &bitplace, int start, int end, int &prev_ord, long *o, int *v, int bits, int opt_var)
Definition: ring.cc:2287
BOOLEAN rOrd_is_MixedDegree_Ordering(ring r)
Definition: ring.cc:3381
static void rSetOutParams(ring r)
Definition: ring.cc:3028
static void rSetDegStuff(ring r)
Definition: ring.cc:3130
static void rO_WDegree_neg(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct, int *weights)
Definition: ring.cc:2261
static void rO_Syzcomp(int &place, int &bitplace, int &prev_ord, long *o, sro_ord &ord_struct)
Definition: ring.cc:2363
static void rO_TDegree(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct)
Definition: ring.cc:2153
static void rO_WMDegree(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct, int *weights)
Definition: ring.cc:2221
static void rO_Syz(int &place, int &bitplace, int &prev_ord, int syz_comp, long *o, sro_ord &ord_struct)
Definition: ring.cc:2378
static unsigned long rGetExpSize(unsigned long bitmask, int &bits)
Definition: ring.cc:2513
static void rCheckOrdSgn(ring r, int i)
Definition: ring.cc:3805
static unsigned long rGetDivMask(int bits)
get r->divmask depending on bits per exponent
Definition: ring.cc:4061
static void rRightAdjustVarOffset(ring r)
right-adjust r->VarOffset
Definition: ring.cc:4035
static void rO_ISPrefix(int &place, int &bitplace, int &prev_ord, long *o, int, int *v, sro_ord &ord_struct)
Definition: ring.cc:2404
static void rO_Align(int &place, int &bitplace)
Definition: ring.cc:2142
static void rO_TDegree_neg(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct)
Definition: ring.cc:2167
static void rO_WDegree(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct, int *weights)
Definition: ring.cc:2181
static void rO_LexVars_neg(int &place, int &bitplace, int start, int end, int &prev_ord, long *o, int *v, int bits, int opt_var)
Definition: ring.cc:2324
@ ro_syz
Definition: ring.h:60
@ ro_is
Definition: ring.h:61
@ ro_isTemp
Definition: ring.h:61
@ ro_syzcomp
Definition: ring.h:59
@ ringorder_am
Definition: ring.h:88
@ ringorder_a64
for int64 weights
Definition: ring.h:71
@ ringorder_unspec
Definition: ring.h:94
@ ringorder_no
Definition: ring.h:69
int order_index
Definition: ring.h:221

◆ rCopy()

ring rCopy ( ring  r)

Definition at line 1648 of file ring.cc.

1649 {
1650  if (r == NULL) return NULL;
1651  ring res=rCopy0(r,FALSE,TRUE);
1652  rComplete(res, 1); // res is purely commutative so far
1653  if (r->qideal!=NULL) res->qideal=idrCopyR_NoSort(r->qideal, r, res);
1654 
1655 #ifdef HAVE_PLURAL
1656  if (rIsPluralRing(r))
1657  if( nc_rCopy(res, r, true) ) {}
1658 #endif
1659 
1660  return res;
1661 }
bool nc_rCopy(ring res, const ring r, bool bSetupQuotient)
Definition: old.gring.cc:3003

◆ rCopy0()

ring rCopy0 ( const ring  r,
BOOLEAN  copy_qideal,
BOOLEAN  copy_ordering 
)

Definition at line 1366 of file ring.cc.

1367 {
1368  if (r == NULL) return NULL;
1369  int i,j;
1370  ring res=(ring)omAlloc0Bin(sip_sring_bin);
1371  //memset: res->idroot=NULL; /* local objects */
1372  //ideal minideal;
1373  res->options=r->options; /* ring dependent options */
1374 
1375  //memset: res->ordsgn=NULL;
1376  //memset: res->typ=NULL;
1377  //memset: res->VarOffset=NULL;
1378  //memset: res->firstwv=NULL;
1379 
1380  //struct omBin PolyBin; /* Bin from where monoms are allocated */
1381  //memset: res->PolyBin=NULL; // rComplete
1382  res->cf=nCopyCoeff(r->cf); /* coeffs */
1383 
1384  //memset: res->ref=0; /* reference counter to the ring */
1385 
1386  res->N=rVar(r); /* number of vars */
1387 
1388  res->firstBlockEnds=r->firstBlockEnds;
1389 #ifdef HAVE_PLURAL
1390  res->real_var_start=r->real_var_start;
1391  res->real_var_end=r->real_var_end;
1392 #endif
1393 
1394 #ifdef HAVE_SHIFTBBA
1395  res->isLPring=r->isLPring; /* 0 for non-letterplace rings, otherwise the number of LP blocks, at least 1, known also as lV */
1396  res->LPncGenCount=r->LPncGenCount;
1397 #endif
1398 
1399  res->VectorOut=r->VectorOut;
1400  res->ShortOut=r->ShortOut;
1401  res->CanShortOut=r->CanShortOut;
1402 
1403  //memset: res->ExpL_Size=0;
1404  //memset: res->CmpL_Size=0;
1405  //memset: res->VarL_Size=0;
1406  //memset: res->pCompIndex=0;
1407  //memset: res->pOrdIndex=0;
1408  //memset: res->OrdSize=0;
1409  //memset: res->VarL_LowIndex=0;
1410  //memset: res->NegWeightL_Size=0;
1411  //memset: res->NegWeightL_Offset=NULL;
1412  //memset: res->VarL_Offset=NULL;
1413 
1414  // the following are set by rComplete unless predefined
1415  // therefore, we copy these values: maybe they are non-standard
1416  /* mask for getting single exponents */
1417  res->bitmask=r->bitmask;
1418  res->divmask=r->divmask;
1419  res->BitsPerExp = r->BitsPerExp;
1420  res->ExpPerLong = r->ExpPerLong;
1421 
1422  //memset: res->p_Procs=NULL;
1423  //memset: res->pFDeg=NULL;
1424  //memset: res->pLDeg=NULL;
1425  //memset: res->pFDegOrig=NULL;
1426  //memset: res->pLDegOrig=NULL;
1427  //memset: res->p_Setm=NULL;
1428  //memset: res->cf=NULL;
1429 
1430 /*
1431  if (r->extRing!=NULL)
1432  r->extRing->ref++;
1433 
1434  res->extRing=r->extRing;
1435  //memset: res->qideal=NULL;
1436 */
1437 
1438 
1439  if (copy_ordering == TRUE)
1440  {
1441  res->LexOrder=r->LexOrder; // TRUE if the monomial ordering has polynomial and power series blocks
1442  res->MixedOrder=r->MixedOrder; // TRUE for mixed (global/local) ordering, FALSE otherwise,
1443  i=rBlocks(r);
1444  res->wvhdl = (int **)omAlloc(i * sizeof(int *));
1445  res->order = (rRingOrder_t *) omAlloc(i * sizeof(rRingOrder_t));
1446  res->block0 = (int *) omAlloc(i * sizeof(int));
1447  res->block1 = (int *) omAlloc(i * sizeof(int));
1448  for (j=0; j<i; j++)
1449  {
1450  if (r->wvhdl[j]!=NULL)
1451  {
1452  res->wvhdl[j] = (int*) omMemDup(r->wvhdl[j]);
1453  }
1454  else
1455  res->wvhdl[j]=NULL;
1456  }
1457  memcpy(res->order,r->order,i * sizeof(rRingOrder_t));
1458  memcpy(res->block0,r->block0,i * sizeof(int));
1459  memcpy(res->block1,r->block1,i * sizeof(int));
1460  }
1461  //memset: else
1462  //memset: {
1463  //memset: res->wvhdl = NULL;
1464  //memset: res->order = NULL;
1465  //memset: res->block0 = NULL;
1466  //memset: res->block1 = NULL;
1467  //memset: }
1468 
1469  res->names = (char **)omAlloc0(rVar(r) * sizeof(char *));
1470  for (i=0; i<rVar(res); i++)
1471  {
1472  res->names[i] = omStrDup(r->names[i]);
1473  }
1474  if (r->qideal!=NULL)
1475  {
1476  if (copy_qideal)
1477  {
1478  assume(copy_ordering);
1479  rComplete(res);
1480  res->qideal= idrCopyR_NoSort(r->qideal, r, res);
1481  rUnComplete(res);
1482  }
1483  //memset: else res->qideal = NULL;
1484  }
1485  //memset: else res->qideal = NULL;
1486  //memset: res->GetNC() = NULL; // copy is purely commutative!!!
1487  return res;
1488 }
static FORCE_INLINE coeffs nCopyCoeff(const coeffs r)
"copy" coeffs, i.e. increment ref
Definition: coeffs.h:430
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define omAlloc0Bin(bin)
Definition: omAllocDecl.h:206
VAR omBin sip_sring_bin
Definition: ring.cc:43
void rUnComplete(ring r)
Definition: ring.cc:3918
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:597

◆ rCopy0AndAddA()

ring rCopy0AndAddA ( const ring  r,
int64vec wv64,
BOOLEAN  copy_qideal,
BOOLEAN  copy_ordering 
)

Definition at line 1495 of file ring.cc.

1496 {
1497  if (r == NULL) return NULL;
1498  int i,j;
1499  ring res=(ring)omAlloc0Bin(sip_sring_bin);
1500  //memcpy(res,r,sizeof(ip_sring));
1501  //memset: res->idroot=NULL; /* local objects */
1502  //ideal minideal;
1503  res->options=r->options; /* ring dependent options */
1504 
1505  //memset: res->ordsgn=NULL;
1506  //memset: res->typ=NULL;
1507  //memset: res->VarOffset=NULL;
1508  //memset: res->firstwv=NULL;
1509 
1510  //struct omBin PolyBin; /* Bin from where monoms are allocated */
1511  //memset: res->PolyBin=NULL; // rComplete
1512  res->cf=nCopyCoeff(r->cf); /* coeffs */
1513 
1514  //memset: res->ref=0; /* reference counter to the ring */
1515 
1516  res->N=rVar(r); /* number of vars */
1517 
1518  res->firstBlockEnds=r->firstBlockEnds;
1519 #ifdef HAVE_PLURAL
1520  res->real_var_start=r->real_var_start;
1521  res->real_var_end=r->real_var_end;
1522 #endif
1523 
1524 #ifdef HAVE_SHIFTBBA
1525  res->isLPring=r->isLPring; /* 0 for non-letterplace rings, otherwise the number of LP blocks, at least 1, known also as lV */
1526  res->LPncGenCount=r->LPncGenCount;
1527 #endif
1528 
1529  res->VectorOut=r->VectorOut;
1530  res->ShortOut=r->ShortOut;
1531  res->CanShortOut=r->CanShortOut;
1532  res->LexOrder=r->LexOrder; // TRUE if the monomial ordering has polynomial and power series blocks
1533  res->MixedOrder=r->MixedOrder; // TRUE for mixed (global/local) ordering, FALSE otherwise,
1534 
1535  //memset: res->ExpL_Size=0;
1536  //memset: res->CmpL_Size=0;
1537  //memset: res->VarL_Size=0;
1538  //memset: res->pCompIndex=0;
1539  //memset: res->pOrdIndex=0;
1540  //memset: res->OrdSize=0;
1541  //memset: res->VarL_LowIndex=0;
1542  //memset: res->NegWeightL_Size=0;
1543  //memset: res->NegWeightL_Offset=NULL;
1544  //memset: res->VarL_Offset=NULL;
1545 
1546  // the following are set by rComplete unless predefined
1547  // therefore, we copy these values: maybe they are non-standard
1548  /* mask for getting single exponents */
1549  res->bitmask=r->bitmask;
1550  res->divmask=r->divmask;
1551  res->BitsPerExp = r->BitsPerExp;
1552  res->ExpPerLong = r->ExpPerLong;
1553 
1554  //memset: res->p_Procs=NULL;
1555  //memset: res->pFDeg=NULL;
1556  //memset: res->pLDeg=NULL;
1557  //memset: res->pFDegOrig=NULL;
1558  //memset: res->pLDegOrig=NULL;
1559  //memset: res->p_Setm=NULL;
1560  //memset: res->cf=NULL;
1561 
1562 /*
1563  if (r->extRing!=NULL)
1564  r->extRing->ref++;
1565 
1566  res->extRing=r->extRing;
1567  //memset: res->qideal=NULL;
1568 */
1569 
1570 
1571  if (copy_ordering == TRUE)
1572  {
1573  i=rBlocks(r)+1; // DIFF to rCopy0
1574  res->wvhdl = (int **)omAlloc(i * sizeof(int *));
1575  res->order = (rRingOrder_t *) omAlloc(i * sizeof(rRingOrder_t));
1576  res->block0 = (int *) omAlloc(i * sizeof(int));
1577  res->block1 = (int *) omAlloc(i * sizeof(int));
1578  for (j=0; j<i-1; j++)
1579  {
1580  if (r->wvhdl[j]!=NULL)
1581  {
1582  res->wvhdl[j+1] = (int*) omMemDup(r->wvhdl[j]); //DIFF
1583  }
1584  else
1585  res->wvhdl[j+1]=NULL; //DIFF
1586  }
1587  memcpy(&(res->order[1]),r->order,(i-1) * sizeof(rRingOrder_t)); //DIFF
1588  memcpy(&(res->block0[1]),r->block0,(i-1) * sizeof(int)); //DIFF
1589  memcpy(&(res->block1[1]),r->block1,(i-1) * sizeof(int)); //DIFF
1590  }
1591  //memset: else
1592  //memset: {
1593  //memset: res->wvhdl = NULL;
1594  //memset: res->order = NULL;
1595  //memset: res->block0 = NULL;
1596  //memset: res->block1 = NULL;
1597  //memset: }
1598 
1599  //the added A
1600  res->order[0]=ringorder_a64;
1601  int length=wv64->rows();
1602  int64 *A=(int64 *)omAlloc(length*sizeof(int64));
1603  for(j=length-1;j>=0;j--)
1604  {
1605  A[j]=(*wv64)[j];
1606  }
1607  res->wvhdl[0]=(int *)A;
1608  res->block0[0]=1;
1609  res->block1[0]=length;
1610  //
1611 
1612  res->names = (char **)omAlloc0(rVar(r) * sizeof(char *));
1613  for (i=0; i<rVar(res); i++)
1614  {
1615  res->names[i] = omStrDup(r->names[i]);
1616  }
1617  if (r->qideal!=NULL)
1618  {
1619  if (copy_qideal)
1620  {
1621  #ifndef SING_NDEBUG
1622  if (!copy_ordering)
1623  WerrorS("internal error: rCopy0(Q,TRUE,FALSE)");
1624  else
1625  #endif
1626  {
1627  #ifndef SING_NDEBUG
1628  WarnS("internal bad stuff: rCopy0(Q,TRUE,TRUE)");
1629  #endif
1630  rComplete(res);
1631  res->qideal= idrCopyR_NoSort(r->qideal, r, res);
1632  rUnComplete(res);
1633  }
1634  }
1635  //memset: else res->qideal = NULL;
1636  }
1637  //memset: else res->qideal = NULL;
1638  //memset: res->GetNC() = NULL; // copy is purely commutative!!!
1639  return res;
1640 }
int rows() const
Definition: int64vec.h:66
#define A
Definition: sirandom.c:24

◆ rDBChangeSComps()

static void rDBChangeSComps ( int *  currComponents,
long *  currShiftedComponents,
int  length,
ring  r 
)
inlinestatic

Definition at line 4374 of file ring.cc.

4378 {
4379  assume(r->typ[1].ord_typ == ro_syzcomp);
4380 
4381  r->typ[1].data.syzcomp.length = length;
4382  rNChangeSComps( currComponents, currShiftedComponents, r);
4383 }

◆ rDBGetSComps()

static void rDBGetSComps ( int **  currComponents,
long **  currShiftedComponents,
int *  length,
ring  r 
)
inlinestatic

Definition at line 4384 of file ring.cc.

4388 {
4389  assume(r->typ[1].ord_typ == ro_syzcomp);
4390 
4391  *length = r->typ[1].data.syzcomp.length;
4392  rNGetSComps( currComponents, currShiftedComponents, r);
4393 }
static void rNGetSComps(int **currComponents, long **currShiftedComponents, ring r)
Definition: ring.cc:4366

◆ rDBTest()

BOOLEAN rDBTest ( ring  r,
const char *  fn,
const int  l 
)

Definition at line 1992 of file ring.cc.

1993 {
1994  int i,j;
1995 
1996  if (r == NULL)
1997  {
1998  dReportError("Null ring in %s:%d", fn, l);
1999  return FALSE;
2000  }
2001 
2002 
2003  if (r->N == 0) return TRUE;
2004 
2005  if ((r->OrdSgn!=1) && (r->OrdSgn!= -1))
2006  {
2007  dReportError("missing OrdSgn in %s:%d", fn, l);
2008  return FALSE;
2009  }
2010 
2011 // omCheckAddrSize(r,sizeof(ip_sring));
2012 #if OM_CHECK > 0
2013  i=rBlocks(r);
2014  omCheckAddrSize(r->order,i*sizeof(int));
2015  omCheckAddrSize(r->block0,i*sizeof(int));
2016  omCheckAddrSize(r->block1,i*sizeof(int));
2017  for(int j=0;j<=i;j++)
2018  {
2019  if((r->order[j]<0)||(r->order[j]>ringorder_unspec))
2020  dError("wrong order in r->order");
2021  }
2022  if (r->wvhdl!=NULL)
2023  {
2024  omCheckAddrSize(r->wvhdl,i*sizeof(int *));
2025  for (j=0;j<i; j++)
2026  {
2027  if (r->wvhdl[j] != NULL) omCheckAddr(r->wvhdl[j]);
2028  }
2029  }
2030 #endif
2031  if (r->VarOffset == NULL)
2032  {
2033  dReportError("Null ring VarOffset -- no rComplete (?) in n %s:%d", fn, l);
2034  return FALSE;
2035  }
2036  omCheckAddrSize(r->VarOffset,(r->N+1)*sizeof(int));
2037 
2038  if ((r->OrdSize==0)!=(r->typ==NULL))
2039  {
2040  dReportError("mismatch OrdSize and typ-pointer in %s:%d");
2041  return FALSE;
2042  }
2043  omcheckAddrSize(r->typ,r->OrdSize*sizeof(*(r->typ)));
2044  omCheckAddrSize(r->VarOffset,(r->N+1)*sizeof(*(r->VarOffset)));
2045  // test assumptions:
2046  for(i=0;i<=r->N;i++) // for all variables (i = 0..N)
2047  {
2048  if(r->typ!=NULL)
2049  {
2050  for(j=0;j<r->OrdSize;j++) // for all ordering blocks (j =0..OrdSize-1)
2051  {
2052  if(r->typ[j].ord_typ == ro_isTemp)
2053  {
2054  const int p = r->typ[j].data.isTemp.suffixpos;
2055 
2056  if(p <= j)
2057  dReportError("ordrec prefix %d is unmatched",j);
2058 
2059  assume( p < r->OrdSize );
2060 
2061  if(r->typ[p].ord_typ != ro_is)
2062  dReportError("ordrec prefix %d is unmatched (suffix: %d is wrong!!!)",j, p);
2063 
2064  // Skip all intermediate blocks for undone variables:
2065  if(r->typ[j].data.isTemp.pVarOffset[i] != -1) // Check i^th variable
2066  {
2067  j = p - 1; // SKIP ALL INTERNAL BLOCKS...???
2068  continue; // To make for check OrdSize bound...
2069  }
2070  }
2071  else if (r->typ[j].ord_typ == ro_is)
2072  {
2073  // Skip all intermediate blocks for undone variables:
2074  if(r->typ[j].data.is.pVarOffset[i] != -1)
2075  {
2076  // TODO???
2077  }
2078 
2079  }
2080  else
2081  {
2082  if (r->typ[j].ord_typ==ro_cp)
2083  {
2084  if(((short)r->VarOffset[i]) == r->typ[j].data.cp.place)
2085  dReportError("ordrec %d conflicts with var %d",j,i);
2086  }
2087  else
2088  if ((r->typ[j].ord_typ!=ro_syzcomp)
2089  && (r->VarOffset[i] == r->typ[j].data.dp.place))
2090  dReportError("ordrec %d conflicts with var %d",j,i);
2091  }
2092  }
2093  }
2094  int tmp;
2095  tmp=r->VarOffset[i] & 0xffffff;
2096  #if SIZEOF_LONG == 8
2097  if ((r->VarOffset[i] >> 24) >63)
2098  #else
2099  if ((r->VarOffset[i] >> 24) >31)
2100  #endif
2101  dReportError("bit_start out of range:%d",r->VarOffset[i] >> 24);
2102  if (i > 0 && ((tmp<0) ||(tmp>r->ExpL_Size-1)))
2103  {
2104  dReportError("varoffset out of range for var %d: %d",i,tmp);
2105  }
2106  }
2107  if(r->typ!=NULL)
2108  {
2109  for(j=0;j<r->OrdSize;j++)
2110  {
2111  if ((r->typ[j].ord_typ==ro_dp)
2112  || (r->typ[j].ord_typ==ro_wp)
2113  || (r->typ[j].ord_typ==ro_wp_neg))
2114  {
2115  if (r->typ[j].data.dp.start > r->typ[j].data.dp.end)
2116  dReportError("in ordrec %d: start(%d) > end(%d)",j,
2117  r->typ[j].data.dp.start, r->typ[j].data.dp.end);
2118  if ((r->typ[j].data.dp.start < 1)
2119  || (r->typ[j].data.dp.end > r->N))
2120  dReportError("in ordrec %d: start(%d)<1 or end(%d)>vars(%d)",j,
2121  r->typ[j].data.dp.start, r->typ[j].data.dp.end,r->N);
2122  }
2123  }
2124  }
2125 
2126  assume(r != NULL);
2127  assume(r->cf != NULL);
2128 
2129  if (nCoeff_is_algExt(r->cf))
2130  {
2131  assume(r->cf->extRing != NULL);
2132  assume(r->cf->extRing->qideal != NULL);
2133  omCheckAddr(r->cf->extRing->qideal->m[0]);
2134  }
2135 
2136  //assume(r->cf!=NULL);
2137 
2138  return TRUE;
2139 }
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:934
#define omCheckAddr(addr)
Definition: omAllocDecl.h:328
#define omCheckAddrSize(addr, size)
Definition: omAllocDecl.h:327
#define omcheckAddrSize(addr, size)
Definition: omAllocDecl.h:329
@ ro_cp
Definition: ring.h:58
@ ro_wp_neg
Definition: ring.h:56
@ ro_wp
Definition: ring.h:53

◆ rDebugPrint()

void rDebugPrint ( const ring  r)

Definition at line 4075 of file ring.cc.

4076 {
4077  if (r==NULL)
4078  {
4079  PrintS("NULL ?\n");
4080  return;
4081  }
4082  // corresponds to ro_typ from ring.h:
4083  const char *TYP[]={"ro_dp","ro_wp","ro_am","ro_wp64","ro_wp_neg","ro_cp",
4084  "ro_syzcomp", "ro_syz", "ro_isTemp", "ro_is", "ro_none"};
4085  int i,j;
4086 
4087  Print("ExpL_Size:%d ",r->ExpL_Size);
4088  Print("CmpL_Size:%d ",r->CmpL_Size);
4089  Print("VarL_Size:%d\n",r->VarL_Size);
4090  Print("bitmask=0x%lx (expbound=%ld) \n",r->bitmask, r->bitmask);
4091  Print("divmask=%lx\n", r->divmask);
4092  Print("BitsPerExp=%d ExpPerLong=%d at L[%d]\n", r->BitsPerExp, r->ExpPerLong, r->VarL_Offset[0]);
4093 
4094  Print("VarL_LowIndex: %d\n", r->VarL_LowIndex);
4095  PrintS("VarL_Offset:\n");
4096  if (r->VarL_Offset==NULL) PrintS(" NULL");
4097  else
4098  for(j = 0; j < r->VarL_Size; j++)
4099  Print(" VarL_Offset[%d]: %d ", j, r->VarL_Offset[j]);
4100  PrintLn();
4101 
4102 
4103  PrintS("VarOffset:\n");
4104  if (r->VarOffset==NULL) PrintS(" NULL\n");
4105  else
4106  for(j=0;j<=r->N;j++)
4107  Print(" v%d at e-pos %d, bit %d\n",
4108  j,r->VarOffset[j] & 0xffffff, r->VarOffset[j] >>24);
4109  PrintS("ordsgn:\n");
4110  for(j=0;j<r->CmpL_Size;j++)
4111  Print(" ordsgn %ld at pos %d\n",r->ordsgn[j],j);
4112  Print("OrdSgn:%d\n",r->OrdSgn);
4113  PrintS("ordrec:\n");
4114  for(j=0;j<r->OrdSize;j++)
4115  {
4116  Print(" typ %s", TYP[r->typ[j].ord_typ]);
4117  if (r->typ[j].ord_typ==ro_syz)
4118  {
4119  const short place = r->typ[j].data.syz.place;
4120  const int limit = r->typ[j].data.syz.limit;
4121  const int curr_index = r->typ[j].data.syz.curr_index;
4122  const int* syz_index = r->typ[j].data.syz.syz_index;
4123 
4124  Print(" limit %d (place: %d, curr_index: %d), syz_index: ", limit, place, curr_index);
4125 
4126  if( syz_index == NULL )
4127  PrintS("(NULL)");
4128  else
4129  {
4130  PrintS("{");
4131  for( i=0; i <= limit; i++ )
4132  Print("%d ", syz_index[i]);
4133  PrintS("}");
4134  }
4135 
4136  }
4137  else if (r->typ[j].ord_typ==ro_isTemp)
4138  {
4139  Print(" start (level) %d, suffixpos: %d, VO: ",r->typ[j].data.isTemp.start, r->typ[j].data.isTemp.suffixpos);
4140 
4141  }
4142  else if (r->typ[j].ord_typ==ro_is)
4143  {
4144  Print(" start %d, end: %d: ",r->typ[j].data.is.start, r->typ[j].data.is.end);
4145 
4146 // for( int k = 0; k <= r->N; k++) if (r->typ[j].data.is.pVarOffset[k] != -1) Print("[%2d]: %04x; ", k, r->typ[j].data.is.pVarOffset[k]);
4147 
4148  Print(" limit %d",r->typ[j].data.is.limit);
4149 #ifndef SING_NDEBUG
4150  //PrintS(" F: ");idShow(r->typ[j].data.is.F, r, r, 1);
4151 #endif
4152 
4153  PrintLn();
4154  }
4155  else if (r->typ[j].ord_typ==ro_am)
4156  {
4157  Print(" place %d",r->typ[j].data.am.place);
4158  Print(" start %d",r->typ[j].data.am.start);
4159  Print(" end %d",r->typ[j].data.am.end);
4160  Print(" len_gen %d",r->typ[j].data.am.len_gen);
4161  PrintS(" w:");
4162  int l=0;
4163  for(l=r->typ[j].data.am.start;l<=r->typ[j].data.am.end;l++)
4164  Print(" %d",r->typ[j].data.am.weights[l-r->typ[j].data.am.start]);
4165  l=r->typ[j].data.am.end+1;
4166  int ll=r->typ[j].data.am.weights[l-r->typ[j].data.am.start];
4167  PrintS(" m:");
4168  for(int lll=l+1;lll<l+ll+1;lll++)
4169  Print(" %d",r->typ[j].data.am.weights[lll-r->typ[j].data.am.start]);
4170  }
4171  else
4172  {
4173  Print(" place %d",r->typ[j].data.dp.place);
4174 
4175  if (r->typ[j].ord_typ!=ro_syzcomp && r->typ[j].ord_typ!=ro_syz)
4176  {
4177  Print(" start %d",r->typ[j].data.dp.start);
4178  Print(" end %d",r->typ[j].data.dp.end);
4179  if ((r->typ[j].ord_typ==ro_wp)
4180  || (r->typ[j].ord_typ==ro_wp_neg))
4181  {
4182  PrintS(" w:");
4183  for(int l=r->typ[j].data.wp.start;l<=r->typ[j].data.wp.end;l++)
4184  Print(" %d",r->typ[j].data.wp.weights[l-r->typ[j].data.wp.start]);
4185  }
4186  else if (r->typ[j].ord_typ==ro_wp64)
4187  {
4188  PrintS(" w64:");
4189  int l;
4190  for(l=r->typ[j].data.wp64.start;l<=r->typ[j].data.wp64.end;l++)
4191  Print(" %ld",(long)(((int64*)r->typ[j].data.wp64.weights64)+l-r->typ[j].data.wp64.start));
4192  }
4193  }
4194  }
4195  PrintLn();
4196  }
4197  Print("pOrdIndex:%d pCompIndex:%d\n", r->pOrdIndex, r->pCompIndex);
4198  Print("OrdSize:%d\n",r->OrdSize);
4199  PrintS("--------------------\n");
4200  for(j=0;j<r->ExpL_Size;j++)
4201  {
4202  Print("L[%d]: ",j);
4203  if (j< r->CmpL_Size)
4204  Print("ordsgn %ld ", r->ordsgn[j]);
4205  else
4206  PrintS("no comp ");
4207  i=1;
4208  for(;i<=r->N;i++)
4209  {
4210  if( (r->VarOffset[i] & 0xffffff) == j )
4211  { Print("v%d at e[%d], bit %d; ", i,r->VarOffset[i] & 0xffffff,
4212  r->VarOffset[i] >>24 ); }
4213  }
4214  if( r->pCompIndex==j ) PrintS("v0; ");
4215  for(i=0;i<r->OrdSize;i++)
4216  {
4217  if (r->typ[i].data.dp.place == j)
4218  {
4219  Print("ordrec:%s (start:%d, end:%d) ",TYP[r->typ[i].ord_typ],
4220  r->typ[i].data.dp.start, r->typ[i].data.dp.end);
4221  }
4222  }
4223 
4224  if (j==r->pOrdIndex)
4225  PrintS("pOrdIndex\n");
4226  else
4227  PrintLn();
4228  }
4229  Print("LexOrder:%d, MixedOrder:%d\n",r->LexOrder, r->MixedOrder);
4230 
4231  Print("NegWeightL_Size: %d, NegWeightL_Offset: ", r->NegWeightL_Size);
4232  if (r->NegWeightL_Offset==NULL) PrintS(" NULL");
4233  else
4234  for(j = 0; j < r->NegWeightL_Size; j++)
4235  Print(" [%d]: %d ", j, r->NegWeightL_Offset[j]);
4236  PrintLn();
4237 
4238  // p_Procs stuff
4239  p_Procs_s proc_names;
4240  const char* field;
4241  const char* length;
4242  const char* ord;
4243  p_Debug_GetProcNames(r, &proc_names); // changes p_Procs!!!
4244  p_Debug_GetSpecNames(r, field, length, ord);
4245 
4246  Print("p_Spec : %s, %s, %s\n", field, length, ord);
4247  PrintS("p_Procs :\n");
4248  for (i=0; i<(int) (sizeof(p_Procs_s)/sizeof(void*)); i++)
4249  {
4250  Print(" %s,\n", ((char**) &proc_names)[i]);
4251  }
4252 
4253  {
4254  PrintLn();
4255  PrintS("pFDeg : ");
4256 #define pFDeg_CASE(A) if(r->pFDeg == A) PrintS( "" #A "" )
4257  pFDeg_CASE(p_Totaldegree); else
4259  pFDeg_CASE(p_WTotaldegree); else
4260  pFDeg_CASE(p_Deg); else
4261 #undef pFDeg_CASE
4262  Print("(%p)", r->pFDeg); // default case
4263 
4264  PrintLn();
4265  Print("pLDeg : (%p)", r->pLDeg);
4266  PrintLn();
4267  }
4268  PrintS("pSetm:");
4269  void p_Setm_Dummy(poly p, const ring r);
4270  void p_Setm_TotalDegree(poly p, const ring r);
4271  void p_Setm_WFirstTotalDegree(poly p, const ring r);
4272  void p_Setm_General(poly p, const ring r);
4273  if (r->p_Setm==p_Setm_General) PrintS("p_Setm_General\n");
4274  else if (r->p_Setm==p_Setm_Dummy) PrintS("p_Setm_Dummy\n");
4275  else if (r->p_Setm==p_Setm_TotalDegree) PrintS("p_Setm_Totaldegree\n");
4276  else if (r->p_Setm==p_Setm_WFirstTotalDegree) PrintS("p_Setm_WFirstTotalDegree\n");
4277  else Print("%p\n",r->p_Setm);
4278 }
void p_Debug_GetProcNames(const ring r, p_Procs_s *p_Procs)
Definition: p_Procs_Set.h:232
void p_Debug_GetSpecNames(const ring r, const char *&field, const char *&length, const char *&ord)
Definition: p_Procs_Set.h:221
void p_Setm_WFirstTotalDegree(poly p, const ring r)
Definition: p_polys.cc:549
long p_WFirstTotalDegree(poly p, const ring r)
Definition: p_polys.cc:591
void p_Setm_Dummy(poly p, const ring r)
Definition: p_polys.cc:536
void p_Setm_TotalDegree(poly p, const ring r)
Definition: p_polys.cc:542
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:582
#define pFDeg_CASE(A)
@ ro_wp64
Definition: ring.h:55
@ ro_am
Definition: ring.h:54

◆ rDefault() [1/4]

ring rDefault ( const coeffs  cf,
int  N,
char **  n,
const rRingOrder_t  o 
)

Definition at line 138 of file ring.cc.

139 {
140  assume( cf != NULL);
141  /*order: o=lp,0*/
142  rRingOrder_t *order = (rRingOrder_t *) omAlloc(2* sizeof(rRingOrder_t));
143  int *block0 = (int *)omAlloc0(2 * sizeof(int));
144  int *block1 = (int *)omAlloc0(2 * sizeof(int));
145  /* ringorder o=lp for the first block: var 1..N */
146  order[0] = o;
147  block0[0] = 1;
148  block1[0] = N;
149  /* the last block: everything is 0 */
150  order[1] = (rRingOrder_t)0;
151 
152  return rDefault(cf,N,n,2,order,block0,block1);
153 }
CanonicalForm cf
Definition: cfModGcd.cc:4085
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
Definition: ring.cc:102

◆ rDefault() [2/4]

ring rDefault ( const coeffs  cf,
int  N,
char **  n,
int  ord_size,
rRingOrder_t ord,
int *  block0,
int *  block1,
int **  wvhdl,
unsigned long  bitmask 
)

Definition at line 102 of file ring.cc.

103 {
104  assume( cf != NULL);
105  ring r=(ring) omAlloc0Bin(sip_sring_bin);
106  r->N = N;
107  r->cf = cf;
108  /*rPar(r) = 0; Alloc0 */
109  /*names*/
110  r->names = (char **) omAlloc0(N * sizeof(char *));
111  int i;
112  for(i=0;i<N;i++)
113  {
114  r->names[i] = omStrDup(n[i]);
115  }
116  /*weights: entries for 2 blocks: NULL*/
117  if (wvhdl==NULL)
118  r->wvhdl = (int **)omAlloc0((ord_size+1) * sizeof(int *));
119  else
120  r->wvhdl=wvhdl;
121  r->order = ord;
122  r->block0 = block0;
123  r->block1 = block1;
124  if (bitmask!=0) r->wanted_maxExp=bitmask;
125 
126  /* complete ring intializations */
127  rComplete(r);
128  return r;
129 }

◆ rDefault() [3/4]

ring rDefault ( int  ch,
int  N,
char **  n 
)

Definition at line 155 of file ring.cc.

156 {
157  coeffs cf;
158  if (ch==0) cf=nInitChar(n_Q,NULL);
159  else cf=nInitChar(n_Zp,(void*)(long)ch);
160  assume( cf != NULL);
161  return rDefault(cf,N,n);
162 }
@ n_Q
rational (GMP) numbers
Definition: coeffs.h:31
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:30
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:353

◆ rDefault() [4/4]

ring rDefault ( int  ch,
int  N,
char **  n,
int  ord_size,
rRingOrder_t ord,
int *  block0,
int *  block1,
int **  wvhdl 
)

Definition at line 130 of file ring.cc.

131 {
132  coeffs cf;
133  if (ch==0) cf=nInitChar(n_Q,NULL);
134  else cf=nInitChar(n_Zp,(void*)(long)ch);
135  assume( cf != NULL);
136  return rDefault(cf,N,n,ord_size,ord,block0,block1,wvhdl);
137 }

◆ rDelete()

void rDelete ( ring  r)

unconditionally deletes fields in r

Definition at line 449 of file ring.cc.

450 {
451  int i, j;
452 
453  if (r == NULL) return;
454 
455  assume( r->ref <= 0 );
456 
457  if( r->ref > 0 ) // ->ref means the number of Interpreter objects referring to the ring...
458  return; // this should never happen.
459 
460  if( r->qideal != NULL )
461  {
462  ideal q = r->qideal;
463  r->qideal = NULL;
464  id_Delete(&q, r);
465  }
466 
467 #ifdef HAVE_PLURAL
468  if (rIsPluralRing(r))
469  nc_rKill(r);
470 #endif
471 
472  rUnComplete(r); // may need r->cf for p_Delete
473  nKillChar(r->cf); r->cf = NULL;
474  // delete order stuff
475  if (r->order != NULL)
476  {
477  i=rBlocks(r);
478  assume(r->block0 != NULL && r->block1 != NULL && r->wvhdl != NULL);
479  // delete order
480  omFreeSize((ADDRESS)r->order,i*sizeof(rRingOrder_t));
481  omFreeSize((ADDRESS)r->block0,i*sizeof(int));
482  omFreeSize((ADDRESS)r->block1,i*sizeof(int));
483  // delete weights
484  for (j=0; j<i; j++)
485  {
486  if (r->wvhdl[j]!=NULL)
487  omFree(r->wvhdl[j]);
488  }
489  omFreeSize((ADDRESS)r->wvhdl,i*sizeof(int *));
490  }
491  else
492  {
493  assume(r->block0 == NULL && r->block1 == NULL && r->wvhdl == NULL);
494  }
495 
496  // delete varnames
497  if(r->names!=NULL)
498  {
499  for (i=0; i<r->N; i++)
500  {
501  if (r->names[i] != NULL) omFree((ADDRESS)r->names[i]);
502  }
503  omFreeSize((ADDRESS)r->names,r->N*sizeof(char *));
504  }
505 
507 }
void nKillChar(coeffs r)
undo all initialisations
Definition: numbers.cc:513
void nc_rKill(ring r)
complete destructor
Definition: old.gring.cc:2475
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259

◆ rEnvelope()

ring rEnvelope ( ring  R)

Definition at line 5643 of file ring.cc.

5646 {
5647  ring Ropp = rOpposite(R);
5648  ring Renv = NULL;
5649  int stat = rSum(R, Ropp, Renv); /* takes care of qideals */
5650  if ( stat <=0 )
5651  WarnS("Error in rEnvelope at rSum");
5652  rTest(Renv);
5653  return Renv;
5654 }
int rSum(ring r1, ring r2, ring &sum)
Definition: ring.cc:1347
ring rOpposite(ring src)
Definition: ring.cc:5253

◆ rEqual()

BOOLEAN rEqual ( ring  r1,
ring  r2,
BOOLEAN  qr 
)

returns TRUE, if r1 equals r2 FALSE, otherwise Equality is determined componentwise, if qr == 1, then qrideal equality is tested, as well

Definition at line 1663 of file ring.cc.

1664 {
1665  if (r1 == r2) return TRUE;
1666  if (r1 == NULL || r2 == NULL) return FALSE;
1667  if (r1->cf!=r2->cf) return FALSE;
1668  if (rVar(r1)!=rVar(r2)) return FALSE;
1669  if (r1->bitmask!=r2->bitmask) return FALSE;
1670  #ifdef HAVE_SHIFTBBA
1671  if (r1->isLPring!=r2->isLPring) return FALSE;
1672  if (r1->LPncGenCount!=r2->LPncGenCount) return FALSE;
1673  #endif
1674 
1675  if( !rSamePolyRep(r1, r2) )
1676  return FALSE;
1677 
1678  int i/*, j*/;
1679 
1680  for (i=0; i<rVar(r1); i++)
1681  {
1682  if ((r1->names[i] != NULL) && (r2->names[i] != NULL))
1683  {
1684  if (strcmp(r1->names[i], r2->names[i])) return FALSE;
1685  }
1686  else if ((r1->names[i] != NULL) ^ (r2->names[i] != NULL))
1687  {
1688  return FALSE;
1689  }
1690  }
1691 
1692  if (qr)
1693  {
1694  if (r1->qideal != NULL)
1695  {
1696  ideal id1 = r1->qideal, id2 = r2->qideal;
1697  int i, n;
1698  poly *m1, *m2;
1699 
1700  if (id2 == NULL) return FALSE;
1701  if ((n = IDELEMS(id1)) != IDELEMS(id2)) return FALSE;
1702 
1703  {
1704  m1 = id1->m;
1705  m2 = id2->m;
1706  for (i=0; i<n; i++)
1707  if (! p_EqualPolys(m1[i],m2[i], r1, r2)) return FALSE;
1708  }
1709  }
1710  else if (r2->qideal != NULL) return FALSE;
1711  }
1712 
1713  return TRUE;
1714 }
Definition: qr.h:46
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4538
BOOLEAN rSamePolyRep(ring r1, ring r2)
returns TRUE, if r1 and r2 represents the monomials in the same way FALSE, otherwise this is an analo...
Definition: ring.cc:1716
#define IDELEMS(i)
Definition: simpleideals.h:23

◆ rGetDivMask()

static unsigned long rGetDivMask ( int  bits)
static

get r->divmask depending on bits per exponent

Definition at line 4061 of file ring.cc.

4062 {
4063  unsigned long divmask = 1;
4064  int i = bits;
4065 
4066  while (i < BIT_SIZEOF_LONG)
4067  {
4068  divmask |= (((unsigned long) 1) << (unsigned long) i);
4069  i += bits;
4070  }
4071  return divmask;
4072 }

◆ rGetExpSize() [1/2]

static unsigned long rGetExpSize ( unsigned long  bitmask,
int &  bits 
)
static

Definition at line 2513 of file ring.cc.

2514 {
2515  if (bitmask == 0)
2516  {
2517  bits=16; bitmask=0xffff;
2518  }
2519  else if (bitmask <= 1L)
2520  {
2521  bits=1; bitmask = 1L;
2522  }
2523  else if (bitmask <= 3L)
2524  {
2525  bits=2; bitmask = 3L;
2526  }
2527  else if (bitmask <= 7L)
2528  {
2529  bits=3; bitmask=7L;
2530  }
2531  else if (bitmask <= 0xfL)
2532  {
2533  bits=4; bitmask=0xfL;
2534  }
2535  else if (bitmask <= 0x1fL)
2536  {
2537  bits=5; bitmask=0x1fL;
2538  }
2539  else if (bitmask <= 0x3fL)
2540  {
2541  bits=6; bitmask=0x3fL;
2542  }
2543 #if SIZEOF_LONG == 8
2544  else if (bitmask <= 0x7fL)
2545  {
2546  bits=7; bitmask=0x7fL; /* 64 bit longs only */
2547  }
2548 #endif
2549  else if (bitmask <= 0xffL)
2550  {
2551  bits=8; bitmask=0xffL;
2552  }
2553 #if SIZEOF_LONG == 8
2554  else if (bitmask <= 0x1ffL)
2555  {
2556  bits=9; bitmask=0x1ffL; /* 64 bit longs only */
2557  }
2558 #endif
2559  else if (bitmask <= 0x3ffL)
2560  {
2561  bits=10; bitmask=0x3ffL;
2562  }
2563 #if SIZEOF_LONG == 8
2564  else if (bitmask <= 0xfffL)
2565  {
2566  bits=12; bitmask=0xfff; /* 64 bit longs only */
2567  }
2568 #endif
2569  else if (bitmask <= 0xffffL)
2570  {
2571  bits=16; bitmask=0xffffL;
2572  }
2573 #if SIZEOF_LONG == 8
2574  else if (bitmask <= 0xfffffL)
2575  {
2576  bits=20; bitmask=0xfffffL; /* 64 bit longs only */
2577  }
2578  else if (bitmask <= 0xffffffffL)
2579  {
2580  bits=32; bitmask=0xffffffffL;
2581  }
2582  else if (bitmask <= 0x7fffffffffffffffL)
2583  {
2584  bits=63; bitmask=0x7fffffffffffffffL; /* for overflow tests*/
2585  }
2586  else
2587  {
2588  bits=63; bitmask=0x7fffffffffffffffL; /* for overflow tests*/
2589  }
2590 #else
2591  else if (bitmask <= 0x7fffffff)
2592  {
2593  bits=31; bitmask=0x7fffffff; /* for overflow tests*/
2594  }
2595  else
2596  {
2597  bits=31; bitmask=0x7fffffffL; /* for overflow tests*/
2598  }
2599 #endif
2600  return bitmask;
2601 }

◆ rGetExpSize() [2/2]

unsigned long rGetExpSize ( unsigned long  bitmask,
int &  bits,
int  N 
)

Definition at line 2606 of file ring.cc.

2607 {
2608 #if SIZEOF_LONG == 8
2609  if (N<4) N=4;
2610 #else
2611  if (N<2) N=2;
2612 #endif
2613  bitmask =rGetExpSize(bitmask, bits);
2614  int vars_per_long=BIT_SIZEOF_LONG/bits;
2615  int bits1;
2616  loop
2617  {
2618  if (bits == BIT_SIZEOF_LONG-1)
2619  {
2620  bits = BIT_SIZEOF_LONG - 1;
2621  return LONG_MAX;
2622  }
2623  unsigned long bitmask1 =rGetExpSize(bitmask+1, bits1);
2624  int vars_per_long1=BIT_SIZEOF_LONG/bits1;
2625  if ((((N+vars_per_long-1)/vars_per_long) ==
2626  ((N+vars_per_long1-1)/vars_per_long1)))
2627  {
2628  vars_per_long=vars_per_long1;
2629  bits=bits1;
2630  bitmask=bitmask1;
2631  }
2632  else
2633  {
2634  return bitmask; /* and bits */
2635  }
2636  }
2637 }
#define loop
Definition: structs.h:80

◆ rGetISPos()

int rGetISPos ( const int  p,
const ring  r 
)

Finds p^th IS ordering, and returns its position in r->typ[] returns -1 if something went wrong! p - starts with 0!

return the position of the p^th IS block order block in r->typ[]...

Definition at line 4950 of file ring.cc.

4951 {
4952  // Put the reference set F into the ring -ordering -recor
4953 #if MYTEST
4954  Print("rIsIS(p: %d)\nF:", p);
4955  PrintLn();
4956 #endif
4957 
4958  if (r->typ==NULL)
4959  {
4960 // dReportError("'rIsIS:' Error: wrong ring! (typ == NULL)");
4961  return -1;
4962  }
4963 
4964  int j = p; // Which IS record to use...
4965  for( int pos = 0; pos < r->OrdSize; pos++ )
4966  if( r->typ[pos].ord_typ == ro_is)
4967  if( j-- == 0 )
4968  return pos;
4969 
4970  return -1;
4971 }

◆ rGetMaxSyzComp()

int rGetMaxSyzComp ( int  i,
const ring  r 
)

return the max-comonent wchich has syzIndex i Assume: i<= syzIndex_limit

Definition at line 5108 of file ring.cc.

5109 {
5110  if ((r->typ!=NULL) && (r->typ[0].ord_typ==ro_syz) &&
5111  r->typ[0].data.syz.limit > 0 && i > 0)
5112  {
5113  assume(i <= r->typ[0].data.syz.limit);
5114  int j;
5115  for (j=0; j<r->typ[0].data.syz.limit; j++)
5116  {
5117  if (r->typ[0].data.syz.syz_index[j] == i &&
5118  r->typ[0].data.syz.syz_index[j+1] != i)
5119  {
5120  assume(r->typ[0].data.syz.syz_index[j+1] == i+1);
5121  return j;
5122  }
5123  }
5124  return r->typ[0].data.syz.limit;
5125  }
5126  else
5127  {
5128  #ifndef SING_NDEBUG
5129  WarnS("rGetMaxSyzComp: order c");
5130  #endif
5131  return 0;
5132  }
5133 }

◆ rGetOrderType()

rOrderType_t rGetOrderType ( ring  r)

Definition at line 1757 of file ring.cc.

1758 {
1759  // check for simple ordering
1760  if (rHasSimpleOrder(r))
1761  {
1762  if ((r->order[1] == ringorder_c)
1763  || (r->order[1] == ringorder_C))
1764  {
1765  switch(r->order[0])
1766  {
1767  case ringorder_dp:
1768  case ringorder_wp:
1769  case ringorder_ds:
1770  case ringorder_ws:
1771  case ringorder_ls:
1772  case ringorder_unspec:
1773  if (r->order[1] == ringorder_C
1774  || r->order[0] == ringorder_unspec)
1775  return rOrderType_ExpComp;
1776  return rOrderType_Exp;
1777 
1778  default:
1779  assume(r->order[0] == ringorder_lp ||
1780  r->order[0] == ringorder_rs ||
1781  r->order[0] == ringorder_Dp ||
1782  r->order[0] == ringorder_Wp ||
1783  r->order[0] == ringorder_Ds ||
1784  r->order[0] == ringorder_Ws);
1785 
1786  if (r->order[1] == ringorder_c) return rOrderType_ExpComp;
1787  return rOrderType_Exp;
1788  }
1789  }
1790  else
1791  {
1792  assume((r->order[0]==ringorder_c)||(r->order[0]==ringorder_C));
1793  return rOrderType_CompExp;
1794  }
1795  }
1796  else
1797  return rOrderType_General;
1798 }
BOOLEAN rHasSimpleOrder(const ring r)
Definition: ring.cc:1804
@ rOrderType_CompExp
simple ordering, component has priority
Definition: ring.h:100
@ rOrderType_Exp
simple ordering, exponent vector has priority component is compatible with exp-vector order
Definition: ring.h:103
@ rOrderType_General
non-simple ordering as specified by currRing
Definition: ring.h:99
@ rOrderType_ExpComp
simple ordering, exponent vector has priority component not compatible with exp-vector order
Definition: ring.h:101

◆ rGetSComps()

void rGetSComps ( int **  currComponents,
long **  currShiftedComponents,
int *  length,
ring  r 
)

Definition at line 4405 of file ring.cc.

4406 {
4407 #ifdef PDEBUG
4408  rDBGetSComps(currComponents, currShiftedComponents, length, r);
4409 #else
4410  rNGetSComps(currComponents, currShiftedComponents, r);
4411 #endif
4412 }
static void rDBGetSComps(int **currComponents, long **currShiftedComponents, int *length, ring r)
Definition: ring.cc:4384

◆ rGetVar()

poly rGetVar ( const int  varIndex,
const ring  r 
)

Definition at line 5758 of file ring.cc.

5759 {
5760  poly p = p_ISet(1, r);
5761  p_SetExp(p, varIndex, 1, r);
5762  p_Setm(p, r);
5763  return p;
5764 }
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1292
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:488
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233

◆ rGetWeightVec()

int64* rGetWeightVec ( const ring  r)

Definition at line 5194 of file ring.cc.

5195 {
5196  assume(r!=NULL);
5197  assume(r->OrdSize>0);
5198  int i=0;
5199  while((r->typ[i].ord_typ!=ro_wp64) && (r->typ[i].ord_typ>0)) i++;
5200  assume(r->typ[i].ord_typ==ro_wp64);
5201  return (int64*)(r->typ[i].data.wp64.weights64);
5202 }

◆ rHas_c_Ordering()

BOOLEAN rHas_c_Ordering ( const ring  r)

Definition at line 1800 of file ring.cc.

1801 {
1802  return (r->order[0] == ringorder_c);
1803 }

◆ rHasSimpleLexOrder()

BOOLEAN rHasSimpleLexOrder ( const ring  r)

returns TRUE, if simple lp or ls ordering

Definition at line 1836 of file ring.cc.

1837 {
1838  return rHasSimpleOrder(r) &&
1839  (r->order[0] == ringorder_ls ||
1840  r->order[0] == ringorder_lp ||
1841  r->order[1] == ringorder_ls ||
1842  r->order[1] == ringorder_lp);
1843 }

◆ rHasSimpleOrder()

BOOLEAN rHasSimpleOrder ( const ring  r)

Definition at line 1804 of file ring.cc.

1805 {
1806  if (r->order[0] == ringorder_unspec) return TRUE;
1807  int blocks = rBlocks(r) - 1;
1808  assume(blocks >= 1);
1809  if (blocks == 1) return TRUE;
1810 
1811  int s = 0;
1812  while( (s < blocks) && (r->order[s] == ringorder_IS) && (r->order[blocks-1] == ringorder_IS) )
1813  {
1814  s++;
1815  blocks--;
1816  }
1817 
1818  if ((blocks - s) > 2) return FALSE;
1819 
1820  assume( blocks == s + 2 );
1821 
1822  if (
1823  (r->order[s] != ringorder_c)
1824  && (r->order[s] != ringorder_C)
1825  && (r->order[s+1] != ringorder_c)
1826  && (r->order[s+1] != ringorder_C)
1827  )
1828  return FALSE;
1829  if ((r->order[s+1] == ringorder_M)
1830  || (r->order[s] == ringorder_M))
1831  return FALSE;
1832  return TRUE;
1833 }

◆ rHasSimpleOrderAA()

BOOLEAN rHasSimpleOrderAA ( ring  r)

Definition at line 1879 of file ring.cc.

1880 {
1881  if (r->order[0] == ringorder_unspec) return TRUE;
1882  int blocks = rBlocks(r) - 1;
1883  assume(blocks >= 1);
1884  if (blocks == 1) return TRUE;
1885 
1886  int s = 0;
1887  while( (s < blocks) && (r->order[s] == ringorder_IS) && (r->order[blocks-1] == ringorder_IS) )
1888  {
1889  s++;
1890  blocks--;
1891  }
1892 
1893  if ((blocks - s) > 3) return FALSE;
1894 
1895 // if ((blocks > 3) || (blocks < 2)) return FALSE;
1896  if ((blocks - s) == 3)
1897  {
1898  return (((r->order[s] == ringorder_aa) && (r->order[s+1] != ringorder_M) &&
1899  ((r->order[s+2] == ringorder_c) || (r->order[s+2] == ringorder_C))) ||
1900  (((r->order[s] == ringorder_c) || (r->order[s] == ringorder_C)) &&
1901  (r->order[s+1] == ringorder_aa) && (r->order[s+2] != ringorder_M)));
1902  }
1903  else
1904  {
1905  return ((r->order[s] == ringorder_aa) && (r->order[s+1] != ringorder_M));
1906  }
1907 }

◆ rIsPolyVar()

BOOLEAN rIsPolyVar ( int  v,
const ring  r 
)

returns TRUE if var(i) belongs to p-block

Definition at line 1953 of file ring.cc.

1954 {
1955  int i=0;
1956  while(r->order[i]!=0)
1957  {
1958  if((r->block0[i]<=v)
1959  && (r->block1[i]>=v))
1960  {
1961  switch(r->order[i])
1962  {
1963  case ringorder_a:
1964  return (r->wvhdl[i][v-r->block0[i]]>0);
1965  case ringorder_M:
1966  return 2; /*don't know*/
1967  case ringorder_a64: /* assume: all weight are non-negative!*/
1968  case ringorder_lp:
1969  case ringorder_rs:
1970  case ringorder_dp:
1971  case ringorder_Dp:
1972  case ringorder_wp:
1973  case ringorder_Wp:
1974  return TRUE;
1975  case ringorder_ls:
1976  case ringorder_ds:
1977  case ringorder_Ds:
1978  case ringorder_ws:
1979  case ringorder_Ws:
1980  return FALSE;
1981  default:
1982  break;
1983  }
1984  }
1985  i++;
1986  }
1987  return 3; /* could not find var v*/
1988 }

◆ rKillModified_Wp_Ring()

void rKillModified_Wp_Ring ( ring  r)

Definition at line 3017 of file ring.cc.

3018 {
3019  rUnComplete(r);
3020  omFree(r->order);
3021  omFree(r->block0);
3022  omFree(r->block1);
3023  omFree(r->wvhdl[0]);
3024  omFree(r->wvhdl);
3026 }

◆ rKillModifiedRing()

void rKillModifiedRing ( ring  r)

Definition at line 3007 of file ring.cc.

3008 {
3009  rUnComplete(r);
3010  omFree(r->order);
3011  omFree(r->block0);
3012  omFree(r->block1);
3013  omFree(r->wvhdl);
3015 }

◆ rMinusVar()

ring rMinusVar ( const ring  r,
char *  v 
)

undo rPlusVar

Definition at line 5871 of file ring.cc.

5872 {
5873  if (r->order[2]!=0)
5874  {
5875  WerrorS("only for rings with an ordering of one block");
5876  return NULL;
5877  }
5878  int p;
5879  if((r->order[0]==ringorder_C)
5880  ||(r->order[0]==ringorder_c))
5881  p=1;
5882  else
5883  p=0;
5884  if((r->order[p]!=ringorder_dp)
5885  && (r->order[p]!=ringorder_Dp)
5886  && (r->order[p]!=ringorder_lp)
5887  && (r->order[p]!=ringorder_rp)
5888  && (r->order[p]!=ringorder_ds)
5889  && (r->order[p]!=ringorder_Ds)
5890  && (r->order[p]!=ringorder_ls))
5891  {
5892  WerrorS("ordering must be dp,Dp,lp,rp,ds,Ds or ls");
5893  return NULL;
5894  }
5895  ring R=rCopy0(r);
5896  int i=R->N-1;
5897  while(i>=0)
5898  {
5899  if (strcmp(R->names[i],v)==0)
5900  {
5901  R->N--;
5902  omFree(R->names[i]);
5903  for(int j=i;j<R->N;j++) R->names[j]=R->names[j+1];
5904  R->names=(char**)omReallocSize(R->names,r->N*sizeof(char_ptr),R->N*sizeof(char_ptr));
5905  }
5906  i--;
5907  }
5908  R->block1[p]=R->N;
5909  rComplete(R,1);
5910  return R;
5911 }
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220
char * char_ptr
Definition: structs.h:58

◆ rModify_a_to_A()

void rModify_a_to_A ( ring  r)

Definition at line 5735 of file ring.cc.

5738 {
5739  int i=0;
5740  int j;
5741  while(r->order[i]!=0)
5742  {
5743  if (r->order[i]==ringorder_a)
5744  {
5745  r->order[i]=ringorder_a64;
5746  int *w=r->wvhdl[i];
5747  int64 *w64=(int64 *)omAlloc((r->block1[i]-r->block0[i]+1)*sizeof(int64));
5748  for(j=r->block1[i]-r->block0[i];j>=0;j--)
5749  w64[j]=(int64)w[j];
5750  r->wvhdl[i]=(int*)w64;
5751  omFreeSize(w,(r->block1[i]-r->block0[i]+1)*sizeof(int));
5752  }
5753  i++;
5754  }
5755 }
const CanonicalForm & w
Definition: facAbsFact.cc:51

◆ rModifyRing()

ring rModifyRing ( ring  r,
BOOLEAN  omit_degree,
BOOLEAN  try_omit_comp,
unsigned long  exp_limit 
)

< How many induced ordering block do we have?

Definition at line 2646 of file ring.cc.

2649 {
2650  assume (r != NULL );
2651  assume (exp_limit > 1);
2652  BOOLEAN omitted_degree = FALSE;
2653 
2654  int bits;
2655  exp_limit=rGetExpSize(exp_limit, bits, r->N);
2656  BOOLEAN need_other_ring = (exp_limit != r->bitmask);
2657 
2658  int iNeedInducedOrderingSetup = 0; ///< How many induced ordering block do we have?
2659 
2660  int nblocks=rBlocks(r);
2661  rRingOrder_t *order=(rRingOrder_t*)omAlloc0((nblocks+1)*sizeof(rRingOrder_t));
2662  int *block0=(int*)omAlloc0((nblocks+1)*sizeof(int));
2663  int *block1=(int*)omAlloc0((nblocks+1)*sizeof(int));
2664  int **wvhdl=(int**)omAlloc0((nblocks+1)*sizeof(int *));
2665 
2666  int i=0;
2667  int j=0; /* i index in r, j index in res */
2668 
2669  for( rRingOrder_t r_ord=r->order[i]; (r_ord != (rRingOrder_t)0) && (i < nblocks); j++, r_ord=r->order[++i])
2670  {
2671  BOOLEAN copy_block_index=TRUE;
2672 
2673  if (r->block0[i]==r->block1[i])
2674  {
2675  switch(r_ord)
2676  {
2677  case ringorder_wp:
2678  case ringorder_dp:
2679  case ringorder_Wp:
2680  case ringorder_Dp:
2681  r_ord=ringorder_lp;
2682  break;
2683  case ringorder_Ws:
2684  case ringorder_Ds:
2685  case ringorder_ws:
2686  case ringorder_ds:
2687  r_ord=ringorder_ls;
2688  break;
2689  default:
2690  break;
2691  }
2692  }
2693  switch(r_ord)
2694  {
2695  case ringorder_S:
2696  {
2697 #ifndef SING_NDEBUG
2698  Warn("Error: unhandled ordering in rModifyRing: ringorder_S = [%d]", r_ord);
2699 #endif
2700  order[j]=r_ord; /*r->order[i];*/
2701  break;
2702  }
2703  case ringorder_C:
2704  case ringorder_c:
2705  if (!try_omit_comp)
2706  {
2707  order[j]=r_ord; /*r->order[i]*/;
2708  }
2709  else
2710  {
2711  j--;
2712  need_other_ring=TRUE;
2713  try_omit_comp=FALSE;
2714  copy_block_index=FALSE;
2715  }
2716  break;
2717  case ringorder_wp:
2718  case ringorder_dp:
2719  case ringorder_ws:
2720  case ringorder_ds:
2721  if(!omit_degree)
2722  {
2723  order[j]=r_ord; /*r->order[i]*/;
2724  }
2725  else
2726  {
2727  order[j]=ringorder_rs;
2728  need_other_ring=TRUE;
2729  omit_degree=FALSE;
2730  omitted_degree = TRUE;
2731  }
2732  break;
2733  case ringorder_Wp:
2734  case ringorder_Dp:
2735  case ringorder_Ws:
2736  case ringorder_Ds:
2737  if(!omit_degree)
2738  {
2739  order[j]=r_ord; /*r->order[i];*/
2740  }
2741  else
2742  {
2743  order[j]=ringorder_lp;
2744  need_other_ring=TRUE;
2745  omit_degree=FALSE;
2746  omitted_degree = TRUE;
2747  }
2748  break;
2749  case ringorder_IS:
2750  {
2751  if (try_omit_comp)
2752  {
2753  // tried, but cannot omit component due to the ordering block [%d]: %d (ringorder_IS)", i, r_ord
2754  try_omit_comp = FALSE;
2755  }
2756  order[j]=r_ord; /*r->order[i];*/
2757  iNeedInducedOrderingSetup++;
2758  break;
2759  }
2760  case ringorder_s:
2761  {
2762  assume((i == 0) && (j == 0));
2763  if (try_omit_comp)
2764  {
2765  // tried, but cannot omit component due to the ordering block [%d]: %d (ringorder_s)", i, r_ord
2766  try_omit_comp = FALSE;
2767  }
2768  order[j]=r_ord; /*r->order[i];*/
2769  break;
2770  }
2771  default:
2772  order[j]=r_ord; /*r->order[i];*/
2773  break;
2774  }
2775  if (copy_block_index)
2776  {
2777  block0[j]=r->block0[i];
2778  block1[j]=r->block1[i];
2779  wvhdl[j]=r->wvhdl[i];
2780  }
2781 
2782  // order[j]=ringorder_no; // done by omAlloc0
2783  }
2784  if(!need_other_ring)
2785  {
2786  omFreeSize(order,(nblocks+1)*sizeof(rRingOrder_t));
2787  omFreeSize(block0,(nblocks+1)*sizeof(int));
2788  omFreeSize(block1,(nblocks+1)*sizeof(int));
2789  omFreeSize(wvhdl,(nblocks+1)*sizeof(int *));
2790  return r;
2791  }
2792  ring res=(ring)omAlloc0Bin(sip_sring_bin);
2793  *res = *r;
2794 
2795 #ifdef HAVE_PLURAL
2796  res->GetNC() = NULL;
2797 #endif
2798 
2799  // res->qideal, res->idroot ???
2800  res->wvhdl=wvhdl;
2801  res->order=order;
2802  res->block0=block0;
2803  res->block1=block1;
2804  res->bitmask=exp_limit;
2805  res->wanted_maxExp=r->wanted_maxExp;
2806  //int tmpref=r->cf->ref0;
2807  rComplete(res, 1);
2808  //r->cf->ref=tmpref;
2809 
2810  // adjust res->pFDeg: if it was changed globally, then
2811  // it must also be changed for new ring
2812  if (r->pFDegOrig != res->pFDegOrig &&
2814  {
2815  // still might need adjustment for weighted orderings
2816  // and omit_degree
2817  res->firstwv = r->firstwv;
2818  res->firstBlockEnds = r->firstBlockEnds;
2819  res->pFDeg = res->pFDegOrig = p_WFirstTotalDegree;
2820  }
2821  if (omitted_degree)
2822  res->pLDeg = r->pLDegOrig;
2823 
2824  rOptimizeLDeg(res); // also sets res->pLDegOrig
2825 
2826  // set syzcomp
2827  if (res->typ != NULL)
2828  {
2829  if( res->typ[0].ord_typ == ro_syz) // "s" Always on [0] place!
2830  {
2831  res->typ[0] = r->typ[0]; // Copy struct!? + setup the same limit!
2832 
2833  if (r->typ[0].data.syz.limit > 0)
2834  {
2835  res->typ[0].data.syz.syz_index
2836  = (int*) omAlloc((r->typ[0].data.syz.limit +1)*sizeof(int));
2837  memcpy(res->typ[0].data.syz.syz_index, r->typ[0].data.syz.syz_index,
2838  (r->typ[0].data.syz.limit +1)*sizeof(int));
2839  }
2840  }
2841 
2842  if( iNeedInducedOrderingSetup > 0 )
2843  {
2844  for(j = 0, i = 0; (i < nblocks) && (iNeedInducedOrderingSetup > 0); i++)
2845  if( res->typ[i].ord_typ == ro_is ) // Search for suffixes!
2846  {
2847  ideal F = idrHeadR(r->typ[i].data.is.F, r, res); // Copy F from r into res!
2848  assume(
2850  F, // WILL BE COPIED!
2851  r->typ[i].data.is.limit,
2852  j++
2853  )
2854  );
2855  id_Delete(&F, res);
2856  iNeedInducedOrderingSetup--;
2857  }
2858  } // Process all induced Ordering blocks! ...
2859  }
2860  // the special case: homog (omit_degree) and 1 block rs: that is global:
2861  // it comes from dp
2862  res->OrdSgn=r->OrdSgn;
2863 
2864 
2865 #ifdef HAVE_PLURAL
2866  if (rIsPluralRing(r))
2867  {
2868  if ( nc_rComplete(r, res, false) ) // no qideal!
2869  {
2870 #ifndef SING_NDEBUG
2871  WarnS("error in nc_rComplete");
2872 #endif
2873  // cleanup?
2874 
2875 // rDelete(res);
2876 // return r;
2877 
2878  // just go on..
2879  }
2880 
2881  if( rIsSCA(r) )
2882  {
2883  if( !sca_Force(res, scaFirstAltVar(r), scaLastAltVar(r)) )
2884  WarnS("error in sca_Force!");
2885  }
2886  }
2887 #endif
2888 
2889  return res;
2890 }
#define Warn
Definition: emacs.cc:77
bool sca_Force(ring rGR, int b, int e)
Definition: sca.cc:1161
ideal idrHeadR(ideal id, ring r, ring dest_r)
Copy leading terms of id[i] via prHeeadR into dest_r.
Definition: prCopy.cc:155
BOOLEAN rSetISReference(const ring r, const ideal F, const int i, const int p)
Changes r by setting induced ordering parameters: limit and reference leading terms F belong to r,...
Definition: ring.cc:4982
static void rOptimizeLDeg(ring r)
Definition: ring.cc:3103
BOOLEAN rOrd_is_WeightedDegree_Ordering(const ring r)
Definition: ring.cc:1944
static short scaLastAltVar(ring r)
Definition: sca.h:25
static short scaFirstAltVar(ring r)
Definition: sca.h:18

◆ rModifyRing_Simple()

ring rModifyRing_Simple ( ring  r,
BOOLEAN  ommit_degree,
BOOLEAN  ommit_comp,
unsigned long  exp_limit,
BOOLEAN simple 
)

Definition at line 2941 of file ring.cc.

2942 {
2943  simple=TRUE;
2944  if (!rHasSimpleOrder(r))
2945  {
2946  simple=FALSE; // sorting needed
2947  assume (r != NULL );
2948  assume (exp_limit > 1);
2949  int bits;
2950 
2951  exp_limit=rGetExpSize(exp_limit, bits, r->N);
2952 
2953  int nblocks=1+(ommit_comp!=0);
2954  rRingOrder_t *order=(rRingOrder_t*)omAlloc0((nblocks+1)*sizeof(rRingOrder_t));
2955  int *block0=(int*)omAlloc0((nblocks+1)*sizeof(int));
2956  int *block1=(int*)omAlloc0((nblocks+1)*sizeof(int));
2957  int **wvhdl=(int**)omAlloc0((nblocks+1)*sizeof(int *));
2958 
2959  order[0]=ringorder_lp;
2960  block0[0]=1;
2961  block1[0]=r->N;
2962  if (!ommit_comp)
2963  {
2964  order[1]=ringorder_C;
2965  }
2966  ring res=(ring)omAlloc0Bin(sip_sring_bin);
2967  *res = *r;
2968 #ifdef HAVE_PLURAL
2969  res->GetNC() = NULL;
2970 #endif
2971  // res->qideal, res->idroot ???
2972  res->wvhdl=wvhdl;
2973  res->order=order;
2974  res->block0=block0;
2975  res->block1=block1;
2976  res->bitmask=exp_limit;
2977  res->wanted_maxExp=r->wanted_maxExp;
2978  //int tmpref=r->cf->ref;
2979  rComplete(res, 1);
2980  //r->cf->ref=tmpref;
2981 
2982 #ifdef HAVE_PLURAL
2983  if (rIsPluralRing(r))
2984  {
2985  if ( nc_rComplete(r, res, false) ) // no qideal!
2986  {
2987 #ifndef SING_NDEBUG
2988  WarnS("error in nc_rComplete");
2989 #endif
2990  // cleanup?
2991 
2992 // rDelete(res);
2993 // return r;
2994 
2995  // just go on..
2996  }
2997  }
2998 #endif
2999 
3000  rOptimizeLDeg(res);
3001 
3002  return res;
3003  }
3004  return rModifyRing(r, ommit_degree, ommit_comp, exp_limit);
3005 }
ring rModifyRing(ring r, BOOLEAN omit_degree, BOOLEAN try_omit_comp, unsigned long exp_limit)
Definition: ring.cc:2646

◆ rModifyRing_Wp()

ring rModifyRing_Wp ( ring  r,
int *  weights 
)

construct Wp, C ring

Definition at line 2893 of file ring.cc.

2894 {
2895  ring res=(ring)omAlloc0Bin(sip_sring_bin);
2896  *res = *r;
2897 #ifdef HAVE_PLURAL
2898  res->GetNC() = NULL;
2899 #endif
2900 
2901  /*weights: entries for 3 blocks: NULL*/
2902  res->wvhdl = (int **)omAlloc0(3 * sizeof(int *));
2903  /*order: Wp,C,0*/
2904  res->order = (rRingOrder_t *) omAlloc(3 * sizeof(rRingOrder_t *));
2905  res->block0 = (int *)omAlloc0(3 * sizeof(int *));
2906  res->block1 = (int *)omAlloc0(3 * sizeof(int *));
2907  /* ringorder Wp for the first block: var 1..r->N */
2908  res->order[0] = ringorder_Wp;
2909  res->block0[0] = 1;
2910  res->block1[0] = r->N;
2911  res->wvhdl[0] = weights;
2912  /* ringorder C for the second block: no vars */
2913  res->order[1] = ringorder_C;
2914  /* the last block: everything is 0 */
2915  res->order[2] = (rRingOrder_t)0;
2916 
2917  //int tmpref=r->cf->ref;
2918  rComplete(res, 1);
2919  //r->cf->ref=tmpref;
2920 #ifdef HAVE_PLURAL
2921  if (rIsPluralRing(r))
2922  {
2923  if ( nc_rComplete(r, res, false) ) // no qideal!
2924  {
2925 #ifndef SING_NDEBUG
2926  WarnS("error in nc_rComplete");
2927 #endif
2928  // cleanup?
2929 
2930 // rDelete(res);
2931 // return r;
2932 
2933  // just go on..
2934  }
2935  }
2936 #endif
2937  return res;
2938 }

◆ rNChangeSComps()

static void rNChangeSComps ( int *  currComponents,
long *  currShiftedComponents,
ring  r 
)
inlinestatic

Definition at line 4358 of file ring.cc.

4359 {
4360  assume(r->typ[1].ord_typ == ro_syzcomp);
4361 
4362  r->typ[1].data.syzcomp.ShiftedComponents = currShiftedComponents;
4363  r->typ[1].data.syzcomp.Components = currComponents;
4364 }

◆ rNGetSComps()

static void rNGetSComps ( int **  currComponents,
long **  currShiftedComponents,
ring  r 
)
inlinestatic

Definition at line 4366 of file ring.cc.

4367 {
4368  assume(r->typ[1].ord_typ == ro_syzcomp);
4369 
4370  *currShiftedComponents = r->typ[1].data.syzcomp.ShiftedComponents;
4371  *currComponents = r->typ[1].data.syzcomp.Components;
4372 }

◆ rO_Align()

static void rO_Align ( int &  place,
int &  bitplace 
)
static

Definition at line 2142 of file ring.cc.

2143 {
2144  // increment place to the next aligned one
2145  // (count as Exponent_t,align as longs)
2146  if (bitplace!=BITS_PER_LONG)
2147  {
2148  place++;
2149  bitplace=BITS_PER_LONG;
2150  }
2151 }

◆ rO_ISPrefix()

static void rO_ISPrefix ( int &  place,
int &  bitplace,
int &  prev_ord,
long *  o,
int  ,
int *  v,
sro_ord ord_struct 
)
static

Definition at line 2404 of file ring.cc.

2406 {
2407  if ((prev_ord== 1) || (bitplace!=BITS_PER_LONG))
2408  rO_Align(place,bitplace);
2409  // since we add something afterwards - it's better to start with anew!?
2410 
2411  ord_struct.ord_typ = ro_isTemp;
2412  ord_struct.data.isTemp.start = place;
2413  ord_struct.data.isTemp.pVarOffset = (int *)omMemDup(v);
2414  ord_struct.data.isTemp.suffixpos = -1;
2415 
2416  // We will act as rO_Syz on our own!!!
2417  // Here we allocate an exponent as a level placeholder
2418  o[place]= -1;
2419  prev_ord=-1;
2420  place++;
2421 }
ro_typ ord_typ
Definition: ring.h:220
union sro_ord::@0 data

◆ rO_ISSuffix()

static void rO_ISSuffix ( int &  place,
int &  bitplace,
int &  prev_ord,
long *  o,
int  N,
int *  v,
sro_ord tmp_typ,
int &  typ_i,
int  sgn 
)
static

Definition at line 2422 of file ring.cc.

2424 {
2425 
2426  // Let's find previous prefix:
2427  int typ_j = typ_i - 1;
2428  while(typ_j >= 0)
2429  {
2430  if( tmp_typ[typ_j].ord_typ == ro_isTemp)
2431  break;
2432  typ_j --;
2433  }
2434 
2435  assume( typ_j >= 0 );
2436 
2437  if( typ_j < 0 ) // Found NO prefix!!! :(
2438  return;
2439 
2440  assume( tmp_typ[typ_j].ord_typ == ro_isTemp );
2441 
2442  // Get saved state:
2443  const int start = tmp_typ[typ_j].data.isTemp.start;
2444  int *pVarOffset = tmp_typ[typ_j].data.isTemp.pVarOffset;
2445 
2446 /*
2447  // shift up all blocks
2448  while(typ_j < (typ_i-1))
2449  {
2450  tmp_typ[typ_j] = tmp_typ[typ_j+1];
2451  typ_j++;
2452  }
2453  typ_j = typ_i - 1; // No increment for typ_i
2454 */
2455  tmp_typ[typ_j].data.isTemp.suffixpos = typ_i;
2456 
2457  // Let's keep that dummy for now...
2458  typ_j = typ_i; // the typ to change!
2459  typ_i++; // Just for now...
2460 
2461 
2462  for( int i = 0; i <= N; i++ ) // Note [0] == component !!! No Skip?
2463  {
2464  // Was i-th variable allocated inbetween?
2465  if( v[i] != pVarOffset[i] )
2466  {
2467  pVarOffset[i] = v[i]; // Save for later...
2468  v[i] = -1; // Undo!
2469  assume( pVarOffset[i] != -1 );
2470  }
2471  else
2472  pVarOffset[i] = -1; // No change here...
2473  }
2474 
2475  if( pVarOffset[0] != -1 )
2476  pVarOffset[0] &= 0x0fff;
2477 
2478  sro_ord &ord_struct = tmp_typ[typ_j];
2479 
2480 
2481  ord_struct.ord_typ = ro_is;
2482  ord_struct.data.is.start = start;
2483  ord_struct.data.is.end = place;
2484  ord_struct.data.is.pVarOffset = pVarOffset;
2485 
2486 
2487  // What about component???
2488 // if( v[0] != -1 ) // There is a component already...???
2489 // if( o[ v[0] & 0x0fff ] == sgn )
2490 // {
2491 // pVarOffset[0] = -1; // NEVER USED Afterwards...
2492 // return;
2493 // }
2494 
2495 
2496  // Moreover: we need to allocate the module component (v[0]) here!
2497  if( v[0] == -1) // It's possible that there was module component v0 at the begining (before prefix)!
2498  {
2499  // Start with a whole long exponent
2500  if( bitplace != BITS_PER_LONG )
2501  rO_Align(place, bitplace);
2502 
2503  assume( bitplace == BITS_PER_LONG );
2504  bitplace -= BITS_PER_LONG;
2505  assume(bitplace == 0);
2506  v[0] = place | (bitplace << 24); // Never mind whether pVarOffset[0] > 0!!!
2507  o[place] = sgn; // Singnum for component ordering
2508  prev_ord = sgn;
2509  }
2510 }

◆ rO_LexVars()

static void rO_LexVars ( int &  place,
int &  bitplace,
int  start,
int  end,
int &  prev_ord,
long *  o,
int *  v,
int  bits,
int  opt_var 
)
static

Definition at line 2287 of file ring.cc.

2289 {
2290  // a block of variables v_start..v_end with lex order, ordsgn 1
2291  int k;
2292  int incr=1;
2293  if(prev_ord==-1) rO_Align(place,bitplace);
2294 
2295  if (start>end)
2296  {
2297  incr=-1;
2298  }
2299  for(k=start;;k+=incr)
2300  {
2301  bitplace-=bits;
2302  if (bitplace < 0) { bitplace=BITS_PER_LONG-bits; place++; }
2303  o[place]=1;
2304  v[k]= place | (bitplace << 24);
2305  if (k==end) break;
2306  }
2307  prev_ord=1;
2308  if (opt_var!= -1)
2309  {
2310  assume((opt_var == end+1) ||(opt_var == end-1));
2311  if((opt_var != end+1) &&(opt_var != end-1)) WarnS("hier-2");
2312  int save_bitplace=bitplace;
2313  bitplace-=bits;
2314  if (bitplace < 0)
2315  {
2316  bitplace=save_bitplace;
2317  return;
2318  }
2319  // there is enough space for the optional var
2320  v[opt_var]=place | (bitplace << 24);
2321  }
2322 }

◆ rO_LexVars_neg()

static void rO_LexVars_neg ( int &  place,
int &  bitplace,
int  start,
int  end,
int &  prev_ord,
long *  o,
int *  v,
int  bits,
int  opt_var 
)
static

Definition at line 2324 of file ring.cc.

2326 {
2327  // a block of variables v_start..v_end with lex order, ordsgn -1
2328  int k;
2329  int incr=1;
2330  if(prev_ord==1) rO_Align(place,bitplace);
2331 
2332  if (start>end)
2333  {
2334  incr=-1;
2335  }
2336  for(k=start;;k+=incr)
2337  {
2338  bitplace-=bits;
2339  if (bitplace < 0) { bitplace=BITS_PER_LONG-bits; place++; }
2340  o[place]=-1;
2341  v[k]=place | (bitplace << 24);
2342  if (k==end) break;
2343  }
2344  prev_ord=-1;
2345 // #if 0
2346  if (opt_var!= -1)
2347  {
2348  assume((opt_var == end+1) ||(opt_var == end-1));
2349  if((opt_var != end+1) &&(opt_var != end-1)) WarnS("hier-1");
2350  int save_bitplace=bitplace;
2351  bitplace-=bits;
2352  if (bitplace < 0)
2353  {
2354  bitplace=save_bitplace;
2355  return;
2356  }
2357  // there is enough space for the optional var
2358  v[opt_var]=place | (bitplace << 24);
2359  }
2360 // #endif
2361 }

◆ rO_Syz()

static void rO_Syz ( int &  place,
int &  bitplace,
int &  prev_ord,
int  syz_comp,
long *  o,
sro_ord ord_struct 
)
static

Definition at line 2378 of file ring.cc.

2380 {
2381  // ordering is derived from component number
2382  // let's reserve one Exponent_t for it
2383  if ((prev_ord== 1) || (bitplace!=BITS_PER_LONG))
2384  rO_Align(place,bitplace);
2385  ord_struct.ord_typ=ro_syz;
2386  ord_struct.data.syz.place=place;
2387  ord_struct.data.syz.limit=syz_comp;
2388  if (syz_comp>0)
2389  ord_struct.data.syz.syz_index = (int*) omAlloc0((syz_comp+1)*sizeof(int));
2390  else
2391  ord_struct.data.syz.syz_index = NULL;
2392  ord_struct.data.syz.curr_index = 1;
2393  o[place]= -1;
2394  prev_ord=-1;
2395  place++;
2396 }

◆ rO_Syzcomp()

static void rO_Syzcomp ( int &  place,
int &  bitplace,
int &  prev_ord,
long *  o,
sro_ord ord_struct 
)
static

Definition at line 2363 of file ring.cc.

2365 {
2366  // ordering is derived from component number
2367  rO_Align(place,bitplace);
2368  ord_struct.ord_typ=ro_syzcomp;
2369  ord_struct.data.syzcomp.place=place;
2370  ord_struct.data.syzcomp.Components=NULL;
2371  ord_struct.data.syzcomp.ShiftedComponents=NULL;
2372  o[place]=1;
2373  prev_ord=1;
2374  place++;
2375  rO_Align(place,bitplace);
2376 }

◆ rO_TDegree()

static void rO_TDegree ( int &  place,
int &  bitplace,
int  start,
int  end,
long *  o,
sro_ord ord_struct 
)
static

Definition at line 2153 of file ring.cc.

2155 {
2156  // degree (aligned) of variables v_start..v_end, ordsgn 1
2157  rO_Align(place,bitplace);
2158  ord_struct.ord_typ=ro_dp;
2159  ord_struct.data.dp.start=start;
2160  ord_struct.data.dp.end=end;
2161  ord_struct.data.dp.place=place;
2162  o[place]=1;
2163  place++;
2164  rO_Align(place,bitplace);
2165 }

◆ rO_TDegree_neg()

static void rO_TDegree_neg ( int &  place,
int &  bitplace,
int  start,
int  end,
long *  o,
sro_ord ord_struct 
)
static

Definition at line 2167 of file ring.cc.

2169 {
2170  // degree (aligned) of variables v_start..v_end, ordsgn -1
2171  rO_Align(place,bitplace);
2172  ord_struct.ord_typ=ro_dp;
2173  ord_struct.data.dp.start=start;
2174  ord_struct.data.dp.end=end;
2175  ord_struct.data.dp.place=place;
2176  o[place]=-1;
2177  place++;
2178  rO_Align(place,bitplace);
2179 }

◆ rO_WDegree()

static void rO_WDegree ( int &  place,
int &  bitplace,
int  start,
int  end,
long *  o,
sro_ord ord_struct,
int *  weights 
)
static

Definition at line 2181 of file ring.cc.

2183 {
2184  // weighted degree (aligned) of variables v_start..v_end, ordsgn 1
2185  while((start<end) && (weights[0]==0)) { start++; weights++; }
2186  while((start<end) && (weights[end-start]==0)) { end--; }
2187  int i;
2188  int pure_tdeg=1;
2189  for(i=start;i<=end;i++)
2190  {
2191  if(weights[i-start]!=1)
2192  {
2193  pure_tdeg=0;
2194  break;
2195  }
2196  }
2197  if (pure_tdeg)
2198  {
2199  rO_TDegree(place,bitplace,start,end,o,ord_struct);
2200  return;
2201  }
2202  rO_Align(place,bitplace);
2203  ord_struct.ord_typ=ro_wp;
2204  ord_struct.data.wp.start=start;
2205  ord_struct.data.wp.end=end;
2206  ord_struct.data.wp.place=place;
2207  ord_struct.data.wp.weights=weights;
2208  o[place]=1;
2209  place++;
2210  rO_Align(place,bitplace);
2211  for(i=start;i<=end;i++)
2212  {
2213  if(weights[i-start]<0)
2214  {
2215  ord_struct.ord_typ=ro_wp_neg;
2216  break;
2217  }
2218  }
2219 }

◆ rO_WDegree64()

static void rO_WDegree64 ( int &  place,
int &  bitplace,
int  start,
int  end,
long *  o,
sro_ord ord_struct,
int64 weights 
)
static

Definition at line 2243 of file ring.cc.

2245 {
2246  // weighted degree (aligned) of variables v_start..v_end, ordsgn 1,
2247  // reserved 2 places
2248  rO_Align(place,bitplace);
2249  ord_struct.ord_typ=ro_wp64;
2250  ord_struct.data.wp64.start=start;
2251  ord_struct.data.wp64.end=end;
2252  ord_struct.data.wp64.place=place;
2253  ord_struct.data.wp64.weights64=weights;
2254  o[place]=1;
2255  place++;
2256  o[place]=1;
2257  place++;
2258  rO_Align(place,bitplace);
2259 }

◆ rO_WDegree_neg()

static void rO_WDegree_neg ( int &  place,
int &  bitplace,
int  start,
int  end,
long *  o,
sro_ord ord_struct,
int *  weights 
)
static

Definition at line 2261 of file ring.cc.

2263 {
2264  // weighted degree (aligned) of variables v_start..v_end, ordsgn -1
2265  while((start<end) && (weights[0]==0)) { start++; weights++; }
2266  while((start<end) && (weights[end-start]==0)) { end--; }
2267  rO_Align(place,bitplace);
2268  ord_struct.ord_typ=ro_wp;
2269  ord_struct.data.wp.start=start;
2270  ord_struct.data.wp.end=end;
2271  ord_struct.data.wp.place=place;
2272  ord_struct.data.wp.weights=weights;
2273  o[place]=-1;
2274  place++;
2275  rO_Align(place,bitplace);
2276  int i;
2277  for(i=start;i<=end;i++)
2278  {
2279  if(weights[i-start]<0)
2280  {
2281  ord_struct.ord_typ=ro_wp_neg;
2282  break;
2283  }
2284  }
2285 }

◆ rO_WMDegree()

static void rO_WMDegree ( int &  place,
int &  bitplace,
int  start,
int  end,
long *  o,
sro_ord ord_struct,
int *  weights 
)
static

Definition at line 2221 of file ring.cc.

2223 {
2224  assume(weights != NULL);
2225 
2226  // weighted degree (aligned) of variables v_start..v_end, ordsgn 1
2227 // while((start<end) && (weights[0]==0)) { start++; weights++; }
2228 // while((start<end) && (weights[end-start]==0)) { end--; }
2229  rO_Align(place,bitplace);
2230  ord_struct.ord_typ=ro_am;
2231  ord_struct.data.am.start=start;
2232  ord_struct.data.am.end=end;
2233  ord_struct.data.am.place=place;
2234  ord_struct.data.am.weights=weights;
2235  ord_struct.data.am.weights_m = weights + (end-start+1);
2236  ord_struct.data.am.len_gen=weights[end-start+1];
2237  assume( ord_struct.data.am.weights_m[0] == ord_struct.data.am.len_gen );
2238  o[place]=1;
2239  place++;
2240  rO_Align(place,bitplace);
2241 }

◆ rOpposite()

ring rOpposite ( ring  src)

Definition at line 5253 of file ring.cc.

5257 {
5258  if (src == NULL) return(NULL);
5259 
5260  //rChangeCurrRing(src);
5261 #ifdef RDEBUG
5262  rTest(src);
5263 // rWrite(src);
5264 // rDebugPrint(src);
5265 #endif
5266 
5267  ring r = rCopy0(src,FALSE);
5268  if (src->qideal != NULL)
5269  {
5270  id_Delete(&(r->qideal), src);
5271  }
5272 
5273  // change vars v1..vN -> vN..v1
5274  int i;
5275  int i2 = (rVar(r)-1)/2;
5276  for(i=i2; i>=0; i--)
5277  {
5278  // index: 0..N-1
5279  //Print("ex var names: %d <-> %d\n",i,rOppVar(r,i));
5280  // exchange names
5281  char *p;
5282  p = r->names[rVar(r)-1-i];
5283  r->names[rVar(r)-1-i] = r->names[i];
5284  r->names[i] = p;
5285  }
5286 // i2=(rVar(r)+1)/2;
5287 // for(int i=i2; i>0; i--)
5288 // {
5289 // // index: 1..N
5290 // //Print("ex var places: %d <-> %d\n",i,rVar(r)+1-i);
5291 // // exchange VarOffset
5292 // int t;
5293 // t=r->VarOffset[i];
5294 // r->VarOffset[i]=r->VarOffset[rOppVar(r,i)];
5295 // r->VarOffset[rOppVar(r,i)]=t;
5296 // }
5297  // change names:
5298  // TODO: does this work the same way for Letterplace?
5299  for (i=rVar(r)-1; i>=0; i--)
5300  {
5301  char *p=r->names[i];
5302  if(isupper(*p)) *p = tolower(*p);
5303  else *p = toupper(*p);
5304  }
5305  // change ordering: listing
5306  // change ordering: compare
5307 // for(i=0; i<r->OrdSize; i++)
5308 // {
5309 // int t,tt;
5310 // switch(r->typ[i].ord_typ)
5311 // {
5312 // case ro_dp:
5313 // //
5314 // t=r->typ[i].data.dp.start;
5315 // r->typ[i].data.dp.start=rOppVar(r,r->typ[i].data.dp.end);
5316 // r->typ[i].data.dp.end=rOppVar(r,t);
5317 // break;
5318 // case ro_wp:
5319 // case ro_wp_neg:
5320 // {
5321 // t=r->typ[i].data.wp.start;
5322 // r->typ[i].data.wp.start=rOppVar(r,r->typ[i].data.wp.end);
5323 // r->typ[i].data.wp.end=rOppVar(r,t);
5324 // // invert r->typ[i].data.wp.weights
5325 // rOppWeight(r->typ[i].data.wp.weights,
5326 // r->typ[i].data.wp.end-r->typ[i].data.wp.start);
5327 // break;
5328 // }
5329 // //case ro_wp64:
5330 // case ro_syzcomp:
5331 // case ro_syz:
5332 // WerrorS("not implemented in rOpposite");
5333 // // should not happen
5334 // break;
5335 //
5336 // case ro_cp:
5337 // t=r->typ[i].data.cp.start;
5338 // r->typ[i].data.cp.start=rOppVar(r,r->typ[i].data.cp.end);
5339 // r->typ[i].data.cp.end=rOppVar(r,t);
5340 // break;
5341 // case ro_none:
5342 // default:
5343 // Werror("unknown type in rOpposite(%d)",r->typ[i].ord_typ);
5344 // break;
5345 // }
5346 // }
5347  // Change order/block structures (needed for rPrint, rAdd etc.)
5348 
5349  int j=0;
5350  int l=rBlocks(src);
5351  if ( ! rIsLPRing(src) )
5352  {
5353  // ie Plural or commutative
5354  for(i=0; src->order[i]!=0; i++)
5355  {
5356  switch (src->order[i])
5357  {
5358  case ringorder_c: /* c-> c */
5359  case ringorder_C: /* C-> C */
5360  case ringorder_no /*=0*/: /* end-of-block */
5361  r->order[j]=src->order[i];
5362  j++; break;
5363  case ringorder_lp: /* lp -> rp */
5364  r->order[j]=ringorder_rp;
5365  r->block0[j]=rOppVar(r, src->block1[i]);
5366  r->block1[j]=rOppVar(r, src->block0[i]);
5367  j++;break;
5368  case ringorder_rp: /* rp -> lp */
5369  r->order[j]=ringorder_lp;
5370  r->block0[j]=rOppVar(r, src->block1[i]);
5371  r->block1[j]=rOppVar(r, src->block0[i]);
5372  j++;break;
5373  case ringorder_dp: /* dp -> a(1..1),ls */
5374  {
5375  l=rRealloc1(r,l,j);
5376  r->order[j]=ringorder_a;
5377  r->block0[j]=rOppVar(r, src->block1[i]);
5378  r->block1[j]=rOppVar(r, src->block0[i]);
5379  r->wvhdl[j]=(int*)omAlloc((r->block1[j]-r->block0[j]+1)*sizeof(int));
5380  for(int k=r->block0[j]; k<=r->block1[j]; k++)
5381  r->wvhdl[j][k-r->block0[j]]=1;
5382  j++;
5383  r->order[j]=ringorder_ls;
5384  r->block0[j]=rOppVar(r, src->block1[i]);
5385  r->block1[j]=rOppVar(r, src->block0[i]);
5386  j++;
5387  break;
5388  }
5389  case ringorder_Dp: /* Dp -> a(1..1),rp */
5390  {
5391  l=rRealloc1(r,l,j);
5392  r->order[j]=ringorder_a;
5393  r->block0[j]=rOppVar(r, src->block1[i]);
5394  r->block1[j]=rOppVar(r, src->block0[i]);
5395  r->wvhdl[j]=(int*)omAlloc((r->block1[j]-r->block0[j]+1)*sizeof(int));
5396  for(int k=r->block0[j]; k<=r->block1[j]; k++)
5397  r->wvhdl[j][k-r->block0[j]]=1;
5398  j++;
5399  r->order[j]=ringorder_rp;
5400  r->block0[j]=rOppVar(r, src->block1[i]);
5401  r->block1[j]=rOppVar(r, src->block0[i]);
5402  j++;
5403  break;
5404  }
5405  case ringorder_wp: /* wp -> a(...),ls */
5406  {
5407  l=rRealloc1(r,l,j);
5408  r->order[j]=ringorder_a;
5409  r->block0[j]=rOppVar(r, src->block1[i]);
5410  r->block1[j]=rOppVar(r, src->block0[i]);
5411  r->wvhdl[j]=r->wvhdl[j+1]; r->wvhdl[j+1]=NULL;
5412  rOppWeight(r->wvhdl[j], r->block1[j]-r->block0[j]);
5413  j++;
5414  r->order[j]=ringorder_ls;
5415  r->block0[j]=rOppVar(r, src->block1[i]);
5416  r->block1[j]=rOppVar(r, src->block0[i]);
5417  j++;
5418  break;
5419  }
5420  case ringorder_Wp: /* Wp -> a(...),rp */
5421  {
5422  l=rRealloc1(r,l,j);
5423  r->order[j]=ringorder_a;
5424  r->block0[j]=rOppVar(r, src->block1[i]);
5425  r->block1[j]=rOppVar(r, src->block0[i]);
5426  r->wvhdl[j]=r->wvhdl[j+1]; r->wvhdl[j+1]=NULL;
5427  rOppWeight(r->wvhdl[j], r->block1[j]-r->block0[j]);
5428  j++;
5429  r->order[j]=ringorder_rp;
5430  r->block0[j]=rOppVar(r, src->block1[i]);
5431  r->block1[j]=rOppVar(r, src->block0[i]);
5432  j++;
5433  break;
5434  }
5435  case ringorder_M: /* M -> M */
5436  {
5437  r->order[j]=ringorder_M;
5438  r->block0[j]=rOppVar(r, src->block1[i]);
5439  r->block1[j]=rOppVar(r, src->block0[i]);
5440  int n=r->block1[j]-r->block0[j];
5441  /* M is a (n+1)x(n+1) matrix */
5442  for (int nn=0; nn<=n; nn++)
5443  {
5444  rOppWeight(&(r->wvhdl[j][nn*(n+1)]), n /*r->block1[j]-r->block0[j]*/);
5445  }
5446  j++;
5447  break;
5448  }
5449  case ringorder_a: /* a(...),ls -> wp/dp */
5450  {
5451  r->block0[j]=rOppVar(r, src->block1[i]);
5452  r->block1[j]=rOppVar(r, src->block0[i]);
5453  rOppWeight(r->wvhdl[j], r->block1[j]-r->block0[j]);
5454  if (src->order[i+1]==ringorder_ls)
5455  {
5456  r->order[j]=ringorder_wp;
5457  i++;
5458  //l=rReallocM1(r,l,j);
5459  }
5460  else
5461  {
5462  r->order[j]=ringorder_a;
5463  }
5464  j++;
5465  break;
5466  }
5467  // not yet done:
5468  case ringorder_ls:
5469  case ringorder_rs:
5470  case ringorder_ds:
5471  case ringorder_Ds:
5472  case ringorder_ws:
5473  case ringorder_Ws:
5474  case ringorder_am:
5475  case ringorder_a64:
5476  // should not occur:
5477  case ringorder_S:
5478  case ringorder_IS:
5479  case ringorder_s:
5480  case ringorder_aa:
5481  case ringorder_L:
5482  case ringorder_unspec:
5483  Werror("order %s not (yet) supported", rSimpleOrdStr(src->order[i]));
5484  break;
5485  }
5486  }
5487  } /* end if (!rIsLPRing(src)) */
5488  if (rIsLPRing(src))
5489  {
5490  // applies to Letterplace only
5491  // Letterplace conventions: dp<->Dp, lp<->rp
5492  // Wp(v) cannot be converted since wp(v) does not encode a monomial ordering
5493  // (a(w),<) is troublesome and thus postponed
5494  for(i=0; src->order[i]!=0; i++)
5495  {
5496  switch (src->order[i])
5497  {
5498  case ringorder_c: /* c-> c */
5499  case ringorder_C: /* C-> C */
5500  case ringorder_no /*=0*/: /* end-of-block */
5501  r->order[j]=src->order[i];
5502  j++; break;
5503  case ringorder_lp: /* lp -> rp */
5504  r->order[j]=ringorder_rp;
5505  r->block0[j]=rOppVar(r, src->block1[i]);
5506  r->block1[j]=rOppVar(r, src->block0[i]);
5507  j++;break;
5508  case ringorder_rp: /* rp -> lp */
5509  r->order[j]=ringorder_lp;
5510  r->block0[j]=rOppVar(r, src->block1[i]);
5511  r->block1[j]=rOppVar(r, src->block0[i]);
5512  j++;break;
5513  case ringorder_dp: /* dp -> Dp */
5514  {
5515  r->order[j]=ringorder_Dp;
5516  r->block0[j]=rOppVar(r, src->block1[i]);
5517  r->block1[j]=rOppVar(r, src->block0[i]);
5518  j++;break;
5519  }
5520  case ringorder_Dp: /* Dp -> dp*/
5521  {
5522  r->order[j]=ringorder_dp;
5523  r->block0[j]=rOppVar(r, src->block1[i]);
5524  r->block1[j]=rOppVar(r, src->block0[i]);
5525  j++;break;
5526  }
5527  // not clear how to do:
5528  case ringorder_wp:
5529  case ringorder_Wp:
5530  case ringorder_M:
5531  case ringorder_a:
5532  // not yet done:
5533  case ringorder_ls:
5534  case ringorder_rs:
5535  case ringorder_ds:
5536  case ringorder_Ds:
5537  case ringorder_ws:
5538  case ringorder_Ws:
5539  case ringorder_am:
5540  case ringorder_a64:
5541  // should not occur:
5542  case ringorder_S:
5543  case ringorder_IS:
5544  case ringorder_s:
5545  case ringorder_aa:
5546  case ringorder_L:
5547  case ringorder_unspec:
5548  Werror("order %s not (yet) supported", rSimpleOrdStr(src->order[i]));
5549  break;
5550  }
5551  }
5552  } /* end if (rIsLPRing(src)) */
5553  rComplete(r);
5554 
5555  //rChangeCurrRing(r);
5556 #ifdef RDEBUG
5557  rTest(r);
5558 // rWrite(r);
5559 // rDebugPrint(r);
5560 #endif
5561 
5562 #ifdef HAVE_PLURAL
5563  // now, we initialize a non-comm structure on r
5564  if (rIsPluralRing(src))
5565  {
5566 // assume( currRing == r);
5567 
5568  int *perm = (int *)omAlloc0((rVar(r)+1)*sizeof(int));
5569  int *par_perm = NULL;
5570  nMapFunc nMap = n_SetMap(src->cf,r->cf);
5571  int ni,nj;
5572  for(i=1; i<=r->N; i++)
5573  {
5574  perm[i] = rOppVar(r,i);
5575  }
5576 
5577  matrix C = mpNew(rVar(r),rVar(r));
5578  matrix D = mpNew(rVar(r),rVar(r));
5579 
5580  for (i=1; i< rVar(r); i++)
5581  {
5582  for (j=i+1; j<=rVar(r); j++)
5583  {
5584  ni = r->N +1 - i;
5585  nj = r->N +1 - j; /* i<j ==> nj < ni */
5586 
5587  assume(MATELEM(src->GetNC()->C,i,j) != NULL);
5588  MATELEM(C,nj,ni) = p_PermPoly(MATELEM(src->GetNC()->C,i,j),perm,src,r, nMap,par_perm,rPar(src));
5589 
5590  if(MATELEM(src->GetNC()->D,i,j) != NULL)
5591  MATELEM(D,nj,ni) = p_PermPoly(MATELEM(src->GetNC()->D,i,j),perm,src,r, nMap,par_perm,rPar(src));
5592  }
5593  }
5594 
5595  id_Test((ideal)C, r);
5596  id_Test((ideal)D, r);
5597 
5598  if (nc_CallPlural(C, D, NULL, NULL, r, false, false, true, r)) // no qring setup!
5599  WarnS("Error initializing non-commutative multiplication!");
5600 
5601 #ifdef RDEBUG
5602  rTest(r);
5603 // rWrite(r);
5604 // rDebugPrint(r);
5605 #endif
5606 
5607  assume( r->GetNC()->IsSkewConstant == src->GetNC()->IsSkewConstant);
5608 
5609  omFreeSize((ADDRESS)perm,(rVar(r)+1)*sizeof(int));
5610  }
5611 #endif /* HAVE_PLURAL */
5612 
5613  /* now oppose the qideal for qrings */
5614  if (src->qideal != NULL)
5615  {
5616 #ifdef HAVE_PLURAL
5617  r->qideal = idOppose(src, src->qideal, r); // into the currRing: r
5618 #else
5619  r->qideal = id_Copy(src->qideal, r); // ?
5620 #endif
5621 
5622 #ifdef HAVE_PLURAL
5623  if( rIsPluralRing(r) )
5624  {
5625  nc_SetupQuotient(r);
5626 #ifdef RDEBUG
5627  rTest(r);
5628 // rWrite(r);
5629 // rDebugPrint(r);
5630 #endif
5631  }
5632 #endif
5633  }
5634 #ifdef HAVE_PLURAL
5635  if( rIsPluralRing(r) )
5636  assume( ncRingType(r) == ncRingType(src) );
5637 #endif
5638  rTest(r);
5639 
5640  return r;
5641 }
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:74
ideal id_Copy(ideal h1, const ring r)
copy an ideal
ideal idOppose(ring Rop_src, ideal I, const ring Rop_dst)
opposes a module I from Rop to currRing(dst)
Definition: old.gring.cc:3381
poly p_PermPoly(poly p, const int *perm, const ring oldRing, const ring dst, nMapFunc nMap, const int *par_perm, int OldPar, BOOLEAN use_mult)
Definition: p_polys.cc:4156
const char * rSimpleOrdStr(int ord)
Definition: ring.cc:77
#define rOppVar(R, I)
Definition: ring.cc:5250
static void rOppWeight(int *w, int l)
Definition: ring.cc:5237
static int rRealloc1(ring r, int size, int pos)
Definition: ring.cc:5214
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:604
static BOOLEAN rIsLPRing(const ring r)
Definition: ring.h:411
@ ringorder_L
Definition: ring.h:89

◆ rOppWeight()

static void rOppWeight ( int *  w,
int  l 
)
static

Definition at line 5237 of file ring.cc.

5238 {
5239  /* works for commutative/Plural; need to be changed for Letterplace */
5240  /* Letterpace: each block of vars needs to be reverted on it own */
5241  int i2=(l+1)/2;
5242  for(int j=0; j<=i2; j++)
5243  {
5244  int t=w[j];
5245  w[j]=w[l-j];
5246  w[l-j]=t;
5247  }
5248 }

◆ rOptimizeLDeg()

static void rOptimizeLDeg ( ring  r)
static

Definition at line 3103 of file ring.cc.

3104 {
3105  if (r->pFDeg == p_Deg)
3106  {
3107  if (r->pLDeg == pLDeg1)
3108  r->pLDeg = pLDeg1_Deg;
3109  if (r->pLDeg == pLDeg1c)
3110  r->pLDeg = pLDeg1c_Deg;
3111  }
3112  else if (r->pFDeg == p_Totaldegree)
3113  {
3114  if (r->pLDeg == pLDeg1)
3115  r->pLDeg = pLDeg1_Totaldegree;
3116  if (r->pLDeg == pLDeg1c)
3117  r->pLDeg = pLDeg1c_Totaldegree;
3118  }
3119  else if (r->pFDeg == p_WFirstTotalDegree)
3120  {
3121  if (r->pLDeg == pLDeg1)
3122  r->pLDeg = pLDeg1_WFirstTotalDegree;
3123  if (r->pLDeg == pLDeg1c)
3124  r->pLDeg = pLDeg1c_WFirstTotalDegree;
3125  }
3126  r->pLDegOrig = r->pLDeg;
3127 }
long pLDeg1_Totaldegree(poly p, int *l, const ring r)
Definition: p_polys.cc:970
long pLDeg1_WFirstTotalDegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1033
long pLDeg1c_WFirstTotalDegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1063
long pLDeg1c_Deg(poly p, int *l, const ring r)
Definition: p_polys.cc:936
long pLDeg1(poly p, int *l, const ring r)
Definition: p_polys.cc:836
long pLDeg1_Deg(poly p, int *l, const ring r)
Definition: p_polys.cc:905
long pLDeg1c(poly p, int *l, const ring r)
Definition: p_polys.cc:872
long pLDeg1c_Totaldegree(poly p, int *l, const ring r)
Definition: p_polys.cc:1000

◆ rOrd_is_MixedDegree_Ordering()

BOOLEAN rOrd_is_MixedDegree_Ordering ( ring  r)

Definition at line 3381 of file ring.cc.

3382 {
3383  int i;
3384  poly p=p_One(r);
3385  p_SetExp(p,1,1,r);
3386  p_Setm(p,r);
3387  int vz=sign(p_FDeg(p,r));
3388  for(i=2;i<=rVar(r);i++)
3389  {
3390  p_SetExp(p,i-1,0,r);
3391  p_SetExp(p,i,1,r);
3392  p_Setm(p,r);
3393  if (sign(p_FDeg(p,r))!=vz)
3394  {
3395  p_Delete(&p,r);
3396  return TRUE;
3397  }
3398  }
3399  p_Delete(&p,r);
3400  return FALSE;
3401 }
static long p_FDeg(const poly p, const ring r)
Definition: p_polys.h:380
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:861
static int sign(int x)
Definition: ring.cc:3380

◆ rOrd_is_Totaldegree_Ordering()

BOOLEAN rOrd_is_Totaldegree_Ordering ( const ring  r)

Definition at line 1930 of file ring.cc.

1931 {
1932  // Hmm.... what about Syz orderings?
1933  return (rVar(r) > 1 &&
1934  ((rHasSimpleOrder(r) &&
1935  (rOrder_is_DegOrdering((rRingOrder_t)r->order[0]) ||
1936  rOrder_is_DegOrdering(( rRingOrder_t)r->order[1]))) ||
1937  (rHasSimpleOrderAA(r) &&
1938  (rOrder_is_DegOrdering((rRingOrder_t)r->order[1]) ||
1939  ((r->order[1]!=0) &&
1940  rOrder_is_DegOrdering((rRingOrder_t)r->order[2]))))));
1941 }
BOOLEAN rOrder_is_DegOrdering(const rRingOrder_t order)
Definition: ring.cc:1845
BOOLEAN rHasSimpleOrderAA(ring r)
Definition: ring.cc:1879

◆ rOrd_is_WeightedDegree_Ordering()

BOOLEAN rOrd_is_WeightedDegree_Ordering ( const ring  r)

Definition at line 1944 of file ring.cc.

1945 {
1946  // Hmm.... what about Syz orderings?
1947  return ((rVar(r) > 1) &&
1948  rHasSimpleOrder(r) &&
1949  (rOrder_is_WeightedOrdering((rRingOrder_t)r->order[0]) ||
1950  rOrder_is_WeightedOrdering(( rRingOrder_t)r->order[1])));
1951 }
BOOLEAN rOrder_is_WeightedOrdering(rRingOrder_t order)
Definition: ring.cc:1864

◆ rOrd_SetCompRequiresSetm()

BOOLEAN rOrd_SetCompRequiresSetm ( const ring  r)

return TRUE if p_SetComp requires p_Setm

Definition at line 1910 of file ring.cc.

1911 {
1912  if (r->typ != NULL)
1913  {
1914  int pos;
1915  for (pos=0;pos<r->OrdSize;pos++)
1916  {
1917  sro_ord* o=&(r->typ[pos]);
1918  if ( (o->ord_typ == ro_syzcomp)
1919  || (o->ord_typ == ro_syz)
1920  || (o->ord_typ == ro_is)
1921  || (o->ord_typ == ro_am)
1922  || (o->ord_typ == ro_isTemp))
1923  return TRUE;
1924  }
1925  }
1926  return FALSE;
1927 }

◆ rOrder_is_DegOrdering()

BOOLEAN rOrder_is_DegOrdering ( const rRingOrder_t  order)

Definition at line 1845 of file ring.cc.

1846 {
1847  switch(order)
1848  {
1849  case ringorder_dp:
1850  case ringorder_Dp:
1851  case ringorder_ds:
1852  case ringorder_Ds:
1853  case ringorder_Ws:
1854  case ringorder_Wp:
1855  case ringorder_ws:
1856  case ringorder_wp:
1857  return TRUE;
1858 
1859  default:
1860  return FALSE;
1861  }
1862 }

◆ rOrder_is_WeightedOrdering()

BOOLEAN rOrder_is_WeightedOrdering ( rRingOrder_t  order)

Definition at line 1864 of file ring.cc.

1865 {
1866  switch(order)
1867  {
1868  case ringorder_Ws:
1869  case ringorder_Wp:
1870  case ringorder_ws:
1871  case ringorder_wp:
1872  return TRUE;
1873 
1874  default:
1875  return FALSE;
1876  }
1877 }

◆ rOrderName()

rRingOrder_t rOrderName ( char *  ordername)

Definition at line 509 of file ring.cc.

510 {
511  int order=ringorder_unspec;
512  while (order!= 0)
513  {
514  if (strcmp(ordername,rSimpleOrdStr(order))==0)
515  break;
516  order--;
517  }
518  if (order==0) Werror("wrong ring order `%s`",ordername);
519  omFree((ADDRESS)ordername);
520  return (rRingOrder_t)order;
521 }

◆ rOrdStr()

char* rOrdStr ( ring  r)

Definition at line 523 of file ring.cc.

524 {
525  if ((r==NULL)||(r->order==NULL)) return omStrDup("");
526  int nblocks,l,i;
527 
528  for (nblocks=0; r->order[nblocks]; nblocks++);
529  nblocks--;
530 
531  StringSetS("");
532  for (l=0; ; l++)
533  {
534  StringAppendS((char *)rSimpleOrdStr(r->order[l]));
535  if (r->order[l] == ringorder_s)
536  {
537  StringAppend("(%d)",r->block0[l]);
538  }
539  else if (
540  (r->order[l] != ringorder_c)
541  && (r->order[l] != ringorder_C)
542  && (r->order[l] != ringorder_s)
543  && (r->order[l] != ringorder_S)
544  && (r->order[l] != ringorder_IS)
545  )
546  {
547  if (r->wvhdl[l]!=NULL)
548  {
549  #ifndef SING_NDEBUG
550  if((r->order[l] != ringorder_wp)
551  &&(r->order[l] != ringorder_Wp)
552  &&(r->order[l] != ringorder_ws)
553  &&(r->order[l] != ringorder_Ws)
554  &&(r->order[l] != ringorder_a)
555  &&(r->order[l] != ringorder_am)
556  &&(r->order[l] != ringorder_M))
557  {
558  Warn("should not have wvhdl entry at pos. %d",l);
559  StringAppend("(%d)",r->block1[l]-r->block0[l]+1);
560  }
561  else
562  #endif
563  {
564  StringAppendS("(");
565  for (int j= 0;
566  j<(r->block1[l]-r->block0[l]+1)*(r->block1[l]-r->block0[l]+1);
567  j+=i+1)
568  {
569  char c=',';
570  if(r->order[l]==ringorder_a64)
571  {
572  int64 * w=(int64 *)r->wvhdl[l];
573  for (i = 0; i<r->block1[l]-r->block0[l]; i++)
574  {
575  StringAppend("%lld," ,w[i]);
576  }
577  StringAppend("%lld)" ,w[i]);
578  break;
579  }
580  else
581  {
582  for (i = 0; i<r->block1[l]-r->block0[l]; i++)
583  {
584  StringAppend("%d," ,r->wvhdl[l][i+j]);
585  }
586  }
587  if (r->order[l]!=ringorder_M)
588  {
589  StringAppend("%d)" ,r->wvhdl[l][i+j]);
590  break;
591  }
592  if (j+i+1==(r->block1[l]-r->block0[l]+1)*(r->block1[l]-r->block0[l]+1))
593  c=')';
594  StringAppend("%d%c" ,r->wvhdl[l][i+j],c);
595  }
596  }
597  }
598  else
599  StringAppend("(%d)",r->block1[l]-r->block0[l]+1);
600  }
601  else if (r->order[l] == ringorder_IS)
602  {
603  assume( r->block0[l] == r->block1[l] );
604  const int s = r->block0[l];
605  assume( (-2 < s) && (s < 2) );
606 
607  StringAppend("(%d)", s);
608  }
609 
610  if (l==nblocks)
611  {
612  if (r->wanted_maxExp!=0)
613  {
614  long mm=r->wanted_maxExp;
615  if (mm>MAX_INT_VAL) mm=MAX_INT_VAL;
616  StringAppend(",L(%ld)",mm);
617  }
618  return StringEndS();
619  }
620  StringAppendS(",");
621  }
622 }
for(int i=0;i<=n;i++) degsf[i]
Definition: cfEzgcd.cc:72
#define StringAppend
Definition: emacs.cc:79
const int MAX_INT_VAL
Definition: mylimits.h:12
void StringSetS(const char *st)
Definition: reporter.cc:128
void StringAppendS(const char *st)
Definition: reporter.cc:107
char * StringEndS()
Definition: reporter.cc:151

◆ rParStr()

char* rParStr ( ring  r)

Definition at line 650 of file ring.cc.

651 {
652  if ((r==NULL)||(rParameter(r)==NULL)) return omStrDup("");
653 
654  char const * const * const params = rParameter(r);
655 
656  int i;
657  int l=2;
658 
659  for (i=0; i<rPar(r); i++)
660  {
661  l+=strlen(params[i])+1;
662  }
663  char *s=(char *)omAlloc((long)l);
664  s[0]='\0';
665  for (i=0; i<rPar(r)-1; i++)
666  {
667  strcat(s, params[i]);
668  strcat(s,",");
669  }
670  strcat(s, params[i]);
671  return s;
672 }
static char const ** rParameter(const ring r)
(r->cf->parameter)
Definition: ring.h:630

◆ rPlusVar()

ring rPlusVar ( const ring  r,
char *  v,
int  left 
)

K[x],"y" -> K[x,y] resp. K[y,x].

Definition at line 5789 of file ring.cc.

5790 {
5791  if (r->order[2]!=0)
5792  {
5793  WerrorS("only for rings with an ordering of one block");
5794  return NULL;
5795  }
5796  int p;
5797  if((r->order[0]==ringorder_C)
5798  ||(r->order[0]==ringorder_c))
5799  p=1;
5800  else
5801  p=0;
5802  if((r->order[p]!=ringorder_dp)
5803  && (r->order[p]!=ringorder_Dp)
5804  && (r->order[p]!=ringorder_lp)
5805  && (r->order[p]!=ringorder_rp)
5806  && (r->order[p]!=ringorder_ds)
5807  && (r->order[p]!=ringorder_Ds)
5808  && (r->order[p]!=ringorder_ls))
5809  {
5810  WerrorS("ordering must be dp,Dp,lp,rp,ds,Ds or ls");
5811  return NULL;
5812  }
5813  for(int i=r->N-1;i>=0;i--)
5814  {
5815  if (strcmp(r->names[i],v)==0)
5816  {
5817  Werror("duplicate variable name >>%s<<",v);
5818  return NULL;
5819  }
5820  }
5821  ring R=rCopy0(r);
5822  char **names;
5823  #ifdef HAVE_SHIFTBBA
5824  if (rIsLPRing(r))
5825  {
5826  R->isLPring=r->isLPring+1;
5827  R->N=((r->N)/r->isLPring)+r->N;
5828  names=(char**)omAlloc(R->N*sizeof(char_ptr));
5829  if (left)
5830  {
5831  for(int b=0;b<((r->N)/r->isLPring);b++)
5832  {
5833  names[b*R->isLPring]=omStrDup(v);
5834  for(int i=R->isLPring-1;i>0;i--)
5835  names[i+b*R->isLPring]=R->names[i-1+b*r->isLPring];
5836  }
5837  }
5838  else
5839  {
5840  for(int b=0;b<((r->N)/r->isLPring);b++)
5841  {
5842  names[(b+1)*R->isLPring-1]=omStrDup(v);
5843  for(int i=R->isLPring-2;i>=0;i--)
5844  names[i+b*R->isLPring]=R->names[i+b*r->isLPring];
5845  }
5846  }
5847  }
5848  else
5849  #endif
5850  {
5851  R->N++;
5852  names=(char**)omAlloc(R->N*sizeof(char_ptr));
5853  if (left)
5854  {
5855  names[0]=omStrDup(v);
5856  for(int i=R->N-1;i>0;i--) names[i]=R->names[i-1];
5857  }
5858  else
5859  {
5860  names[R->N-1]=omStrDup(v);
5861  for(int i=R->N-2;i>=0;i--) names[i]=R->names[i];
5862  }
5863  }
5864  omFreeSize(R->names,r->N*sizeof(char_ptr));
5865  R->names=names;
5866  R->block1[p]=R->N;
5867  rComplete(R);
5868  return R;
5869 }

◆ rRealloc1()

static int rRealloc1 ( ring  r,
int  size,
int  pos 
)
static

Definition at line 5214 of file ring.cc.

5215 {
5216  r->order=(rRingOrder_t*)omReallocSize(r->order, size*sizeof(rRingOrder_t), (size+1)*sizeof(rRingOrder_t));
5217  r->block0=(int*)omReallocSize(r->block0, size*sizeof(int), (size+1)*sizeof(int));
5218  r->block1=(int*)omReallocSize(r->block1, size*sizeof(int), (size+1)*sizeof(int));
5219  r->wvhdl=(int **)omReallocSize(r->wvhdl,size*sizeof(int *), (size+1)*sizeof(int *));
5220  for(int k=size; k>pos; k--) r->wvhdl[k]=r->wvhdl[k-1];
5221  r->order[size]=(rRingOrder_t)0;
5222  size++;
5223  return size;
5224 }
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600

◆ rRightAdjustVarOffset()

static void rRightAdjustVarOffset ( ring  r)
static

right-adjust r->VarOffset

Definition at line 4035 of file ring.cc.

4036 {
4037  int* shifts = (int*) omAlloc(r->ExpL_Size*sizeof(int));
4038  int i;
4039  // initialize shifts
4040  for (i=0;i<r->ExpL_Size;i++)
4041  shifts[i] = BIT_SIZEOF_LONG;
4042 
4043  // find minimal bit shift in each long exp entry
4044  for (i=1;i<=r->N;i++)
4045  {
4046  if (shifts[r->VarOffset[i] & 0xffffff] > r->VarOffset[i] >> 24)
4047  shifts[r->VarOffset[i] & 0xffffff] = r->VarOffset[i] >> 24;
4048  }
4049  // reset r->VarOffset: set the minimal shift to 0
4050  for (i=1;i<=r->N;i++)
4051  {
4052  if (shifts[r->VarOffset[i] & 0xffffff] != 0)
4053  r->VarOffset[i]
4054  = (r->VarOffset[i] & 0xffffff) |
4055  (((r->VarOffset[i] >> 24) - shifts[r->VarOffset[i] & 0xffffff]) << 24);
4056  }
4057  omFree(shifts);
4058 }

◆ rRing_has_CompLastBlock()

BOOLEAN rRing_has_CompLastBlock ( const ring  r)

Definition at line 5157 of file ring.cc.

5158 {
5159  assume(r != NULL);
5160  int lb = rBlocks(r) - 2;
5161  return (r->order[lb] == ringorder_c || r->order[lb] == ringorder_C);
5162 }

◆ rRing_is_Homog()

BOOLEAN rRing_is_Homog ( const ring  r)

Definition at line 5135 of file ring.cc.

5136 {
5137  if (r == NULL) return FALSE;
5138  int i, j, nb = rBlocks(r);
5139  for (i=0; i<nb; i++)
5140  {
5141  if (r->wvhdl[i] != NULL)
5142  {
5143  int length = r->block1[i] - r->block0[i];
5144  int* wvhdl = r->wvhdl[i];
5145  if (r->order[i] == ringorder_M) length *= length;
5146  assume(omSizeOfAddr(wvhdl) >= length*sizeof(int));
5147 
5148  for (j=0; j< length; j++)
5149  {
5150  if (wvhdl[j] != 0 && wvhdl[j] != 1) return FALSE;
5151  }
5152  }
5153  }
5154  return TRUE;
5155 }
size_t omSizeOfAddr(const void *addr)

◆ rRing_ord_pure_dp()

BOOLEAN rRing_ord_pure_dp ( const ring  r)

Definition at line 5164 of file ring.cc.

5165 {
5166  if ((r->order[0]==ringorder_dp) &&(r->block0[0]==1) &&(r->block1[0]==r->N))
5167  return TRUE;
5168  if (((r->order[0]==ringorder_c)||(r->order[0]==ringorder_C))
5169  && ((r->order[1]==ringorder_dp) &&(r->block0[1]==1) &&(r->block1[1]==r->N)))
5170  return TRUE;
5171  return FALSE;
5172 }

◆ rRing_ord_pure_Dp()

BOOLEAN rRing_ord_pure_Dp ( const ring  r)

Definition at line 5174 of file ring.cc.

5175 {
5176  if ((r->order[0]==ringorder_Dp) &&(r->block0[0]==1) &&(r->block1[0]==r->N))
5177  return TRUE;
5178  if (((r->order[0]==ringorder_c)||(r->order[0]==ringorder_C))
5179  && ((r->order[1]==ringorder_Dp) &&(r->block0[1]==1) &&(r->block1[1]==r->N)))
5180  return TRUE;
5181  return FALSE;
5182 }

◆ rRing_ord_pure_lp()

BOOLEAN rRing_ord_pure_lp ( const ring  r)

Definition at line 5184 of file ring.cc.

5185 {
5186  if ((r->order[0]==ringorder_lp) &&(r->block0[0]==1) &&(r->block1[0]==r->N))
5187  return TRUE;
5188  if (((r->order[0]==ringorder_c)||(r->order[0]==ringorder_C))
5189  && ((r->order[1]==ringorder_lp) &&(r->block0[1]==1) &&(r->block1[1]==r->N)))
5190  return TRUE;
5191  return FALSE;
5192 }

◆ rSamePolyRep()

BOOLEAN rSamePolyRep ( ring  r1,
ring  r2 
)

returns TRUE, if r1 and r2 represents the monomials in the same way FALSE, otherwise this is an analogue to rEqual but not so strict

Definition at line 1716 of file ring.cc.

1717 {
1718  int i, j;
1719 
1720  if (r1 == r2) return TRUE;
1721 
1722  if (r1 == NULL || r2 == NULL) return FALSE;
1723 
1724  if ((r1->cf != r2->cf)
1725  || (rVar(r1) != rVar(r2))
1726  || (r1->OrdSgn != r2->OrdSgn))
1727  return FALSE;
1728 
1729  i=0;
1730  while (r1->order[i] != 0)
1731  {
1732  if (r2->order[i] == 0) return FALSE;
1733  if ((r1->order[i] != r2->order[i])
1734  || (r1->block0[i] != r2->block0[i])
1735  || (r1->block1[i] != r2->block1[i]))
1736  return FALSE;
1737  if (r1->wvhdl[i] != NULL)
1738  {
1739  if (r2->wvhdl[i] == NULL)
1740  return FALSE;
1741  for (j=0; j<r1->block1[i]-r1->block0[i]+1; j++)
1742  if (r2->wvhdl[i][j] != r1->wvhdl[i][j])
1743  return FALSE;
1744  }
1745  else if (r2->wvhdl[i] != NULL) return FALSE;
1746  i++;
1747  }
1748  if (r2->order[i] != 0) return FALSE;
1749 
1750  // we do not check variable names
1751  // we do not check minpoly/minideal
1752  // we do not check qideal
1753 
1754  return TRUE;
1755 }

◆ rSetDegStuff()

static void rSetDegStuff ( ring  r)
static

Definition at line 3130 of file ring.cc.

3131 {
3132  rRingOrder_t* order = r->order;
3133  int* block0 = r->block0;
3134  int* block1 = r->block1;
3135  int** wvhdl = r->wvhdl;
3136 
3137  if (order[0]==ringorder_S ||order[0]==ringorder_s || order[0]==ringorder_IS)
3138  {
3139  order++;
3140  block0++;
3141  block1++;
3142  wvhdl++;
3143  }
3144  r->LexOrder = FALSE;
3145  r->pFDeg = p_Totaldegree;
3146  r->pLDeg = (r->OrdSgn == 1 ? pLDegb : pLDeg0);
3147 
3148  /*======== ordering type is (am,_) ==================*/
3149  if (order[0]==ringorder_am)
3150  {
3151  for(int ii=block0[0];ii<=block1[0];ii++)
3152  if (wvhdl[0][ii-1]<0) { r->MixedOrder=2;break;}
3153  r->LexOrder=FALSE;
3154  for(int ii=block0[0];ii<=block1[0];ii++)
3155  if (wvhdl[0][ii-1]==0) { r->LexOrder=TRUE;break;}
3156  if ((block0[0]==1)&&(block1[0]==r->N))
3157  {
3158  r->pFDeg = p_Deg;
3159  r->pLDeg = pLDeg1c_Deg;
3160  }
3161  else
3162  {
3163  r->pFDeg = p_WTotaldegree;
3164  r->LexOrder=TRUE;
3165  r->pLDeg = pLDeg1c_WFirstTotalDegree;
3166  }
3167  r->firstwv = wvhdl[0];
3168  }
3169  /*======== ordering type is (_,c) =========================*/
3170  else if ((order[0]==ringorder_unspec) || (order[1] == 0)
3171  ||(
3172  ((order[1]==ringorder_c)||(order[1]==ringorder_C)
3173  ||(order[1]==ringorder_S)
3174  ||(order[1]==ringorder_s))
3175  && (order[0]!=ringorder_M)
3176  && (order[2]==0))
3177  )
3178  {
3179  if (r->OrdSgn == -1) r->pLDeg = pLDeg0c;
3180  if ((order[0] == ringorder_lp)
3181  || (order[0] == ringorder_ls)
3182  || (order[0] == ringorder_rp)
3183  || (order[0] == ringorder_rs))
3184  {
3185  r->LexOrder=TRUE;
3186  r->pLDeg = pLDeg1c;
3187  r->pFDeg = p_Totaldegree;
3188  }
3189  else if ((order[0] == ringorder_a)
3190  || (order[0] == ringorder_wp)
3191  || (order[0] == ringorder_Wp))
3192  {
3193  r->pFDeg = p_WFirstTotalDegree;
3194  }
3195  else if ((order[0] == ringorder_ws)
3196  || (order[0] == ringorder_Ws))
3197  {
3198  for(int ii=block0[0];ii<=block1[0];ii++)
3199  {
3200  if (wvhdl[0][ii-1]<0) { r->MixedOrder=2;break;}
3201  }
3202  if (r->MixedOrder==0)
3203  {
3204  if ((block0[0]==1)&&(block1[0]==r->N))
3205  r->pFDeg = p_WTotaldegree;
3206  else
3207  r->pFDeg = p_WFirstTotalDegree;
3208  }
3209  else
3210  r->pFDeg = p_Totaldegree;
3211  }
3212  r->firstBlockEnds=block1[0];
3213  r->firstwv = wvhdl[0];
3214  }
3215  /*======== ordering type is (c,_) =========================*/
3216  else if (((order[0]==ringorder_c)
3217  ||(order[0]==ringorder_C)
3218  ||(order[0]==ringorder_S)
3219  ||(order[0]==ringorder_s))
3220  && (order[1]!=ringorder_M)
3221  && (order[2]==0))
3222  {
3223  if ((order[1] == ringorder_lp)
3224  || (order[1] == ringorder_ls)
3225  || (order[1] == ringorder_rp)
3226  || order[1] == ringorder_rs)
3227  {
3228  r->LexOrder=TRUE;
3229  r->pLDeg = pLDeg1c;
3230  r->pFDeg = p_Totaldegree;
3231  }
3232  r->firstBlockEnds=block1[1];
3233  if (wvhdl!=NULL) r->firstwv = wvhdl[1];
3234  if ((order[1] == ringorder_a)
3235  || (order[1] == ringorder_wp)
3236  || (order[1] == ringorder_Wp))
3237  r->pFDeg = p_WFirstTotalDegree;
3238  else if ((order[1] == ringorder_ws)
3239  || (order[1] == ringorder_Ws))
3240  {
3241  for(int ii=block0[1];ii<=block1[1];ii++)
3242  if (wvhdl[1][ii-1]<0) { r->MixedOrder=2;break;}
3243  if (r->MixedOrder==FALSE)
3244  r->pFDeg = p_WFirstTotalDegree;
3245  else
3246  r->pFDeg = p_Totaldegree;
3247  }
3248  }
3249  /*------- more than one block ----------------------*/
3250  else
3251  {
3252  if ((r->VectorOut)||(order[0]==ringorder_C)||(order[0]==ringorder_S)||(order[0]==ringorder_s))
3253  {
3254  rSetFirstWv(r, 1, order, block1, wvhdl);
3255  }
3256  else
3257  rSetFirstWv(r, 0, order, block1, wvhdl);
3258 
3259  if ((order[0]!=ringorder_c)
3260  && (order[0]!=ringorder_C)
3261  && (order[0]!=ringorder_S)
3262  && (order[0]!=ringorder_s))
3263  {
3264  r->pLDeg = pLDeg1c;
3265  }
3266  else
3267  {
3268  r->pLDeg = pLDeg1;
3269  }
3270  r->pFDeg = p_WTotaldegree; // may be improved: p_Totaldegree for lp/dp/ls/.. blocks
3271  }
3272 
3275  {
3276  if(r->MixedOrder==FALSE)
3277  r->pFDeg = p_Deg;
3278  else
3279  r->pFDeg = p_Totaldegree;
3280  }
3281 
3282  if( rGetISPos(0, r) != -1 ) // Are there Schreyer induced blocks?
3283  {
3284 #ifndef SING_NDEBUG
3285  assume( r->pFDeg == p_Deg || r->pFDeg == p_WTotaldegree || r->pFDeg == p_Totaldegree);
3286 #endif
3287 
3288  r->pLDeg = pLDeg1; // ?
3289  }
3290 
3291  r->pFDegOrig = r->pFDeg;
3292  // NOTE: this leads to wrong ecart during std
3293  // in Old/sre.tst
3294  rOptimizeLDeg(r); // also sets r->pLDegOrig
3295 }
if(yy_init)
Definition: libparse.cc:1420
long pLDegb(poly p, int *l, const ring r)
Definition: p_polys.cc:806
long pLDeg0c(poly p, int *l, const ring r)
Definition: p_polys.cc:765
long pLDeg0(poly p, int *l, const ring r)
Definition: p_polys.cc:734
int rGetISPos(const int p, const ring r)
Finds p^th IS ordering, and returns its position in r->typ[] returns -1 if something went wrong!...
Definition: ring.cc:4950
BOOLEAN rOrd_is_Totaldegree_Ordering(const ring r)
Definition: ring.cc:1930
static void rSetFirstWv(ring r, int i, rRingOrder_t *order, int *block1, int **wvhdl)
Definition: ring.cc:3071

◆ rSetFirstWv()

static void rSetFirstWv ( ring  r,
int  i,
rRingOrder_t order,
int *  block1,
int **  wvhdl 
)
static

Definition at line 3071 of file ring.cc.

3072 {
3073  // cheat for ringorder_aa
3074  if (order[i] == ringorder_aa)
3075  i++;
3076  if(block1[i]!=r->N) r->LexOrder=TRUE;
3077  r->firstBlockEnds=block1[i];
3078  r->firstwv = wvhdl[i];
3079  if ((order[i]== ringorder_ws)
3080  || (order[i]==ringorder_Ws)
3081  || (order[i]== ringorder_wp)
3082  || (order[i]==ringorder_Wp)
3083  || (order[i]== ringorder_a)
3084  /*|| (order[i]==ringorder_A)*/)
3085  {
3086  int j;
3087  for(j=block1[i]-r->block0[i];j>=0;j--)
3088  {
3089  if (r->firstwv[j]==0) r->LexOrder=TRUE;
3090  }
3091  }
3092  else if (order[i]==ringorder_a64)
3093  {
3094  int j;
3095  int64 *w=rGetWeightVec(r);
3096  for(j=block1[i]-r->block0[i];j>=0;j--)
3097  {
3098  if (w[j]==0) r->LexOrder=TRUE;
3099  }
3100  }
3101 }
int64 * rGetWeightVec(const ring r)
Definition: ring.cc:5194

◆ rSetISReference()

BOOLEAN rSetISReference ( const ring  r,
const ideal  F,
const int  i,
const int  p 
)

Changes r by setting induced ordering parameters: limit and reference leading terms F belong to r, we will DO a copy! We will use it AS IS! returns true is everything was allright!

Definition at line 4982 of file ring.cc.

4983 {
4984  // Put the reference set F into the ring -ordering -recor
4985 
4986  if (r->typ==NULL)
4987  {
4988  dReportError("Error: WRONG USE of rSetISReference: wrong ring! (typ == NULL)");
4989  return FALSE;
4990  }
4991 
4992 
4993  int pos = rGetISPos(p, r);
4994 
4995  if( pos == -1 )
4996  {
4997  dReportError("Error: WRONG USE of rSetISReference: specified ordering block was not found!!!" );
4998  return FALSE;
4999  }
5000 
5001 #if MYTEST
5002  if( i != r->typ[pos].data.is.limit )
5003  Print("Changing record on pos: %d\nOld limit: %d --->> New Limit: %d\n", pos, r->typ[pos].data.is.limit, i);
5004 #endif
5005 
5006  const ideal FF = idrHeadR(F, r, r); // id_Copy(F, r); // ???
5007 
5008 
5009  if( r->typ[pos].data.is.F != NULL)
5010  {
5011 #if MYTEST
5012  PrintS("Deleting old reference set F... \n"); // idShow(r->typ[pos].data.is.F, r); PrintLn();
5013 #endif
5014  id_Delete(&r->typ[pos].data.is.F, r);
5015  r->typ[pos].data.is.F = NULL;
5016  }
5017 
5018  assume(r->typ[pos].data.is.F == NULL);
5019 
5020  r->typ[pos].data.is.F = FF; // F is owened by ring now! TODO: delete at the end!
5021 
5022  r->typ[pos].data.is.limit = i; // First induced component
5023 
5024 #if MYTEST
5025  PrintS("New reference set FF : \n"); idShow(FF, r, r, 1); PrintLn();
5026 #endif
5027 
5028  return TRUE;
5029 }
void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint)
Definition: simpleideals.cc:57

◆ rSetNegWeight()

static void rSetNegWeight ( ring  r)
static

Definition at line 3300 of file ring.cc.

3301 {
3302  int i,l;
3303  if (r->typ!=NULL)
3304  {
3305  l=0;
3306  for(i=0;i<r->OrdSize;i++)
3307  {
3308  if((r->typ[i].ord_typ==ro_wp_neg)
3309  ||(r->typ[i].ord_typ==ro_am))
3310  l++;
3311  }
3312  if (l>0)
3313  {
3314  r->NegWeightL_Size=l;
3315  r->NegWeightL_Offset=(int *) omAlloc(l*sizeof(int));
3316  l=0;
3317  for(i=0;i<r->OrdSize;i++)
3318  {
3319  if(r->typ[i].ord_typ==ro_wp_neg)
3320  {
3321  r->NegWeightL_Offset[l]=r->typ[i].data.wp.place;
3322  l++;
3323  }
3324  else if(r->typ[i].ord_typ==ro_am)
3325  {
3326  r->NegWeightL_Offset[l]=r->typ[i].data.am.place;
3327  l++;
3328  }
3329  }
3330  return;
3331  }
3332  }
3333  r->NegWeightL_Size = 0;
3334  r->NegWeightL_Offset = NULL;
3335 }

◆ rSetOption()

static void rSetOption ( ring  r)
static

Definition at line 3337 of file ring.cc.

3338 {
3339  // set redthrough
3340  if (!TEST_OPT_OLDSTD && r->OrdSgn == 1 && ! r->LexOrder)
3341  r->options |= Sy_bit(OPT_REDTHROUGH);
3342  else
3343  r->options &= ~Sy_bit(OPT_REDTHROUGH);
3344 
3345  // set intStrategy
3346  if ( (r->cf->extRing!=NULL)
3347  || rField_is_Q(r)
3348  || rField_is_Ring(r)
3349  )
3350  r->options |= Sy_bit(OPT_INTSTRATEGY);
3351  else
3352  r->options &= ~Sy_bit(OPT_INTSTRATEGY);
3353 
3354  // set redTail
3355  if (r->LexOrder || r->OrdSgn == -1 || (r->cf->extRing!=NULL))
3356  r->options &= ~Sy_bit(OPT_REDTAIL);
3357  else
3358  r->options |= Sy_bit(OPT_REDTAIL);
3359 }
#define OPT_INTSTRATEGY
Definition: options.h:91
#define OPT_REDTAIL
Definition: options.h:90
#define TEST_OPT_OLDSTD
Definition: options.h:122
#define OPT_REDTHROUGH
Definition: options.h:81
#define Sy_bit(x)
Definition: options.h:31
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:489
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:511

◆ rSetOutParams()

static void rSetOutParams ( ring  r)
static

Definition at line 3028 of file ring.cc.

3029 {
3030  r->VectorOut = (r->order[0] == ringorder_c);
3031  if (rIsNCRing(r))
3032  r->CanShortOut=FALSE;
3033  else
3034  {
3035  r->CanShortOut = TRUE;
3036  int i;
3037  if (rParameter(r)!=NULL)
3038  {
3039  for (i=0;i<rPar(r);i++)
3040  {
3041  if(strlen(rParameter(r)[i])>1)
3042  {
3043  r->CanShortOut=FALSE;
3044  break;
3045  }
3046  }
3047  }
3048  if (r->CanShortOut)
3049  {
3050  // Hmm... sometimes (e.g., from maGetPreimage) new variables
3051  // are introduced, but their names are never set
3052  // hence, we do the following awkward trick
3053  int N = omSizeOfAddr(r->names)/sizeof(char_ptr);
3054  if (r->N < N) N = r->N;
3055 
3056  for (i=(N-1);i>=0;i--)
3057  {
3058  if(r->names[i] != NULL && strlen(r->names[i])>1)
3059  {
3060  r->CanShortOut=FALSE;
3061  break;
3062  }
3063  }
3064  }
3065  }
3066  r->ShortOut = r->CanShortOut;
3067 
3068  assume( !( !r->CanShortOut && r->ShortOut ) );
3069 }
char * char_ptr
Definition: ring.cc:42
static BOOLEAN rIsNCRing(const ring r)
Definition: ring.h:421

◆ rSetSyzComp()

void rSetSyzComp ( int  k,
const ring  r 
)

Definition at line 5036 of file ring.cc.

5037 {
5038  if(k < 0)
5039  {
5040  dReportError("rSetSyzComp with negative limit!");
5041  return;
5042  }
5043 
5044  assume( k >= 0 );
5045  if (TEST_OPT_PROT) Print("{%d}", k);
5046  if ((r->typ!=NULL) && (r->typ[0].ord_typ==ro_syz))
5047  {
5048  r->block0[0]=r->block1[0] = k;
5049  if( k == r->typ[0].data.syz.limit )
5050  return; // nothing to do
5051 
5052  int i;
5053  if (r->typ[0].data.syz.limit == 0)
5054  {
5055  r->typ[0].data.syz.syz_index = (int*) omAlloc0((k+1)*sizeof(int));
5056  r->typ[0].data.syz.syz_index[0] = 0;
5057  r->typ[0].data.syz.curr_index = 1;
5058  }
5059  else
5060  {
5061  r->typ[0].data.syz.syz_index = (int*)
5062  omReallocSize(r->typ[0].data.syz.syz_index,
5063  (r->typ[0].data.syz.limit+1)*sizeof(int),
5064  (k+1)*sizeof(int));
5065  }
5066  for (i=r->typ[0].data.syz.limit + 1; i<= k; i++)
5067  {
5068  r->typ[0].data.syz.syz_index[i] =
5069  r->typ[0].data.syz.curr_index;
5070  }
5071  if(k < r->typ[0].data.syz.limit) // ?
5072  {
5073 #ifndef SING_NDEBUG
5074  Warn("rSetSyzComp called with smaller limit (%d) as before (%d)", k, r->typ[0].data.syz.limit);
5075 #endif
5076  r->typ[0].data.syz.curr_index = 1 + r->typ[0].data.syz.syz_index[k];
5077  }
5078 
5079 
5080  r->typ[0].data.syz.limit = k;
5081  r->typ[0].data.syz.curr_index++;
5082  }
5083  else if(
5084  (r->typ!=NULL) &&
5085  (r->typ[0].ord_typ==ro_isTemp)
5086  )
5087  {
5088 // (r->typ[currRing->typ[0].data.isTemp.suffixpos].data.is.limit == k)
5089 #ifndef SING_NDEBUG
5090  Warn("rSetSyzComp(%d) in an IS ring! Be careful!", k);
5091 #endif
5092  }
5093  else if (r->order[0]==ringorder_s)
5094  {
5095  r->block0[0] = r->block1[0] = k;
5096  }
5097  else if (r->order[0]!=ringorder_c)
5098  {
5099  dReportError("syzcomp in incompatible ring");
5100  }
5101 #ifdef PDEBUG
5102  EXTERN_VAR int pDBsyzComp;
5103  pDBsyzComp=k;
5104 #endif
5105 }
#define EXTERN_VAR
Definition: globaldefs.h:6
#define TEST_OPT_PROT
Definition: options.h:102
VAR int pDBsyzComp
Definition: ring.cc:5032

◆ rSetVarL()

static void rSetVarL ( ring  r)
static

set r->VarL_Size, r->VarL_Offset, r->VarL_LowIndex

Definition at line 3980 of file ring.cc.

3981 {
3982  int min = MAX_INT_VAL, min_j = -1;
3983  int* VarL_Number = (int*) omAlloc0(r->ExpL_Size*sizeof(int));
3984 
3985  int i,j;
3986 
3987  // count how often a var long is occupied by an exponent
3988  for (i=1; i<=r->N; i++)
3989  {
3990  VarL_Number[r->VarOffset[i] & 0xffffff]++;
3991  }
3992 
3993  // determine how many and min
3994  for (i=0, j=0; i<r->ExpL_Size; i++)
3995  {
3996  if (VarL_Number[i] != 0)
3997  {
3998  if (min > VarL_Number[i])
3999  {
4000  min = VarL_Number[i];
4001  min_j = j;
4002  }
4003  j++;
4004  }
4005  }
4006 
4007  r->VarL_Size = j; // number of long with exp. entries in
4008  // in p->exp
4009  r->VarL_Offset = (int*) omAlloc(r->VarL_Size*sizeof(int));
4010  r->VarL_LowIndex = 0;
4011 
4012  // set VarL_Offset
4013  for (i=0, j=0; i<r->ExpL_Size; i++)
4014  {
4015  if (VarL_Number[i] != 0)
4016  {
4017  r->VarL_Offset[j] = i;
4018  if (j > 0 && r->VarL_Offset[j-1] != r->VarL_Offset[j] - 1)
4019  r->VarL_LowIndex = -1;
4020  j++;
4021  }
4022  }
4023  if (r->VarL_LowIndex >= 0)
4024  r->VarL_LowIndex = r->VarL_Offset[0];
4025 
4026  if (min_j != 0)
4027  {
4028  j = r->VarL_Offset[min_j];
4029  r->VarL_Offset[min_j] = r->VarL_Offset[0];
4030  r->VarL_Offset[0] = j;
4031  }
4032  omFree(VarL_Number);
4033 }
static int min(int a, int b)
Definition: fast_mult.cc:268

◆ rSetWeightVec()

void rSetWeightVec ( ring  r,
int64 wv 
)

Definition at line 5204 of file ring.cc.

5205 {
5206  assume(r!=NULL);
5207  assume(r->OrdSize>0);
5208  assume(r->typ[0].ord_typ==ro_wp64);
5209  memcpy(r->typ[0].data.wp64.weights64,wv,r->N*sizeof(int64));
5210 }

◆ rSimpleOrdStr()

const char* rSimpleOrdStr ( int  ord)

Definition at line 77 of file ring.cc.

78 {
79  return ringorder_name[ord];
80 }
static const char *const ringorder_name[]
Definition: ring.cc:47

◆ rString()

char* rString ( ring  r)

Definition at line 674 of file ring.cc.

675 {
676  if ((r!=NULL)&&(r->cf!=NULL))
677  {
678  char *ch=rCharStr(r);
679  char *var=rVarStr(r);
680  char *ord=rOrdStr(r);
681  char *res=(char *)omAlloc(strlen(ch)+strlen(var)+strlen(ord)+9);
682  sprintf(res,"(%s),(%s),(%s)",ch,var,ord);
683  omFree((ADDRESS)ch);
684  omFree((ADDRESS)var);
685  omFree((ADDRESS)ord);
686  return res;
687  }
688  else
689  return omStrDup("undefined");
690 }
char * rVarStr(ring r)
Definition: ring.cc:624
char * rOrdStr(ring r)
Definition: ring.cc:523
char * rCharStr(const ring r)
TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar.
Definition: ring.cc:648

◆ rSum()

int rSum ( ring  r1,
ring  r2,
ring &  sum 
)

Definition at line 1347 of file ring.cc.

1348 {
1349  if ((r1==NULL)||(r2==NULL)
1350  ||(r1->cf==NULL)||(r2->cf==NULL))
1351  return -1;
1352  if (r1==r2)
1353  {
1354  sum=r1;
1355  rIncRefCnt(r1);
1356  return 0;
1357  }
1358  return rSumInternal(r1,r2,sum,TRUE,FALSE);
1359 }
int rSumInternal(ring r1, ring r2, ring &sum, BOOLEAN vartest, BOOLEAN dp_dp)
returns -1 for not compatible, 1 for compatible (and sum) dp_dp:0: block ordering,...
Definition: ring.cc:750
static ring rIncRefCnt(ring r)
Definition: ring.h:847

◆ rSumInternal()

int rSumInternal ( ring  r1,
ring  r2,
ring &  sum,
BOOLEAN  vartest,
BOOLEAN  dp_dp 
)

returns -1 for not compatible, 1 for compatible (and sum) dp_dp:0: block ordering, 1: dp,dp, 2: aa(...),dp vartest: check for name conflicts

Definition at line 750 of file ring.cc.

751 {
752 
753  ip_sring tmpR;
754  memset(&tmpR,0,sizeof(tmpR));
755  /* check coeff. field =====================================================*/
756 
757  if (r1->cf==r2->cf)
758  {
759  tmpR.cf=nCopyCoeff(r1->cf);
760  }
761  else /* different type */
762  {
763  if (getCoeffType(r1->cf)==n_Zp)
764  {
765  if (getCoeffType(r2->cf)==n_Q)
766  {
767  tmpR.cf=nCopyCoeff(r1->cf);
768  }
769  else if (nCoeff_is_Extension(r2->cf) && rChar(r2) == rChar(r1))
770  {
771  /*AlgExtInfo extParam;
772  extParam.r = r2->cf->extRing;
773  extParam.i = r2->cf->extRing->qideal;*/
774  tmpR.cf=nCopyCoeff(r2->cf);
775  }
776  else
777  {
778  WerrorS("Z/p+...");
779  return -1;
780  }
781  }
782  else if ((getCoeffType(r1->cf)==n_Zn)||(getCoeffType(r1->cf)==n_Znm))
783  {
784  if (getCoeffType(r2->cf)==n_Q)
785  {
786  tmpR.cf=nCopyCoeff(r1->cf);
787  }
788  else if (nCoeff_is_Extension(r2->cf)
789  && (mpz_cmp(r1->cf->modNumber,r2->cf->extRing->cf->modNumber)==0))
790  { // covers transext.cc and algext.cc
791  tmpR.cf=nCopyCoeff(r2->cf);
792  }
793  else
794  {
795  WerrorS("Z/n+...");
796  return -1;
797  }
798  }
799  else if (getCoeffType(r1->cf)==n_R)
800  {
801  WerrorS("R+..");
802  return -1;
803  }
804  else if (getCoeffType(r1->cf)==n_Q)
805  {
806  if (getCoeffType(r2->cf)==n_Zp)
807  {
808  tmpR.cf=nCopyCoeff(r2->cf);
809  }
810  else if (nCoeff_is_Extension(r2->cf))
811  {
812  tmpR.cf=nCopyCoeff(r2->cf);
813  }
814  else
815  {
816  WerrorS("Q+...");
817  return -1;
818  }
819  }
820  else if (nCoeff_is_Extension(r1->cf))
821  {
822  if (r1->cf->extRing->cf==r2->cf)
823  {
824  tmpR.cf=nCopyCoeff(r1->cf);
825  }
826  else if (getCoeffType(r1->cf->extRing->cf)==n_Zp && getCoeffType(r2->cf)==n_Q) //r2->cf == n_Zp should have been handled above
827  {
828  tmpR.cf=nCopyCoeff(r1->cf);
829  }
830  else
831  {
832  WerrorS ("coeff sum of two extension fields not implemented");
833  return -1;
834  }
835  }
836  else
837  {
838  WerrorS("coeff sum not yet implemented");
839  return -1;
840  }
841  }
842  /* variable names ========================================================*/
843  int i,j,k;
844  int l=r1->N+r2->N;
845  char **names=(char **)omAlloc0(l*sizeof(char *));
846  k=0;
847 
848  // collect all varnames from r1, except those which are parameters
849  // of r2, or those which are the empty string
850  for (i=0;i<r1->N;i++)
851  {
852  BOOLEAN b=TRUE;
853 
854  if (*(r1->names[i]) == '\0')
855  b = FALSE;
856  else if ((rParameter(r2)!=NULL) && (strlen(r1->names[i])==1))
857  {
858  if (vartest)
859  {
860  for(j=0;j<rPar(r2);j++)
861  {
862  if (strcmp(r1->names[i],rParameter(r2)[j])==0)
863  {
864  b=FALSE;
865  break;
866  }
867  }
868  }
869  }
870 
871  if (b)
872  {
873  //Print("name : %d: %s\n",k,r1->names[i]);
874  names[k]=omStrDup(r1->names[i]);
875  k++;
876  }
877  //else
878  // Print("no name (par1) %s\n",r1->names[i]);
879  }
880  // Add variables from r2, except those which are parameters of r1
881  // those which are empty strings, and those which equal a var of r1
882  for(i=0;i<r2->N;i++)
883  {
884  BOOLEAN b=TRUE;
885 
886  if (*(r2->names[i]) == '\0')
887  b = FALSE;
888  else if ((rParameter(r1)!=NULL) && (strlen(r2->names[i])==1))
889  {
890  if (vartest)
891  {
892  for(j=0;j<rPar(r1);j++)
893  {
894  if (strcmp(r2->names[i],rParameter(r1)[j])==0)
895  {
896  b=FALSE;
897  break;
898  }
899  }
900  }
901  }
902 
903  if (b)
904  {
905  if (vartest)
906  {
907  for(j=0;j<r1->N;j++)
908  {
909  if (strcmp(r1->names[j],r2->names[i])==0)
910  {
911  b=FALSE;
912  break;
913  }
914  }
915  }
916  if (b)
917  {
918  //Print("name : %d : %s\n",k,r2->names[i]);
919  names[k]=omStrDup(r2->names[i]);
920  k++;
921  }
922  //else
923  // Print("no name (var): %s\n",r2->names[i]);
924  }
925  //else
926  // Print("no name (par): %s\n",r2->names[i]);
927  }
928  // check whether we found any vars at all
929  if (k == 0)
930  {
931  names[k]=omStrDup("");
932  k=1;
933  }
934  tmpR.N=k;
935  tmpR.names=names;
936  /* ordering *======================================================== */
937  tmpR.OrdSgn=0;
938  if ((dp_dp==2)
939  && (r1->OrdSgn==1)
940  && (r2->OrdSgn==1)
941 #ifdef HAVE_PLURAL
942  && !rIsPluralRing(r1) && !rIsPluralRing(r2)
943 #endif
944  )
945  {
946  tmpR.order=(rRingOrder_t*)omAlloc0(4*sizeof(rRingOrder_t));
947  tmpR.block0=(int*)omAlloc0(4*sizeof(int));
948  tmpR.block1=(int*)omAlloc0(4*sizeof(int));
949  tmpR.wvhdl=(int**) omAlloc0(4*sizeof(int**));
950  // ----
951  tmpR.block0[0] = 1;
952  tmpR.block1[0] = rVar(r1)+rVar(r2);
953  tmpR.order[0] = ringorder_aa;
954  tmpR.wvhdl[0]=(int*)omAlloc0((rVar(r1)+rVar(r2) + 1)*sizeof(int));
955  for(int i=0;i<rVar(r1);i++) tmpR.wvhdl[0][i]=1;
956  // ----
957  tmpR.block0[1] = 1;
958  tmpR.block1[1] = rVar(r1)+rVar(r2);
959  tmpR.order[1] = ringorder_dp;
960  // ----
961  tmpR.order[2] = ringorder_C;
962  }
963  else if (dp_dp
964 #ifdef HAVE_PLURAL
965  && !rIsPluralRing(r1) && !rIsPluralRing(r2)
966 #endif
967  )
968  {
969  tmpR.order=(rRingOrder_t*)omAlloc(4*sizeof(rRingOrder_t));
970  tmpR.block0=(int*)omAlloc0(4*sizeof(int));
971  tmpR.block1=(int*)omAlloc0(4*sizeof(int));
972  tmpR.wvhdl=(int**)omAlloc0(4*sizeof(int *));
973  tmpR.order[0]=ringorder_dp;
974  tmpR.block0[0]=1;
975  tmpR.block1[0]=rVar(r1);
976  if (r2->OrdSgn==1)
977  {
978  if ((r2->block0[0]==1)
979  && (r2->block1[0]==rVar(r2))
980  && ((r2->order[0]==ringorder_wp)
981  || (r2->order[0]==ringorder_Wp)
982  || (r2->order[0]==ringorder_Dp))
983  )
984  {
985  tmpR.order[1]=r2->order[0];
986  if (r2->wvhdl[0]!=NULL)
987  tmpR.wvhdl[1]=(int *)omMemDup(r2->wvhdl[0]);
988  }
989  else
990  tmpR.order[1]=ringorder_dp;
991  }
992  else
993  {
994  tmpR.order[1]=ringorder_ds;
995  tmpR.OrdSgn=-1;
996  }
997  tmpR.block0[1]=rVar(r1)+1;
998  tmpR.block1[1]=rVar(r1)+rVar(r2);
999  tmpR.order[2]=ringorder_C;
1000  tmpR.order[3]=(rRingOrder_t)0;
1001  }
1002  else
1003  {
1004  if ((r1->order[0]==ringorder_unspec)
1005  && (r2->order[0]==ringorder_unspec))
1006  {
1007  tmpR.order=(rRingOrder_t*)omAlloc(3*sizeof(rRingOrder_t));
1008  tmpR.block0=(int*)omAlloc(3*sizeof(int));
1009  tmpR.block1=(int*)omAlloc(3*sizeof(int));
1010  tmpR.wvhdl=(int**)omAlloc0(3*sizeof(int *));
1011  tmpR.order[0]=ringorder_unspec;
1012  tmpR.order[1]=ringorder_C;
1013  tmpR.order[2]=(rRingOrder_t)0;
1014  tmpR.block0[0]=1;
1015  tmpR.block1[0]=tmpR.N;
1016  }
1017  else if (l==k) /* r3=r1+r2 */
1018  {
1019  int b;
1020  ring rb;
1021  if (r1->order[0]==ringorder_unspec)
1022  {
1023  /* extend order of r2 to r3 */
1024  b=rBlocks(r2);
1025  rb=r2;
1026  tmpR.OrdSgn=r2->OrdSgn;
1027  }
1028  else if (r2->order[0]==ringorder_unspec)
1029  {
1030  /* extend order of r1 to r3 */
1031  b=rBlocks(r1);
1032  rb=r1;
1033  tmpR.OrdSgn=r1->OrdSgn;
1034  }
1035  else
1036  {
1037  b=rBlocks(r1)+rBlocks(r2)-2; /* for only one order C, only one 0 */
1038  rb=NULL;
1039  }
1040  tmpR.order=(rRingOrder_t*)omAlloc0(b*sizeof(rRingOrder_t));
1041  tmpR.block0=(int*)omAlloc0(b*sizeof(int));
1042  tmpR.block1=(int*)omAlloc0(b*sizeof(int));
1043  tmpR.wvhdl=(int**)omAlloc0(b*sizeof(int *));
1044  /* weights not implemented yet ...*/
1045  if (rb!=NULL)
1046  {
1047  for (i=0;i<b;i++)
1048  {
1049  tmpR.order[i]=rb->order[i];
1050  tmpR.block0[i]=rb->block0[i];
1051  tmpR.block1[i]=rb->block1[i];
1052  if (rb->wvhdl[i]!=NULL)
1053  WarnS("rSum: weights not implemented");
1054  }
1055  tmpR.block0[0]=1;
1056  }
1057  else /* ring sum for complete rings */
1058  {
1059  for (i=0;r1->order[i]!=0;i++)
1060  {
1061  tmpR.order[i]=r1->order[i];
1062  tmpR.block0[i]=r1->block0[i];
1063  tmpR.block1[i]=r1->block1[i];
1064  if (r1->wvhdl[i]!=NULL)
1065  tmpR.wvhdl[i] = (int*) omMemDup(r1->wvhdl[i]);
1066  }
1067  j=i;
1068  i--;
1069  if ((r1->order[i]==ringorder_c)
1070  ||(r1->order[i]==ringorder_C))
1071  {
1072  j--;
1073  tmpR.order[b-2]=r1->order[i];
1074  }
1075  for (i=0;r2->order[i]!=0;i++)
1076  {
1077  if ((r2->order[i]!=ringorder_c)
1078  &&(r2->order[i]!=ringorder_C))
1079  {
1080  tmpR.order[j]=r2->order[i];
1081  tmpR.block0[j]=r2->block0[i]+rVar(r1);
1082  tmpR.block1[j]=r2->block1[i]+rVar(r1);
1083  if (r2->wvhdl[i]!=NULL)
1084  {
1085  tmpR.wvhdl[j] = (int*) omMemDup(r2->wvhdl[i]);
1086  }
1087  j++;
1088  }
1089  }
1090  if((r1->OrdSgn==-1)||(r2->OrdSgn==-1))
1091  tmpR.OrdSgn=-1;
1092  }
1093  }
1094  else if ((k==rVar(r1)) && (k==rVar(r2))) /* r1 and r2 are "quite"
1095  the same ring */
1096  /* copy r1, because we have the variables from r1 */
1097  {
1098  int b=rBlocks(r1);
1099 
1100  tmpR.order=(rRingOrder_t*)omAlloc0(b*sizeof(rRingOrder_t));
1101  tmpR.block0=(int*)omAlloc0(b*sizeof(int));
1102  tmpR.block1=(int*)omAlloc0(b*sizeof(int));
1103  tmpR.wvhdl=(int**)omAlloc0(b*sizeof(int *));
1104  /* weights not implemented yet ...*/
1105  for (i=0;i<b;i++)
1106  {
1107  tmpR.order[i]=r1->order[i];
1108  tmpR.block0[i]=r1->block0[i];
1109  tmpR.block1[i]=r1->block1[i];
1110  if (r1->wvhdl[i]!=NULL)
1111  {
1112  tmpR.wvhdl[i] = (int*) omMemDup(r1->wvhdl[i]);
1113  }
1114  }
1115  tmpR.OrdSgn=r1->OrdSgn;
1116  }
1117  else
1118  {
1119  for(i=0;i<k;i++) omFree((ADDRESS)tmpR.names[i]);
1120  omFreeSize((ADDRESS)names,tmpR.N*sizeof(char *));
1121  Werror("variables must not overlap (# of vars: %d,%d -> %d)",rVar(r1),rVar(r2),k);
1122  return -1;
1123  }
1124  }
1125  tmpR.bitmask=si_max(r1->bitmask,r2->bitmask);
1126  sum=(ring)omAllocBin(sip_sring_bin);
1127  memcpy(sum,&tmpR,sizeof(ip_sring));
1128  rComplete(sum);
1129 
1130 //#ifdef RDEBUG
1131 // rDebugPrint(sum);
1132 //#endif
1133 
1134 
1135 
1136 #ifdef HAVE_PLURAL
1137  if(1)
1138  {
1139 // ring old_ring = currRing;
1140 
1141  BOOLEAN R1_is_nc = rIsPluralRing(r1);
1142  BOOLEAN R2_is_nc = rIsPluralRing(r2);
1143 
1144  if ( (R1_is_nc) || (R2_is_nc))
1145  {
1146  ring R1 = nc_rCreateNCcomm_rCopy(r1);
1147  assume( rIsPluralRing(R1) );
1148 
1149 #if 0
1150 #ifdef RDEBUG
1151  rWrite(R1);
1152  rDebugPrint(R1);
1153 #endif
1154 #endif
1155  ring R2 = nc_rCreateNCcomm_rCopy(r2);
1156 #if 0
1157 #ifdef RDEBUG
1158  rWrite(R2);
1159  rDebugPrint(R2);
1160 #endif
1161 #endif
1162 
1163 // rChangeCurrRing(sum); // ?
1164 
1165  // Projections from R_i into Sum:
1166  /* multiplication matrices business: */
1167  /* find permutations of vars and pars */
1168  int *perm1 = (int *)omAlloc0((rVar(R1)+1)*sizeof(int));
1169  int *par_perm1 = NULL;
1170  if (rPar(R1)!=0) par_perm1=(int *)omAlloc0((rPar(R1)+1)*sizeof(int));
1171 
1172  int *perm2 = (int *)omAlloc0((rVar(R2)+1)*sizeof(int));
1173  int *par_perm2 = NULL;
1174  if (rPar(R2)!=0) par_perm2=(int *)omAlloc0((rPar(R2)+1)*sizeof(int));
1175 
1176  maFindPerm(R1->names, rVar(R1), rParameter(R1), rPar(R1),
1177  sum->names, rVar(sum), rParameter(sum), rPar(sum),
1178  perm1, par_perm1, sum->cf->type);
1179 
1180  maFindPerm(R2->names, rVar(R2), rParameter(R2), rPar(R2),
1181  sum->names, rVar(sum), rParameter(sum), rPar(sum),
1182  perm2, par_perm2, sum->cf->type);
1183 
1184 
1185  matrix C1 = R1->GetNC()->C, C2 = R2->GetNC()->C;
1186  matrix D1 = R1->GetNC()->D, D2 = R2->GetNC()->D;
1187 
1188  // !!!! BUG? C1 and C2 might live in different baserings!!!
1189 
1190  int l = rVar(R1) + rVar(R2);
1191 
1192  matrix C = mpNew(l,l);
1193  matrix D = mpNew(l,l);
1194 
1195  for (i = 1; i <= rVar(R1); i++)
1196  for (j= rVar(R1)+1; j <= l; j++)
1197  MATELEM(C,i,j) = p_One(sum); // in 'sum'
1198 
1199  id_Test((ideal)C, sum);
1200 
1201  nMapFunc nMap1 = n_SetMap(R1->cf,sum->cf); /* can change something global: not usable
1202  after the next nSetMap call :( */
1203  // Create blocked C and D matrices:
1204  for (i=1; i<= rVar(R1); i++)
1205  for (j=i+1; j<=rVar(R1); j++)
1206  {
1207  assume(MATELEM(C1,i,j) != NULL);
1208  MATELEM(C,i,j) = p_PermPoly(MATELEM(C1,i,j), perm1, R1, sum, nMap1, par_perm1, rPar(R1)); // need ADD + CMP ops.
1209 
1210  if (MATELEM(D1,i,j) != NULL)
1211  MATELEM(D,i,j) = p_PermPoly(MATELEM(D1,i,j), perm1, R1, sum, nMap1, par_perm1, rPar(R1));
1212  }
1213 
1214  id_Test((ideal)C, sum);
1215  id_Test((ideal)D, sum);
1216 
1217 
1218  nMapFunc nMap2 = n_SetMap(R2->cf,sum->cf); /* can change something global: not usable
1219  after the next nSetMap call :( */
1220  for (i=1; i<= rVar(R2); i++)
1221  for (j=i+1; j<=rVar(R2); j++)
1222  {
1223  assume(MATELEM(C2,i,j) != NULL);
1224  MATELEM(C,rVar(R1)+i,rVar(R1)+j) = p_PermPoly(MATELEM(C2,i,j),perm2,R2,sum, nMap2,par_perm2,rPar(R2));
1225 
1226  if (MATELEM(D2,i,j) != NULL)
1227  MATELEM(D,rVar(R1)+i,rVar(R1)+j) = p_PermPoly(MATELEM(D2,i,j),perm2,R2,sum, nMap2,par_perm2,rPar(R2));
1228  }
1229 
1230  id_Test((ideal)C, sum);
1231  id_Test((ideal)D, sum);
1232 
1233  // Now sum is non-commutative with blocked structure constants!
1234  if (nc_CallPlural(C, D, NULL, NULL, sum, false, false, true, sum))
1235  WarnS("Error initializing non-commutative multiplication!");
1236 
1237  /* delete R1, R2*/
1238 
1239 #if 0
1240 #ifdef RDEBUG
1241  rWrite(sum);
1242  rDebugPrint(sum);
1243 
1244  Print("\nRefs: R1: %d, R2: %d\n", R1->GetNC()->ref, R2->GetNC()->ref);
1245 
1246 #endif
1247 #endif
1248 
1249 
1250  rDelete(R1);
1251  rDelete(R2);
1252 
1253  /* delete perm arrays */
1254  if (perm1!=NULL) omFree((ADDRESS)perm1);
1255  if (perm2!=NULL) omFree((ADDRESS)perm2);
1256  if (par_perm1!=NULL) omFree((ADDRESS)par_perm1);
1257  if (par_perm2!=NULL) omFree((ADDRESS)par_perm2);
1258 
1259 // rChangeCurrRing(old_ring);
1260  }
1261 
1262  }
1263 #endif
1264 
1265  ideal Q=NULL;
1266  ideal Q1=NULL, Q2=NULL;
1267  if (r1->qideal!=NULL)
1268  {
1269 // rChangeCurrRing(sum);
1270 // if (r2->qideal!=NULL)
1271 // {
1272 // WerrorS("todo: qring+qring");
1273 // return -1;
1274 // }
1275 // else
1276 // {}
1277  /* these were defined in the Plural Part above... */
1278  int *perm1 = (int *)omAlloc0((rVar(r1)+1)*sizeof(int));
1279  int *par_perm1 = NULL;
1280  if (rPar(r1)!=0) par_perm1=(int *)omAlloc0((rPar(r1)+1)*sizeof(int));
1281  maFindPerm(r1->names, rVar(r1), rParameter(r1), rPar(r1),
1282  sum->names, rVar(sum), rParameter(sum), rPar(sum),
1283  perm1, par_perm1, sum->cf->type);
1284  nMapFunc nMap1 = n_SetMap(r1->cf,sum->cf);
1285  Q1 = idInit(IDELEMS(r1->qideal),1);
1286 
1287  for (int for_i=0;for_i<IDELEMS(r1->qideal);for_i++)
1288  Q1->m[for_i] = p_PermPoly(
1289  r1->qideal->m[for_i], perm1,
1290  r1, sum,
1291  nMap1,
1292  par_perm1, rPar(r1));
1293 
1294  omFree((ADDRESS)perm1);
1295  }
1296 
1297  if (r2->qideal!=NULL)
1298  {
1299  //if (currRing!=sum)
1300  // rChangeCurrRing(sum);
1301  int *perm2 = (int *)omAlloc0((rVar(r2)+1)*sizeof(int));
1302  int *par_perm2 = NULL;
1303  if (rPar(r2)!=0) par_perm2=(int *)omAlloc0((rPar(r2)+1)*sizeof(int));
1304  maFindPerm(r2->names, rVar(r2), rParameter(r2), rPar(r2),
1305  sum->names, rVar(sum), rParameter(sum), rPar(sum),
1306  perm2, par_perm2, sum->cf->type);
1307  nMapFunc nMap2 = n_SetMap(r2->cf,sum->cf);
1308  Q2 = idInit(IDELEMS(r2->qideal),1);
1309 
1310  for (int for_i=0;for_i<IDELEMS(r2->qideal);for_i++)
1311  Q2->m[for_i] = p_PermPoly(
1312  r2->qideal->m[for_i], perm2,
1313  r2, sum,
1314  nMap2,
1315  par_perm2, rPar(r2));
1316 
1317  omFree((ADDRESS)perm2);
1318  }
1319  if (Q1!=NULL)
1320  {
1321  if ( Q2!=NULL)
1322  Q = id_SimpleAdd(Q1,Q2,sum);
1323  else
1324  Q=id_Copy(Q1,sum);
1325  }
1326  else
1327  {
1328  if ( Q2!=NULL)
1329  Q = id_Copy(Q2,sum);
1330  else
1331  Q=NULL;
1332  }
1333  sum->qideal = Q;
1334 
1335 #ifdef HAVE_PLURAL
1336  if( rIsPluralRing(sum) )
1337  nc_SetupQuotient( sum );
1338 #endif
1339  return 1;
1340 }
static int si_max(const int a, const int b)
Definition: auxiliary.h:124
@ n_R
single prescision (6,6) real numbers
Definition: coeffs.h:32
@ n_Znm
only used if HAVE_RINGS is defined
Definition: coeffs.h:46
@ n_Zn
only used if HAVE_RINGS is defined
Definition: coeffs.h:45
STATIC_VAR jList * Q
Definition: janet.cc:30
void maFindPerm(char const *const *const preim_names, int preim_n, char const *const *const preim_par, int preim_p, char const *const *const names, int n, char const *const *const par, int nop, int *perm, int *par_perm, n_coeffType ch)
Definition: maps.cc:163
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
int rChar(ring r)
Definition: ring.cc:714
ring nc_rCreateNCcomm_rCopy(ring r)
Definition: ring.cc:720
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
ideal id_SimpleAdd(ideal h1, ideal h2, const ring R)
concat the lists h1 and h2 without zeros
Definition: ring.h:248
n_Procs_s * cf
Definition: ring.h:368
int * block0
Definition: ring.h:254
short N
Definition: ring.h:303
int * block1
Definition: ring.h:255
rRingOrder_t * order
Definition: ring.h:253
int ** wvhdl
Definition: ring.h:257
unsigned long bitmask
Definition: ring.h:350
char ** names
Definition: ring.h:258
short OrdSgn
Definition: ring.h:305

◆ rTypeOfMatrixOrder()

int rTypeOfMatrixOrder ( const intvec order)

Definition at line 185 of file ring.cc.

186 {
187  int i=0,j,typ=1;
188  int sz = (int)sqrt((double)(order->length()-2));
189  if ((sz*sz)!=(order->length()-2))
190  {
191  WerrorS("Matrix order is not a square matrix");
192  typ=0;
193  }
194  while ((i<sz) && (typ==1))
195  {
196  j=0;
197  while ((j<sz) && ((*order)[j*sz+i+2]==0)) j++;
198  if (j>=sz)
199  {
200  typ = 0;
201  WerrorS("Matrix order not complete");
202  }
203  else if ((*order)[j*sz+i+2]<0)
204  typ = -1;
205  else
206  i++;
207  }
208  return typ;
209 }
gmp_float sqrt(const gmp_float &a)
Definition: mpr_complex.cc:327

◆ rUnComplete()

void rUnComplete ( ring  r)

Definition at line 3918 of file ring.cc.

3919 {
3920  if (r == NULL) return;
3921  if (r->VarOffset != NULL)
3922  {
3923  if (r->OrdSize!=0 && r->typ != NULL)
3924  {
3925  for(int i = 0; i < r->OrdSize; i++)
3926  if( r->typ[i].ord_typ == ro_is) // Search for suffixes! (prefix have the same VarOffset)
3927  {
3928  id_Delete(&r->typ[i].data.is.F, r);
3929 
3930  if( r->typ[i].data.is.pVarOffset != NULL )
3931  {
3932  omFreeSize((ADDRESS)r->typ[i].data.is.pVarOffset, (r->N +1)*sizeof(int));
3933  }
3934  }
3935  else if (r->typ[i].ord_typ == ro_syz)
3936  {
3937  if(r->typ[i].data.syz.limit > 0)
3938  omFreeSize(r->typ[i].data.syz.syz_index, ((r->typ[i].data.syz.limit) +1)*sizeof(int));
3939  }
3940  else if (r->typ[i].ord_typ == ro_syzcomp)
3941  {
3942  assume( r->typ[i].data.syzcomp.ShiftedComponents == NULL );
3943  assume( r->typ[i].data.syzcomp.Components == NULL );
3944 // WarnS( "rUnComplete : ord_typ == ro_syzcomp was unhandled!!! Possibly memory leak!!!" );
3945 #ifndef SING_NDEBUG
3946 // assume(0);
3947 #endif
3948  }
3949 
3950  omFreeSize((ADDRESS)r->typ,r->OrdSize*sizeof(sro_ord)); r->typ = NULL;
3951  }
3952 
3953  if (r->PolyBin != NULL)
3954  omUnGetSpecBin(&(r->PolyBin));
3955 
3956  omFreeSize((ADDRESS)r->VarOffset, (r->N +1)*sizeof(int));
3957  r->VarOffset=NULL;
3958 
3959  if (r->ordsgn != NULL && r->CmpL_Size != 0)
3960  {
3961  omFreeSize((ADDRESS)r->ordsgn,r->ExpL_Size*sizeof(long));
3962  r->ordsgn=NULL;
3963  }
3964  if (r->p_Procs != NULL)
3965  {
3966  omFreeSize(r->p_Procs, sizeof(p_Procs_s));
3967  r->p_Procs=NULL;
3968  }
3969  omfreeSize(r->VarL_Offset, r->VarL_Size*sizeof(int));
3970  r->VarL_Offset=NULL;
3971  }
3972  if (r->NegWeightL_Offset!=NULL)
3973  {
3974  omFreeSize(r->NegWeightL_Offset, r->NegWeightL_Size*sizeof(int));
3975  r->NegWeightL_Offset=NULL;
3976  }
3977 }
#define omfreeSize(addr, size)
Definition: omAllocDecl.h:236
#define omUnGetSpecBin(bin_ptr)
Definition: omBin.h:14

◆ rVarStr()

char* rVarStr ( ring  r)

Definition at line 624 of file ring.cc.

625 {
626  if ((r==NULL)||(r->names==NULL)) return omStrDup("");
627  int i;
628  int l=2;
629  char *s;
630 
631  for (i=0; i<r->N; i++)
632  {
633  l+=strlen(r->names[i])+1;
634  }
635  s=(char *)omAlloc((long)l);
636  s[0]='\0';
637  for (i=0; i<r->N-1; i++)
638  {
639  strcat(s,r->names[i]);
640  strcat(s,",");
641  }
642  strcat(s,r->names[i]);
643  return s;
644 }

◆ rWrite()

void rWrite ( ring  r,
BOOLEAN  details 
)

Definition at line 226 of file ring.cc.

227 {
228  if ((r==NULL)||(r->order==NULL))
229  return; /*to avoid printing after errors....*/
230 
231  assume(r != NULL);
232  const coeffs C = r->cf;
233  assume(C != NULL);
234 
235  int nblocks=rBlocks(r);
236 
237  // omCheckAddrSize(r,sizeof(ip_sring));
238  omCheckAddrSize(r->order,nblocks*sizeof(int));
239  omCheckAddrSize(r->block0,nblocks*sizeof(int));
240  omCheckAddrSize(r->block1,nblocks*sizeof(int));
241  omCheckAddrSize(r->wvhdl,nblocks*sizeof(int *));
242  omCheckAddrSize(r->names,r->N*sizeof(char *));
243 
244  nblocks--;
245 
246 
247  //Print("ref:%d, C->ref:%d\n",r->ref,C->ref);
248  PrintS("// coefficients: ");
249  if( nCoeff_is_algExt(C) )
250  {
251  // NOTE: the following (non-thread-safe!) UGLYNESS
252  // (changing naRing->ShortOut for a while) is due to Hans!
253  // Just think of other ring using the VERY SAME naRing and possible
254  // side-effects...
255  ring R = C->extRing;
256  const BOOLEAN bSaveShortOut = rShortOut(R); R->ShortOut = rShortOut(r) & rCanShortOut(R);
257 
258  n_CoeffWrite(C, details); // for correct printing of minpoly... WHAT AN UGLYNESS!!!
259 
260  R->ShortOut = bSaveShortOut;
261  }
262  else
263  n_CoeffWrite(C, details);
264  PrintLn();
265 // {
266 // PrintS("// characteristic : ");
267 //
268 // char const * const * const params = rParameter(r);
269 //
270 // if (params!=NULL)
271 // {
272 // Print ("// %d parameter : ",rPar(r));
273 //
274 // char const * const * sp= params;
275 // int nop=0;
276 // while (nop<rPar(r))
277 // {
278 // PrintS(*sp);
279 // PrintS(" ");
280 // sp++; nop++;
281 // }
282 // PrintS("\n// minpoly : ");
283 // if ( rField_is_long_C(r) )
284 // {
285 // // i^2+1:
286 // Print("(%s^2+1)\n", params[0]);
287 // }
288 // else if (rMinpolyIsNULL(r))
289 // {
290 // PrintS("0\n");
291 // }
292 // else
293 // {
294 // StringSetS(""); n_Write(r->cf->minpoly, r); PrintS(StringEndS("\n")); // NOTE/TODO: use StringAppendS("\n"); omFree(s);
295 // }
296 // //if (r->qideal!=NULL)
297 // //{
298 // // iiWriteMatrix((matrix)r->qideal,"// minpolys",1,r,0);
299 // // PrintLn();
300 // //}
301 // }
302 // }
303  Print("// number of vars : %d",r->N);
304 
305  //for (nblocks=0; r->order[nblocks]; nblocks++);
306  nblocks=rBlocks(r)-1;
307 
308  for (int l=0, nlen=0 ; l<nblocks; l++)
309  {
310  int i;
311  Print("\n// block %3d : ",l+1);
312 
313  Print("ordering %s", rSimpleOrdStr(r->order[l]));
314 
315 
316  if (r->order[l] == ringorder_IS)
317  {
318  assume( r->block0[l] == r->block1[l] );
319  const int s = r->block0[l];
320  assume( (-2 < s) && (s < 2) );
321  Print("(%d)", s); // 0 => prefix! +/-1 => suffix!
322  continue;
323  }
324  else if (r->order[l]==ringorder_s)
325  {
326  assume( l == 0 );
327  Print(" syz_comp: %d",r->block0[l]);
328  continue;
329  }
330  else if (
331  ( (r->order[l] >= ringorder_lp)
332  ||(r->order[l] == ringorder_M)
333  ||(r->order[l] == ringorder_a)
334  ||(r->order[l] == ringorder_am)
335  ||(r->order[l] == ringorder_a64)
336  ||(r->order[l] == ringorder_aa) ) && (r->order[l] < ringorder_IS) )
337  {
338  PrintS("\n// : names ");
339  for (i = r->block0[l]-1; i<r->block1[l]; i++)
340  {
341  nlen = strlen(r->names[i]);
342  Print(" %s",r->names[i]);
343  }
344  }
345 
346  if (r->wvhdl[l]!=NULL)
347  {
348  #ifndef SING_NDEBUG
349  if((r->order[l] != ringorder_wp)
350  &&(r->order[l] != ringorder_Wp)
351  &&(r->order[l] != ringorder_ws)
352  &&(r->order[l] != ringorder_Ws)
353  &&(r->order[l] != ringorder_a)
354  &&(r->order[l] != ringorder_am)
355  &&(r->order[l] != ringorder_M))
356  {
357  Warn("should not have wvhdl entry at pos. %d",l);
358  }
359  #endif
360  for (int j= 0;
361  j<(r->block1[l]-r->block0[l]+1)*(r->block1[l]-r->block0[l]+1);
362  j+=i)
363  {
364  PrintS("\n// : weights ");
365  for (i = 0; i<=r->block1[l]-r->block0[l]; i++)
366  {
367  if (r->order[l] == ringorder_a64)
368  {
369  int64 *w=(int64 *)r->wvhdl[l];
370  #if SIZEOF_LONG == 4
371  Print("%*lld " ,nlen,w[i+j]);
372  #else
373  Print(" %*ld" ,nlen,w[i+j]);
374  #endif
375  }
376  else
377  Print(" %*d" ,nlen,r->wvhdl[l][i+j]);
378  }
379  if (r->order[l]!=ringorder_M) break;
380  }
381  if (r->order[l]==ringorder_am)
382  {
383  int m=r->wvhdl[l][i];
384  Print("\n// : %d module weights ",m);
385  m+=i;i++;
386  for(;i<=m;i++) Print(" %*d" ,nlen,r->wvhdl[l][i]);
387  }
388  }
389  }
390 #ifdef HAVE_PLURAL
391  if(rIsPluralRing(r))
392  {
393  PrintS("\n// noncommutative relations:");
394  if( details )
395  {
396  poly pl=NULL;
397  int nl;
398  int i,j;
399  for (i = 1; i<r->N; i++)
400  {
401  for (j = i+1; j<=r->N; j++)
402  {
403  nl = n_IsOne(p_GetCoeff(MATELEM(r->GetNC()->C,i,j),r), r->cf);
404  if ( (MATELEM(r->GetNC()->D,i,j)!=NULL) || (!nl) )
405  {
406  Print("\n// %s%s=",r->names[j-1],r->names[i-1]);
407  pl = MATELEM(r->GetNC()->MT[UPMATELEM(i,j,r->N)],1,1);
408  p_Write0(pl, r, r);
409  }
410  }
411  }
412  } else
413  PrintS(" ...");
414 
415 #if MYTEST /*Singularg should not differ from Singular except in error case*/
416  Print("\n// noncommutative type:%d", (int)ncRingType(r));
417  Print("\n// is skew constant:%d",r->GetNC()->IsSkewConstant);
418  if( rIsSCA(r) )
419  {
420  Print("\n// alternating variables: [%d, %d]", scaFirstAltVar(r), scaLastAltVar(r));
421  const ideal Q = SCAQuotient(r); // resides within r!
422  PrintS("\n// quotient of sca by ideal");
423 
424  if (Q!=NULL)
425  {
426  iiWriteMatrix((matrix)Q,"scaQ",1,r,0);
427  }
428  else
429  PrintS(" (NULL)");
430  }
431 #endif
432  }
433  if (rIsLPRing(r))
434  {
435  Print("\n// letterplace ring (block size %d, ncgen count %d)",r->isLPring, r->LPncGenCount);
436  }
437 #endif
438  if (r->qideal!=NULL)
439  {
440  PrintS("\n// quotient ring from ideal");
441  if( details )
442  {
443  PrintLn();
444  iiWriteMatrix((matrix)r->qideal,"_",1,r,0);
445  } else PrintS(" ...");
446  }
447 }
static FORCE_INLINE void n_CoeffWrite(const coeffs r, BOOLEAN details=TRUE)
output the coeff description
Definition: coeffs.h:743
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:469
#define UPMATELEM(i, j, nVar)
Definition: nc.h:36
void iiWriteMatrix(matrix im, const char *n, int dim, const ring r, int spaces)
set spaces to zero by default
Definition: matpol.cc:834
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:332
static BOOLEAN rShortOut(const ring r)
Definition: ring.h:586
static BOOLEAN rCanShortOut(const ring r)
Definition: ring.h:591
ideal SCAQuotient(const ring r)
Definition: sca.h:10

◆ sign()

static int sign ( int  x)
inlinestatic

Definition at line 3380 of file ring.cc.

3380 { return (x > 0) - (x < 0);}
Variable x
Definition: cfModGcd.cc:4084

Variable Documentation

◆ char_ptr_bin

VAR omBin char_ptr_bin = omGetSpecBin(sizeof(char_ptr))

Definition at line 44 of file ring.cc.

◆ pDBsyzComp

VAR int pDBsyzComp =0

Definition at line 5032 of file ring.cc.

◆ ringorder_name

const char* const ringorder_name[]
static
Initial value:
=
{
" ?",
"a",
"A",
"c",
"C",
"M",
"S",
"s",
"lp",
"dp",
"rp",
"Dp",
"wp",
"Wp",
"ls",
"ds",
"Ds",
"ws",
"Ws",
"am",
"L",
"aa",
"rs",
"IS",
" _"
}

Definition at line 47 of file ring.cc.

◆ sip_sring_bin

VAR omBin sip_sring_bin = omGetSpecBin(sizeof(ip_sring))

Definition at line 43 of file ring.cc.