My Project
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
ring.h File Reference
#include "misc/auxiliary.h"
#include "coeffs/coeffs.h"
#include "misc/intvec.h"
#include "misc/int64vec.h"
#include "polys/monomials/monomials.h"

Go to the source code of this file.

Data Structures

struct  sro_dp
 
struct  sro_wp
 
struct  sro_am
 
struct  sro_wp64
 
struct  sro_cp
 
struct  sro_syzcomp
 
struct  sro_syz
 
struct  sro_ISTemp
 
struct  sro_IS
 
struct  sro_ord
 
struct  ring
 
union  sro_ord.data
 

Macros

#define rField_is_Ring(R)   nCoeff_is_Ring((R)->cf)
 
#define rTest(r)   rDBTest(r, __FILE__, __LINE__)
 

Typedefs

typedef idrecidhdl
 
typedef struct p_Procs_s p_Procs_s
 
typedef kBucketkBucket_pt
 
typedef long(* pLDegProc) (poly p, int *length, ring r)
 
typedef long(* pFDegProc) (poly p, ring r)
 
typedef void(* p_SetmProc) (poly p, const ring r)
 
typedef poly(* pShallowCopyDeleteProc) (poly s_p, ring source_r, ring dest_r, omBin dest_bin)
 returns a poly from dest_r which is a ShallowCopy of s_p from source_r assumes that source_r->N == dest_r->N and that orderings are the same More...
 
typedef skStrategykStrategy
 
typedef poly(* NF_Proc) (ideal, ideal, poly, int, int, const ring _currRing)
 
typedef ideal(* BBA_Proc) (const ideal, const ideal, const intvec *, const intvec *, kStrategy strat, const ring)
 

Enumerations

enum  ro_typ {
  ro_dp , ro_wp , ro_am , ro_wp64 ,
  ro_wp_neg , ro_cp , ro_syzcomp , ro_syz ,
  ro_isTemp , ro_is , ro_none
}
 
enum  rRingOrder_t {
  ringorder_no = 0 , ringorder_a , ringorder_a64 , ringorder_c ,
  ringorder_C , ringorder_M , ringorder_S , ringorder_s ,
  ringorder_lp , ringorder_dp , ringorder_rp , ringorder_Dp ,
  ringorder_wp , ringorder_Wp , ringorder_ls , ringorder_ds ,
  ringorder_Ds , ringorder_ws , ringorder_Ws , ringorder_am ,
  ringorder_L , ringorder_aa , ringorder_rs , ringorder_IS ,
  ringorder_unspec
}
 order stuff More...
 
enum  rOrderType_t {
  rOrderType_General = 0 , rOrderType_CompExp , rOrderType_ExpComp , rOrderType_Exp ,
  rOrderType_Syz , rOrderType_Schreyer , rOrderType_Syz2dpc , rOrderType_ExpNoComp
}
 

Functions

ring rDefault (int ch, int N, char **n)
 
ring rDefault (const coeffs cf, int N, char **n, const rRingOrder_t o=ringorder_lp)
 
ring rDefault (int ch, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl=NULL)
 
ring rDefault (const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl=NULL, unsigned long bitmask=0)
 
unsigned long rGetExpSize (unsigned long bitmask, int &bits, int N)
 
int r_IsRingVar (const char *n, char **names, int N)
 
void rWrite (ring r, BOOLEAN details=FALSE)
 
ring rCopy (ring r)
 
ring rCopy0 (const ring r, BOOLEAN copy_qideal=TRUE, BOOLEAN copy_ordering=TRUE)
 
ring rCopy0AndAddA (ring r, int64vec *wv64, BOOLEAN copy_qideal=TRUE, BOOLEAN copy_ordering=TRUE)
 
ring rOpposite (ring r)
 
ring rEnvelope (ring r)
 
static BOOLEAN rIsPluralRing (const ring r)
 we must always have this test! More...
 
static BOOLEAN rIsLPRing (const ring r)
 
static BOOLEAN rIsNCRing (const ring r)
 
static BOOLEAN rIsRatGRing (const ring r)
 
void rChangeSComps (int *currComponents, long *currShiftedComponents, int length, ring r)
 
void rGetSComps (int **currComponents, long **currShiftedComponents, int *length, ring r)
 
const char * rSimpleOrdStr (int ord)
 
rRingOrder_t rOrderName (char *ordername)
 
char * rOrdStr (ring r)
 
char * rVarStr (ring r)
 
char * rCharStr (ring r)
 TODO: make it a virtual method of coeffs, together with: Decompose & Compose, rParameter & rPar. More...
 
char * rString (ring r)
 
int rChar (ring r)
 
char * rParStr (ring r)
 
int rSum (ring r1, ring r2, ring &sum)
 
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...
 
BOOLEAN rEqual (ring r1, ring r2, BOOLEAN qr=TRUE)
 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...
 
void rUnComplete (ring r)
 
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)
 
static BOOLEAN rField_is_Ring_2toM (const ring r)
 
static BOOLEAN rField_is_Ring_PtoM (const ring r)
 
static BOOLEAN rField_is_Domain (const ring r)
 
static BOOLEAN rField_has_Units (const ring r)
 
static BOOLEAN rField_is_Zp (const ring r)
 
static BOOLEAN rField_is_Zp (const ring r, int p)
 
static BOOLEAN rField_is_Q (const ring r)
 
static BOOLEAN rField_is_Z (const ring r)
 
static BOOLEAN rField_is_Zn (const ring r)
 
static BOOLEAN rField_is_numeric (const ring r)
 
static BOOLEAN rField_is_R (const ring r)
 
static BOOLEAN rField_is_GF (const ring r)
 
static BOOLEAN rField_is_GF (const ring r, int q)
 
static BOOLEAN rField_is_Zp_a (const ring r)
 
static BOOLEAN rField_is_Zp_a (const ring r, int p)
 
static BOOLEAN rField_is_Q_a (const ring r)
 
static BOOLEAN rField_is_long_R (const ring r)
 
static BOOLEAN rField_is_long_C (const ring r)
 
static BOOLEAN rField_has_simple_inverse (const ring r)
 
static BOOLEAN rField_has_simple_Alloc (const ring r)
 Z/p, GF(p,n), R: nCopy, nNew, nDelete are dummies. More...
 
static n_coeffType rFieldType (const ring r)
 the type of the coefficient filed of r (n_Zp, n_Q, etc) More...
 
BOOLEAN rComplete (ring r, int force=0)
 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 p_SetGlobals (const ring r, BOOLEAN complete=TRUE)
 set all properties of a new ring - also called by rComplete More...
 
static int rBlocks (ring r)
 
static char * rRingVar (short i, const ring r)
 
static BOOLEAN rShortOut (const ring r)
 
static BOOLEAN rCanShortOut (const ring r)
 
static short rVar (const ring r)
 #define rVar(r) (r->N) More...
 
static int rPar (const ring r)
 (r->cf->P) More...
 
static char const ** rParameter (const ring r)
 (r->cf->parameter) More...
 
static number n_Param (const short iParameter, const ring r)
 return the specified parameter as a (new!) number in the given polynomial ring, or NULL if invalid parameters (as variables) begin with 1! More...
 
int n_IsParam (number m, const ring r)
 if m == var(i)/1 => return i, More...
 
static int rInternalChar (const ring r)
 
static BOOLEAN rMinpolyIsNULL (const ring r)
 Tests whether '(r->cf->minpoly) == NULL'. More...
 
static BOOLEAN rIsSyzIndexRing (const ring r)
 
static int rGetCurrSyzLimit (const ring r)
 
void rSetSyzComp (int k, const ring r)
 
ring rAssure_HasComp (const ring r)
 
ring rAssure_SyzOrder (const ring r, BOOLEAN complete)
 
ring rAssure_SyzComp (const ring r, BOOLEAN complete=TRUE)
 
ring rAssure_InducedSchreyerOrdering (const ring r, BOOLEAN complete=TRUE, int sgn=1)
 
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)
 
ring rAssure_CompLastBlock (const ring r, BOOLEAN complete=TRUE)
 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...
 
ring rAssure_TDeg (const ring r, int &pos)
 
int rGetMaxSyzComp (int i, const ring r)
 return the max-comonent wchich has syzIndex i Assume: i<= syzIndex_limit More...
 
BOOLEAN rHasSimpleOrder (const ring r)
 
BOOLEAN rHas_c_Ordering (const ring r)
 
BOOLEAN rHasSimpleLexOrder (const ring r)
 returns TRUE, if simple lp or ls ordering More...
 
BOOLEAN rHasGlobalOrdering (const ring r)
 
BOOLEAN rHasLocalOrMixedOrdering (const ring r)
 
BOOLEAN rHasMixedOrdering (const ring r)
 
BOOLEAN rOrd_is_Totaldegree_Ordering (const ring r)
 
BOOLEAN rOrd_SetCompRequiresSetm (const ring r)
 return TRUE if p_SetComp requires p_Setm More...
 
rOrderType_t rGetOrderType (ring r)
 
BOOLEAN rIsPolyVar (int i, const ring r)
 returns TRUE if var(i) belongs to p-block More...
 
static BOOLEAN rOrd_is_Comp_dp (const ring r)
 
BOOLEAN rDBTest (ring r, const char *fn, const int l)
 
ring rModifyRing (ring r, BOOLEAN omit_degree, BOOLEAN omit_comp, unsigned long exp_limit)
 
ring rModifyRing_Wp (ring r, int *weights)
 construct Wp, C ring More...
 
void rModify_a_to_A (ring r)
 
void rKillModifiedRing (ring r)
 
void rKillModified_Wp_Ring (ring r)
 
ring rModifyRing_Simple (ring r, BOOLEAN omit_degree, BOOLEAN omit_comp, unsigned long exp_limit, BOOLEAN &simple)
 
void rDebugPrint (const ring r)
 
void p_DebugPrint (poly p, const ring r)
 
int64rGetWeightVec (const ring r)
 
void rSetWeightVec (ring r, int64 *wv)
 
poly rGetVar (const int varIndex, const ring r)
 
BOOLEAN rSetISReference (const ring r, const ideal F, const int i=0, const int p=0)
 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...
 
int rGetISPos (const int p, const ring r)
 return the position of the p^th IS block order block in r->typ[]... More...
 
void pISUpdateComponents (ideal F, const intvec *const V, const int MIN, const ring r)
 
BOOLEAN rCheckIV (const intvec *iv)
 
int rTypeOfMatrixOrder (const intvec *order)
 
void rDelete (ring r)
 unconditionally deletes fields in r 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...
 
static ring rIncRefCnt (ring r)
 
static void rDecRefCnt (ring r)
 

Variables

EXTERN_VAR omBin sip_sring_bin
 

Data Structure Documentation

◆ sro_dp

struct sro_dp

Definition at line 113 of file ring.h.

Data Fields
short end
short place
short start

◆ sro_wp

struct sro_wp

Definition at line 122 of file ring.h.

Data Fields
short end
short place
short start
int * weights

◆ sro_am

struct sro_am

Definition at line 132 of file ring.h.

Data Fields
short end
short len_gen
short place
short start
int * weights
int * weights_m

◆ sro_wp64

struct sro_wp64

Definition at line 147 of file ring.h.

Data Fields
short end
short place
short start
int64 * weights64

◆ sro_cp

struct sro_cp

Definition at line 157 of file ring.h.

Data Fields
short end
short place
short start

◆ sro_syzcomp

struct sro_syzcomp

Definition at line 166 of file ring.h.

Data Fields
int * Components
long length
short place
long * ShiftedComponents

◆ sro_syz

struct sro_syz

Definition at line 178 of file ring.h.

Data Fields
int curr_index
int limit
short place
int * syz_index

◆ sro_ISTemp

struct sro_ISTemp

Definition at line 194 of file ring.h.

Data Fields
int * pVarOffset
short start
int suffixpos

◆ sro_IS

struct sro_IS

Definition at line 204 of file ring.h.

Data Fields
short end
ideal F
int limit
int * pVarOffset
short start

◆ sro_ord

struct sro_ord

Definition at line 218 of file ring.h.

Data Fields
union sro_ord.data data
ro_typ ord_typ
int order_index

◆ sro_ord.data

union sro_ord.data

Definition at line 222 of file ring.h.

Data Fields
sro_am am
sro_cp cp
sro_dp dp
sro_IS is
sro_ISTemp isTemp
sro_syz syz
sro_syzcomp syzcomp
sro_wp wp
sro_wp64 wp64

Macro Definition Documentation

◆ rField_is_Ring

#define rField_is_Ring (   R)    nCoeff_is_Ring((R)->cf)

Definition at line 486 of file ring.h.

◆ rTest

#define rTest (   r)    rDBTest(r, __FILE__, __LINE__)

Definition at line 786 of file ring.h.

Typedef Documentation

◆ BBA_Proc

typedef ideal(* BBA_Proc) (const ideal, const ideal, const intvec *, const intvec *, kStrategy strat, const ring)

Definition at line 244 of file ring.h.

◆ idhdl

typedef idrec* idhdl

Definition at line 21 of file ring.h.

◆ kBucket_pt

typedef kBucket* kBucket_pt

Definition at line 25 of file ring.h.

◆ kStrategy

Definition at line 241 of file ring.h.

◆ NF_Proc

typedef poly(* NF_Proc) (ideal, ideal, poly, int, int, const ring _currRing)

Definition at line 243 of file ring.h.

◆ p_Procs_s

typedef struct p_Procs_s p_Procs_s

Definition at line 23 of file ring.h.

◆ p_SetmProc

typedef void(* p_SetmProc) (poly p, const ring r)

Definition at line 39 of file ring.h.

◆ pFDegProc

typedef long(* pFDegProc) (poly p, ring r)

Definition at line 38 of file ring.h.

◆ pLDegProc

typedef long(* pLDegProc) (poly p, int *length, ring r)

Definition at line 37 of file ring.h.

◆ pShallowCopyDeleteProc

typedef poly(* pShallowCopyDeleteProc) (poly s_p, ring source_r, ring dest_r, omBin dest_bin)

returns a poly from dest_r which is a ShallowCopy of s_p from source_r assumes that source_r->N == dest_r->N and that orderings are the same

Definition at line 44 of file ring.h.

Enumeration Type Documentation

◆ ro_typ

enum ro_typ
Enumerator
ro_dp 
ro_wp 
ro_am 
ro_wp64 
ro_wp_neg 
ro_cp 
ro_syzcomp 
ro_syz 
ro_isTemp 
ro_is 
ro_none 

Definition at line 50 of file ring.h.

51{
52 ro_dp, // total degree with weights 1
53 ro_wp, // total weighted degree with weights>0 in wvhdl
54 ro_am, // weights for vars + weights for gen
55 ro_wp64, // weighted64 degree weights in wvhdl
56 ro_wp_neg, // total weighted degree with weights in Z in wvhdl
57 // (with possibly negative weights)
58 ro_cp, // ??ordering duplicates variables
59 ro_syzcomp, // ??ordering indicates "subset" of component number (ringorder_S)
60 ro_syz, // component number if <=syzcomp else 0 (ringorder_s)
61 ro_isTemp, ro_is, // ??Induced Syzygy (Schreyer) ordering (and prefix data placeholder dummy) (ringorder_IS)
63}
@ ro_wp64
Definition: ring.h:55
@ ro_syz
Definition: ring.h:60
@ ro_cp
Definition: ring.h:58
@ ro_dp
Definition: ring.h:52
@ ro_is
Definition: ring.h:61
@ ro_wp_neg
Definition: ring.h:56
@ ro_wp
Definition: ring.h:53
@ ro_isTemp
Definition: ring.h:61
@ ro_am
Definition: ring.h:54
@ ro_none
Definition: ring.h:62
@ ro_syzcomp
Definition: ring.h:59

◆ rOrderType_t

Enumerator
rOrderType_General 

non-simple ordering as specified by currRing

rOrderType_CompExp 

simple ordering, component has priority

rOrderType_ExpComp 

simple ordering, exponent vector has priority component not compatible with exp-vector order

rOrderType_Exp 

simple ordering, exponent vector has priority component is compatible with exp-vector order

rOrderType_Syz 

syzygy ordering

rOrderType_Schreyer 

Schreyer ordering.

rOrderType_Syz2dpc 

syzcomp2dpc

rOrderType_ExpNoComp 

simple ordering, differences in component are not considered

Definition at line 97 of file ring.h.

98{
99 rOrderType_General = 0, ///< non-simple ordering as specified by currRing
100 rOrderType_CompExp, ///< simple ordering, component has priority
101 rOrderType_ExpComp, ///< simple ordering, exponent vector has priority
102 ///< component not compatible with exp-vector order
103 rOrderType_Exp, ///< simple ordering, exponent vector has priority
104 ///< component is compatible with exp-vector order
105 rOrderType_Syz, ///< syzygy ordering
106 rOrderType_Schreyer, ///< Schreyer ordering
107 rOrderType_Syz2dpc, ///< syzcomp2dpc
108 rOrderType_ExpNoComp ///< simple ordering, differences in component are
109 ///< not considered
rOrderType_t
Definition: ring.h:98
@ rOrderType_Syz
syzygy ordering
Definition: ring.h:105
@ rOrderType_Syz2dpc
syzcomp2dpc
Definition: ring.h:107
@ 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_Schreyer
Schreyer ordering.
Definition: ring.h:106
@ rOrderType_ExpNoComp
simple ordering, differences in component are not considered
Definition: ring.h:108
@ rOrderType_ExpComp
simple ordering, exponent vector has priority component not compatible with exp-vector order
Definition: ring.h:101

◆ rRingOrder_t

order stuff

Enumerator
ringorder_no 
ringorder_a 
ringorder_a64 

for int64 weights

ringorder_c 
ringorder_C 
ringorder_M 
ringorder_S 

S?

ringorder_s 

s?

ringorder_lp 
ringorder_dp 
ringorder_rp 
ringorder_Dp 
ringorder_wp 
ringorder_Wp 
ringorder_ls 
ringorder_ds 
ringorder_Ds 
ringorder_ws 
ringorder_Ws 
ringorder_am 
ringorder_L 
ringorder_aa 

for idElimination, like a, except pFDeg, pWeigths ignore it

ringorder_rs 

opposite of ls

ringorder_IS 

Induced (Schreyer) ordering.

ringorder_unspec 

Definition at line 67 of file ring.h.

68{
69 ringorder_no = 0,
71 ringorder_a64, ///< for int64 weights
75 ringorder_S, ///< S?
76 ringorder_s, ///< s?
90 // the following are only used internally
91 ringorder_aa, ///< for idElimination, like a, except pFDeg, pWeigths ignore it
92 ringorder_rs, ///< opposite of ls
93 ringorder_IS, ///< Induced (Schreyer) ordering
rRingOrder_t
order stuff
Definition: ring.h:68
@ ringorder_lp
Definition: ring.h:77
@ ringorder_a
Definition: ring.h:70
@ ringorder_am
Definition: ring.h:88
@ ringorder_a64
for int64 weights
Definition: ring.h:71
@ ringorder_rs
opposite of ls
Definition: ring.h:92
@ ringorder_C
Definition: ring.h:73
@ ringorder_S
S?
Definition: ring.h:75
@ ringorder_ds
Definition: ring.h:84
@ ringorder_Dp
Definition: ring.h:80
@ ringorder_unspec
Definition: ring.h:94
@ ringorder_L
Definition: ring.h:89
@ ringorder_Ds
Definition: ring.h:85
@ ringorder_dp
Definition: ring.h:78
@ ringorder_c
Definition: ring.h:72
@ ringorder_rp
Definition: ring.h:79
@ ringorder_aa
for idElimination, like a, except pFDeg, pWeigths ignore it
Definition: ring.h:91
@ ringorder_no
Definition: ring.h:69
@ ringorder_Wp
Definition: ring.h:82
@ ringorder_ws
Definition: ring.h:86
@ ringorder_Ws
Definition: ring.h:87
@ ringorder_IS
Induced (Schreyer) ordering.
Definition: ring.h:93
@ ringorder_ls
Definition: ring.h:83
@ ringorder_s
s?
Definition: ring.h:76
@ ringorder_wp
Definition: ring.h:81
@ ringorder_M
Definition: ring.h:74

Function Documentation

◆ n_IsParam()

int n_IsParam ( const number  m,
const ring  r 
)

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

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

Definition at line 5897 of file ring.cc.

5898{
5899 assume(r != NULL);
5900 const coeffs C = r->cf;
5901 assume(C != NULL);
5902
5904
5905 const n_coeffType _filed_type = getCoeffType(C);
5906
5907 if(( _filed_type == n_algExt )||( _filed_type == n_polyExt ))
5908 return naIsParam(m, C);
5909
5910 if( _filed_type == n_transExt )
5911 return ntIsParam(m, C);
5912
5913 Werror("n_IsParam: IsParam is not to be used for (coeff_type = %d)",getCoeffType(C));
5914
5915 return 0;
5916}
int naIsParam(number m, const coeffs cf)
if m == var(i)/1 => return i,
Definition: algext.cc:1096
int m
Definition: cfEzgcd.cc:128
static FORCE_INLINE BOOLEAN nCoeff_is_Extension(const coeffs r)
Definition: coeffs.h:846
n_coeffType
Definition: coeffs.h:27
@ n_polyExt
used to represent polys as coeffcients
Definition: coeffs.h:34
@ n_algExt
used for all algebraic extensions, i.e., the top-most extension in an extension tower is algebraic
Definition: coeffs.h:35
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition: coeffs.h:38
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
#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

◆ n_Param()

static number n_Param ( const short  iParameter,
const ring  r 
)
inlinestatic

return the specified parameter as a (new!) number in the given polynomial ring, or NULL if invalid parameters (as variables) begin with 1!

Definition at line 653 of file ring.h.

654{
655 assume(r != NULL);
656 const coeffs C = r->cf;
657 assume(C != NULL);
658 return n_Param(iParameter, C);
659// const n_coeffType _filed_type = getCoeffType(C);
660//
661// if ( iParameter <= 0 || iParameter > rPar(r) )
662// // Wrong parameter
663// return NULL;
664//
665// if( _filed_type == n_algExt )
666// return naParameter(iParameter, C);
667//
668// if( _filed_type == n_transExt )
669// return ntParameter(iParameter, C);
670//
671// if (_filed_type == n_GF)// if (nCoeff_is_GF(C))
672// {
673// number nfPar (int i, const coeffs);
674// return nfPar(iParameter, C);
675// }
676//
677// if (_filed_type == n_long_C) // if (nCoeff_is_long_C(C))
678// {
679// number ngcPar(int i, const coeffs r);
680// return ngcPar(iParameter, C);
681// }
682//
683// return NULL;
684}
static number n_Param(const short iParameter, const ring r)
return the specified parameter as a (new!) number in the given polynomial ring, or NULL if invalid pa...
Definition: ring.h:653

◆ p_DebugPrint()

void p_DebugPrint ( poly  p,
const ring  r 
)

Definition at line 4369 of file ring.cc.

4370{
4371 int i,j;
4372 p_Write(p,r);
4373 j=2;
4374 while(p!=NULL)
4375 {
4376 Print("\nexp[0..%d]\n",r->ExpL_Size-1);
4377 for(i=0;i<r->ExpL_Size;i++)
4378 Print("%ld ",p->exp[i]);
4379 PrintLn();
4380 Print("v0:%ld ",p_GetComp(p, r));
4381 for(i=1;i<=r->N;i++) Print(" v%d:%ld",i,p_GetExp(p,i, r));
4382 PrintLn();
4383 pIter(p);
4384 j--;
4385 if (j==0) { PrintS("...\n"); break; }
4386 }
4387}
int i
Definition: cfEzgcd.cc:132
int p
Definition: cfModGcd.cc:4078
#define Print
Definition: emacs.cc:80
int j
Definition: facHensel.cc:110
#define p_GetComp(p, r)
Definition: monomials.h:64
#define pIter(p)
Definition: monomials.h:37
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:342
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 PrintS(const char *s)
Definition: reporter.cc:284
void PrintLn()
Definition: reporter.cc:310

◆ p_SetGlobals()

void p_SetGlobals ( const ring  r,
BOOLEAN  complete = TRUE 
)

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

Definition at line 3457 of file ring.cc.

3458{
3459// // // if (r->ppNoether!=NULL) p_Delete(&r->ppNoether,r); // ???
3460
3461 r->pLexOrder=r->LexOrder;
3462 if (complete)
3463 {
3464 si_opt_1 &= ~ TEST_RINGDEP_OPTS;
3465 si_opt_1 |= r->options;
3466 }
3467}
VAR unsigned si_opt_1
Definition: options.c:5

◆ pISUpdateComponents()

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

Definition at line 4406 of file ring.cc.

4407{
4408 assume( V != NULL );
4409 assume( MIN >= 0 );
4410
4411 if( F == NULL )
4412 return;
4413
4414 for( int j = (F->ncols*F->nrows) - 1; j >= 0; j-- )
4415 {
4416#ifdef PDEBUG
4417 Print("F[%d]:", j);
4418 p_wrp(F->m[j], r);
4419#endif
4420
4421 for( poly p = F->m[j]; p != NULL; pIter(p) )
4422 {
4423 int c = p_GetComp(p, r);
4424
4425 if( c > MIN )
4426 {
4427#ifdef PDEBUG
4428 Print("gen[%d] -> gen(%d)\n", c, MIN + (*V)[ c - MIN - 1 ]);
4429#endif
4430
4431 p_SetComp( p, MIN + (*V)[ c - MIN - 1 ], r );
4432 }
4433 }
4434#ifdef PDEBUG
4435 Print("new F[%d]:", j);
4436 p_Test(F->m[j], r);
4437 p_wrp(F->m[j], r);
4438#endif
4439 }
4440}
#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}
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56

◆ rAssure_C_dp()

ring rAssure_C_dp ( const ring  r)

Definition at line 5065 of file ring.cc.

5066{
5068}
static ring rAssure_Global(rRingOrder_t b1, rRingOrder_t b2, const ring r)
Definition: ring.cc:4884

◆ rAssure_c_dp()

ring rAssure_c_dp ( const ring  r)

Definition at line 5070 of file ring.cc.

5071{
5073}

◆ rAssure_CompLastBlock()

ring rAssure_CompLastBlock ( const ring  r,
BOOLEAN  complete = TRUE 
)

makes sure that c/C ordering is last ordering

Definition at line 4774 of file ring.cc.

4775{
4776 int last_block = rBlocks(r) - 2;
4777 if (r->order[last_block] != ringorder_c &&
4778 r->order[last_block] != ringorder_C)
4779 {
4780 int c_pos = 0;
4781 int i;
4782
4783 for (i=0; i< last_block; i++)
4784 {
4785 if (r->order[i] == ringorder_c || r->order[i] == ringorder_C)
4786 {
4787 c_pos = i;
4788 break;
4789 }
4790 }
4791 if (c_pos != -1)
4792 {
4793 ring new_r = rCopy0(r, FALSE, TRUE);
4794 for (i=c_pos+1; i<=last_block; i++)
4795 {
4796 new_r->order[i-1] = new_r->order[i];
4797 new_r->block0[i-1] = new_r->block0[i];
4798 new_r->block1[i-1] = new_r->block1[i];
4799 new_r->wvhdl[i-1] = new_r->wvhdl[i];
4800 }
4801 new_r->order[last_block] = r->order[c_pos];
4802 new_r->block0[last_block] = r->block0[c_pos];
4803 new_r->block1[last_block] = r->block1[c_pos];
4804 new_r->wvhdl[last_block] = r->wvhdl[c_pos];
4805 if (complete)
4806 {
4807 rComplete(new_r, 1);
4808
4809#ifdef HAVE_PLURAL
4810 if (rIsPluralRing(r))
4811 {
4812 if ( nc_rComplete(r, new_r, false) ) // no qideal!
4813 {
4814#ifndef SING_NDEBUG
4815 WarnS("error in nc_rComplete"); // cleanup?// rDelete(res);// return r; // just go on..
4816#endif
4817 }
4818 }
4819 assume(rIsPluralRing(r) == rIsPluralRing(new_r));
4820#endif
4821 }
4822 return new_r;
4823 }
4824 }
4825 return r;
4826}
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
#define WarnS
Definition: emacs.cc:78
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:3492
BOOLEAN nc_rComplete(const ring src, ring dest, bool bSetupQuotient)
Definition: ring.cc:5786
ring rCopy0(const ring r, BOOLEAN copy_qideal, BOOLEAN copy_ordering)
Definition: ring.cc:1421
static int rBlocks(ring r)
Definition: ring.h:569
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:400

◆ rAssure_dp_C()

ring rAssure_dp_C ( const ring  r)

Definition at line 5060 of file ring.cc.

5061{
5063}

◆ rAssure_dp_S()

ring rAssure_dp_S ( const ring  r)

Definition at line 5055 of file ring.cc.

5056{
5058}

◆ rAssure_HasComp()

ring rAssure_HasComp ( const ring  r)

Definition at line 4705 of file ring.cc.

4706{
4707 int last_block;
4708 int i=0;
4709 do
4710 {
4711 if (r->order[i] == ringorder_c ||
4712 r->order[i] == ringorder_C) return r;
4713 if (r->order[i] == 0)
4714 break;
4715 i++;
4716 } while (1);
4717 //WarnS("re-creating ring with comps");
4718 last_block=i-1;
4719
4720 ring new_r = rCopy0(r, FALSE, FALSE);
4721 i+=2;
4722 new_r->wvhdl=(int **)omAlloc0(i * sizeof(int *));
4723 new_r->order = (rRingOrder_t *) omAlloc0(i * sizeof(rRingOrder_t));
4724 new_r->block0 = (int *) omAlloc0(i * sizeof(int));
4725 new_r->block1 = (int *) omAlloc0(i * sizeof(int));
4726 memcpy(new_r->order,r->order,(i-1) * sizeof(rRingOrder_t));
4727 memcpy(new_r->block0,r->block0,(i-1) * sizeof(int));
4728 memcpy(new_r->block1,r->block1,(i-1) * sizeof(int));
4729 for (int j=0; j<=last_block; j++)
4730 {
4731 if (r->wvhdl[j]!=NULL)
4732 {
4733 #ifdef HAVE_OMALLOC
4734 new_r->wvhdl[j] = (int*) omMemDup(r->wvhdl[j]);
4735 #else
4736 {
4737 int l=r->block1[j]-r->block0[j]+1;
4738 if (r->order[j]==ringorder_a64) l*=2;
4739 else if (r->order[j]==ringorder_M) l=l*l;
4740 else if (r->order[j]==ringorder_am)
4741 {
4742 l+=r->wvhdl[j][r->block1[j]-r->block0[j]+1]+1;
4743 }
4744 new_r->wvhdl[j]=(int*)omalloc(l*sizeof(int));
4745 memcpy(new_r->wvhdl[j],r->wvhdl[j],l*sizeof(int));
4746 }
4747 #endif
4748 }
4749 }
4750 last_block++;
4751 new_r->order[last_block]=ringorder_C;
4752 //new_r->block0[last_block]=0;
4753 //new_r->block1[last_block]=0;
4754 //new_r->wvhdl[last_block]=NULL;
4755
4756 rComplete(new_r, 1);
4757
4758#ifdef HAVE_PLURAL
4759 if (rIsPluralRing(r))
4760 {
4761 if ( nc_rComplete(r, new_r, false) ) // no qideal!
4762 {
4763#ifndef SING_NDEBUG
4764 WarnS("error in nc_rComplete"); // cleanup?// rDelete(res);// return r; // just go on..
4765#endif
4766 }
4767 }
4768 assume(rIsPluralRing(r) == rIsPluralRing(new_r));
4769#endif
4770
4771 return new_r;
4772}
int l
Definition: cfEzgcd.cc:100
#define omalloc(size)
Definition: omAllocDecl.h:228
#define omAlloc0(size)
Definition: omAllocDecl.h:211
#define omMemDup(s)
Definition: omAllocDecl.h:264

◆ rAssure_InducedSchreyerOrdering()

ring rAssure_InducedSchreyerOrdering ( const ring  r,
BOOLEAN  complete = TRUE,
int  sgn = 1 
)

Definition at line 4930 of file ring.cc.

4931{ // TODO: ???? Add leading Syz-comp ordering here...????
4932
4933#if MYTEST
4934 Print("rAssure_InducedSchreyerOrdering(r, complete = %d, sgn = %d): r: \n", complete, sgn);
4935 rWrite(r);
4936#ifdef RDEBUG
4937 rDebugPrint(r);
4938#endif
4939 PrintLn();
4940#endif
4941 assume((sgn == 1) || (sgn == -1));
4942
4943 ring res=rCopy0(r, FALSE, FALSE); // No qideal & ordering copy.
4944
4945 int n = rBlocks(r); // Including trailing zero!
4946
4947 // Create 2 more blocks for prefix/suffix:
4948 res->order=(rRingOrder_t *)omAlloc0((n+2)*sizeof(rRingOrder_t)); // 0 .. n+1
4949 res->block0=(int *)omAlloc0((n+2)*sizeof(int));
4950 res->block1=(int *)omAlloc0((n+2)*sizeof(int));
4951 int ** wvhdl =(int **)omAlloc0((n+2)*sizeof(int**));
4952
4953 // Encapsulate all existing blocks between induced Schreyer ordering markers: prefix and suffix!
4954 // Note that prefix and suffix have the same ringorder marker and only differ in block[] parameters!
4955
4956 // new 1st block
4957 int j = 0;
4958 res->order[j] = ringorder_IS; // Prefix
4959 res->block0[j] = res->block1[j] = 0;
4960 // wvhdl[j] = NULL;
4961 j++;
4962
4963 for(int i = 0; (i <= n) && (r->order[i] != 0); i++, j++) // i = [0 .. n-1] <- non-zero old blocks
4964 {
4965 res->order [j] = r->order [i];
4966 res->block0[j] = r->block0[i];
4967 res->block1[j] = r->block1[i];
4968
4969 if (r->wvhdl[i] != NULL)
4970 {
4971 #ifdef HAVE_OMALLOC
4972 wvhdl[j] = (int*) omMemDup(r->wvhdl[i]);
4973 #else
4974 {
4975 int l=(r->block1[i]-r->block0[i]+1);
4976 if (r->order[i]==ringorder_a64) l*=2;
4977 else if (r->order[i]==ringorder_M) l=l*l;
4978 else if (r->order[i]==ringorder_am)
4979 {
4980 l+=r->wvhdl[i][r->block1[i]-r->block0[i]+1]+1;
4981 }
4982 wvhdl[j]=(int*)omalloc(l*sizeof(int));
4983 memcpy(wvhdl[j],r->wvhdl[i],l*sizeof(int));
4984 }
4985 #endif
4986 } // else wvhdl[j] = NULL;
4987 }
4988
4989 // new last block
4990 res->order [j] = ringorder_IS; // Suffix
4991 res->block0[j] = res->block1[j] = sgn; // Sign of v[o]: 1 for C, -1 for c
4992 // wvhdl[j] = NULL;
4993 j++;
4994
4995 // res->order [j] = 0; // The End!
4996 res->wvhdl = wvhdl;
4997
4998 // j == the last zero block now!
4999 assume(j == (n+1));
5000 assume(res->order[0]==ringorder_IS);
5001 assume(res->order[j-1]==ringorder_IS);
5002 assume(res->order[j]==0);
5003
5004
5005 if (complete)
5006 {
5007 rComplete(res, 1);
5008
5009#ifdef HAVE_PLURAL
5010 if (rIsPluralRing(r))
5011 {
5012 if ( nc_rComplete(r, res, false) ) // no qideal!
5013 {
5014#ifndef SING_NDEBUG
5015 WarnS("error in nc_rComplete"); // cleanup?// rDelete(res);// return r; // just go on..
5016#endif
5017 }
5018 }
5020#endif
5021
5022
5023#ifdef HAVE_PLURAL
5024 ring old_ring = r;
5025#endif
5026
5027 if (r->qideal!=NULL)
5028 {
5029 res->qideal= idrCopyR_NoSort(r->qideal, r, res);
5030
5031 assume(id_RankFreeModule(res->qideal, res) == 0);
5032
5033#ifdef HAVE_PLURAL
5034 if( rIsPluralRing(res) )
5035 if( nc_SetupQuotient(res, r, true) )
5036 {
5037// WarnS("error in nc_SetupQuotient"); // cleanup? rDelete(res); return r; // just go on...?
5038 }
5039
5040#endif
5041 assume(id_RankFreeModule(res->qideal, res) == 0);
5042 }
5043
5044#ifdef HAVE_PLURAL
5045 assume((res->qideal==NULL) == (old_ring->qideal==NULL));
5046 assume(rIsPluralRing(res) == rIsPluralRing(old_ring));
5047 assume(rIsSCA(res) == rIsSCA(old_ring));
5048 assume(ncRingType(res) == ncRingType(old_ring));
5049#endif
5050 }
5051
5052 return res;
5053}
int sgn(const Rational &a)
Definition: GMPrat.cc:430
CanonicalForm res
Definition: facAbsFact.cc:60
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
ideal idrCopyR_NoSort(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:205
void rWrite(ring r, BOOLEAN details)
Definition: ring.cc:226
void rDebugPrint(const ring r)
Definition: ring.cc:4164
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 = TRUE 
)

Definition at line 4515 of file ring.cc.

4516{
4517 if ( r->order[0] == ringorder_s ) return r;
4518
4519 if ( r->order[0] == ringorder_IS )
4520 {
4521#ifndef SING_NDEBUG
4522 WarnS("rAssure_SyzComp: input ring has an IS-ordering!");
4523#endif
4524// return r;
4525 }
4526 ring res=rCopy0(r, FALSE, FALSE);
4527 int i=rBlocks(r);
4528 int j;
4529
4530 res->order=(rRingOrder_t *)omAlloc((i+1)*sizeof(rRingOrder_t));
4531 res->block0=(int *)omAlloc0((i+1)*sizeof(int));
4532 res->block1=(int *)omAlloc0((i+1)*sizeof(int));
4533 int ** wvhdl =(int **)omAlloc0((i+1)*sizeof(int**));
4534 for(j=i;j>0;j--)
4535 {
4536 res->order[j]=r->order[j-1];
4537 res->block0[j]=r->block0[j-1];
4538 res->block1[j]=r->block1[j-1];
4539 if (r->wvhdl[j-1] != NULL)
4540 {
4541 #ifdef HAVE_OMALLOC
4542 wvhdl[j] = (int*) omMemDup(r->wvhdl[j-1]);
4543 #else
4544 {
4545 int l=r->block1[j-1]-r->block0[j-1]+1;
4546 if (r->order[j-1]==ringorder_a64) l*=2;
4547 else if (r->order[j-1]==ringorder_M) l=l*l;
4548 else if (r->order[j-1]==ringorder_am)
4549 {
4550 l+=r->wvhdl[j-1][r->block1[j-1]-r->block0[j-1]+1]+1;
4551 }
4552 wvhdl[j]=(int*)omalloc(l*sizeof(int));
4553 memcpy(wvhdl[j],r->wvhdl[j-1],l*sizeof(int));
4554 }
4555 #endif
4556 }
4557 }
4558 res->order[0]=ringorder_s;
4559
4560 res->wvhdl = wvhdl;
4561
4562 if (complete)
4563 {
4564 rComplete(res, 1);
4565#ifdef HAVE_PLURAL
4566 if (rIsPluralRing(r))
4567 {
4568 if ( nc_rComplete(r, res, false) ) // no qideal!
4569 {
4570#ifndef SING_NDEBUG
4571 WarnS("error in nc_rComplete"); // cleanup?// rDelete(res);// return r; // just go on..
4572#endif
4573 }
4574 }
4576#endif
4577
4578#ifdef HAVE_PLURAL
4579 ring old_ring = r;
4580#endif
4581 if (r->qideal!=NULL)
4582 {
4583 res->qideal= idrCopyR_NoSort(r->qideal, r, res);
4584 assume(id_RankFreeModule(res->qideal, res) == 0);
4585#ifdef HAVE_PLURAL
4586 if( rIsPluralRing(res) )
4587 {
4588 if( nc_SetupQuotient(res, r, true) )
4589 {
4590// WarnS("error in nc_SetupQuotient"); // cleanup? rDelete(res); return r; // just go on...?
4591 }
4592 assume(id_RankFreeModule(res->qideal, res) == 0);
4593 }
4594#endif
4595 }
4596
4597#ifdef HAVE_PLURAL
4598 assume((res->qideal==NULL) == (old_ring->qideal==NULL));
4599 assume(rIsPluralRing(res) == rIsPluralRing(old_ring));
4600 assume(rIsSCA(res) == rIsSCA(old_ring));
4601 assume(ncRingType(res) == ncRingType(old_ring));
4602#endif
4603 }
4604 return res;
4605}
#define omAlloc(size)
Definition: omAllocDecl.h:210

◆ 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 4829 of file ring.cc.

4830{
4831 rTest(r);
4832
4833 ring new_r_1 = rAssure_CompLastBlock(r, FALSE); // due to this FALSE - no completion!
4834 ring new_r = rAssure_SyzComp(new_r_1, FALSE); // new_r_1 is used only here!!!
4835
4836 if (new_r == r)
4837 return r;
4838
4839 ring old_r = r;
4840 if (new_r_1 != new_r && new_r_1 != old_r) rDelete(new_r_1);
4841
4842 rComplete(new_r, TRUE);
4843#ifdef HAVE_PLURAL
4844 if (rIsPluralRing(old_r))
4845 {
4846 if ( nc_rComplete(old_r, new_r, false) ) // no qideal!
4847 {
4848# ifndef SING_NDEBUG
4849 WarnS("error in nc_rComplete"); // cleanup? rDelete(res); return r; // just go on...?
4850# endif
4851 }
4852 }
4853#endif
4854
4855///? rChangeCurrRing(new_r);
4856 if (old_r->qideal != NULL)
4857 {
4858 new_r->qideal = idrCopyR(old_r->qideal, old_r, new_r);
4859 }
4860
4861#ifdef HAVE_PLURAL
4862 if( rIsPluralRing(old_r) )
4863 if( nc_SetupQuotient(new_r, old_r, true) )
4864 {
4865#ifndef SING_NDEBUG
4866 WarnS("error in nc_SetupQuotient"); // cleanup? rDelete(res); return r; // just go on...?
4867#endif
4868 }
4869#endif
4870
4871#ifdef HAVE_PLURAL
4872 assume((new_r->qideal==NULL) == (old_r->qideal==NULL));
4873 assume(rIsPluralRing(new_r) == rIsPluralRing(old_r));
4874 assume(rIsSCA(new_r) == rIsSCA(old_r));
4875 assume(ncRingType(new_r) == ncRingType(old_r));
4876#endif
4877
4878 rTest(new_r);
4879 rTest(old_r);
4880 return new_r;
4881}
ideal idrCopyR(ideal id, ring src_r, ring dest_r)
Definition: prCopy.cc:192
ring rAssure_SyzComp(const ring r, BOOLEAN complete)
Definition: ring.cc:4515
void rDelete(ring r)
unconditionally deletes fields in r
Definition: ring.cc:450
ring rAssure_CompLastBlock(ring r, BOOLEAN complete)
makes sure that c/C ordering is last ordering
Definition: ring.cc:4774
#define rTest(r)
Definition: ring.h:786

◆ rAssure_SyzOrder()

ring rAssure_SyzOrder ( const ring  r,
BOOLEAN  complete 
)

Definition at line 4510 of file ring.cc.

4511{
4512 if ( r->order[0] == ringorder_c ) return r;
4513 return rAssure_SyzComp(r,complete);
4514}

◆ rAssure_TDeg()

ring rAssure_TDeg ( const ring  r,
int &  pos 
)

Definition at line 4607 of file ring.cc.

4608{
4609 if (r->N==1) // special: dp(1)==lp(1)== no entry in typ
4610 {
4611 pos=r->VarL_LowIndex;
4612 return r;
4613 }
4614 if (r->typ!=NULL)
4615 {
4616 for(int i=r->OrdSize-1;i>=0;i--)
4617 {
4618 if ((r->typ[i].ord_typ==ro_dp)
4619 && (r->typ[i].data.dp.start==1)
4620 && (r->typ[i].data.dp.end==r->N))
4621 {
4622 pos=r->typ[i].data.dp.place;
4623 //printf("no change, pos=%d\n",pos);
4624 return r;
4625 }
4626 }
4627 }
4628
4629#ifdef HAVE_PLURAL
4630 nc_struct* save=r->GetNC();
4631 r->GetNC()=NULL;
4632#endif
4633 ring res=rCopy(r);
4634 if (res->qideal!=NULL)
4635 {
4636 id_Delete(&res->qideal,r);
4637 }
4638
4639 int j;
4640
4641 res->ExpL_Size=r->ExpL_Size+1; // one word more in each monom
4642 res->PolyBin=omGetSpecBin(POLYSIZE + (res->ExpL_Size)*sizeof(long));
4643 omFree((ADDRESS)res->ordsgn);
4644 res->ordsgn=(long *)omAlloc0(res->ExpL_Size*sizeof(long));
4645 for(j=0;j<r->CmpL_Size;j++)
4646 {
4647 res->ordsgn[j] = r->ordsgn[j];
4648 }
4649 res->OrdSize=r->OrdSize+1; // one block more for pSetm
4650 if (r->typ!=NULL)
4651 omFree((ADDRESS)res->typ);
4652 res->typ=(sro_ord*)omAlloc0(res->OrdSize*sizeof(sro_ord));
4653 if (r->typ!=NULL)
4654 memcpy(res->typ,r->typ,r->OrdSize*sizeof(sro_ord));
4655 // the additional block for pSetm: total degree at the last word
4656 // but not included in the compare part
4657 res->typ[res->OrdSize-1].ord_typ=ro_dp;
4658 res->typ[res->OrdSize-1].data.dp.start=1;
4659 res->typ[res->OrdSize-1].data.dp.end=res->N;
4660 res->typ[res->OrdSize-1].data.dp.place=res->ExpL_Size-1;
4661 pos=res->ExpL_Size-1;
4662 //res->pOrdIndex=pos; //NO: think of a(1,0),dp !
4663 extern void p_Setm_General(poly p, ring r);
4664 res->p_Setm=p_Setm_General;
4665 // ----------------------------
4666 omFree((ADDRESS)res->p_Procs);
4667 res->p_Procs = (p_Procs_s*)omAlloc(sizeof(p_Procs_s));
4668
4669 p_ProcsSet(res, res->p_Procs);
4670#ifdef HAVE_PLURAL
4671 r->GetNC()=save;
4672 if (rIsPluralRing(r))
4673 {
4674 if ( nc_rComplete(r, res, false) ) // no qideal!
4675 {
4676#ifndef SING_NDEBUG
4677 WarnS("error in nc_rComplete");
4678#endif
4679 // just go on..
4680 }
4681 }
4682#endif
4683 if (r->qideal!=NULL)
4684 {
4685 res->qideal=idrCopyR_NoSort(r->qideal,r, res);
4686#ifdef HAVE_PLURAL
4687 if (rIsPluralRing(res))
4688 {
4689// nc_SetupQuotient(res, currRing);
4690 nc_SetupQuotient(res, r); // ?
4691 }
4692 assume((res->qideal==NULL) == (r->qideal==NULL));
4693#endif
4694 }
4695
4696#ifdef HAVE_PLURAL
4698 assume(rIsSCA(res) == rIsSCA(r));
4700#endif
4701
4702 return res;
4703}
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:158
ring rCopy(ring r)
Definition: ring.cc:1731
struct p_Procs_s p_Procs_s
Definition: ring.h:23
Definition: ring.h:219
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition: nc.h:68

◆ rBlocks()

static int rBlocks ( ring  r)
inlinestatic

Definition at line 569 of file ring.h.

570{
571 assume(r != NULL);
572 int i=0;
573 while (r->order[i]!=0) i++;
574 return i+1;
575}

◆ rCanShortOut()

static BOOLEAN rCanShortOut ( const ring  r)
inlinestatic

Definition at line 587 of file ring.h.

588{
589 assume(r != NULL); return (r->CanShortOut);
590}

◆ rChangeSComps()

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

Definition at line 4485 of file ring.cc.

4486{
4487#ifdef PDEBUG
4488 rDBChangeSComps(currComponents, currShiftedComponents, length, r);
4489#else
4490 rNChangeSComps(currComponents, currShiftedComponents, r);
4491#endif
4492}
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:257
static void rNChangeSComps(int *currComponents, long *currShiftedComponents, ring r)
Definition: ring.cc:4447
static void rDBChangeSComps(int *currComponents, long *currShiftedComponents, int length, ring r)
Definition: ring.cc:4463
EXTERN_VAR long * currShiftedComponents
Definition: syz.h:118

◆ rChar()

int rChar ( ring  r)

Definition at line 713 of file ring.cc.

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

◆ rCharStr()

char * rCharStr ( ring  r)

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

Definition at line 647 of file ring.cc.

647{ 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:959

◆ 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

◆ rComplete()

BOOLEAN rComplete ( ring  r,
int  force = 0 
)

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 3492 of file ring.cc.

3493{
3494 if (r->VarOffset!=NULL && force == 0) return FALSE;
3495 rSetOutParams(r);
3496 int n=rBlocks(r)-1;
3497 int i;
3498 int bits;
3499 r->bitmask=rGetExpSize(r->wanted_maxExp,bits,r->N);
3500 r->BitsPerExp = bits;
3501 r->ExpPerLong = BIT_SIZEOF_LONG / bits;
3502 r->divmask=rGetDivMask(bits);
3503
3504 // will be used for ordsgn:
3505 long *tmp_ordsgn=(long *)omAlloc0(3*(n+r->N)*sizeof(long));
3506 // will be used for VarOffset:
3507 int *v=(int *)omAlloc((r->N+1)*sizeof(int));
3508 for(i=r->N; i>=0 ; i--)
3509 {
3510 v[i]=-1;
3511 }
3512 sro_ord *tmp_typ=(sro_ord *)omAlloc0(3*(n+r->N)*sizeof(sro_ord));
3513 int typ_i=0;
3514 int prev_ordsgn=0;
3515
3516 // fill in v, tmp_typ, tmp_ordsgn, determine typ_i (== ordSize)
3517 int j=0;
3518 int j_bits=BITS_PER_LONG;
3519
3520 BOOLEAN need_to_add_comp=FALSE; // Only for ringorder_s and ringorder_S!
3521
3522 for(i=0;i<n;i++)
3523 {
3524 tmp_typ[typ_i].order_index=i;
3525 switch (r->order[i])
3526 {
3527 case ringorder_a:
3528 case ringorder_aa:
3529 rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],
3530 r->wvhdl[i]);
3531 typ_i++;
3532 break;
3533
3534 case ringorder_am:
3535 rO_WMDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,tmp_typ[typ_i],
3536 r->wvhdl[i]);
3537 typ_i++;
3538 break;
3539
3540 case ringorder_a64:
3541 rO_WDegree64(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3542 tmp_typ[typ_i], (int64 *)(r->wvhdl[i]));
3543 typ_i++;
3544 break;
3545
3546 case ringorder_c:
3547 rO_Align(j, j_bits);
3548 rO_LexVars_neg(j, j_bits, 0,0, prev_ordsgn,tmp_ordsgn,v,BITS_PER_LONG, -1);
3549 r->ComponentOrder=1;
3550 break;
3551
3552 case ringorder_C:
3553 rO_Align(j, j_bits);
3554 rO_LexVars(j, j_bits, 0,0, prev_ordsgn,tmp_ordsgn,v,BITS_PER_LONG, -1);
3555 r->ComponentOrder=-1;
3556 break;
3557
3558 case ringorder_M:
3559 {
3560 int k,l;
3561 k=r->block1[i]-r->block0[i]+1; // number of vars
3562 for(l=0;l<k;l++)
3563 {
3564 rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3565 tmp_typ[typ_i],
3566 r->wvhdl[i]+(r->block1[i]-r->block0[i]+1)*l);
3567 typ_i++;
3568 }
3569 break;
3570 }
3571
3572 case ringorder_lp:
3573 rO_LexVars(j, j_bits, r->block0[i],r->block1[i], prev_ordsgn,
3574 tmp_ordsgn,v,bits, -1);
3575 break;
3576
3577 case ringorder_ls:
3578 rO_LexVars_neg(j, j_bits, r->block0[i],r->block1[i], prev_ordsgn,
3579 tmp_ordsgn,v, bits, -1);
3580 break;
3581
3582 case ringorder_rs:
3583 rO_LexVars_neg(j, j_bits, r->block1[i],r->block0[i], prev_ordsgn,
3584 tmp_ordsgn,v, bits, -1);
3585 break;
3586
3587 case ringorder_rp:
3588 rO_LexVars(j, j_bits, r->block1[i],r->block0[i], prev_ordsgn,
3589 tmp_ordsgn,v, bits, -1);
3590 break;
3591
3592 case ringorder_dp:
3593 if (r->block0[i]==r->block1[i])
3594 {
3595 rO_LexVars(j, j_bits, r->block0[i],r->block0[i], prev_ordsgn,
3596 tmp_ordsgn,v, bits, -1);
3597 }
3598 else
3599 {
3600 rO_TDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3601 tmp_typ[typ_i]);
3602 typ_i++;
3603 rO_LexVars_neg(j, j_bits, r->block1[i],r->block0[i]+1,
3604 prev_ordsgn,tmp_ordsgn,v,bits, r->block0[i]);
3605 }
3606 break;
3607
3608 case ringorder_Dp:
3609 if (r->block0[i]==r->block1[i])
3610 {
3611 rO_LexVars(j, j_bits, r->block0[i],r->block0[i], prev_ordsgn,
3612 tmp_ordsgn,v, bits, -1);
3613 }
3614 else
3615 {
3616 rO_TDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3617 tmp_typ[typ_i]);
3618 typ_i++;
3619 rO_LexVars(j, j_bits, r->block0[i],r->block1[i]-1, prev_ordsgn,
3620 tmp_ordsgn,v, bits, r->block1[i]);
3621 }
3622 break;
3623
3624 case ringorder_ds:
3625 if (r->block0[i]==r->block1[i])
3626 {
3627 rO_LexVars_neg(j, j_bits,r->block0[i],r->block1[i],prev_ordsgn,
3628 tmp_ordsgn,v,bits, -1);
3629 }
3630 else
3631 {
3632 rO_TDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3633 tmp_typ[typ_i]);
3634 typ_i++;
3635 rO_LexVars_neg(j, j_bits, r->block1[i],r->block0[i]+1,
3636 prev_ordsgn,tmp_ordsgn,v,bits, r->block0[i]);
3637 }
3638 break;
3639
3640 case ringorder_Ds:
3641 if (r->block0[i]==r->block1[i])
3642 {
3643 rO_LexVars_neg(j, j_bits, r->block0[i],r->block0[i],prev_ordsgn,
3644 tmp_ordsgn,v, bits, -1);
3645 }
3646 else
3647 {
3648 rO_TDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3649 tmp_typ[typ_i]);
3650 typ_i++;
3651 rO_LexVars(j, j_bits, r->block0[i],r->block1[i]-1, prev_ordsgn,
3652 tmp_ordsgn,v, bits, r->block1[i]);
3653 }
3654 break;
3655
3656 case ringorder_wp:
3657 rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3658 tmp_typ[typ_i], r->wvhdl[i]);
3659 typ_i++;
3660 { // check for weights <=0
3661 int jj;
3662 BOOLEAN have_bad_weights=FALSE;
3663 for(jj=r->block1[i]-r->block0[i];jj>=0; jj--)
3664 {
3665 if (r->wvhdl[i][jj]<=0) have_bad_weights=TRUE;
3666 }
3667 if (have_bad_weights)
3668 {
3669 rO_TDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3670 tmp_typ[typ_i]);
3671 typ_i++;
3672 }
3673 }
3674 if (r->block1[i]!=r->block0[i])
3675 {
3676 rO_LexVars_neg(j, j_bits,r->block1[i],r->block0[i]+1, prev_ordsgn,
3677 tmp_ordsgn, v,bits, r->block0[i]);
3678 }
3679 break;
3680
3681 case ringorder_Wp:
3682 rO_WDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3683 tmp_typ[typ_i], r->wvhdl[i]);
3684 typ_i++;
3685 { // check for weights <=0
3686 int jj;
3687 BOOLEAN have_bad_weights=FALSE;
3688 for(jj=r->block1[i]-r->block0[i];jj>=0; jj--)
3689 {
3690 if (r->wvhdl[i][jj]<=0) have_bad_weights=TRUE;
3691 }
3692 if (have_bad_weights)
3693 {
3694 rO_TDegree(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3695 tmp_typ[typ_i]);
3696 typ_i++;
3697 }
3698 }
3699 if (r->block1[i]!=r->block0[i])
3700 {
3701 rO_LexVars(j, j_bits,r->block0[i],r->block1[i]-1, prev_ordsgn,
3702 tmp_ordsgn,v, bits, r->block1[i]);
3703 }
3704 break;
3705
3706 case ringorder_ws:
3707 rO_WDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3708 tmp_typ[typ_i], r->wvhdl[i]);
3709 typ_i++;
3710 if (r->block1[i]!=r->block0[i])
3711 {
3712 rO_LexVars_neg(j, j_bits,r->block1[i],r->block0[i]+1, prev_ordsgn,
3713 tmp_ordsgn, v,bits, r->block0[i]);
3714 }
3715 break;
3716
3717 case ringorder_Ws:
3718 rO_WDegree_neg(j,j_bits,r->block0[i],r->block1[i],tmp_ordsgn,
3719 tmp_typ[typ_i], r->wvhdl[i]);
3720 typ_i++;
3721 if (r->block1[i]!=r->block0[i])
3722 {
3723 rO_LexVars(j, j_bits,r->block0[i],r->block1[i]-1, prev_ordsgn,
3724 tmp_ordsgn,v, bits, r->block1[i]);
3725 }
3726 break;
3727
3728 case ringorder_S:
3729 assume(typ_i == 1); // For LaScala3 only: on the 2nd place ([1])!
3730 // TODO: for K[x]: it is 0...?!
3731 rO_Syzcomp(j, j_bits,prev_ordsgn, tmp_ordsgn,tmp_typ[typ_i]);
3732 need_to_add_comp=TRUE;
3733 r->ComponentOrder=-1;
3734 typ_i++;
3735 break;
3736
3737 case ringorder_s:
3738 assume(typ_i == 0 && j == 0);
3739 rO_Syz(j, j_bits, prev_ordsgn, r->block0[i], tmp_ordsgn, tmp_typ[typ_i]); // set syz-limit?
3740 need_to_add_comp=TRUE;
3741 r->ComponentOrder=-1;
3742 typ_i++;
3743 break;
3744
3745 case ringorder_IS:
3746 {
3747
3748 assume( r->block0[i] == r->block1[i] );
3749 const int s = r->block0[i];
3750 assume( -2 < s && s < 2);
3751
3752 if(s == 0) // Prefix IS
3753 rO_ISPrefix(j, j_bits, prev_ordsgn, tmp_ordsgn, r->N, v, tmp_typ[typ_i++]); // What about prev_ordsgn?
3754 else // s = +1 or -1 // Note: typ_i might be incrimented here inside!
3755 {
3756 rO_ISSuffix(j, j_bits, prev_ordsgn, tmp_ordsgn, r->N, v, tmp_typ, typ_i, s); // Suffix.
3757 need_to_add_comp=FALSE;
3758 }
3759
3760 break;
3761 }
3762 case ringorder_unspec:
3763 case ringorder_no:
3764 default:
3765 dReportError("undef. ringorder used\n");
3766 break;
3767 }
3768 }
3769 rCheckOrdSgn(r,n-1);
3770
3771 int j0=j; // save j
3772 int j_bits0=j_bits; // save jbits
3773 rO_Align(j,j_bits);
3774 r->CmpL_Size = j;
3775
3776 j_bits=j_bits0; j=j0;
3777
3778 // fill in some empty slots with variables not already covered
3779 // v0 is special, is therefore normally already covered
3780 // now we do have rings without comp...
3781 if((need_to_add_comp) && (v[0]== -1))
3782 {
3783 if (prev_ordsgn==1)
3784 {
3785 rO_Align(j, j_bits);
3786 rO_LexVars(j, j_bits, 0,0, prev_ordsgn,tmp_ordsgn,v,BITS_PER_LONG, -1);
3787 }
3788 else
3789 {
3790 rO_Align(j, j_bits);
3791 rO_LexVars_neg(j, j_bits, 0,0, prev_ordsgn,tmp_ordsgn,v,BITS_PER_LONG, -1);
3792 }
3793 }
3794 // the variables
3795 for(i=1 ; i<=r->N ; i++)
3796 {
3797 if(v[i]==(-1))
3798 {
3799 if (prev_ordsgn==1)
3800 {
3801 rO_LexVars(j, j_bits, i,i, prev_ordsgn,tmp_ordsgn,v,bits, -1);
3802 }
3803 else
3804 {
3805 rO_LexVars_neg(j,j_bits,i,i, prev_ordsgn,tmp_ordsgn,v,bits, -1);
3806 }
3807 }
3808 }
3809
3810 rO_Align(j,j_bits);
3811 // ----------------------------
3812 // finished with constructing the monomial, computing sizes:
3813
3814 r->ExpL_Size=j;
3815 r->PolyBin = omGetSpecBin(POLYSIZE + (r->ExpL_Size)*sizeof(long));
3816 assume(r->PolyBin != NULL);
3817
3818 // ----------------------------
3819 // indices and ordsgn vector for comparison
3820 //
3821 // r->pCompHighIndex already set
3822 r->ordsgn=(long *)omAlloc0(r->ExpL_Size*sizeof(long));
3823
3824 for(j=0;j<r->CmpL_Size;j++)
3825 {
3826 r->ordsgn[j] = tmp_ordsgn[j];
3827 }
3828
3829 omFreeSize((ADDRESS)tmp_ordsgn,(3*(n+r->N)*sizeof(long)));
3830
3831 // ----------------------------
3832 // description of orderings for setm:
3833 //
3834 r->OrdSize=typ_i;
3835 if (typ_i==0) r->typ=NULL;
3836 else
3837 {
3838 r->typ=(sro_ord*)omAlloc(typ_i*sizeof(sro_ord));
3839 memcpy(r->typ,tmp_typ,typ_i*sizeof(sro_ord));
3840 }
3841 omFreeSize((ADDRESS)tmp_typ,(3*(n+r->N)*sizeof(sro_ord)));
3842
3843 // ----------------------------
3844 // indices for (first copy of ) variable entries in exp.e vector (VarOffset):
3845 r->VarOffset=v;
3846
3847 // ----------------------------
3848 // other indicies
3849 r->pCompIndex=(r->VarOffset[0] & 0xffff); //r->VarOffset[0];
3850 i=0; // position
3851 j=0; // index in r->typ
3852 if (i==r->pCompIndex) i++; // IS???
3853 while ((j < r->OrdSize)
3854 && ((r->typ[j].ord_typ==ro_syzcomp) ||
3855 (r->typ[j].ord_typ==ro_syz) || (r->typ[j].ord_typ==ro_isTemp) || (r->typ[j].ord_typ==ro_is) ||
3856 (r->order[r->typ[j].order_index] == ringorder_aa)))
3857 {
3858 i++; j++;
3859 }
3860
3861 if (i==r->pCompIndex) i++;
3862 r->pOrdIndex=i;
3863
3864 // ----------------------------
3865 rSetDegStuff(r); // OrdSgn etc already set
3866 rSetOption(r);
3867 // ----------------------------
3868 // r->p_Setm
3869 r->p_Setm = p_GetSetmProc(r);
3870
3871 // ----------------------------
3872 // set VarL_*
3873 rSetVarL(r);
3874
3875 // ----------------------------
3876 // right-adjust VarOffset
3878
3879 // ----------------------------
3880 // set NegWeightL*
3881 rSetNegWeight(r);
3882
3883 // ----------------------------
3884 // p_Procs: call AFTER NegWeightL
3885 r->p_Procs = (p_Procs_s*)omAlloc(sizeof(p_Procs_s));
3886 p_ProcsSet(r, r->p_Procs);
3887
3888 // use totaldegree on crazy oderings:
3889 if ((r->pFDeg==p_WTotaldegree) && rOrd_is_MixedDegree_Ordering(r))
3890 r->pFDeg = p_Totaldegree;
3891 return FALSE;
3892}
long int64
Definition: auxiliary.h:68
#define BIT_SIZEOF_LONG
Definition: auxiliary.h:80
int BOOLEAN
Definition: auxiliary.h:87
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:613
p_SetmProc p_GetSetmProc(const ring r)
Definition: p_polys.cc:560
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1507
static void rSetNegWeight(ring r)
Definition: ring.cc:3389
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:2516
static void rSetOption(ring r)
Definition: ring.cc:3426
#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:2326
static void rSetVarL(ring r)
set r->VarL_Size, r->VarL_Offset, r->VarL_LowIndex
Definition: ring.cc:4069
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:2376
BOOLEAN rOrd_is_MixedDegree_Ordering(ring r)
Definition: ring.cc:3470
static void rSetOutParams(ring r)
Definition: ring.cc:3122
static void rSetDegStuff(ring r)
Definition: ring.cc:3219
static void rO_WDegree_neg(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct, int *weights)
Definition: ring.cc:2350
static void rO_Syzcomp(int &place, int &bitplace, int &prev_ord, long *o, sro_ord &ord_struct)
Definition: ring.cc:2452
static void rO_TDegree(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct)
Definition: ring.cc:2236
static void rO_WMDegree(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct, int *weights)
Definition: ring.cc:2304
static void rO_Syz(int &place, int &bitplace, int &prev_ord, int syz_comp, long *o, sro_ord &ord_struct)
Definition: ring.cc:2467
static unsigned long rGetExpSize(unsigned long bitmask, int &bits)
Definition: ring.cc:2607
static void rCheckOrdSgn(ring r, int i)
Definition: ring.cc:3894
static unsigned long rGetDivMask(int bits)
get r->divmask depending on bits per exponent
Definition: ring.cc:4150
static void rRightAdjustVarOffset(ring r)
right-adjust r->VarOffset
Definition: ring.cc:4124
static void rO_ISPrefix(int &place, int &bitplace, int &prev_ord, long *o, int N, int *v, sro_ord &ord_struct)
Definition: ring.cc:2493
static void rO_Align(int &place, int &bitplace)
Definition: ring.cc:2225
static void rO_TDegree_neg(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct)
Definition: ring.cc:2250
static void rO_WDegree(int &place, int &bitplace, int start, int end, long *o, sro_ord &ord_struct, int *weights)
Definition: ring.cc:2264
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:2413
int order_index
Definition: ring.h:221

◆ rCopy()

ring rCopy ( ring  r)

Definition at line 1731 of file ring.cc.

1732{
1733 if (r == NULL) return NULL;
1734 ring res=rCopy0(r,FALSE,TRUE);
1735 rComplete(res, 1); // res is purely commutative so far
1736 if (r->qideal!=NULL) res->qideal=idrCopyR_NoSort(r->qideal, r, res);
1737
1738#ifdef HAVE_PLURAL
1739 if (rIsPluralRing(r))
1740 if( nc_rCopy(res, r, true) ) {}
1741#endif
1742
1743 return res;
1744}
bool nc_rCopy(ring res, const ring r, bool bSetupQuotient)
Definition: old.gring.cc:3003

◆ rCopy0()

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

Definition at line 1421 of file ring.cc.

1422{
1423 if (r == NULL) return NULL;
1424 int i,j;
1425 ring res=(ring)omAlloc0Bin(sip_sring_bin);
1426 //memset: res->idroot=NULL; /* local objects */
1427 //ideal minideal;
1428 res->options=r->options; /* ring dependent options */
1429
1430 //memset: res->ordsgn=NULL;
1431 //memset: res->typ=NULL;
1432 //memset: res->VarOffset=NULL;
1433 //memset: res->firstwv=NULL;
1434
1435 //struct omBin PolyBin; /* Bin from where monoms are allocated */
1436 //memset: res->PolyBin=NULL; // rComplete
1437 res->cf=nCopyCoeff(r->cf); /* coeffs */
1438
1439 //memset: res->ref=0; /* reference counter to the ring */
1440
1441 res->N=rVar(r); /* number of vars */
1442
1443 res->firstBlockEnds=r->firstBlockEnds;
1444#ifdef HAVE_PLURAL
1445 res->real_var_start=r->real_var_start;
1446 res->real_var_end=r->real_var_end;
1447#endif
1448
1449#ifdef HAVE_SHIFTBBA
1450 res->isLPring=r->isLPring; /* 0 for non-letterplace rings, otherwise the number of LP blocks, at least 1, known also as lV */
1451 res->LPncGenCount=r->LPncGenCount;
1452#endif
1453
1454 res->VectorOut=r->VectorOut;
1455 res->ShortOut=r->ShortOut;
1456 res->CanShortOut=r->CanShortOut;
1457
1458 //memset: res->ExpL_Size=0;
1459 //memset: res->CmpL_Size=0;
1460 //memset: res->VarL_Size=0;
1461 //memset: res->pCompIndex=0;
1462 //memset: res->pOrdIndex=0;
1463 //memset: res->OrdSize=0;
1464 //memset: res->VarL_LowIndex=0;
1465 //memset: res->NegWeightL_Size=0;
1466 //memset: res->NegWeightL_Offset=NULL;
1467 //memset: res->VarL_Offset=NULL;
1468
1469 // the following are set by rComplete unless predefined
1470 // therefore, we copy these values: maybe they are non-standard
1471 /* mask for getting single exponents */
1472 res->bitmask=r->bitmask;
1473 res->divmask=r->divmask;
1474 res->BitsPerExp = r->BitsPerExp;
1475 res->ExpPerLong = r->ExpPerLong;
1476
1477 //memset: res->p_Procs=NULL;
1478 //memset: res->pFDeg=NULL;
1479 //memset: res->pLDeg=NULL;
1480 //memset: res->pFDegOrig=NULL;
1481 //memset: res->pLDegOrig=NULL;
1482 //memset: res->p_Setm=NULL;
1483 //memset: res->cf=NULL;
1484
1485/*
1486 if (r->extRing!=NULL)
1487 r->extRing->ref++;
1488
1489 res->extRing=r->extRing;
1490 //memset: res->qideal=NULL;
1491*/
1492
1493
1494 if (copy_ordering == TRUE)
1495 {
1496 res->LexOrder=r->LexOrder; // TRUE if the monomial ordering has polynomial and power series blocks
1497 res->MixedOrder=r->MixedOrder; // TRUE for mixed (global/local) ordering, FALSE otherwise,
1498 i=rBlocks(r);
1499 res->wvhdl = (int **)omAlloc(i * sizeof(int *));
1500 res->order = (rRingOrder_t *) omAlloc(i * sizeof(rRingOrder_t));
1501 res->block0 = (int *) omAlloc(i * sizeof(int));
1502 res->block1 = (int *) omAlloc(i * sizeof(int));
1503 for (j=0; j<i; j++)
1504 {
1505 if (r->wvhdl[j]!=NULL)
1506 {
1507 #ifdef HAVE_OMALLOC
1508 res->wvhdl[j] = (int*) omMemDup(r->wvhdl[j]);
1509 #else
1510 {
1511 int l=r->block1[j]-r->block0[j]+1;
1512 if (r->order[j]==ringorder_a64) l*=2;
1513 else if (r->order[j]==ringorder_M) l=l*l;
1514 else if (r->order[j]==ringorder_am)
1515 {
1516 l+=r->wvhdl[j][r->block1[j]-r->block0[j]+1]+1;
1517 }
1518 res->wvhdl[j]=(int*)omalloc(l*sizeof(int));
1519 memcpy(res->wvhdl[j],r->wvhdl[j],l*sizeof(int));
1520 }
1521 #endif
1522 }
1523 else
1524 res->wvhdl[j]=NULL;
1525 }
1526 memcpy(res->order,r->order,i * sizeof(rRingOrder_t));
1527 memcpy(res->block0,r->block0,i * sizeof(int));
1528 memcpy(res->block1,r->block1,i * sizeof(int));
1529 }
1530 //memset: else
1531 //memset: {
1532 //memset: res->wvhdl = NULL;
1533 //memset: res->order = NULL;
1534 //memset: res->block0 = NULL;
1535 //memset: res->block1 = NULL;
1536 //memset: }
1537
1538 res->names = (char **)omAlloc0(rVar(r) * sizeof(char *));
1539 for (i=0; i<rVar(res); i++)
1540 {
1541 res->names[i] = omStrDup(r->names[i]);
1542 }
1543 if (r->qideal!=NULL)
1544 {
1545 if (copy_qideal)
1546 {
1547 assume(copy_ordering);
1548 rComplete(res);
1549 res->qideal= idrCopyR_NoSort(r->qideal, r, res);
1551 }
1552 //memset: else res->qideal = NULL;
1553 }
1554 //memset: else res->qideal = NULL;
1555 //memset: res->GetNC() = NULL; // copy is purely commutative!!!
1556 return res;
1557}
static FORCE_INLINE coeffs nCopyCoeff(const coeffs r)
"copy" coeffs, i.e. increment ref
Definition: coeffs.h:429
#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:4007
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:593

◆ rCopy0AndAddA()

ring rCopy0AndAddA ( ring  r,
int64vec wv64,
BOOLEAN  copy_qideal = TRUE,
BOOLEAN  copy_ordering = TRUE 
)

Definition at line 1564 of file ring.cc.

1565{
1566 if (r == NULL) return NULL;
1567 int i,j;
1568 ring res=(ring)omAlloc0Bin(sip_sring_bin);
1569 //memcpy(res,r,sizeof(ip_sring));
1570 //memset: res->idroot=NULL; /* local objects */
1571 //ideal minideal;
1572 res->options=r->options; /* ring dependent options */
1573
1574 //memset: res->ordsgn=NULL;
1575 //memset: res->typ=NULL;
1576 //memset: res->VarOffset=NULL;
1577 //memset: res->firstwv=NULL;
1578
1579 //struct omBin PolyBin; /* Bin from where monoms are allocated */
1580 //memset: res->PolyBin=NULL; // rComplete
1581 res->cf=nCopyCoeff(r->cf); /* coeffs */
1582
1583 //memset: res->ref=0; /* reference counter to the ring */
1584
1585 res->N=rVar(r); /* number of vars */
1586
1587 res->firstBlockEnds=r->firstBlockEnds;
1588#ifdef HAVE_PLURAL
1589 res->real_var_start=r->real_var_start;
1590 res->real_var_end=r->real_var_end;
1591#endif
1592
1593#ifdef HAVE_SHIFTBBA
1594 res->isLPring=r->isLPring; /* 0 for non-letterplace rings, otherwise the number of LP blocks, at least 1, known also as lV */
1595 res->LPncGenCount=r->LPncGenCount;
1596#endif
1597
1598 res->VectorOut=r->VectorOut;
1599 res->ShortOut=r->ShortOut;
1600 res->CanShortOut=r->CanShortOut;
1601 res->LexOrder=r->LexOrder; // TRUE if the monomial ordering has polynomial and power series blocks
1602 res->MixedOrder=r->MixedOrder; // TRUE for mixed (global/local) ordering, FALSE otherwise,
1603
1604 //memset: res->ExpL_Size=0;
1605 //memset: res->CmpL_Size=0;
1606 //memset: res->VarL_Size=0;
1607 //memset: res->pCompIndex=0;
1608 //memset: res->pOrdIndex=0;
1609 //memset: res->OrdSize=0;
1610 //memset: res->VarL_LowIndex=0;
1611 //memset: res->NegWeightL_Size=0;
1612 //memset: res->NegWeightL_Offset=NULL;
1613 //memset: res->VarL_Offset=NULL;
1614
1615 // the following are set by rComplete unless predefined
1616 // therefore, we copy these values: maybe they are non-standard
1617 /* mask for getting single exponents */
1618 res->bitmask=r->bitmask;
1619 res->divmask=r->divmask;
1620 res->BitsPerExp = r->BitsPerExp;
1621 res->ExpPerLong = r->ExpPerLong;
1622
1623 //memset: res->p_Procs=NULL;
1624 //memset: res->pFDeg=NULL;
1625 //memset: res->pLDeg=NULL;
1626 //memset: res->pFDegOrig=NULL;
1627 //memset: res->pLDegOrig=NULL;
1628 //memset: res->p_Setm=NULL;
1629 //memset: res->cf=NULL;
1630
1631/*
1632 if (r->extRing!=NULL)
1633 r->extRing->ref++;
1634
1635 res->extRing=r->extRing;
1636 //memset: res->qideal=NULL;
1637*/
1638
1639
1640 if (copy_ordering == TRUE)
1641 {
1642 i=rBlocks(r)+1; // DIFF to rCopy0
1643 res->wvhdl = (int **)omAlloc(i * sizeof(int *));
1644 res->order = (rRingOrder_t *) omAlloc(i * sizeof(rRingOrder_t));
1645 res->block0 = (int *) omAlloc(i * sizeof(int));
1646 res->block1 = (int *) omAlloc(i * sizeof(int));
1647 for (j=0; j<i-1; j++)
1648 {
1649 if (r->wvhdl[j]!=NULL)
1650 {
1651 #ifdef HAVE_OMALLOC
1652 res->wvhdl[j+1] = (int*) omMemDup(r->wvhdl[j]); //DIFF
1653 #else
1654 {
1655 int l=r->block1[j]-r->block0[j]+1;
1656 if (r->order[j]==ringorder_a64) l*=2;
1657 else if (r->order[j]==ringorder_M) l=l*l;
1658 else if (r->order[j]==ringorder_am)
1659 {
1660 l+=r->wvhdl[j][r->block1[j]-r->block0[j]+1]+1;
1661 }
1662 res->wvhdl[j+1]=(int*)omalloc(l*sizeof(int));
1663 memcpy(res->wvhdl[j+1],r->wvhdl[j],l*sizeof(int));
1664 }
1665 #endif
1666 }
1667 else
1668 res->wvhdl[j+1]=NULL; //DIFF
1669 }
1670 memcpy(&(res->order[1]),r->order,(i-1) * sizeof(rRingOrder_t)); //DIFF
1671 memcpy(&(res->block0[1]),r->block0,(i-1) * sizeof(int)); //DIFF
1672 memcpy(&(res->block1[1]),r->block1,(i-1) * sizeof(int)); //DIFF
1673 }
1674 //memset: else
1675 //memset: {
1676 //memset: res->wvhdl = NULL;
1677 //memset: res->order = NULL;
1678 //memset: res->block0 = NULL;
1679 //memset: res->block1 = NULL;
1680 //memset: }
1681
1682 //the added A
1683 res->order[0]=ringorder_a64;
1684 int length=wv64->rows();
1685 int64 *A=(int64 *)omAlloc(length*sizeof(int64));
1686 for(j=length-1;j>=0;j--)
1687 {
1688 A[j]=(*wv64)[j];
1689 }
1690 res->wvhdl[0]=(int *)A;
1691 res->block0[0]=1;
1692 res->block1[0]=length;
1693 //
1694
1695 res->names = (char **)omAlloc0(rVar(r) * sizeof(char *));
1696 for (i=0; i<rVar(res); i++)
1697 {
1698 res->names[i] = omStrDup(r->names[i]);
1699 }
1700 if (r->qideal!=NULL)
1701 {
1702 if (copy_qideal)
1703 {
1704 #ifndef SING_NDEBUG
1705 if (!copy_ordering)
1706 WerrorS("internal error: rCopy0(Q,TRUE,FALSE)");
1707 else
1708 #endif
1709 {
1710 #ifndef SING_NDEBUG
1711 WarnS("internal bad stuff: rCopy0(Q,TRUE,TRUE)");
1712 #endif
1713 rComplete(res);
1714 res->qideal= idrCopyR_NoSort(r->qideal, r, res);
1716 }
1717 }
1718 //memset: else res->qideal = NULL;
1719 }
1720 //memset: else res->qideal = NULL;
1721 //memset: res->GetNC() = NULL; // copy is purely commutative!!!
1722 return res;
1723}
int rows() const
Definition: int64vec.h:66
#define A
Definition: sirandom.c:24

◆ rDBTest()

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

Definition at line 2075 of file ring.cc.

2076{
2077 int i,j;
2078
2079 if (r == NULL)
2080 {
2081 dReportError("Null ring in %s:%d", fn, l);
2082 return FALSE;
2083 }
2084
2085
2086 if (r->N == 0) return TRUE;
2087
2088 if ((r->OrdSgn!=1) && (r->OrdSgn!= -1))
2089 {
2090 dReportError("missing OrdSgn in %s:%d", fn, l);
2091 return FALSE;
2092 }
2093
2094// omCheckAddrSize(r,sizeof(ip_sring));
2095#if OM_CHECK > 0
2096 i=rBlocks(r);
2097 omCheckAddrSize(r->order,i*sizeof(int));
2098 omCheckAddrSize(r->block0,i*sizeof(int));
2099 omCheckAddrSize(r->block1,i*sizeof(int));
2100 for(int j=0;j<=i;j++)
2101 {
2102 if((r->order[j]<0)||(r->order[j]>ringorder_unspec))
2103 dError("wrong order in r->order");
2104 }
2105 if (r->wvhdl!=NULL)
2106 {
2107 omCheckAddrSize(r->wvhdl,i*sizeof(int *));
2108 for (j=0;j<i; j++)
2109 {
2110 if (r->wvhdl[j] != NULL) omCheckAddr(r->wvhdl[j]);
2111 }
2112 }
2113#endif
2114 if (r->VarOffset == NULL)
2115 {
2116 dReportError("Null ring VarOffset -- no rComplete (?) in n %s:%d", fn, l);
2117 return FALSE;
2118 }
2119 omCheckAddrSize(r->VarOffset,(r->N+1)*sizeof(int));
2120
2121 if ((r->OrdSize==0)!=(r->typ==NULL))
2122 {
2123 dReportError("mismatch OrdSize and typ-pointer in %s:%d");
2124 return FALSE;
2125 }
2126 omcheckAddrSize(r->typ,r->OrdSize*sizeof(*(r->typ)));
2127 omCheckAddrSize(r->VarOffset,(r->N+1)*sizeof(*(r->VarOffset)));
2128 // test assumptions:
2129 for(i=0;i<=r->N;i++) // for all variables (i = 0..N)
2130 {
2131 if(r->typ!=NULL)
2132 {
2133 for(j=0;j<r->OrdSize;j++) // for all ordering blocks (j =0..OrdSize-1)
2134 {
2135 if(r->typ[j].ord_typ == ro_isTemp)
2136 {
2137 const int p = r->typ[j].data.isTemp.suffixpos;
2138
2139 if(p <= j)
2140 dReportError("ordrec prefix %d is unmatched",j);
2141
2142 assume( p < r->OrdSize );
2143
2144 if(r->typ[p].ord_typ != ro_is)
2145 dReportError("ordrec prefix %d is unmatched (suffix: %d is wrong!!!)",j, p);
2146
2147 // Skip all intermediate blocks for undone variables:
2148 if(r->typ[j].data.isTemp.pVarOffset[i] != -1) // Check i^th variable
2149 {
2150 j = p - 1; // SKIP ALL INTERNAL BLOCKS...???
2151 continue; // To make for check OrdSize bound...
2152 }
2153 }
2154 else if (r->typ[j].ord_typ == ro_is)
2155 {
2156 // Skip all intermediate blocks for undone variables:
2157 if(r->typ[j].data.is.pVarOffset[i] != -1)
2158 {
2159 // TODO???
2160 }
2161
2162 }
2163 else
2164 {
2165 if (r->typ[j].ord_typ==ro_cp)
2166 {
2167 if(((short)r->VarOffset[i]) == r->typ[j].data.cp.place)
2168 dReportError("ordrec %d conflicts with var %d",j,i);
2169 }
2170 else
2171 if ((r->typ[j].ord_typ!=ro_syzcomp)
2172 && (r->VarOffset[i] == r->typ[j].data.dp.place))
2173 dReportError("ordrec %d conflicts with var %d",j,i);
2174 }
2175 }
2176 }
2177 int tmp;
2178 tmp=r->VarOffset[i] & 0xffffff;
2179 #if SIZEOF_LONG == 8
2180 if ((r->VarOffset[i] >> 24) >63)
2181 #else
2182 if ((r->VarOffset[i] >> 24) >31)
2183 #endif
2184 dReportError("bit_start out of range:%d",r->VarOffset[i] >> 24);
2185 if (i > 0 && ((tmp<0) ||(tmp>r->ExpL_Size-1)))
2186 {
2187 dReportError("varoffset out of range for var %d: %d",i,tmp);
2188 }
2189 }
2190 if(r->typ!=NULL)
2191 {
2192 for(j=0;j<r->OrdSize;j++)
2193 {
2194 if ((r->typ[j].ord_typ==ro_dp)
2195 || (r->typ[j].ord_typ==ro_wp)
2196 || (r->typ[j].ord_typ==ro_wp_neg))
2197 {
2198 if (r->typ[j].data.dp.start > r->typ[j].data.dp.end)
2199 dReportError("in ordrec %d: start(%d) > end(%d)",j,
2200 r->typ[j].data.dp.start, r->typ[j].data.dp.end);
2201 if ((r->typ[j].data.dp.start < 1)
2202 || (r->typ[j].data.dp.end > r->N))
2203 dReportError("in ordrec %d: start(%d)<1 or end(%d)>vars(%d)",j,
2204 r->typ[j].data.dp.start, r->typ[j].data.dp.end,r->N);
2205 }
2206 }
2207 }
2208
2209 assume(r != NULL);
2210 assume(r->cf != NULL);
2211
2212 if (nCoeff_is_algExt(r->cf))
2213 {
2214 assume(r->cf->extRing != NULL);
2215 assume(r->cf->extRing->qideal != NULL);
2216 omCheckAddr(r->cf->extRing->qideal->m[0]);
2217 }
2218
2219 //assume(r->cf!=NULL);
2220
2221 return TRUE;
2222}
static FORCE_INLINE BOOLEAN nCoeff_is_algExt(const coeffs r)
TRUE iff r represents an algebraic extension field.
Definition: coeffs.h:910
#define omCheckAddr(addr)
Definition: omAllocDecl.h:328
#define omCheckAddrSize(addr, size)
Definition: omAllocDecl.h:327
#define omcheckAddrSize(addr, size)
Definition: omAllocDecl.h:329

◆ rDebugPrint()

void rDebugPrint ( const ring  r)

Definition at line 4164 of file ring.cc.

4165{
4166 if (r==NULL)
4167 {
4168 PrintS("NULL ?\n");
4169 return;
4170 }
4171 // corresponds to ro_typ from ring.h:
4172 const char *TYP[]={"ro_dp","ro_wp","ro_am","ro_wp64","ro_wp_neg","ro_cp",
4173 "ro_syzcomp", "ro_syz", "ro_isTemp", "ro_is", "ro_none"};
4174 int i,j;
4175
4176 Print("ExpL_Size:%d ",r->ExpL_Size);
4177 Print("CmpL_Size:%d ",r->CmpL_Size);
4178 Print("VarL_Size:%d\n",r->VarL_Size);
4179 Print("bitmask=0x%lx (expbound=%ld) \n",r->bitmask, r->bitmask);
4180 Print("divmask=%lx\n", r->divmask);
4181 Print("BitsPerExp=%d ExpPerLong=%d at L[%d]\n", r->BitsPerExp, r->ExpPerLong, r->VarL_Offset[0]);
4182
4183 Print("VarL_LowIndex: %d\n", r->VarL_LowIndex);
4184 PrintS("VarL_Offset:\n");
4185 if (r->VarL_Offset==NULL) PrintS(" NULL");
4186 else
4187 for(j = 0; j < r->VarL_Size; j++)
4188 Print(" VarL_Offset[%d]: %d ", j, r->VarL_Offset[j]);
4189 PrintLn();
4190
4191
4192 PrintS("VarOffset:\n");
4193 if (r->VarOffset==NULL) PrintS(" NULL\n");
4194 else
4195 for(j=0;j<=r->N;j++)
4196 Print(" v%d at e-pos %d, bit %d\n",
4197 j,r->VarOffset[j] & 0xffffff, r->VarOffset[j] >>24);
4198 PrintS("ordsgn:\n");
4199 for(j=0;j<r->CmpL_Size;j++)
4200 Print(" ordsgn %ld at pos %d\n",r->ordsgn[j],j);
4201 Print("OrdSgn:%d\n",r->OrdSgn);
4202 PrintS("ordrec:\n");
4203 for(j=0;j<r->OrdSize;j++)
4204 {
4205 Print(" typ %s", TYP[r->typ[j].ord_typ]);
4206 if (r->typ[j].ord_typ==ro_syz)
4207 {
4208 const short place = r->typ[j].data.syz.place;
4209 const int limit = r->typ[j].data.syz.limit;
4210 const int curr_index = r->typ[j].data.syz.curr_index;
4211 const int* syz_index = r->typ[j].data.syz.syz_index;
4212
4213 Print(" limit %d (place: %d, curr_index: %d), syz_index: ", limit, place, curr_index);
4214
4215 if( syz_index == NULL )
4216 PrintS("(NULL)");
4217 else
4218 {
4219 PrintS("{");
4220 for( i=0; i <= limit; i++ )
4221 Print("%d ", syz_index[i]);
4222 PrintS("}");
4223 }
4224
4225 }
4226 else if (r->typ[j].ord_typ==ro_isTemp)
4227 {
4228 Print(" start (level) %d, suffixpos: %d, VO: ",r->typ[j].data.isTemp.start, r->typ[j].data.isTemp.suffixpos);
4229
4230 }
4231 else if (r->typ[j].ord_typ==ro_is)
4232 {
4233 Print(" start %d, end: %d: ",r->typ[j].data.is.start, r->typ[j].data.is.end);
4234
4235// 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]);
4236
4237 Print(" limit %d",r->typ[j].data.is.limit);
4238#ifndef SING_NDEBUG
4239 //PrintS(" F: ");idShow(r->typ[j].data.is.F, r, r, 1);
4240#endif
4241
4242 PrintLn();
4243 }
4244 else if (r->typ[j].ord_typ==ro_am)
4245 {
4246 Print(" place %d",r->typ[j].data.am.place);
4247 Print(" start %d",r->typ[j].data.am.start);
4248 Print(" end %d",r->typ[j].data.am.end);
4249 Print(" len_gen %d",r->typ[j].data.am.len_gen);
4250 PrintS(" w:");
4251 int l=0;
4252 for(l=r->typ[j].data.am.start;l<=r->typ[j].data.am.end;l++)
4253 Print(" %d",r->typ[j].data.am.weights[l-r->typ[j].data.am.start]);
4254 l=r->typ[j].data.am.end+1;
4255 int ll=r->typ[j].data.am.weights[l-r->typ[j].data.am.start];
4256 PrintS(" m:");
4257 for(int lll=l+1;lll<l+ll+1;lll++)
4258 Print(" %d",r->typ[j].data.am.weights[lll-r->typ[j].data.am.start]);
4259 }
4260 else
4261 {
4262 Print(" place %d",r->typ[j].data.dp.place);
4263
4264 if (r->typ[j].ord_typ!=ro_syzcomp && r->typ[j].ord_typ!=ro_syz)
4265 {
4266 Print(" start %d",r->typ[j].data.dp.start);
4267 Print(" end %d",r->typ[j].data.dp.end);
4268 if ((r->typ[j].ord_typ==ro_wp)
4269 || (r->typ[j].ord_typ==ro_wp_neg))
4270 {
4271 PrintS(" w:");
4272 for(int l=r->typ[j].data.wp.start;l<=r->typ[j].data.wp.end;l++)
4273 Print(" %d",r->typ[j].data.wp.weights[l-r->typ[j].data.wp.start]);
4274 }
4275 else if (r->typ[j].ord_typ==ro_wp64)
4276 {
4277 PrintS(" w64:");
4278 int l;
4279 for(l=r->typ[j].data.wp64.start;l<=r->typ[j].data.wp64.end;l++)
4280 Print(" %ld",(long)(r->typ[j].data.wp64.weights64+l-r->typ[j].data.wp64.start));
4281 }
4282 }
4283 }
4284 PrintLn();
4285 }
4286 Print("pOrdIndex:%d pCompIndex:%d\n", r->pOrdIndex, r->pCompIndex);
4287 Print("OrdSize:%d\n",r->OrdSize);
4288 PrintS("--------------------\n");
4289 for(j=0;j<r->ExpL_Size;j++)
4290 {
4291 Print("L[%d]: ",j);
4292 if (j< r->CmpL_Size)
4293 Print("ordsgn %ld ", r->ordsgn[j]);
4294 else
4295 PrintS("no comp ");
4296 i=1;
4297 for(;i<=r->N;i++)
4298 {
4299 if( (r->VarOffset[i] & 0xffffff) == j )
4300 { Print("v%d at e[%d], bit %d; ", i,r->VarOffset[i] & 0xffffff,
4301 r->VarOffset[i] >>24 ); }
4302 }
4303 if( r->pCompIndex==j ) PrintS("v0; ");
4304 for(i=0;i<r->OrdSize;i++)
4305 {
4306 if (r->typ[i].data.dp.place == j)
4307 {
4308 Print("ordrec:%s (start:%d, end:%d) ",TYP[r->typ[i].ord_typ],
4309 r->typ[i].data.dp.start, r->typ[i].data.dp.end);
4310 }
4311 }
4312
4313 if (j==r->pOrdIndex)
4314 PrintS("pOrdIndex\n");
4315 else
4316 PrintLn();
4317 }
4318 Print("LexOrder:%d, MixedOrder:%d\n",r->LexOrder, r->MixedOrder);
4319
4320 Print("NegWeightL_Size: %d, NegWeightL_Offset: ", r->NegWeightL_Size);
4321 if (r->NegWeightL_Offset==NULL) PrintS(" NULL");
4322 else
4323 for(j = 0; j < r->NegWeightL_Size; j++)
4324 Print(" [%d]: %d ", j, r->NegWeightL_Offset[j]);
4325 PrintLn();
4326
4327 // p_Procs stuff
4328 p_Procs_s proc_names;
4329 const char* field;
4330 const char* length;
4331 const char* ord;
4332 p_Debug_GetProcNames(r, &proc_names); // changes p_Procs!!!
4333 p_Debug_GetSpecNames(r, field, length, ord);
4334
4335 Print("p_Spec : %s, %s, %s\n", field, length, ord);
4336 PrintS("p_Procs :\n");
4337 for (i=0; i<(int) (sizeof(p_Procs_s)/sizeof(void*)); i++)
4338 {
4339 Print(" %s,\n", ((char**) &proc_names)[i]);
4340 }
4341
4342 {
4343 PrintLn();
4344 PrintS("pFDeg : ");
4345#define pFDeg_CASE(A) if(r->pFDeg == A) PrintS( "" #A "" )
4349 pFDeg_CASE(p_Deg); else
4350#undef pFDeg_CASE
4351 Print("(%p)", r->pFDeg); // default case
4352
4353 PrintLn();
4354 Print("pLDeg : (%p)", r->pLDeg);
4355 PrintLn();
4356 }
4357 PrintS("pSetm:");
4358 void p_Setm_Dummy(poly p, const ring r);
4359 void p_Setm_TotalDegree(poly p, const ring r);
4360 void p_Setm_WFirstTotalDegree(poly p, const ring r);
4361 void p_Setm_General(poly p, const ring r);
4362 if (r->p_Setm==p_Setm_General) PrintS("p_Setm_General\n");
4363 else if (r->p_Setm==p_Setm_Dummy) PrintS("p_Setm_Dummy\n");
4364 else if (r->p_Setm==p_Setm_TotalDegree) PrintS("p_Setm_Totaldegree\n");
4365 else if (r->p_Setm==p_Setm_WFirstTotalDegree) PrintS("p_Setm_WFirstTotalDegree\n");
4366 else Print("%p\n",r->p_Setm);
4367}
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:554
long p_WFirstTotalDegree(poly p, const ring r)
Definition: p_polys.cc:596
void p_Setm_Dummy(poly p, const ring r)
Definition: p_polys.cc:541
void p_Setm_TotalDegree(poly p, const ring r)
Definition: p_polys.cc:547
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:587
#define pFDeg_CASE(A)

◆ rDecRefCnt()

static void rDecRefCnt ( ring  r)
inlinestatic

Definition at line 844 of file ring.h.

844{ r->ref--; }

◆ rDefault() [1/4]

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

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:4083
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 = NULL,
unsigned long  bitmask = 0 
)

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:30
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:29
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition: numbers.cc:354

◆ rDefault() [4/4]

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

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 450 of file ring.cc.

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

5775{
5776 ring Ropp = rOpposite(R);
5777 ring Renv = NULL;
5778 int stat = rSum(R, Ropp, Renv); /* takes care of qideals */
5779 if ( stat <=0 )
5780 WarnS("Error in rEnvelope at rSum");
5781 rTest(Renv);
5782 return Renv;
5783}
int rSum(ring r1, ring r2, ring &sum)
Definition: ring.cc:1402
ring rOpposite(ring src)
Definition: ring.cc:5382
#define R
Definition: sirandom.c:27

◆ rEqual()

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

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 1746 of file ring.cc.

1747{
1748 if (r1 == r2) return TRUE;
1749 if (r1 == NULL || r2 == NULL) return FALSE;
1750 if (r1->cf!=r2->cf) return FALSE;
1751 if (rVar(r1)!=rVar(r2)) return FALSE;
1752 if (r1->bitmask!=r2->bitmask) return FALSE;
1753 #ifdef HAVE_SHIFTBBA
1754 if (r1->isLPring!=r2->isLPring) return FALSE;
1755 if (r1->LPncGenCount!=r2->LPncGenCount) return FALSE;
1756 #endif
1757
1758 if( !rSamePolyRep(r1, r2) )
1759 return FALSE;
1760
1761 int i/*, j*/;
1762
1763 for (i=0; i<rVar(r1); i++)
1764 {
1765 if ((r1->names[i] != NULL) && (r2->names[i] != NULL))
1766 {
1767 if (strcmp(r1->names[i], r2->names[i])) return FALSE;
1768 }
1769 else if ((r1->names[i] != NULL) ^ (r2->names[i] != NULL))
1770 {
1771 return FALSE;
1772 }
1773 }
1774
1775 if (qr)
1776 {
1777 if (r1->qideal != NULL)
1778 {
1779 ideal id1 = r1->qideal, id2 = r2->qideal;
1780 int i, n;
1781 poly *m1, *m2;
1782
1783 if (id2 == NULL) return FALSE;
1784 if ((n = IDELEMS(id1)) != IDELEMS(id2)) return FALSE;
1785
1786 {
1787 m1 = id1->m;
1788 m2 = id2->m;
1789 for (i=0; i<n; i++)
1790 if (! p_EqualPolys(m1[i],m2[i], r1, r2)) return FALSE;
1791 }
1792 }
1793 else if (r2->qideal != NULL) return FALSE;
1794 }
1795
1796 return TRUE;
1797}
Definition: qr.h:46
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4577
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:1799
#define IDELEMS(i)
Definition: simpleideals.h:23

◆ rField_has_simple_Alloc()

static BOOLEAN rField_has_simple_Alloc ( const ring  r)
inlinestatic

Z/p, GF(p,n), R: nCopy, nNew, nDelete are dummies.

Definition at line 553 of file ring.h.

554{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_has_simple_Alloc(r->cf); }
static FORCE_INLINE BOOLEAN nCoeff_has_simple_Alloc(const coeffs r)
TRUE if n_Delete/n_New are empty operations.
Definition: coeffs.h:906

◆ rField_has_simple_inverse()

static BOOLEAN rField_has_simple_inverse ( const ring  r)
inlinestatic

Definition at line 549 of file ring.h.

550{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_has_simple_inverse(r->cf); }
static FORCE_INLINE BOOLEAN nCoeff_has_simple_inverse(const coeffs r)
TRUE, if the computation of the inverse is fast, i.e. prefer leading coeff. 1 over content.
Definition: coeffs.h:902

◆ rField_has_Units()

static BOOLEAN rField_has_Units ( const ring  r)
inlinestatic

Definition at line 491 of file ring.h.

492{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_has_Units(r->cf); }
static FORCE_INLINE BOOLEAN nCoeff_has_Units(const coeffs r)
returns TRUE, if r is not a field and r has non-trivial units
Definition: coeffs.h:797

◆ rField_is_Domain()

static BOOLEAN rField_is_Domain ( const ring  r)
inlinestatic

Definition at line 488 of file ring.h.

489{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Domain(r->cf); }
static FORCE_INLINE BOOLEAN nCoeff_is_Domain(const coeffs r)
returns TRUE, if r is a field or r has no zero divisors (i.e is a domain)
Definition: coeffs.h:739

◆ rField_is_GF() [1/2]

static BOOLEAN rField_is_GF ( const ring  r)
inlinestatic

Definition at line 522 of file ring.h.

523{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_GF(r->cf); }
static FORCE_INLINE BOOLEAN nCoeff_is_GF(const coeffs r)
Definition: coeffs.h:839

◆ rField_is_GF() [2/2]

static BOOLEAN rField_is_GF ( const ring  r,
int  q 
)
inlinestatic

Definition at line 525 of file ring.h.

526{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_GF(r->cf, q); }

◆ rField_is_long_C()

static BOOLEAN rField_is_long_C ( const ring  r)
inlinestatic

Definition at line 546 of file ring.h.

547{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_long_C(r->cf); }
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:894

◆ rField_is_long_R()

static BOOLEAN rField_is_long_R ( const ring  r)
inlinestatic

Definition at line 543 of file ring.h.

544{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_long_R(r->cf); }
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:891

◆ rField_is_numeric()

static BOOLEAN rField_is_numeric ( const ring  r)
inlinestatic

Definition at line 516 of file ring.h.

517{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_numeric(r->cf); }
static FORCE_INLINE BOOLEAN nCoeff_is_numeric(const coeffs r)
Definition: coeffs.h:832

◆ rField_is_Q()

static BOOLEAN rField_is_Q ( const ring  r)
inlinestatic

Definition at line 507 of file ring.h.

508{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Q(r->cf); }
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:806

◆ rField_is_Q_a()

static BOOLEAN rField_is_Q_a ( const ring  r)
inlinestatic

Definition at line 540 of file ring.h.

541{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Q_a(r->cf); }
static FORCE_INLINE BOOLEAN nCoeff_is_Q_a(const coeffs r)
Definition: coeffs.h:885

◆ rField_is_R()

static BOOLEAN rField_is_R ( const ring  r)
inlinestatic

Definition at line 519 of file ring.h.

520{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_R(r->cf); }
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition: coeffs.h:836

◆ rField_is_Ring_2toM()

static BOOLEAN rField_is_Ring_2toM ( const ring  r)
inlinestatic

Definition at line 480 of file ring.h.

481{ assume(r != NULL); assume(r->cf != NULL); return ( nCoeff_is_Ring_2toM(r->cf) ); }
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_2toM(const coeffs r)
Definition: coeffs.h:724

◆ rField_is_Ring_PtoM()

static BOOLEAN rField_is_Ring_PtoM ( const ring  r)
inlinestatic

Definition at line 483 of file ring.h.

484{ assume(r != NULL); assume(r->cf != NULL); return ( nCoeff_is_Ring_PtoM(r->cf) ); }
static FORCE_INLINE BOOLEAN nCoeff_is_Ring_PtoM(const coeffs r)
Definition: coeffs.h:727

◆ rField_is_Z()

static BOOLEAN rField_is_Z ( const ring  r)
inlinestatic

Definition at line 510 of file ring.h.

511{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Z(r->cf); }
static FORCE_INLINE BOOLEAN nCoeff_is_Z(const coeffs r)
Definition: coeffs.h:816

◆ rField_is_Zn()

static BOOLEAN rField_is_Zn ( const ring  r)
inlinestatic

Definition at line 513 of file ring.h.

514{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Zn(r->cf); }
static FORCE_INLINE BOOLEAN nCoeff_is_Zn(const coeffs r)
Definition: coeffs.h:826

◆ rField_is_Zp() [1/2]

static BOOLEAN rField_is_Zp ( const ring  r)
inlinestatic

Definition at line 501 of file ring.h.

502{ assume(r != NULL); assume(r->cf != NULL); return (getCoeffType(r->cf) == n_Zp); }

◆ rField_is_Zp() [2/2]

static BOOLEAN rField_is_Zp ( const ring  r,
int  p 
)
inlinestatic

Definition at line 504 of file ring.h.

505{ assume(r != NULL); assume(r->cf != NULL); return (getCoeffType(r->cf) == n_Zp) && (r->cf->ch == p); }

◆ rField_is_Zp_a() [1/2]

static BOOLEAN rField_is_Zp_a ( const ring  r)
inlinestatic

Definition at line 530 of file ring.h.

531{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Zp_a(r->cf); }
static FORCE_INLINE BOOLEAN nCoeff_is_Zp_a(const coeffs r)
Definition: coeffs.h:859

◆ rField_is_Zp_a() [2/2]

static BOOLEAN rField_is_Zp_a ( const ring  r,
int  p 
)
inlinestatic

Definition at line 535 of file ring.h.

536{ assume(r != NULL); assume(r->cf != NULL); return nCoeff_is_Zp_a(r->cf, p); }

◆ rFieldType()

static n_coeffType rFieldType ( const ring  r)
inlinestatic

the type of the coefficient filed of r (n_Zp, n_Q, etc)

Definition at line 557 of file ring.h.

557{ return (r->cf->type); }

◆ rGetCurrSyzLimit()

static int rGetCurrSyzLimit ( const ring  r)
inlinestatic

Definition at line 724 of file ring.h.

725{ assume(r != NULL); assume(r->cf != NULL); return (rIsSyzIndexRing(r)? r->typ[0].data.syz.limit : 0);}
static BOOLEAN rIsSyzIndexRing(const ring r)
Definition: ring.h:721

◆ rGetExpSize()

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

Definition at line 2700 of file ring.cc.

2701{
2702#if SIZEOF_LONG == 8
2703 if (N<4) N=4;
2704#else
2705 if (N<2) N=2;
2706#endif
2707 bitmask =rGetExpSize(bitmask, bits);
2708 int vars_per_long=BIT_SIZEOF_LONG/bits;
2709 int bits1;
2710 loop
2711 {
2712 if (bits == BIT_SIZEOF_LONG-1)
2713 {
2714 bits = BIT_SIZEOF_LONG - 1;
2715 return LONG_MAX;
2716 }
2717 unsigned long bitmask1 =rGetExpSize(bitmask+1, bits1);
2718 int vars_per_long1=BIT_SIZEOF_LONG/bits1;
2719 if ((((N+vars_per_long-1)/vars_per_long) ==
2720 ((N+vars_per_long1-1)/vars_per_long1)))
2721 {
2722 vars_per_long=vars_per_long1;
2723 bits=bits1;
2724 bitmask=bitmask1;
2725 }
2726 else
2727 {
2728 return bitmask; /* and bits */
2729 }
2730 }
2731}
#define loop
Definition: structs.h:75

◆ rGetISPos()

int rGetISPos ( const int  p,
const ring  r 
)

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

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

Definition at line 5080 of file ring.cc.

5081{
5082 // Put the reference set F into the ring -ordering -recor
5083#if MYTEST
5084 Print("rIsIS(p: %d)\nF:", p);
5085 PrintLn();
5086#endif
5087
5088 if (r->typ==NULL)
5089 {
5090// dReportError("'rIsIS:' Error: wrong ring! (typ == NULL)");
5091 return -1;
5092 }
5093
5094 int j = p; // Which IS record to use...
5095 for( int pos = 0; pos < r->OrdSize; pos++ )
5096 if( r->typ[pos].ord_typ == ro_is)
5097 if( j-- == 0 )
5098 return pos;
5099
5100 return -1;
5101}

◆ rGetMaxSyzComp()

int rGetMaxSyzComp ( int  i,
const ring  r 
)

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

Definition at line 5238 of file ring.cc.

5239{
5240 if ((r->typ!=NULL) && (r->typ[0].ord_typ==ro_syz) &&
5241 r->typ[0].data.syz.limit > 0 && i > 0)
5242 {
5243 assume(i <= r->typ[0].data.syz.limit);
5244 int j;
5245 for (j=0; j<r->typ[0].data.syz.limit; j++)
5246 {
5247 if (r->typ[0].data.syz.syz_index[j] == i &&
5248 r->typ[0].data.syz.syz_index[j+1] != i)
5249 {
5250 assume(r->typ[0].data.syz.syz_index[j+1] == i+1);
5251 return j;
5252 }
5253 }
5254 return r->typ[0].data.syz.limit;
5255 }
5256 else
5257 {
5258 #ifndef SING_NDEBUG
5259 WarnS("rGetMaxSyzComp: order c");
5260 #endif
5261 return 0;
5262 }
5263}

◆ rGetOrderType()

rOrderType_t rGetOrderType ( ring  r)

Definition at line 1840 of file ring.cc.

1841{
1842 // check for simple ordering
1843 if (rHasSimpleOrder(r))
1844 {
1845 if ((r->order[1] == ringorder_c)
1846 || (r->order[1] == ringorder_C))
1847 {
1848 switch(r->order[0])
1849 {
1850 case ringorder_dp:
1851 case ringorder_wp:
1852 case ringorder_ds:
1853 case ringorder_ws:
1854 case ringorder_ls:
1855 case ringorder_unspec:
1856 if (r->order[1] == ringorder_C
1857 || r->order[0] == ringorder_unspec)
1858 return rOrderType_ExpComp;
1859 return rOrderType_Exp;
1860
1861 default:
1862 assume(r->order[0] == ringorder_lp ||
1863 r->order[0] == ringorder_rs ||
1864 r->order[0] == ringorder_Dp ||
1865 r->order[0] == ringorder_Wp ||
1866 r->order[0] == ringorder_Ds ||
1867 r->order[0] == ringorder_Ws);
1868
1869 if (r->order[1] == ringorder_c) return rOrderType_ExpComp;
1870 return rOrderType_Exp;
1871 }
1872 }
1873 else
1874 {
1875 assume((r->order[0]==ringorder_c)||(r->order[0]==ringorder_C));
1876 return rOrderType_CompExp;
1877 }
1878 }
1879 else
1880 return rOrderType_General;
1881}
BOOLEAN rHasSimpleOrder(const ring r)
Definition: ring.cc:1887

◆ rGetSComps()

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

Definition at line 4494 of file ring.cc.

4495{
4496#ifdef PDEBUG
4497 rDBGetSComps(currComponents, currShiftedComponents, length, r);
4498#else
4499 rNGetSComps(currComponents, currShiftedComponents, r);
4500#endif
4501}
static void rNGetSComps(int **currComponents, long **currShiftedComponents, ring r)
Definition: ring.cc:4455
static void rDBGetSComps(int **currComponents, long **currShiftedComponents, int *length, ring r)
Definition: ring.cc:4473

◆ rGetVar()

poly rGetVar ( const int  varIndex,
const ring  r 
)

Definition at line 5887 of file ring.cc.

5888{
5889 poly p = p_ISet(1, r);
5890 p_SetExp(p, varIndex, 1, r);
5891 p_Setm(p, r);
5892 return p;
5893}
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1297
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 5323 of file ring.cc.

5324{
5325 assume(r!=NULL);
5326 assume(r->OrdSize>0);
5327 int i=0;
5328 while((r->typ[i].ord_typ!=ro_wp64) && (r->typ[i].ord_typ>0)) i++;
5329 if (r->typ[i].ord_typ!=ro_wp64) return NULL; /* should not happen*/
5330 return r->typ[i].data.wp64.weights64;
5331}

◆ rHas_c_Ordering()

BOOLEAN rHas_c_Ordering ( const ring  r)

Definition at line 1883 of file ring.cc.

1884{
1885 return (r->order[0] == ringorder_c);
1886}

◆ rHasGlobalOrdering()

BOOLEAN rHasGlobalOrdering ( const ring  r)
inline

Definition at line 760 of file ring.h.

760{ return (r->OrdSgn==1); }

◆ rHasLocalOrMixedOrdering()

BOOLEAN rHasLocalOrMixedOrdering ( const ring  r)
inline

Definition at line 761 of file ring.h.

761{ return (r->OrdSgn==-1); }

◆ rHasMixedOrdering()

BOOLEAN rHasMixedOrdering ( const ring  r)
inline

Definition at line 762 of file ring.h.

762{ return (r->MixedOrder); }

◆ rHasSimpleLexOrder()

BOOLEAN rHasSimpleLexOrder ( const ring  r)

returns TRUE, if simple lp or ls ordering

Definition at line 1919 of file ring.cc.

1920{
1921 return rHasSimpleOrder(r) &&
1922 (r->order[0] == ringorder_ls ||
1923 r->order[0] == ringorder_lp ||
1924 r->order[1] == ringorder_ls ||
1925 r->order[1] == ringorder_lp);
1926}

◆ rHasSimpleOrder()

BOOLEAN rHasSimpleOrder ( const ring  r)

Definition at line 1887 of file ring.cc.

1888{
1889 if (r->order[0] == ringorder_unspec) return TRUE;
1890 int blocks = rBlocks(r) - 1;
1891 assume(blocks >= 1);
1892 if (blocks == 1) return TRUE;
1893
1894 int s = 0;
1895 while( (s < blocks) && (r->order[s] == ringorder_IS) && (r->order[blocks-1] == ringorder_IS) )
1896 {
1897 s++;
1898 blocks--;
1899 }
1900
1901 if ((blocks - s) > 2) return FALSE;
1902
1903 assume( blocks == s + 2 );
1904
1905 if (
1906 (r->order[s] != ringorder_c)
1907 && (r->order[s] != ringorder_C)
1908 && (r->order[s+1] != ringorder_c)
1909 && (r->order[s+1] != ringorder_C)
1910 )
1911 return FALSE;
1912 if ((r->order[s+1] == ringorder_M)
1913 || (r->order[s] == ringorder_M))
1914 return FALSE;
1915 return TRUE;
1916}

◆ rIncRefCnt()

static ring rIncRefCnt ( ring  r)
inlinestatic

Definition at line 843 of file ring.h.

843{ r->ref++; return r; }

◆ rInternalChar()

static int rInternalChar ( const ring  r)
inlinestatic

Definition at line 690 of file ring.h.

691{
692 assume(r != NULL);
693 const coeffs C = r->cf;
694 assume(C != NULL);
695 return C->ch;
696}

◆ rIsLPRing()

static BOOLEAN rIsLPRing ( const ring  r)
inlinestatic

Definition at line 411 of file ring.h.

412{
413 assume(r != NULL);
414#ifdef HAVE_SHIFTBBA
415 return (r->isLPring!=0);
416#else
417 return FALSE;
418#endif
419}

◆ rIsNCRing()

static BOOLEAN rIsNCRing ( const ring  r)
inlinestatic

Definition at line 421 of file ring.h.

422{
423 assume(r != NULL);
424 return rIsPluralRing(r) || rIsLPRing(r);
425}
static BOOLEAN rIsLPRing(const ring r)
Definition: ring.h:411

◆ rIsPluralRing()

static BOOLEAN rIsPluralRing ( const ring  r)
inlinestatic

we must always have this test!

Definition at line 400 of file ring.h.

401{
402 assume(r != NULL);
403#ifdef HAVE_PLURAL
404 nc_struct *n;
405 return ((n=r->GetNC()) != NULL) /*&& (n->type != nc_error)*/;
406#else
407 return FALSE;
408#endif
409}

◆ rIsPolyVar()

BOOLEAN rIsPolyVar ( int  i,
const ring  r 
)

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

Definition at line 2036 of file ring.cc.

2037{
2038 int i=0;
2039 while(r->order[i]!=0)
2040 {
2041 if((r->block0[i]<=v)
2042 && (r->block1[i]>=v))
2043 {
2044 switch(r->order[i])
2045 {
2046 case ringorder_a:
2047 return (r->wvhdl[i][v-r->block0[i]]>0);
2048 case ringorder_M:
2049 return 2; /*don't know*/
2050 case ringorder_a64: /* assume: all weight are non-negative!*/
2051 case ringorder_lp:
2052 case ringorder_rs:
2053 case ringorder_dp:
2054 case ringorder_Dp:
2055 case ringorder_wp:
2056 case ringorder_Wp:
2057 return TRUE;
2058 case ringorder_ls:
2059 case ringorder_ds:
2060 case ringorder_Ds:
2061 case ringorder_ws:
2062 case ringorder_Ws:
2063 return FALSE;
2064 default:
2065 break;
2066 }
2067 }
2068 i++;
2069 }
2070 return 3; /* could not find var v*/
2071}

◆ rIsRatGRing()

static BOOLEAN rIsRatGRing ( const ring  r)
inlinestatic

Definition at line 427 of file ring.h.

428{
429 assume(r != NULL);
430#ifdef HAVE_PLURAL
431 /* nc_struct *n; */
432 return (r != NULL) /* && ((n=r->GetNC()) != NULL) */
433 && (r->real_var_start>1);
434#else
435 return FALSE;
436#endif
437}

◆ rIsSyzIndexRing()

static BOOLEAN rIsSyzIndexRing ( const ring  r)
inlinestatic

Definition at line 721 of file ring.h.

722{ assume(r != NULL); assume(r->cf != NULL); return r->order[0] == ringorder_s;}

◆ rKillModified_Wp_Ring()

void rKillModified_Wp_Ring ( ring  r)

Definition at line 3111 of file ring.cc.

3112{
3113 rUnComplete(r);
3114 omFree(r->order);
3115 omFree(r->block0);
3116 omFree(r->block1);
3117 omFree(r->wvhdl[0]);
3118 omFree(r->wvhdl);
3120}

◆ rKillModifiedRing()

void rKillModifiedRing ( ring  r)

Definition at line 3101 of file ring.cc.

3102{
3103 rUnComplete(r);
3104 omFree(r->order);
3105 omFree(r->block0);
3106 omFree(r->block1);
3107 omFree(r->wvhdl);
3109}

◆ rMinpolyIsNULL()

static BOOLEAN rMinpolyIsNULL ( const ring  r)
inlinestatic

Tests whether '(r->cf->minpoly) == NULL'.

Definition at line 700 of file ring.h.

701{
702 assume(r != NULL);
703 const coeffs C = r->cf;
704 assume(C != NULL);
705
706 const BOOLEAN ret = nCoeff_is_algExt(C); // || nCoeff_is_GF(C) || nCoeff_is_long_C(C);
707
708 if( ret )
709 {
710 assume( (C->extRing) != NULL );
711 BOOLEAN idIs0 (ideal h);
712 assume((!((C->extRing)->qideal==NULL)) && (!idIs0((C->extRing)->qideal)));
713 }
714
715 // TODO: this leads to test fails (due to rDecompose?)
716 return !ret;
717}
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
STATIC_VAR Poly * h
Definition: janet.cc:971

◆ rMinusVar()

ring rMinusVar ( const ring  r,
char *  v 
)

undo rPlusVar

Definition at line 6000 of file ring.cc.

6001{
6002 if (r->order[2]!=0)
6003 {
6004 WerrorS("only for rings with an ordering of one block");
6005 return NULL;
6006 }
6007 int p;
6008 if((r->order[0]==ringorder_C)
6009 ||(r->order[0]==ringorder_c))
6010 p=1;
6011 else
6012 p=0;
6013 if((r->order[p]!=ringorder_dp)
6014 && (r->order[p]!=ringorder_Dp)
6015 && (r->order[p]!=ringorder_lp)
6016 && (r->order[p]!=ringorder_rp)
6017 && (r->order[p]!=ringorder_ds)
6018 && (r->order[p]!=ringorder_Ds)
6019 && (r->order[p]!=ringorder_ls))
6020 {
6021 WerrorS("ordering must be dp,Dp,lp,rp,ds,Ds or ls");
6022 return NULL;
6023 }
6024 ring R=rCopy0(r);
6025 int i=R->N-1;
6026 while(i>=0)
6027 {
6028 if (strcmp(R->names[i],v)==0)
6029 {
6030 R->N--;
6031 omFree(R->names[i]);
6032 for(int j=i;j<R->N;j++) R->names[j]=R->names[j+1];
6033 R->names=(char**)omReallocSize(R->names,r->N*sizeof(char_ptr),R->N*sizeof(char_ptr));
6034 }
6035 i--;
6036 }
6037 R->block1[p]=R->N;
6038 rComplete(R,1);
6039 return R;
6040}
#define omReallocSize(addr, o_size, size)
Definition: omAllocDecl.h:220
char * char_ptr
Definition: structs.h:53

◆ rModify_a_to_A()

void rModify_a_to_A ( ring  r)

Definition at line 5864 of file ring.cc.

5867{
5868 int i=0;
5869 int j;
5870 while(r->order[i]!=0)
5871 {
5872 if (r->order[i]==ringorder_a)
5873 {
5874 r->order[i]=ringorder_a64;
5875 int *w=r->wvhdl[i];
5876 int64 *w64=(int64 *)omAlloc((r->block1[i]-r->block0[i]+1)*sizeof(int64));
5877 for(j=r->block1[i]-r->block0[i];j>=0;j--)
5878 w64[j]=(int64)w[j];
5879 r->wvhdl[i]=(int*)w64;
5880 omFreeSize(w,(r->block1[i]-r->block0[i]+1)*sizeof(int));
5881 }
5882 i++;
5883 }
5884}
const CanonicalForm & w
Definition: facAbsFact.cc:51

◆ rModifyRing()

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

< How many induced ordering block do we have?

Definition at line 2740 of file ring.cc.

2743{
2744 assume (r != NULL );
2745 assume (exp_limit > 1);
2746 BOOLEAN omitted_degree = FALSE;
2747
2748 int bits;
2749 exp_limit=rGetExpSize(exp_limit, bits, r->N);
2750 BOOLEAN need_other_ring = (exp_limit != r->bitmask);
2751
2752 int iNeedInducedOrderingSetup = 0; ///< How many induced ordering block do we have?
2753
2754 int nblocks=rBlocks(r);
2755 rRingOrder_t *order=(rRingOrder_t*)omAlloc0((nblocks+1)*sizeof(rRingOrder_t));
2756 int *block0=(int*)omAlloc0((nblocks+1)*sizeof(int));
2757 int *block1=(int*)omAlloc0((nblocks+1)*sizeof(int));
2758 int **wvhdl=(int**)omAlloc0((nblocks+1)*sizeof(int *));
2759
2760 int i=0;
2761 int j=0; /* i index in r, j index in res */
2762
2763 for( rRingOrder_t r_ord=r->order[i]; (r_ord != (rRingOrder_t)0) && (i < nblocks); j++, r_ord=r->order[++i])
2764 {
2765 BOOLEAN copy_block_index=TRUE;
2766
2767 if (r->block0[i]==r->block1[i])
2768 {
2769 switch(r_ord)
2770 {
2771 case ringorder_wp:
2772 case ringorder_dp:
2773 case ringorder_Wp:
2774 case ringorder_Dp:
2775 r_ord=ringorder_lp;
2776 break;
2777 case ringorder_Ws:
2778 case ringorder_Ds:
2779 case ringorder_ws:
2780 case ringorder_ds:
2781 r_ord=ringorder_ls;
2782 break;
2783 default:
2784 break;
2785 }
2786 }
2787 switch(r_ord)
2788 {
2789 case ringorder_S:
2790 {
2791#ifndef SING_NDEBUG
2792 Warn("Error: unhandled ordering in rModifyRing: ringorder_S = [%d]", r_ord);
2793#endif
2794 order[j]=r_ord; /*r->order[i];*/
2795 break;
2796 }
2797 case ringorder_C:
2798 case ringorder_c:
2799 if (!try_omit_comp)
2800 {
2801 order[j]=r_ord; /*r->order[i]*/;
2802 }
2803 else
2804 {
2805 j--;
2806 need_other_ring=TRUE;
2807 try_omit_comp=FALSE;
2808 copy_block_index=FALSE;
2809 }
2810 break;
2811 case ringorder_wp:
2812 case ringorder_dp:
2813 case ringorder_ws:
2814 case ringorder_ds:
2815 if(!omit_degree)
2816 {
2817 order[j]=r_ord; /*r->order[i]*/;
2818 }
2819 else
2820 {
2821 order[j]=ringorder_rs;
2822 need_other_ring=TRUE;
2823 omit_degree=FALSE;
2824 omitted_degree = TRUE;
2825 }
2826 break;
2827 case ringorder_Wp:
2828 case ringorder_Dp:
2829 case ringorder_Ws:
2830 case ringorder_Ds:
2831 if(!omit_degree)
2832 {
2833 order[j]=r_ord; /*r->order[i];*/
2834 }
2835 else
2836 {
2837 order[j]=ringorder_lp;
2838 need_other_ring=TRUE;
2839 omit_degree=FALSE;
2840 omitted_degree = TRUE;
2841 }
2842 break;
2843 case ringorder_IS:
2844 {
2845 if (try_omit_comp)
2846 {
2847 // tried, but cannot omit component due to the ordering block [%d]: %d (ringorder_IS)", i, r_ord
2848 try_omit_comp = FALSE;
2849 }
2850 order[j]=r_ord; /*r->order[i];*/
2851 iNeedInducedOrderingSetup++;
2852 break;
2853 }
2854 case ringorder_s:
2855 {
2856 assume((i == 0) && (j == 0));
2857 if (try_omit_comp)
2858 {
2859 // tried, but cannot omit component due to the ordering block [%d]: %d (ringorder_s)", i, r_ord
2860 try_omit_comp = FALSE;
2861 }
2862 order[j]=r_ord; /*r->order[i];*/
2863 break;
2864 }
2865 default:
2866 order[j]=r_ord; /*r->order[i];*/
2867 break;
2868 }
2869 if (copy_block_index)
2870 {
2871 block0[j]=r->block0[i];
2872 block1[j]=r->block1[i];
2873 wvhdl[j]=r->wvhdl[i];
2874 }
2875
2876 // order[j]=ringorder_no; // done by omAlloc0
2877 }
2878 if(!need_other_ring)
2879 {
2880 omFreeSize(order,(nblocks+1)*sizeof(rRingOrder_t));
2881 omFreeSize(block0,(nblocks+1)*sizeof(int));
2882 omFreeSize(block1,(nblocks+1)*sizeof(int));
2883 omFreeSize(wvhdl,(nblocks+1)*sizeof(int *));
2884 return r;
2885 }
2886 ring res=(ring)omAlloc0Bin(sip_sring_bin);
2887 *res = *r;
2888
2889#ifdef HAVE_PLURAL
2890 res->GetNC() = NULL;
2891#endif
2892
2893 // res->qideal, res->idroot ???
2894 res->wvhdl=wvhdl;
2895 res->order=order;
2896 res->block0=block0;
2897 res->block1=block1;
2898 res->bitmask=exp_limit;
2899 res->wanted_maxExp=r->wanted_maxExp;
2900 //int tmpref=r->cf->ref0;
2901 rComplete(res, 1);
2902 //r->cf->ref=tmpref;
2903
2904 // adjust res->pFDeg: if it was changed globally, then
2905 // it must also be changed for new ring
2906 if (r->pFDegOrig != res->pFDegOrig &&
2908 {
2909 // still might need adjustment for weighted orderings
2910 // and omit_degree
2911 res->firstwv = r->firstwv;
2912 res->firstBlockEnds = r->firstBlockEnds;
2913 res->pFDeg = res->pFDegOrig = p_WFirstTotalDegree;
2914 }
2915 if (omitted_degree)
2916 res->pLDeg = r->pLDegOrig;
2917
2918 rOptimizeLDeg(res); // also sets res->pLDegOrig
2919
2920 // set syzcomp
2921 if (res->typ != NULL)
2922 {
2923 if( res->typ[0].ord_typ == ro_syz) // "s" Always on [0] place!
2924 {
2925 res->typ[0] = r->typ[0]; // Copy struct!? + setup the same limit!
2926
2927 if (r->typ[0].data.syz.limit > 0)
2928 {
2929 res->typ[0].data.syz.syz_index
2930 = (int*) omAlloc((r->typ[0].data.syz.limit +1)*sizeof(int));
2931 memcpy(res->typ[0].data.syz.syz_index, r->typ[0].data.syz.syz_index,
2932 (r->typ[0].data.syz.limit +1)*sizeof(int));
2933 }
2934 }
2935
2936 if( iNeedInducedOrderingSetup > 0 )
2937 {
2938 for(j = 0, i = 0; (i < nblocks) && (iNeedInducedOrderingSetup > 0); i++)
2939 if( res->typ[i].ord_typ == ro_is ) // Search for suffixes!
2940 {
2941 ideal F = idrHeadR(r->typ[i].data.is.F, r, res); // Copy F from r into res!
2942 assume(
2944 F, // WILL BE COPIED!
2945 r->typ[i].data.is.limit,
2946 j++
2947 )
2948 );
2949 id_Delete(&F, res);
2950 iNeedInducedOrderingSetup--;
2951 }
2952 } // Process all induced Ordering blocks! ...
2953 }
2954 // the special case: homog (omit_degree) and 1 block rs: that is global:
2955 // it comes from dp
2956 res->OrdSgn=r->OrdSgn;
2957
2958
2959#ifdef HAVE_PLURAL
2960 if (rIsPluralRing(r))
2961 {
2962 if ( nc_rComplete(r, res, false) ) // no qideal!
2963 {
2964#ifndef SING_NDEBUG
2965 WarnS("error in nc_rComplete");
2966#endif
2967 // cleanup?
2968
2969// rDelete(res);
2970// return r;
2971
2972 // just go on..
2973 }
2974
2975 if( rIsSCA(r) )
2976 {
2978 WarnS("error in sca_Force!");
2979 }
2980 }
2981#endif
2982
2983 return res;
2984}
#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:156
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:5112
static void rOptimizeLDeg(ring r)
Definition: ring.cc:3192
BOOLEAN rOrd_is_WeightedDegree_Ordering(const ring r)
Definition: ring.cc:2027
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  omit_degree,
BOOLEAN  omit_comp,
unsigned long  exp_limit,
BOOLEAN simple 
)

Definition at line 3035 of file ring.cc.

3036{
3037 simple=TRUE;
3038 if (!rHasSimpleOrder(r))
3039 {
3040 simple=FALSE; // sorting needed
3041 assume (r != NULL );
3042 assume (exp_limit > 1);
3043 int bits;
3044
3045 exp_limit=rGetExpSize(exp_limit, bits, r->N);
3046
3047 int nblocks=1+(ommit_comp!=0);
3048 rRingOrder_t *order=(rRingOrder_t*)omAlloc0((nblocks+1)*sizeof(rRingOrder_t));
3049 int *block0=(int*)omAlloc0((nblocks+1)*sizeof(int));
3050 int *block1=(int*)omAlloc0((nblocks+1)*sizeof(int));
3051 int **wvhdl=(int**)omAlloc0((nblocks+1)*sizeof(int *));
3052
3053 order[0]=ringorder_lp;
3054 block0[0]=1;
3055 block1[0]=r->N;
3056 if (!ommit_comp)
3057 {
3058 order[1]=ringorder_C;
3059 }
3060 ring res=(ring)omAlloc0Bin(sip_sring_bin);
3061 *res = *r;
3062#ifdef HAVE_PLURAL
3063 res->GetNC() = NULL;
3064#endif
3065 // res->qideal, res->idroot ???
3066 res->wvhdl=wvhdl;
3067 res->order=order;
3068 res->block0=block0;
3069 res->block1=block1;
3070 res->bitmask=exp_limit;
3071 res->wanted_maxExp=r->wanted_maxExp;
3072 //int tmpref=r->cf->ref;
3073 rComplete(res, 1);
3074 //r->cf->ref=tmpref;
3075
3076#ifdef HAVE_PLURAL
3077 if (rIsPluralRing(r))
3078 {
3079 if ( nc_rComplete(r, res, false) ) // no qideal!
3080 {
3081#ifndef SING_NDEBUG
3082 WarnS("error in nc_rComplete");
3083#endif
3084 // cleanup?
3085
3086// rDelete(res);
3087// return r;
3088
3089 // just go on..
3090 }
3091 }
3092#endif
3093
3095
3096 return res;
3097 }
3098 return rModifyRing(r, ommit_degree, ommit_comp, exp_limit);
3099}
ring rModifyRing(ring r, BOOLEAN omit_degree, BOOLEAN try_omit_comp, unsigned long exp_limit)
Definition: ring.cc:2740

◆ rModifyRing_Wp()

ring rModifyRing_Wp ( ring  r,
int *  weights 
)

construct Wp, C ring

Definition at line 2987 of file ring.cc.

2988{
2989 ring res=(ring)omAlloc0Bin(sip_sring_bin);
2990 *res = *r;
2991#ifdef HAVE_PLURAL
2992 res->GetNC() = NULL;
2993#endif
2994
2995 /*weights: entries for 3 blocks: NULL*/
2996 res->wvhdl = (int **)omAlloc0(3 * sizeof(int *));
2997 /*order: Wp,C,0*/
2998 res->order = (rRingOrder_t *) omAlloc(3 * sizeof(rRingOrder_t *));
2999 res->block0 = (int *)omAlloc0(3 * sizeof(int *));
3000 res->block1 = (int *)omAlloc0(3 * sizeof(int *));
3001 /* ringorder Wp for the first block: var 1..r->N */
3002 res->order[0] = ringorder_Wp;
3003 res->block0[0] = 1;
3004 res->block1[0] = r->N;
3005 res->wvhdl[0] = weights;
3006 /* ringorder C for the second block: no vars */
3007 res->order[1] = ringorder_C;
3008 /* the last block: everything is 0 */
3009 res->order[2] = (rRingOrder_t)0;
3010
3011 //int tmpref=r->cf->ref;
3012 rComplete(res, 1);
3013 //r->cf->ref=tmpref;
3014#ifdef HAVE_PLURAL
3015 if (rIsPluralRing(r))
3016 {
3017 if ( nc_rComplete(r, res, false) ) // no qideal!
3018 {
3019#ifndef SING_NDEBUG
3020 WarnS("error in nc_rComplete");
3021#endif
3022 // cleanup?
3023
3024// rDelete(res);
3025// return r;
3026
3027 // just go on..
3028 }
3029 }
3030#endif
3031 return res;
3032}

◆ rOpposite()

ring rOpposite ( ring  r)

Definition at line 5382 of file ring.cc.

5386{
5387 if (src == NULL) return(NULL);
5388
5389 //rChangeCurrRing(src);
5390#ifdef RDEBUG
5391 rTest(src);
5392// rWrite(src);
5393// rDebugPrint(src);
5394#endif
5395
5396 ring r = rCopy0(src,FALSE);
5397 if (src->qideal != NULL)
5398 {
5399 id_Delete(&(r->qideal), src);
5400 }
5401
5402 // change vars v1..vN -> vN..v1
5403 int i;
5404 int i2 = (rVar(r)-1)/2;
5405 for(i=i2; i>=0; i--)
5406 {
5407 // index: 0..N-1
5408 //Print("ex var names: %d <-> %d\n",i,rOppVar(r,i));
5409 // exchange names
5410 char *p;
5411 p = r->names[rVar(r)-1-i];
5412 r->names[rVar(r)-1-i] = r->names[i];
5413 r->names[i] = p;
5414 }
5415// i2=(rVar(r)+1)/2;
5416// for(int i=i2; i>0; i--)
5417// {
5418// // index: 1..N
5419// //Print("ex var places: %d <-> %d\n",i,rVar(r)+1-i);
5420// // exchange VarOffset
5421// int t;
5422// t=r->VarOffset[i];
5423// r->VarOffset[i]=r->VarOffset[rOppVar(r,i)];
5424// r->VarOffset[rOppVar(r,i)]=t;
5425// }
5426 // change names:
5427 // TODO: does this work the same way for Letterplace?
5428 for (i=rVar(r)-1; i>=0; i--)
5429 {
5430 char *p=r->names[i];
5431 if(isupper(*p)) *p = tolower(*p);
5432 else *p = toupper(*p);
5433 }
5434 // change ordering: listing
5435 // change ordering: compare
5436// for(i=0; i<r->OrdSize; i++)
5437// {
5438// int t,tt;
5439// switch(r->typ[i].ord_typ)
5440// {
5441// case ro_dp:
5442// //
5443// t=r->typ[i].data.dp.start;
5444// r->typ[i].data.dp.start=rOppVar(r,r->typ[i].data.dp.end);
5445// r->typ[i].data.dp.end=rOppVar(r,t);
5446// break;
5447// case ro_wp:
5448// case ro_wp_neg:
5449// {
5450// t=r->typ[i].data.wp.start;
5451// r->typ[i].data.wp.start=rOppVar(r,r->typ[i].data.wp.end);
5452// r->typ[i].data.wp.end=rOppVar(r,t);
5453// // invert r->typ[i].data.wp.weights
5454// rOppWeight(r->typ[i].data.wp.weights,
5455// r->typ[i].data.wp.end-r->typ[i].data.wp.start);
5456// break;
5457// }
5458// //case ro_wp64:
5459// case ro_syzcomp:
5460// case ro_syz:
5461// WerrorS("not implemented in rOpposite");
5462// // should not happen
5463// break;
5464//
5465// case ro_cp:
5466// t=r->typ[i].data.cp.start;
5467// r->typ[i].data.cp.start=rOppVar(r,r->typ[i].data.cp.end);
5468// r->typ[i].data.cp.end=rOppVar(r,t);
5469// break;
5470// case ro_none:
5471// default:
5472// Werror("unknown type in rOpposite(%d)",r->typ[i].ord_typ);
5473// break;
5474// }
5475// }
5476 // Change order/block structures (needed for rPrint, rAdd etc.)
5477
5478 int j=0;
5479 int l=rBlocks(src);
5480 if ( ! rIsLPRing(src) )
5481 {
5482 // ie Plural or commutative
5483 for(i=0; src->order[i]!=0; i++)
5484 {
5485 switch (src->order[i])
5486 {
5487 case ringorder_c: /* c-> c */
5488 case ringorder_C: /* C-> C */
5489 case ringorder_no /*=0*/: /* end-of-block */
5490 r->order[j]=src->order[i];
5491 j++; break;
5492 case ringorder_lp: /* lp -> rp */
5493 r->order[j]=ringorder_rp;
5494 r->block0[j]=rOppVar(r, src->block1[i]);
5495 r->block1[j]=rOppVar(r, src->block0[i]);
5496 j++;break;
5497 case ringorder_rp: /* rp -> lp */
5498 r->order[j]=ringorder_lp;
5499 r->block0[j]=rOppVar(r, src->block1[i]);
5500 r->block1[j]=rOppVar(r, src->block0[i]);
5501 j++;break;
5502 case ringorder_dp: /* dp -> a(1..1),ls */
5503 {
5504 l=rRealloc1(r,l,j);
5505 r->order[j]=ringorder_a;
5506 r->block0[j]=rOppVar(r, src->block1[i]);
5507 r->block1[j]=rOppVar(r, src->block0[i]);
5508 r->wvhdl[j]=(int*)omAlloc((r->block1[j]-r->block0[j]+1)*sizeof(int));
5509 for(int k=r->block0[j]; k<=r->block1[j]; k++)
5510 r->wvhdl[j][k-r->block0[j]]=1;
5511 j++;
5512 r->order[j]=ringorder_ls;
5513 r->block0[j]=rOppVar(r, src->block1[i]);
5514 r->block1[j]=rOppVar(r, src->block0[i]);
5515 j++;
5516 break;
5517 }
5518 case ringorder_Dp: /* Dp -> a(1..1),rp */
5519 {
5520 l=rRealloc1(r,l,j);
5521 r->order[j]=ringorder_a;
5522 r->block0[j]=rOppVar(r, src->block1[i]);
5523 r->block1[j]=rOppVar(r, src->block0[i]);
5524 r->wvhdl[j]=(int*)omAlloc((r->block1[j]-r->block0[j]+1)*sizeof(int));
5525 for(int k=r->block0[j]; k<=r->block1[j]; k++)
5526 r->wvhdl[j][k-r->block0[j]]=1;
5527 j++;
5528 r->order[j]=ringorder_rp;
5529 r->block0[j]=rOppVar(r, src->block1[i]);
5530 r->block1[j]=rOppVar(r, src->block0[i]);
5531 j++;
5532 break;
5533 }
5534 case ringorder_wp: /* wp -> a(...),ls */
5535 {
5536 l=rRealloc1(r,l,j);
5537 r->order[j]=ringorder_a;
5538 r->block0[j]=rOppVar(r, src->block1[i]);
5539 r->block1[j]=rOppVar(r, src->block0[i]);
5540 r->wvhdl[j]=r->wvhdl[j+1]; r->wvhdl[j+1]=NULL;
5541 rOppWeight(r->wvhdl[j], r->block1[j]-r->block0[j]);
5542 j++;
5543 r->order[j]=ringorder_ls;
5544 r->block0[j]=rOppVar(r, src->block1[i]);
5545 r->block1[j]=rOppVar(r, src->block0[i]);
5546 j++;
5547 break;
5548 }
5549 case ringorder_Wp: /* Wp -> a(...),rp */
5550 {
5551 l=rRealloc1(r,l,j);
5552 r->order[j]=ringorder_a;
5553 r->block0[j]=rOppVar(r, src->block1[i]);
5554 r->block1[j]=rOppVar(r, src->block0[i]);
5555 r->wvhdl[j]=r->wvhdl[j+1]; r->wvhdl[j+1]=NULL;
5556 rOppWeight(r->wvhdl[j], r->block1[j]-r->block0[j]);
5557 j++;
5558 r->order[j]=ringorder_rp;
5559 r->block0[j]=rOppVar(r, src->block1[i]);
5560 r->block1[j]=rOppVar(r, src->block0[i]);
5561 j++;
5562 break;
5563 }
5564 case ringorder_M: /* M -> M */
5565 {
5566 r->order[j]=ringorder_M;
5567 r->block0[j]=rOppVar(r, src->block1[i]);
5568 r->block1[j]=rOppVar(r, src->block0[i]);
5569 int n=r->block1[j]-r->block0[j];
5570 /* M is a (n+1)x(n+1) matrix */
5571 for (int nn=0; nn<=n; nn++)
5572 {
5573 rOppWeight(&(r->wvhdl[j][nn*(n+1)]), n /*r->block1[j]-r->block0[j]*/);
5574 }
5575 j++;
5576 break;
5577 }
5578 case ringorder_a: /* a(...),ls -> wp/dp */
5579 {
5580 r->block0[j]=rOppVar(r, src->block1[i]);
5581 r->block1[j]=rOppVar(r, src->block0[i]);
5582 rOppWeight(r->wvhdl[j], r->block1[j]-r->block0[j]);
5583 if (src->order[i+1]==ringorder_ls)
5584 {
5585 r->order[j]=ringorder_wp;
5586 i++;
5587 //l=rReallocM1(r,l,j);
5588 }
5589 else
5590 {
5591 r->order[j]=ringorder_a;
5592 }
5593 j++;
5594 break;
5595 }
5596 // not yet done:
5597 case ringorder_ls:
5598 case ringorder_rs:
5599 case ringorder_ds:
5600 case ringorder_Ds:
5601 case ringorder_ws:
5602 case ringorder_Ws:
5603 case ringorder_am:
5604 case ringorder_a64:
5605 // should not occur:
5606 case ringorder_S:
5607 case ringorder_IS:
5608 case ringorder_s:
5609 case ringorder_aa:
5610 case ringorder_L:
5611 case ringorder_unspec:
5612 Werror("order %s not (yet) supported", rSimpleOrdStr(src->order[i]));
5613 break;
5614 }
5615 }
5616 } /* end if (!rIsLPRing(src)) */
5617 if (rIsLPRing(src))
5618 {
5619 // applies to Letterplace only
5620 // Letterplace conventions: dp<->Dp, lp<->rp
5621 // Wp(v) cannot be converted since wp(v) does not encode a monomial ordering
5622 // (a(w),<) is troublesome and thus postponed
5623 for(i=0; src->order[i]!=0; i++)
5624 {
5625 switch (src->order[i])
5626 {
5627 case ringorder_c: /* c-> c */
5628 case ringorder_C: /* C-> C */
5629 case ringorder_no /*=0*/: /* end-of-block */
5630 r->order[j]=src->order[i];
5631 j++; break;
5632 case ringorder_lp: /* lp -> rp */
5633 r->order[j]=ringorder_rp;
5634 r->block0[j]=rOppVar(r, src->block1[i]);
5635 r->block1[j]=rOppVar(r, src->block0[i]);
5636 j++;break;
5637 case ringorder_rp: /* rp -> lp */
5638 r->order[j]=ringorder_lp;
5639 r->block0[j]=rOppVar(r, src->block1[i]);
5640 r->block1[j]=rOppVar(r, src->block0[i]);
5641 j++;break;
5642 case ringorder_dp: /* dp -> Dp */
5643 {
5644 r->order[j]=ringorder_Dp;
5645 r->block0[j]=rOppVar(r, src->block1[i]);
5646 r->block1[j]=rOppVar(r, src->block0[i]);
5647 j++;break;
5648 }
5649 case ringorder_Dp: /* Dp -> dp*/
5650 {
5651 r->order[j]=ringorder_dp;
5652 r->block0[j]=rOppVar(r, src->block1[i]);
5653 r->block1[j]=rOppVar(r, src->block0[i]);
5654 j++;break;
5655 }
5656 // not clear how to do:
5657 case ringorder_wp:
5658 case ringorder_Wp:
5659 case ringorder_M:
5660 case ringorder_a:
5661 // not yet done:
5662 case ringorder_ls:
5663 case ringorder_rs:
5664 case ringorder_ds:
5665 case ringorder_Ds:
5666 case ringorder_ws:
5667 case ringorder_Ws:
5668 case ringorder_am:
5669 case ringorder_a64:
5670 // should not occur:
5671 case ringorder_S:
5672 case ringorder_IS:
5673 case ringorder_s:
5674 case ringorder_aa:
5675 case ringorder_L:
5676 case ringorder_unspec:
5677 Werror("order %s not (yet) supported", rSimpleOrdStr(src->order[i]));
5678 break;
5679 }
5680 }
5681 } /* end if (rIsLPRing(src)) */
5682 rComplete(r);
5683
5684 //rChangeCurrRing(r);
5685#ifdef RDEBUG
5686 rTest(r);
5687// rWrite(r);
5688// rDebugPrint(r);
5689#endif
5690
5691#ifdef HAVE_PLURAL
5692 // now, we initialize a non-comm structure on r
5693 if (rIsPluralRing(src))
5694 {
5695// assume( currRing == r);
5696
5697 int *perm = (int *)omAlloc0((rVar(r)+1)*sizeof(int));
5698 int *par_perm = NULL;
5699 nMapFunc nMap = n_SetMap(src->cf,r->cf);
5700 int ni,nj;
5701 for(i=1; i<=r->N; i++)
5702 {
5703 perm[i] = rOppVar(r,i);
5704 }
5705
5706 matrix C = mpNew(rVar(r),rVar(r));
5707 matrix D = mpNew(rVar(r),rVar(r));
5708
5709 for (i=1; i< rVar(r); i++)
5710 {
5711 for (j=i+1; j<=rVar(r); j++)
5712 {
5713 ni = r->N +1 - i;
5714 nj = r->N +1 - j; /* i<j ==> nj < ni */
5715
5716 assume(MATELEM(src->GetNC()->C,i,j) != NULL);
5717 MATELEM(C,nj,ni) = p_PermPoly(MATELEM(src->GetNC()->C,i,j),perm,src,r, nMap,par_perm,rPar(src));
5718
5719 if(MATELEM(src->GetNC()->D,i,j) != NULL)
5720 MATELEM(D,nj,ni) = p_PermPoly(MATELEM(src->GetNC()->D,i,j),perm,src,r, nMap,par_perm,rPar(src));
5721 }
5722 }
5723
5724 id_Test((ideal)C, r);
5725 id_Test((ideal)D, r);
5726
5727 if (nc_CallPlural(C, D, NULL, NULL, r, false, false, true, r)) // no qring setup!
5728 WarnS("Error initializing non-commutative multiplication!");
5729
5730#ifdef RDEBUG
5731 rTest(r);
5732// rWrite(r);
5733// rDebugPrint(r);
5734#endif
5735
5736 assume( r->GetNC()->IsSkewConstant == src->GetNC()->IsSkewConstant);
5737
5738 omFreeSize((ADDRESS)perm,(rVar(r)+1)*sizeof(int));
5739 }
5740#endif /* HAVE_PLURAL */
5741
5742 /* now oppose the qideal for qrings */
5743 if (src->qideal != NULL)
5744 {
5745#ifdef HAVE_PLURAL
5746 r->qideal = idOppose(src, src->qideal, r); // into the currRing: r
5747#else
5748 r->qideal = id_Copy(src->qideal, r); // ?
5749#endif
5750
5751#ifdef HAVE_PLURAL
5752 if( rIsPluralRing(r) )
5753 {
5755#ifdef RDEBUG
5756 rTest(r);
5757// rWrite(r);
5758// rDebugPrint(r);
5759#endif
5760 }
5761#endif
5762 }
5763#ifdef HAVE_PLURAL
5764 if( rIsPluralRing(r) )
5765 assume( ncRingType(r) == ncRingType(src) );
5766#endif
5767 rTest(r);
5768
5769 return r;
5770}
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:700
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
#define D(A)
Definition: gentable.cc:131
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
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
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
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:4195
#define rOppVar(R, I)
Definition: ring.cc:5379
const char * rSimpleOrdStr(int ord)
Definition: ring.cc:77
static void rOppWeight(int *w, int l)
Definition: ring.cc:5366
static int rRealloc1(ring r, int size, int pos)
Definition: ring.cc:5343
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:600
#define id_Test(A, lR)
Definition: simpleideals.h:78

◆ rOrd_is_Comp_dp()

static BOOLEAN rOrd_is_Comp_dp ( const ring  r)
inlinestatic

Definition at line 776 of file ring.h.

777{
778 assume(r != NULL);
779 assume(r->cf != NULL);
780 return ((r->order[0] == ringorder_c || r->order[0] == ringorder_C) &&
781 r->order[1] == ringorder_dp &&
782 r->order[2] == 0);
783}

◆ rOrd_is_Totaldegree_Ordering()

BOOLEAN rOrd_is_Totaldegree_Ordering ( const ring  r)

Definition at line 2013 of file ring.cc.

2014{
2015 // Hmm.... what about Syz orderings?
2016 return (rVar(r) > 1 &&
2017 ((rHasSimpleOrder(r) &&
2018 (rOrder_is_DegOrdering((rRingOrder_t)r->order[0]) ||
2019 rOrder_is_DegOrdering(( rRingOrder_t)r->order[1]))) ||
2020 (rHasSimpleOrderAA(r) &&
2021 (rOrder_is_DegOrdering((rRingOrder_t)r->order[1]) ||
2022 ((r->order[1]!=0) &&
2023 rOrder_is_DegOrdering((rRingOrder_t)r->order[2]))))));
2024}
BOOLEAN rOrder_is_DegOrdering(const rRingOrder_t order)
Definition: ring.cc:1928
BOOLEAN rHasSimpleOrderAA(ring r)
Definition: ring.cc:1962

◆ rOrd_SetCompRequiresSetm()

BOOLEAN rOrd_SetCompRequiresSetm ( const ring  r)

return TRUE if p_SetComp requires p_Setm

Definition at line 1993 of file ring.cc.

1994{
1995 if (r->typ != NULL)
1996 {
1997 int pos;
1998 for (pos=0;pos<r->OrdSize;pos++)
1999 {
2000 sro_ord* o=&(r->typ[pos]);
2001 if ( (o->ord_typ == ro_syzcomp)
2002 || (o->ord_typ == ro_syz)
2003 || (o->ord_typ == ro_is)
2004 || (o->ord_typ == ro_am)
2005 || (o->ord_typ == ro_isTemp))
2006 return TRUE;
2007 }
2008 }
2009 return FALSE;
2010}
ro_typ ord_typ
Definition: ring.h:220

◆ rOrderName()

rRingOrder_t rOrderName ( char *  ordername)

Definition at line 507 of file ring.cc.

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

◆ rOrdStr()

char * rOrdStr ( ring  r)

Definition at line 521 of file ring.cc.

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

◆ rPar()

static int rPar ( const ring  r)
inlinestatic

(r->cf->P)

Definition at line 600 of file ring.h.

601{
602 assume(r != NULL);
603 const coeffs C = r->cf;
604 assume(C != NULL);
605
606 return n_NumberOfParameters(C);
607// if( nCoeff_is_Extension(C) )
608// {
609// const ring R = C->extRing;
610// assume( R != NULL );
611// return rVar( R );
612// }
613// else if (nCoeff_is_GF(C))
614// {
615// return 1;
616// }
617// else if (nCoeff_is_long_C(C))
618// {
619// return 1;
620// }
621// return 0;
622}
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:774

◆ rParameter()

static char const ** rParameter ( const ring  r)
inlinestatic

(r->cf->parameter)

Definition at line 626 of file ring.h.

627{
628 assume(r != NULL);
629 const coeffs C = r->cf;
630 assume(C != NULL);
631
632 return n_ParameterNames(C);
633// if( nCoeff_is_Extension(C) ) // only alg / trans. exts...
634// {
635// const ring R = C->extRing;
636// assume( R != NULL );
637// return R->names;
638// }
639// else if (nCoeff_is_GF(C))
640// {
641// return &(C->m_nfParameter);
642// }
643// else if (nCoeff_is_long_C(C))
644// {
645// return &(C->complex_parameter);
646// }
647// return NULL;
648}
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:778

◆ rParStr()

char * rParStr ( ring  r)

Definition at line 649 of file ring.cc.

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

◆ rPlusVar()

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

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

Definition at line 5918 of file ring.cc.

5919{
5920 if (r->order[2]!=0)
5921 {
5922 WerrorS("only for rings with an ordering of one block");
5923 return NULL;
5924 }
5925 int p;
5926 if((r->order[0]==ringorder_C)
5927 ||(r->order[0]==ringorder_c))
5928 p=1;
5929 else
5930 p=0;
5931 if((r->order[p]!=ringorder_dp)
5932 && (r->order[p]!=ringorder_Dp)
5933 && (r->order[p]!=ringorder_lp)
5934 && (r->order[p]!=ringorder_rp)
5935 && (r->order[p]!=ringorder_ds)
5936 && (r->order[p]!=ringorder_Ds)
5937 && (r->order[p]!=ringorder_ls))
5938 {
5939 WerrorS("ordering must be dp,Dp,lp,rp,ds,Ds or ls");
5940 return NULL;
5941 }
5942 for(int i=r->N-1;i>=0;i--)
5943 {
5944 if (strcmp(r->names[i],v)==0)
5945 {
5946 Werror("duplicate variable name >>%s<<",v);
5947 return NULL;
5948 }
5949 }
5950 ring R=rCopy0(r);
5951 char **names;
5952 #ifdef HAVE_SHIFTBBA
5953 if (rIsLPRing(r))
5954 {
5955 R->isLPring=r->isLPring+1;
5956 R->N=((r->N)/r->isLPring)+r->N;
5957 names=(char**)omAlloc(R->N*sizeof(char_ptr));
5958 if (left)
5959 {
5960 for(int b=0;b<((r->N)/r->isLPring);b++)
5961 {
5962 names[b*R->isLPring]=omStrDup(v);
5963 for(int i=R->isLPring-1;i>0;i--)
5964 names[i+b*R->isLPring]=R->names[i-1+b*r->isLPring];
5965 }
5966 }
5967 else
5968 {
5969 for(int b=0;b<((r->N)/r->isLPring);b++)
5970 {
5971 names[(b+1)*R->isLPring-1]=omStrDup(v);
5972 for(int i=R->isLPring-2;i>=0;i--)
5973 names[i+b*R->isLPring]=R->names[i+b*r->isLPring];
5974 }
5975 }
5976 }
5977 else
5978 #endif
5979 {
5980 R->N++;
5981 names=(char**)omAlloc(R->N*sizeof(char_ptr));
5982 if (left)
5983 {
5984 names[0]=omStrDup(v);
5985 for(int i=R->N-1;i>0;i--) names[i]=R->names[i-1];
5986 }
5987 else
5988 {
5989 names[R->N-1]=omStrDup(v);
5990 for(int i=R->N-2;i>=0;i--) names[i]=R->names[i];
5991 }
5992 }
5993 omFreeSize(R->names,r->N*sizeof(char_ptr));
5994 R->names=names;
5995 R->block1[p]=R->N;
5996 rComplete(R);
5997 return R;
5998}
CanonicalForm b
Definition: cfModGcd.cc:4103

◆ rRing_has_CompLastBlock()

BOOLEAN rRing_has_CompLastBlock ( const ring  r)

Definition at line 5286 of file ring.cc.

5287{
5288 assume(r != NULL);
5289 int lb = rBlocks(r) - 2;
5290 return (r->order[lb] == ringorder_c || r->order[lb] == ringorder_C);
5291}

◆ rRing_is_Homog()

BOOLEAN rRing_is_Homog ( const ring  r)

Definition at line 5265 of file ring.cc.

5266{
5267 if (r == NULL) return FALSE;
5268 int i, j, nb = rBlocks(r);
5269 for (i=0; i<nb; i++)
5270 {
5271 if (r->wvhdl[i] != NULL)
5272 {
5273 int length = r->block1[i] - r->block0[i]+1;
5274 int* wvhdl = r->wvhdl[i];
5275 if (r->order[i] == ringorder_M) length *= length;
5276
5277 for (j=0; j< length; j++)
5278 {
5279 if (wvhdl[j] != 0 && wvhdl[j] != 1) return FALSE;
5280 }
5281 }
5282 }
5283 return TRUE;
5284}

◆ rRing_ord_pure_dp()

BOOLEAN rRing_ord_pure_dp ( const ring  r)

Definition at line 5293 of file ring.cc.

5294{
5295 if ((r->order[0]==ringorder_dp) &&(r->block0[0]==1) &&(r->block1[0]==r->N))
5296 return TRUE;
5297 if (((r->order[0]==ringorder_c)||(r->order[0]==ringorder_C))
5298 && ((r->order[1]==ringorder_dp) &&(r->block0[1]==1) &&(r->block1[1]==r->N)))
5299 return TRUE;
5300 return FALSE;
5301}

◆ rRing_ord_pure_Dp()

BOOLEAN rRing_ord_pure_Dp ( const ring  r)

Definition at line 5303 of file ring.cc.

5304{
5305 if ((r->order[0]==ringorder_Dp) &&(r->block0[0]==1) &&(r->block1[0]==r->N))
5306 return TRUE;
5307 if (((r->order[0]==ringorder_c)||(r->order[0]==ringorder_C))
5308 && ((r->order[1]==ringorder_Dp) &&(r->block0[1]==1) &&(r->block1[1]==r->N)))
5309 return TRUE;
5310 return FALSE;
5311}

◆ rRing_ord_pure_lp()

BOOLEAN rRing_ord_pure_lp ( const ring  r)

Definition at line 5313 of file ring.cc.

5314{
5315 if ((r->order[0]==ringorder_lp) &&(r->block0[0]==1) &&(r->block1[0]==r->N))
5316 return TRUE;
5317 if (((r->order[0]==ringorder_c)||(r->order[0]==ringorder_C))
5318 && ((r->order[1]==ringorder_lp) &&(r->block0[1]==1) &&(r->block1[1]==r->N)))
5319 return TRUE;
5320 return FALSE;
5321}

◆ rRingVar()

static char * rRingVar ( short  i,
const ring  r 
)
inlinestatic

Definition at line 578 of file ring.h.

579{
580 assume(r != NULL); assume(r->cf != NULL); return r->names[i];
581}

◆ 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 1799 of file ring.cc.

1800{
1801 int i, j;
1802
1803 if (r1 == r2) return TRUE;
1804
1805 if (r1 == NULL || r2 == NULL) return FALSE;
1806
1807 if ((r1->cf != r2->cf)
1808 || (rVar(r1) != rVar(r2))
1809 || (r1->OrdSgn != r2->OrdSgn))
1810 return FALSE;
1811
1812 i=0;
1813 while (r1->order[i] != 0)
1814 {
1815 if (r2->order[i] == 0) return FALSE;
1816 if ((r1->order[i] != r2->order[i])
1817 || (r1->block0[i] != r2->block0[i])
1818 || (r1->block1[i] != r2->block1[i]))
1819 return FALSE;
1820 if (r1->wvhdl[i] != NULL)
1821 {
1822 if (r2->wvhdl[i] == NULL)
1823 return FALSE;
1824 for (j=0; j<r1->block1[i]-r1->block0[i]+1; j++)
1825 if (r2->wvhdl[i][j] != r1->wvhdl[i][j])
1826 return FALSE;
1827 }
1828 else if (r2->wvhdl[i] != NULL) return FALSE;
1829 i++;
1830 }
1831 if (r2->order[i] != 0) return FALSE;
1832
1833 // we do not check variable names
1834 // we do not check minpoly/minideal
1835 // we do not check qideal
1836
1837 return TRUE;
1838}

◆ rSetISReference()

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

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 5112 of file ring.cc.

5113{
5114 // Put the reference set F into the ring -ordering -recor
5115
5116 if (r->typ==NULL)
5117 {
5118 dReportError("Error: WRONG USE of rSetISReference: wrong ring! (typ == NULL)");
5119 return FALSE;
5120 }
5121
5122
5123 int pos = rGetISPos(p, r);
5124
5125 if( pos == -1 )
5126 {
5127 dReportError("Error: WRONG USE of rSetISReference: specified ordering block was not found!!!" );
5128 return FALSE;
5129 }
5130
5131#if MYTEST
5132 if( i != r->typ[pos].data.is.limit )
5133 Print("Changing record on pos: %d\nOld limit: %d --->> New Limit: %d\n", pos, r->typ[pos].data.is.limit, i);
5134#endif
5135
5136 const ideal FF = idrHeadR(F, r, r); // id_Copy(F, r); // ???
5137
5138
5139 if( r->typ[pos].data.is.F != NULL)
5140 {
5141#if MYTEST
5142 PrintS("Deleting old reference set F... \n"); // idShow(r->typ[pos].data.is.F, r); PrintLn();
5143#endif
5144 id_Delete(&r->typ[pos].data.is.F, r);
5145 r->typ[pos].data.is.F = NULL;
5146 }
5147
5148 assume(r->typ[pos].data.is.F == NULL);
5149
5150 r->typ[pos].data.is.F = FF; // F is owened by ring now! TODO: delete at the end!
5151
5152 r->typ[pos].data.is.limit = i; // First induced component
5153
5154#if MYTEST
5155 PrintS("New reference set FF : \n"); idShow(FF, r, r, 1); PrintLn();
5156#endif
5157
5158 return TRUE;
5159}
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:5080
void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint)
Definition: simpleideals.cc:57

◆ rSetSyzComp()

void rSetSyzComp ( int  k,
const ring  r 
)

Definition at line 5166 of file ring.cc.

5167{
5168 if(k < 0)
5169 {
5170 dReportError("rSetSyzComp with negative limit!");
5171 return;
5172 }
5173
5174 assume( k >= 0 );
5175 if (TEST_OPT_PROT) Print("{%d}", k);
5176 if ((r->typ!=NULL) && (r->typ[0].ord_typ==ro_syz))
5177 {
5178 r->block0[0]=r->block1[0] = k;
5179 if( k == r->typ[0].data.syz.limit )
5180 return; // nothing to do
5181
5182 int i;
5183 if (r->typ[0].data.syz.limit == 0)
5184 {
5185 r->typ[0].data.syz.syz_index = (int*) omAlloc0((k+1)*sizeof(int));
5186 r->typ[0].data.syz.syz_index[0] = 0;
5187 r->typ[0].data.syz.curr_index = 1;
5188 }
5189 else
5190 {
5191 r->typ[0].data.syz.syz_index = (int*)
5192 omReallocSize(r->typ[0].data.syz.syz_index,
5193 (r->typ[0].data.syz.limit+1)*sizeof(int),
5194 (k+1)*sizeof(int));
5195 }
5196 for (i=r->typ[0].data.syz.limit + 1; i<= k; i++)
5197 {
5198 r->typ[0].data.syz.syz_index[i] =
5199 r->typ[0].data.syz.curr_index;
5200 }
5201 if(k < r->typ[0].data.syz.limit) // ?
5202 {
5203#ifndef SING_NDEBUG
5204 Warn("rSetSyzComp called with smaller limit (%d) as before (%d)", k, r->typ[0].data.syz.limit);
5205#endif
5206 r->typ[0].data.syz.curr_index = 1 + r->typ[0].data.syz.syz_index[k];
5207 }
5208
5209
5210 r->typ[0].data.syz.limit = k;
5211 r->typ[0].data.syz.curr_index++;
5212 }
5213 else if(
5214 (r->typ!=NULL) &&
5215 (r->typ[0].ord_typ==ro_isTemp)
5216 )
5217 {
5218// (r->typ[currRing->typ[0].data.isTemp.suffixpos].data.is.limit == k)
5219#ifndef SING_NDEBUG
5220 Warn("rSetSyzComp(%d) in an IS ring! Be careful!", k);
5221#endif
5222 }
5223 else if (r->order[0]==ringorder_s)
5224 {
5225 r->block0[0] = r->block1[0] = k;
5226 }
5227 else if (r->order[0]!=ringorder_c)
5228 {
5229 dReportError("syzcomp in incompatible ring");
5230 }
5231#ifdef PDEBUG
5233 pDBsyzComp=k;
5234#endif
5235}
#define EXTERN_VAR
Definition: globaldefs.h:6
#define TEST_OPT_PROT
Definition: options.h:103
VAR int pDBsyzComp
Definition: ring.cc:5162

◆ rSetWeightVec()

void rSetWeightVec ( ring  r,
int64 wv 
)

Definition at line 5333 of file ring.cc.

5334{
5335 assume(r!=NULL);
5336 assume(r->OrdSize>0);
5337 assume(r->typ[0].ord_typ==ro_wp64);
5338 memcpy(r->typ[0].data.wp64.weights64,wv,r->N*sizeof(int64));
5339}

◆ rShortOut()

static BOOLEAN rShortOut ( const ring  r)
inlinestatic

Definition at line 582 of file ring.h.

583{
584 assume(r != NULL); return (r->ShortOut);
585}

◆ 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 673 of file ring.cc.

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

◆ rSum()

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

Definition at line 1402 of file ring.cc.

1403{
1404 if ((r1==NULL)||(r2==NULL)
1405 ||(r1->cf==NULL)||(r2->cf==NULL))
1406 return -1;
1407 if (r1==r2)
1408 {
1409 sum=r1;
1410 rIncRefCnt(r1);
1411 return 0;
1412 }
1413 return rSumInternal(r1,r2,sum,TRUE,FALSE);
1414}
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:749
static ring rIncRefCnt(ring r)
Definition: ring.h:843

◆ 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 749 of file ring.cc.

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

4008{
4009 if (r == NULL) return;
4010 if (r->VarOffset != NULL)
4011 {
4012 if (r->OrdSize!=0 && r->typ != NULL)
4013 {
4014 for(int i = 0; i < r->OrdSize; i++)
4015 if( r->typ[i].ord_typ == ro_is) // Search for suffixes! (prefix have the same VarOffset)
4016 {
4017 id_Delete(&r->typ[i].data.is.F, r);
4018
4019 if( r->typ[i].data.is.pVarOffset != NULL )
4020 {
4021 omFreeSize((ADDRESS)r->typ[i].data.is.pVarOffset, (r->N +1)*sizeof(int));
4022 }
4023 }
4024 else if (r->typ[i].ord_typ == ro_syz)
4025 {
4026 if(r->typ[i].data.syz.limit > 0)
4027 omFreeSize(r->typ[i].data.syz.syz_index, ((r->typ[i].data.syz.limit) +1)*sizeof(int));
4028 }
4029 else if (r->typ[i].ord_typ == ro_syzcomp)
4030 {
4031 assume( r->typ[i].data.syzcomp.ShiftedComponents == NULL );
4032 assume( r->typ[i].data.syzcomp.Components == NULL );
4033// WarnS( "rUnComplete : ord_typ == ro_syzcomp was unhandled!!! Possibly memory leak!!!" );
4034#ifndef SING_NDEBUG
4035// assume(0);
4036#endif
4037 }
4038
4039 omFreeSize((ADDRESS)r->typ,r->OrdSize*sizeof(sro_ord)); r->typ = NULL;
4040 }
4041
4042 if (r->PolyBin != NULL)
4043 omUnGetSpecBin(&(r->PolyBin));
4044
4045 omFreeSize((ADDRESS)r->VarOffset, (r->N +1)*sizeof(int));
4046 r->VarOffset=NULL;
4047
4048 if (r->ordsgn != NULL && r->CmpL_Size != 0)
4049 {
4050 omFreeSize((ADDRESS)r->ordsgn,r->ExpL_Size*sizeof(long));
4051 r->ordsgn=NULL;
4052 }
4053 if (r->p_Procs != NULL)
4054 {
4055 omFreeSize(r->p_Procs, sizeof(p_Procs_s));
4056 r->p_Procs=NULL;
4057 }
4058 omfreeSize(r->VarL_Offset, r->VarL_Size*sizeof(int));
4059 r->VarL_Offset=NULL;
4060 }
4061 if (r->NegWeightL_Offset!=NULL)
4062 {
4063 omFreeSize(r->NegWeightL_Offset, r->NegWeightL_Size*sizeof(int));
4064 r->NegWeightL_Offset=NULL;
4065 }
4066}
#define omfreeSize(addr, size)
Definition: omAllocDecl.h:236
#define omUnGetSpecBin(bin_ptr)
Definition: omBin.h:14

◆ rVar()

static short rVar ( const ring  r)
inlinestatic

#define rVar(r) (r->N)

Definition at line 593 of file ring.h.

594{
595 assume(r != NULL);
596 return r->N;
597}

◆ rVarStr()

char * rVarStr ( ring  r)

Definition at line 623 of file ring.cc.

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

◆ rWrite()

void rWrite ( ring  r,
BOOLEAN  details = FALSE 
)

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_a64)
355 &&(r->order[l] != ringorder_am)
356 &&(r->order[l] != ringorder_M))
357 {
358 Warn("should not have wvhdl entry at pos. %d",l);
359 }
360 #endif
361 for (int j= 0;
362 j<(r->block1[l]-r->block0[l]+1)*(r->block1[l]-r->block0[l]+1);
363 j+=i)
364 {
365 PrintS("\n// : weights ");
366 for (i = 0; i<=r->block1[l]-r->block0[l]; i++)
367 {
368 if (r->order[l] == ringorder_a64)
369 {
370 int64 *w=(int64 *)r->wvhdl[l];
371 #if SIZEOF_LONG == 4
372 Print("%*lld " ,nlen,w[i+j]);
373 #else
374 Print(" %*ld" ,nlen,w[i+j]);
375 #endif
376 }
377 else
378 Print(" %*d" ,nlen,r->wvhdl[l][i+j]);
379 }
380 if (r->order[l]!=ringorder_M) break;
381 }
382 if (r->order[l]==ringorder_am)
383 {
384 int m=r->wvhdl[l][i];
385 Print("\n// : %d module weights ",m);
386 m+=i;i++;
387 for(;i<=m;i++) Print(" %*d" ,nlen,r->wvhdl[l][i]);
388 }
389 }
390 }
391#ifdef HAVE_PLURAL
392 if(rIsPluralRing(r))
393 {
394 PrintS("\n// noncommutative relations:");
395 if( details )
396 {
397 poly pl=NULL;
398 int nl;
399 int i,j;
400 for (i = 1; i<r->N; i++)
401 {
402 for (j = i+1; j<=r->N; j++)
403 {
404 nl = n_IsOne(p_GetCoeff(MATELEM(r->GetNC()->C,i,j),r), r->cf);
405 if ( (MATELEM(r->GetNC()->D,i,j)!=NULL) || (!nl) )
406 {
407 Print("\n// %s%s=",r->names[j-1],r->names[i-1]);
408 pl = MATELEM(r->GetNC()->MT[UPMATELEM(i,j,r->N)],1,1);
409 p_Write0(pl, r, r);
410 }
411 }
412 }
413 } else
414 PrintS(" ...");
415
416#if MYTEST /*Singularg should not differ from Singular except in error case*/
417 Print("\n// noncommutative type:%d", (int)ncRingType(r));
418 Print("\n// is skew constant:%d",r->GetNC()->IsSkewConstant);
419 if( rIsSCA(r) )
420 {
421 Print("\n// alternating variables: [%d, %d]", scaFirstAltVar(r), scaLastAltVar(r));
422 const ideal Q = SCAQuotient(r); // resides within r!
423 PrintS("\n// quotient of sca by ideal");
424
425 if (Q!=NULL)
426 {
427 iiWriteMatrix((matrix)Q,"scaQ",1,r,0);
428 }
429 else
430 PrintS(" (NULL)");
431 }
432#endif
433 }
434 if (rIsLPRing(r))
435 {
436 Print("\n// letterplace ring (block size %d, ncgen count %d)",r->isLPring, r->LPncGenCount);
437 }
438#endif
439 if (r->qideal!=NULL)
440 {
441 PrintS("\n// quotient ring from ideal");
442 if( details )
443 {
444 PrintLn();
445 iiWriteMatrix((matrix)r->qideal,"_",1,r,0);
446 } else PrintS(" ...");
447 }
448}
static FORCE_INLINE void n_CoeffWrite(const coeffs r, BOOLEAN details=TRUE)
output the coeff description
Definition: coeffs.h:719
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:468
#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
#define p_GetCoeff(p, r)
Definition: monomials.h:50
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:332
static BOOLEAN rShortOut(const ring r)
Definition: ring.h:582
static BOOLEAN rCanShortOut(const ring r)
Definition: ring.h:587
ideal SCAQuotient(const ring r)
Definition: sca.h:10

Variable Documentation

◆ sip_sring_bin

EXTERN_VAR omBin sip_sring_bin

Definition at line 834 of file ring.h.