My Project
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
nc.h File Reference
#include "polys/monomials/ring.h"
#include "polys/kbuckets.h"
#include "polys/matpol.h"

Go to the source code of this file.

Data Structures

struct  nc_pProcs
 
struct  nc_struct
 

Macros

#define UPMATELEM(i, j, nVar)   ( (nVar * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1)-(i) )
 

Typedefs

typedef poly(* SPoly_Proc_Ptr) (const poly p1, const poly p2, const ring r)
 
typedef poly(* SPolyReduce_Proc_Ptr) (const poly p1, poly p2, const ring r)
 
typedef void(* bucket_Proc_Ptr) (kBucket_pt b, poly p, number *c)
 

Enumerations

enum  nc_type {
  nc_error = -1 , nc_general = 0 , nc_skew , nc_comm ,
  nc_lie , nc_undef , nc_exterior
}
 

Functions

matrix nc_PrintMat (int a, int b, ring r, int metric)
 returns matrix with the info on noncomm multiplication More...
 
BOOLEAN rIsLikeOpposite (ring rBase, ring rCandidate)
 checks whether rings rBase and rCandidate could be opposite to each other returns TRUE if it is so More...
 
void nc_rKill (ring r)
 complete destructor More...
 
BOOLEAN nc_CheckSubalgebra (poly PolyVar, ring r)
 
static nc_struct *& GetNC (ring r)
 
static nc_typencRingType (nc_struct *p)
 
static nc_type ncRingType (ring r)
 
static void ncRingType (ring r, nc_type t)
 
static void ncRingType (nc_struct *p, nc_type t)
 
static bool rIsSCA (const ring r)
 
poly _nc_p_Mult_q (poly p, poly q, const ring r)
 general NC-multiplication with destruction More...
 
poly _nc_pp_Mult_qq (const poly p, const poly q, const ring r)
 general NC-multiplication without destruction More...
 
poly nc_p_Minus_mm_Mult_qq (poly p, const poly m, const poly q, int &lp, const poly, const ring r)
 for p_Minus_mm_Mult_qq in pInline2.h More...
 
poly nc_p_Plus_mm_Mult_qq (poly p, const poly m, const poly q, int &lp, const int, const ring r)
 
static poly nc_mm_Mult_pp (const poly m, const poly p, const ring r)
 
static poly nc_mm_Mult_p (const poly m, poly p, const ring r)
 
static poly nc_CreateSpoly (const poly p1, const poly p2, const ring r)
 
poly nc_CreateShortSpoly (poly p1, poly p2, const ring r)
 
poly nc_p_Bracket_qq (poly p, const poly q, const ring r)
 returns [p,q], destroys p More...
 
static poly nc_ReduceSpoly (const poly p1, poly p2, const ring r)
 
void nc_PolyPolyRed (poly &b, poly p, number *c, const ring r)
 
static void nc_kBucketPolyRed_NF (kBucket_pt b, poly p, number *c)
 
static void nc_kBucketPolyRed_Z (kBucket_pt b, poly p, number *c)
 
poly nc_pSubst (poly p, int n, poly e, const ring r)
 substitute the n-th variable by e in p destroy p e is not a constant More...
 
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, DO NOT initialize multiplication but call for it at the end checks the ordering condition and evtl. NDC NOTE: all the data belong to the curr, we change r which may be the same ring, and must have the same representation! More...
 
bool nc_SetupQuotient (ring rGR, const ring rG=NULL, bool bCopy=false)
 
BOOLEAN nc_rComplete (const ring src, ring dest, bool bSetupQuotient=true)
 
bool nc_rCopy (ring res, const ring r, bool bSetupQuotient)
 
poly pOppose (ring Rop_src, poly p, const ring Rop_dst)
 opposes a vector p from Rop to currRing (dst!) More...
 
ideal idOppose (ring Rop_src, ideal I, const ring Rop_dst)
 opposes a module I from Rop to currRing(dst) More...
 
int & getNCExtensions ()
 
int setNCExtensions (int iMask)
 
bool ncExtensions (int iMask)
 
void nc_p_ProcsSet (ring rGR, p_Procs_s *p_Procs)
 
static poly GetC (const ring r, int i, int j)
 
static poly GetD (const ring r, int i, int j)
 

Variables

const int GENERICMASK = 0x000
 
const int SCAMASK = 0x001
 
const int NOPLURALMASK = 0x002
 
const int NOFORMULAMASK =0x004
 
const int NOCACHEMASK = 0x008
 
const int TESTSYZSCAMASK = 0x0100 | SCAMASK
 

Data Structure Documentation

◆ nc_pProcs

struct nc_pProcs

Definition at line 50 of file nc.h.

Data Fields
bucket_Proc_Ptr BucketPolyRed_NF
bucket_Proc_Ptr BucketPolyRed_Z
void * GB From "gb_hack.h".
SPolyReduce_Proc_Ptr ReduceSPoly
SPoly_Proc_Ptr SPoly

Macro Definition Documentation

◆ UPMATELEM

#define UPMATELEM (   i,
  j,
  nVar 
)    ( (nVar * ((i)-1) - ((i) * ((i)-1))/2 + (j)-1)-(i) )

Definition at line 36 of file nc.h.

Typedef Documentation

◆ bucket_Proc_Ptr

typedef void(* bucket_Proc_Ptr) (kBucket_pt b, poly p, number *c)

Definition at line 48 of file nc.h.

◆ SPoly_Proc_Ptr

typedef poly(* SPoly_Proc_Ptr) (const poly p1, const poly p2, const ring r)

Definition at line 45 of file nc.h.

◆ SPolyReduce_Proc_Ptr

typedef poly(* SPolyReduce_Proc_Ptr) (const poly p1, poly p2, const ring r)

Definition at line 46 of file nc.h.

Enumeration Type Documentation

◆ nc_type

enum nc_type
Enumerator
nc_error 
nc_general 
nc_skew 
nc_comm 
nc_lie 
nc_undef 
nc_exterior 

Definition at line 12 of file nc.h.

13 {
14  nc_error = -1, // Something's gone wrong!
15  nc_general = 0, /* yx=q xy+... */
16  nc_skew, /*1*/ /* yx=q xy */
17  nc_comm, /*2*/ /* yx= xy */
18  nc_lie, /*3*/ /* yx=xy+... */
19  nc_undef, /*4*/ /* for internal reasons */
20 
21  nc_exterior /*5*/ // Exterior Algebra(SCA): yx= -xy & (!:) x^2 = 0
22 };
@ nc_skew
Definition: nc.h:16
@ nc_lie
Definition: nc.h:18
@ nc_error
Definition: nc.h:14
@ nc_general
Definition: nc.h:15
@ nc_exterior
Definition: nc.h:21
@ nc_undef
Definition: nc.h:19
@ nc_comm
Definition: nc.h:17

Function Documentation

◆ _nc_p_Mult_q()

poly _nc_p_Mult_q ( poly  p,
poly  q,
const ring  r 
)

general NC-multiplication with destruction

Definition at line 215 of file old.gring.cc.

216 {
217  assume( rIsNCRing(rRing) );
218 #ifdef PDEBUG
219  p_Test(pPolyP, rRing);
220  p_Test(pPolyQ, rRing);
221 #endif
222 #ifdef RDEBUG
223  rTest(rRing);
224 #endif
225 
226  int lp, lq;
227 
228  pqLength(pPolyP, pPolyQ, lp, lq, MIN_LENGTH_BUCKET);
229 
230  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (si_max(lp, lq) < MIN_LENGTH_BUCKET); // ???
231 
232  CPolynomialSummator sum(rRing, bUsePolynomial);
233 
234  if (lq <= lp) // ?
235  {
236  // always length(q) times "p * q[j]"
237  for( ; pPolyQ!=NULL; pPolyQ = p_LmDeleteAndNext( pPolyQ, rRing ) )
238  sum += pp_Mult_mm( pPolyP, pPolyQ, rRing);
239 
240  p_Delete( &pPolyP, rRing );
241  } else
242  {
243  // always length(p) times "p[i] * q"
244  for( ; pPolyP!=NULL; pPolyP = p_LmDeleteAndNext( pPolyP, rRing ) )
245  sum += nc_mm_Mult_pp( pPolyP, pPolyQ, rRing);
246 
247  p_Delete( &pPolyQ, rRing );
248  }
249 
250  return(sum);
251 }
static int si_max(const int a, const int b)
Definition: auxiliary.h:124
CPolynomialSummator: unifies bucket and polynomial summation as the later is brocken in buckets :(.
Definition: summator.h:21
static poly nc_mm_Mult_pp(const poly m, const poly p, const ring r)
Definition: nc.h:224
#define assume(x)
Definition: mod2.h:387
Definition: lq.h:40
#define NULL
Definition: omList.c:12
#define TEST_OPT_NOT_BUCKETS
Definition: options.h:105
BOOLEAN pqLength(poly p, poly q, int &lp, int &lq, const int min)
return TRUE and lp == pLength(p), lq == pLength(q), if min(pLength(p), pLength(q)) >= min FALSE if mi...
Definition: p_Mult_q.cc:31
#define MIN_LENGTH_BUCKET
Definition: p_Mult_q.h:21
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:1003
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:873
static poly p_LmDeleteAndNext(poly p, const ring r)
Definition: p_polys.h:731
#define p_Test(p, r)
Definition: p_polys.h:162
static BOOLEAN rIsNCRing(const ring r)
Definition: ring.h:421
#define rTest(r)
Definition: ring.h:786

◆ _nc_pp_Mult_qq()

poly _nc_pp_Mult_qq ( const poly  p,
const poly  q,
const ring  r 
)

general NC-multiplication without destruction

Definition at line 254 of file old.gring.cc.

255 {
256  assume( rIsNCRing(rRing) );
257 #ifdef PDEBUG
258  p_Test(pPolyP, rRing);
259  p_Test(pPolyQ, rRing);
260 #endif
261 #ifdef RDEBUG
262  rTest(rRing);
263 #endif
264 
265  int lp, lq;
266 
267  pqLength(pPolyP, pPolyQ, lp, lq, MIN_LENGTH_BUCKET);
268 
269  bool bUsePolynomial = TEST_OPT_NOT_BUCKETS || (si_max(lp, lq) < MIN_LENGTH_BUCKET); // ???
270 
271  CPolynomialSummator sum(rRing, bUsePolynomial);
272 
273  if (lq <= lp) // ?
274  {
275  // always length(q) times "p * q[j]"
276  for( poly q = pPolyQ; q !=NULL; q = pNext(q) )
277  sum += pp_Mult_mm(pPolyP, q, rRing);
278  } else
279  {
280  // always length(p) times "p[i] * q"
281  for( poly p = pPolyP; p !=NULL; p = pNext(p) )
282  sum += nc_mm_Mult_pp( p, pPolyQ, rRing);
283  }
284 
285  return(sum);
286 }
int p
Definition: cfModGcd.cc:4078
#define pNext(p)
Definition: monomials.h:36

◆ GetC()

static poly GetC ( const ring  r,
int  i,
int  j 
)
inlinestatic

Definition at line 366 of file nc.h.

367 {
368  assume(r!= NULL && rIsPluralRing(r));
369  const matrix C = GetNC(r)->C;
370  assume(C != NULL);
371  const int ncols = C->ncols;
372  assume( (i > 0) && (i < j) && (j <= ncols) );
373  return ( C->m[ncols * ((i)-1) + (j)-1] );
374 }
int i
Definition: cfEzgcd.cc:132
int int ncols
Definition: cf_linsys.cc:32
int ncols
Definition: matpol.h:21
poly * m
Definition: matpol.h:18
int j
Definition: facHensel.cc:110
static nc_struct *& GetNC(ring r)
Definition: nc.h:154
static BOOLEAN rIsPluralRing(const ring r)
we must always have this test!
Definition: ring.h:400
matrix C
Definition: nc.h:75

◆ GetD()

static poly GetD ( const ring  r,
int  i,
int  j 
)
inlinestatic

Definition at line 377 of file nc.h.

378 {
379  assume(r!= NULL && rIsPluralRing(r));
380  const matrix D = GetNC(r)->D;
381  assume(D != NULL);
382  const int ncols = D->ncols;
383  assume( (i > 0) && (i < j) && (j <= ncols) );
384  return ( D->m[ncols * ((i)-1) + (j)-1] );
385 }
#define D(A)
Definition: gentable.cc:131
matrix D
Definition: nc.h:76

◆ GetNC()

static nc_struct*& GetNC ( ring  r)
inlinestatic

Definition at line 154 of file nc.h.

155 {
156  return r->GetNC();
157 }

◆ getNCExtensions()

int& getNCExtensions ( )

Definition at line 82 of file old.gring.cc.

83 {
84  return (iNCExtensions);
85 }
VAR int iNCExtensions
Definition: old.gring.cc:80

◆ idOppose()

ideal idOppose ( ring  Rop_src,
ideal  I,
const ring  Rop_dst 
)

opposes a module I from Rop to currRing(dst)

Definition at line 3381 of file old.gring.cc.

3382 {
3383  /* the simplest case:*/
3384  if ( Rop == dst ) return id_Copy(I, dst);
3385 
3386  /* check Rop == rOpposite(currRing) */
3387  if (!rIsLikeOpposite(dst, Rop))
3388  {
3389  WarnS("an opposite ring should be used");
3390  return NULL;
3391  }
3392  int i;
3393  ideal idOp = idInit(I->ncols, I->rank);
3394  for (i=0; i< (I->ncols)*(I->nrows); i++)
3395  {
3396  idOp->m[i] = pOppose(Rop,I->m[i], dst);
3397  }
3398  id_Test(idOp, dst);
3399  return idOp;
3400 }
#define WarnS
Definition: emacs.cc:78
ideal id_Copy(ideal h1, const ring r)
copy an ideal
poly pOppose(ring Rop, poly p, const ring dst)
opposes a vector p from Rop to currRing (dst!)
Definition: old.gring.cc:3342
BOOLEAN rIsLikeOpposite(ring rBase, ring rCandidate)
checks whether rings rBase and rCandidate could be opposite to each other returns TRUE if it is so
Definition: old.gring.cc:3315
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define id_Test(A, lR)
Definition: simpleideals.h:78

◆ nc_CallPlural()

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, DO NOT initialize multiplication but call for it at the end checks the ordering condition and evtl. NDC NOTE: all the data belong to the curr, we change r which may be the same ring, and must have the same representation!

Definition at line 2682 of file old.gring.cc.

2687 {
2688  assume( r != NULL );
2689  assume( curr != NULL );
2690 
2691  if( !bSetupQuotient)
2692  assume( (r->qideal == NULL) ); // The basering must NOT be a qring!??
2693 
2694  assume( rSamePolyRep(r, curr) || bCopyInput ); // wrong assumption?
2695 
2696 
2697  if( r->N == 1 ) // clearly commutative!!!
2698  {
2699  assume(
2700  ( (CCC != NULL) && (MATCOLS(CCC) == 1) && (MATROWS(CCC) == 1) && (MATELEM(CCC,1,1) == NULL) ) ||
2701  ( (CCN == NULL) )
2702  );
2703 
2704  assume(
2705  ( (DDD != NULL) && (MATCOLS(DDD) == 1) && (MATROWS(DDD) == 1) && (MATELEM(DDD,1,1) == NULL) ) ||
2706  ( (DDN == NULL) )
2707  );
2708  if(!dummy_ring)
2709  {
2710  WarnS("commutative ring with 1 variable");
2711  return FALSE;
2712  }
2713  }
2714 
2715  // there must be:
2716  assume( (CCC != NULL) != (CCN != NULL) ); // exactly one data about coeffs (C).
2717  assume( !((DDD != NULL) && (DDN != NULL)) ); // at most one data about tails (D).
2718 
2719 #if OUTPUT
2720  if( CCC != NULL )
2721  {
2722  PrintS("nc_CallPlural(), Input data, CCC: \n");
2723  iiWriteMatrix(CCC, "C", 2, curr, 4);
2724  }
2725  if( DDD != NULL )
2726  {
2727  PrintS("nc_CallPlural(), Input data, DDD: \n");
2728  iiWriteMatrix(DDD, "D", 2, curr, 4);
2729  }
2730 #endif
2731 
2732 
2733 #ifndef SING_NDEBUG
2734  if (CCC!=NULL) id_Test((ideal)CCC, curr);
2735  if (DDD!=NULL) id_Test((ideal)DDD, curr);
2736  p_Test(CCN, curr);
2737  p_Test(DDN, curr);
2738 #endif
2739 
2740  if( (!bBeQuiet) && (r->GetNC() != NULL) )
2741  WarnS("going to redefine the algebra structure");
2742 
2743  matrix CC = NULL;
2744  poly CN = NULL;
2745  matrix C; bool bCnew = false;
2746 
2747  matrix DD = NULL;
2748  poly DN = NULL;
2749  matrix D; bool bDnew = false;
2750 
2751  number nN, pN, qN;
2752 
2753  bool IsSkewConstant = false, tmpIsSkewConstant;
2754  int i, j;
2755 
2756  nc_type nctype = nc_undef;
2757 
2758  //////////////////////////////////////////////////////////////////
2759  // check the correctness of arguments, without any real chagnes!!!
2760 
2761 
2762 
2763  // check C
2764  if ((CCC != NULL) && ( (MATCOLS(CCC)==1) || MATROWS(CCC)==1 ) )
2765  {
2766  CN = MATELEM(CCC,1,1);
2767  }
2768  else
2769  {
2770  if ((CCC != NULL) && ( (MATCOLS(CCC)!=r->N) || (MATROWS(CCC)!=r->N) ))
2771  {
2772  Werror("Square %d x %d matrix expected", r->N, r->N);
2773  return TRUE;
2774  }
2775  }
2776  if (( CCC != NULL) && (CC == NULL)) CC = CCC; // mp_Copy(CCC, ?); // bug!?
2777  if (( CCN != NULL) && (CN == NULL)) CN = CCN;
2778 
2779  // check D
2780  if ((DDD != NULL) && ( (MATCOLS(DDD)==1) || MATROWS(DDD)==1 ) )
2781  {
2782  DN = MATELEM(DDD,1,1);
2783  }
2784  else
2785  {
2786  if ((DDD != NULL) && ( (MATCOLS(DDD)!=r->N) || (MATROWS(DDD)!=r->N) ))
2787  {
2788  Werror("Square %d x %d matrix expected",r->N,r->N);
2789  return TRUE;
2790  }
2791  }
2792 
2793  if (( DDD != NULL) && (DD == NULL)) DD = DDD; // mp_Copy(DDD, ?); // ???
2794  if (( DDN != NULL) && (DN == NULL)) DN = DDN;
2795 
2796  // further checks and some analysis:
2797  // all data in 'curr'!
2798  if (CN != NULL) /* create matrix C = CN * Id */
2799  {
2800  if (!p_IsConstant(CN,curr))
2801  {
2802  WerrorS("Incorrect input : non-constants are not allowed as coefficients (first argument)");
2803  return TRUE;
2804  }
2805  assume(p_IsConstant(CN,curr));
2806 
2807  nN = pGetCoeff(CN);
2808  if (n_IsZero(nN, curr->cf))
2809  {
2810  WerrorS("Incorrect input : zero coefficients are not allowed");
2811  return TRUE;
2812  }
2813 
2814  if (n_IsOne(nN, curr->cf))
2815  nctype = nc_lie;
2816  else
2817  nctype = nc_general;
2818 
2819  IsSkewConstant = true;
2820 
2821  C = mpNew(r->N,r->N); // ring independent!
2822  bCnew = true;
2823 
2824  for(i=1; i<r->N; i++)
2825  for(j=i+1; j<=r->N; j++)
2826  MATELEM(C,i,j) = prCopyR_NoSort(CN, curr, r); // nc_p_CopyPut(CN, r); // copy CN from curr into r
2827 
2828 #ifndef SING_NDEBUG
2829  id_Test((ideal)C, r);
2830 #endif
2831 
2832  }
2833  else if ( (CN == NULL) && (CC != NULL) ) /* copy matrix C */
2834  {
2835  /* analyze C */
2836 
2837  BOOLEAN pN_set=FALSE;
2838  pN = n_Init(0,curr->cf);
2839 
2840  if( r->N > 1 )
2841  if ( MATELEM(CC,1,2) != NULL )
2842  {
2843  if (!pN_set) n_Delete(&pN,curr->cf); // free initial nInit(0)
2844  pN = p_GetCoeff(MATELEM(CC,1,2), curr);
2845  pN_set=TRUE;
2846  }
2847 
2848  tmpIsSkewConstant = true;
2849 
2850  for(i=1; i<r->N; i++)
2851  for(j=i+1; j<=r->N; j++)
2852  {
2853  if (MATELEM(CC,i,j) == NULL)
2854  qN = NULL;
2855  else
2856  {
2857  if (!p_IsConstant(MATELEM(CC,i,j),curr))
2858  {
2859  Werror("Incorrect input : non-constants are not allowed as coefficients (first argument at [%d, %d])", i, j);
2860  return TRUE;
2861  }
2862  assume(p_IsConstant(MATELEM(CC,i,j),curr));
2863  qN = p_GetCoeff(MATELEM(CC,i,j),curr);
2864  }
2865 
2866  if ( qN == NULL ) /* check the consistency: Cij!=0 */
2867  // find also illegal pN
2868  {
2869  WerrorS("Incorrect input : matrix of coefficients contains zeros in the upper triangle");
2870  return TRUE;
2871  }
2872 
2873  if (!n_Equal(pN, qN, curr->cf)) tmpIsSkewConstant = false;
2874  }
2875 
2876  if( bCopyInput )
2877  {
2878  C = mp_Copy(CC, curr, r); // Copy C into r!!!???
2879 #ifndef SING_NDEBUG
2880  id_Test((ideal)C, r);
2881 #endif
2882  bCnew = true;
2883  }
2884  else
2885 
2886  C = CC;
2887 
2888  IsSkewConstant = tmpIsSkewConstant;
2889 
2890  if ( tmpIsSkewConstant && n_IsOne(pN, curr->cf) )
2891  nctype = nc_lie;
2892  else
2893  nctype = nc_general;
2894  if (!pN_set) n_Delete(&pN,curr->cf); // free initial nInit(0)
2895  }
2896 
2897  /* initialition of the matrix D */
2898  if ( DD == NULL ) /* we treat DN only (it could also be NULL) */
2899  {
2900  D = mpNew(r->N,r->N); bDnew = true;
2901 
2902  if (DN == NULL)
2903  {
2904  if ( (nctype == nc_lie) || (nctype == nc_undef) )
2905  nctype = nc_comm; /* it was nc_skew earlier */
2906  else /* nc_general, nc_skew */
2907  nctype = nc_skew;
2908  }
2909  else /* DN != NULL */
2910  for(i=1; i<r->N; i++)
2911  for(j=i+1; j<=r->N; j++)
2912  MATELEM(D,i,j) = prCopyR_NoSort(DN, curr, r); // project DN into r->GetNC()->basering!
2913 #ifndef SING_NDEBUG
2914  id_Test((ideal)D, r);
2915 #endif
2916  }
2917  else /* DD != NULL */
2918  {
2919  bool b = true; // DD == null ?
2920 
2921  for(int i = 1; (i < r->N) && b; i++)
2922  for(int j = i+1; (j <= r->N) && b; j++)
2923  if (MATELEM(DD, i, j) != NULL)
2924  {
2925  b = false;
2926  break;
2927  }
2928 
2929  if (b) // D == NULL!!!
2930  {
2931  if ( (nctype == nc_lie) || (nctype == nc_undef) )
2932  nctype = nc_comm; /* it was nc_skew earlier */
2933  else /* nc_general, nc_skew */
2934  nctype = nc_skew;
2935  }
2936 
2937  if( bCopyInput )
2938  {
2939  D = mp_Copy(DD, curr, r); // Copy DD into r!!!
2940 #ifndef SING_NDEBUG
2941  id_Test((ideal)D, r);
2942 #endif
2943  bDnew = true;
2944  }
2945  else
2946  D = DD;
2947  }
2948 
2949  assume( C != NULL );
2950  assume( D != NULL );
2951 
2952 #if OUTPUT
2953  PrintS("nc_CallPlural(), Computed data, C: \n");
2954  iiWriteMatrix(C, "C", 2, r, 4);
2955 
2956  PrintS("nc_CallPlural(), Computed data, D: \n");
2957  iiWriteMatrix(D, "D", 2, r, 4);
2958 
2959  Print("\nTemporary: type = %d, IsSkewConstant = %d\n", nctype, IsSkewConstant);
2960 #endif
2961 
2962 
2963  // check the ordering condition for D (both matrix and poly cases):
2964  if ( gnc_CheckOrdCondition(D, r) )
2965  {
2966  if( bCnew ) mp_Delete( &C, r );
2967  if( bDnew ) mp_Delete( &D, r );
2968 
2969  WerrorS("Matrix of polynomials violates the ordering condition");
2970  return TRUE;
2971  }
2972 
2973  // okay now we are ready for this!!!
2974 
2975  // create new non-commutative structure
2976  nc_struct *nc_new = (nc_struct *)omAlloc0(sizeof(nc_struct));
2977 
2978  ncRingType(nc_new, nctype);
2979 
2980  nc_new->C = C; // if C and D were given by matrices at the beginning they are in r
2981  nc_new->D = D; // otherwise they should be in r->GetNC()->basering(polynomial * Id_{N})
2982 
2983  nc_new->IsSkewConstant = (IsSkewConstant?1:0);
2984 
2985  // Setup new NC structure!!!
2986  if (r->GetNC() != NULL)
2987  {
2988 #ifndef SING_NDEBUG
2989  WarnS("Changing the NC-structure of an existing NC-ring!!!");
2990 #endif
2991  nc_rKill(r);
2992  }
2993 
2994  r->GetNC() = nc_new;
2995 
2996  r->ext_ref=NULL;
2997 
2998  return gnc_InitMultiplication(r, bSetupQuotient);
2999 }
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
CanonicalForm b
Definition: cfModGcd.cc:4103
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:464
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:455
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:538
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition: coeffs.h:460
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff 'n' represents the one element.
Definition: coeffs.h:468
#define Print
Definition: emacs.cc:80
void WerrorS(const char *s)
Definition: feFopen.cc:24
nc_type
Definition: nc.h:13
static nc_type & ncRingType(nc_struct *p)
Definition: nc.h:159
void mp_Delete(matrix *a, const ring r)
Definition: matpol.cc:880
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition: matpol.cc:64
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 MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29
#define MATROWS(i)
Definition: matpol.h:26
#define MATCOLS(i)
Definition: matpol.h:27
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:44
#define p_GetCoeff(p, r)
Definition: monomials.h:50
BOOLEAN gnc_InitMultiplication(ring r, bool bSetupQuotient=false)
Definition: old.gring.cc:3015
BOOLEAN gnc_CheckOrdCondition(matrix D, ring r)
Definition: old.gring.cc:2627
void nc_rKill(ring r)
complete destructor
Definition: old.gring.cc:2475
#define omAlloc0(size)
Definition: omAllocDecl.h:211
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1983
poly prCopyR_NoSort(poly p, ring src_r, ring dest_r)
Definition: prCopy.cc:76
void PrintS(const char *s)
Definition: reporter.cc:284
void Werror(const char *fmt,...)
Definition: reporter.cc:189
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:1713
Definition: nc.h:68
int IsSkewConstant
Definition: nc.h:85

◆ nc_CheckSubalgebra()

BOOLEAN nc_CheckSubalgebra ( poly  PolyVar,
ring  r 
)

Definition at line 2568 of file old.gring.cc.

2569 {
2570 // ring save = currRing;
2571 // int WeChangeRing = 0;
2572 // if (currRing != r)
2573 // rChangeCurrRing(r);
2574 // WeChangeRing = 1;
2575 // }
2576  int rN=r->N;
2577  int *ExpVar=(int*)omAlloc0((rN+1)*sizeof(int));
2578  int *ExpTmp=(int*)omAlloc0((rN+1)*sizeof(int));
2579  p_GetExpV(PolyVar, ExpVar, r);
2580  int i; int j; int k;
2581  poly test=NULL;
2582  int OK=1;
2583  for (i=1; i<rN; i++)
2584  {
2585  if (ExpVar[i]==0) /* i.e. not in PolyVar */
2586  {
2587  for (j=i+1; j<=rN; j++)
2588  {
2589  if (ExpVar[j]==0)
2590  {
2591  test = MATELEM(r->GetNC()->D,i,j);
2592  while (test!=NULL)
2593  {
2594  p_GetExpV(test, ExpTmp, r);
2595  OK=1;
2596  for (k=1;k<=rN;k++)
2597  {
2598  if (ExpTmp[k]!=0)
2599  {
2600  if (ExpVar[k]!=0) OK=0;
2601  }
2602  }
2603  if (!OK)
2604  {
2605 // if ( WeChangeRing )
2606 // rChangeCurrRing(save);
2607  return(TRUE);
2608  }
2609  pIter(test);
2610  }
2611  }
2612  }
2613  }
2614  }
2615  freeT(ExpVar,rN);
2616  freeT(ExpTmp,rN);
2617 // if ( WeChangeRing )
2618 // rChangeCurrRing(save);
2619  return(FALSE);
2620 }
int k
Definition: cfEzgcd.cc:99
CanonicalForm test
Definition: cfModGcd.cc:4096
#define pIter(p)
Definition: monomials.h:37
#define freeT(A, v)
Definition: old.gring.cc:101
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1492

◆ nc_CreateShortSpoly()

poly nc_CreateShortSpoly ( poly  p1,
poly  p2,
const ring  r 
)

Definition at line 1879 of file old.gring.cc.

1880 {
1881 #ifdef PDEBUG
1882  p_Test(p1, r);
1883  p_Test(p2, r);
1884 #endif
1885 
1886  const long lCompP1 = p_GetComp(p1,r);
1887  const long lCompP2 = p_GetComp(p2,r);
1888 
1889  if ((lCompP1!=lCompP2) && (lCompP1!=0) && (lCompP2!=0))
1890  {
1891 #ifdef PDEBUG
1892  WerrorS("nc_CreateShortSpoly: wrong module components!"); // !!!!
1893 #endif
1894  return(NULL);
1895  }
1896 
1897  poly m;
1898 
1899 #ifdef HAVE_RATGRING
1900  if ( rIsRatGRing(r))
1901  {
1902  /* rational version */
1903  m = p_LcmRat(p1, p2, si_max(lCompP1, lCompP2), r);
1904  } else
1905 #endif
1906  {
1907  m = p_Lcm(p1, p2, r);
1908  }
1909 
1910  pSetCoeff0(m,NULL);
1911 
1912  return(m);
1913 }
int m
Definition: cfEzgcd.cc:128
#define p_GetComp(p, r)
Definition: monomials.h:64
#define pSetCoeff0(p, n)
Definition: monomials.h:59
poly p_LcmRat(const poly a, const poly b, const long lCompM, const ring r)
Definition: p_polys.cc:1669
void p_Lcm(const poly a, const poly b, poly m, const ring r)
Definition: p_polys.cc:1647
static BOOLEAN rIsRatGRing(const ring r)
Definition: ring.h:427

◆ nc_CreateSpoly()

static poly nc_CreateSpoly ( const poly  p1,
const poly  p2,
const ring  r 
)
inlinestatic

Definition at line 241 of file nc.h.

242 {
243  assume(rIsPluralRing(r));
244  assume(r->GetNC()->p_Procs.SPoly!=NULL);
245  return r->GetNC()->p_Procs.SPoly(p1, p2, r);
246 }

◆ nc_kBucketPolyRed_NF()

static void nc_kBucketPolyRed_NF ( kBucket_pt  b,
poly  p,
number *  c 
)
inlinestatic

Definition at line 275 of file nc.h.

276 {
277  const ring r = b->bucket_ring;
278  assume(rIsPluralRing(r));
279 
280 // return gnc_kBucketPolyRedNew(b, p, c);
281 
282  assume(r->GetNC()->p_Procs.BucketPolyRed_NF!=NULL);
283  return r->GetNC()->p_Procs.BucketPolyRed_NF(b, p, c);
284 }

◆ nc_kBucketPolyRed_Z()

static void nc_kBucketPolyRed_Z ( kBucket_pt  b,
poly  p,
number *  c 
)
inlinestatic

Definition at line 286 of file nc.h.

287 {
288  const ring r = b->bucket_ring;
289  assume(rIsPluralRing(r));
290 
291 // return gnc_kBucketPolyRed_ZNew(b, p, c);
292 
293  assume(r->GetNC()->p_Procs.BucketPolyRed_Z!=NULL);
294  return r->GetNC()->p_Procs.BucketPolyRed_Z(b, p, c);
295 
296 }

◆ nc_mm_Mult_p()

static poly nc_mm_Mult_p ( const poly  m,
poly  p,
const ring  r 
)
inlinestatic

Definition at line 233 of file nc.h.

234 {
235  assume(rIsPluralRing(r));
236  assume(r->p_Procs->p_mm_Mult!=NULL);
237  return r->p_Procs->p_mm_Mult(p, m, r);
238 // return p_Mult_mm( p, m, r);
239 }

◆ nc_mm_Mult_pp()

static poly nc_mm_Mult_pp ( const poly  m,
const poly  p,
const ring  r 
)
inlinestatic

Definition at line 224 of file nc.h.

225 {
226  assume(rIsNCRing(r));
227  assume(r->p_Procs->pp_mm_Mult!=NULL);
228  return r->p_Procs->pp_mm_Mult(p, m, r);
229 }

◆ nc_p_Bracket_qq()

poly nc_p_Bracket_qq ( poly  p,
const poly  q,
const ring  r 
)

returns [p,q], destroys p

Definition at line 2243 of file old.gring.cc.

2244 {
2245  assume(p != NULL && q!= NULL);
2246 
2247  if (!rIsPluralRing(r)) return(NULL);
2248  if (p_ComparePolys(p,q, r)) return(NULL);
2249  /* Components !? */
2250  poly Q=NULL;
2251  number coef=NULL;
2252  poly pres=NULL;
2253  int UseBuckets=1;
2254  if (((pLength(p)< MIN_LENGTH_BUCKET/2) && (pLength(q)< MIN_LENGTH_BUCKET/2))
2256  UseBuckets=0;
2257 
2258 
2259  CPolynomialSummator sum(r, UseBuckets == 0);
2260 
2261  while (p!=NULL)
2262  {
2263  Q=q;
2264  while(Q!=NULL)
2265  {
2266  pres=nc_mm_Bracket_nn(p,Q, r); /* since no coeffs are taken into account there */
2267  if (pres!=NULL)
2268  {
2269  coef = n_Mult(pGetCoeff(p),pGetCoeff(Q), r->cf);
2270  pres = __p_Mult_nn(pres,coef,r);
2271 
2272  sum += pres;
2273  n_Delete(&coef, r->cf);
2274  }
2275  pIter(Q);
2276  }
2277  p=p_LmDeleteAndNext(p, r);
2278  }
2279  return(sum);
2280 }
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:636
STATIC_VAR jList * Q
Definition: janet.cc:30
poly nc_mm_Bracket_nn(poly m1, poly m2, const ring r)
returns [m1,m2] for two monoms, destroys nothing without coeffs
Definition: old.gring.cc:2284
BOOLEAN p_ComparePolys(poly p1, poly p2, const ring r)
returns TRUE if p1 is a skalar multiple of p2 assume p1 != NULL and p2 != NULL
Definition: p_polys.cc:4609
static unsigned pLength(poly a)
Definition: p_polys.h:191
#define __p_Mult_nn(p, n, r)
Definition: p_polys.h:943

◆ nc_p_Minus_mm_Mult_qq()

poly nc_p_Minus_mm_Mult_qq ( poly  p,
const poly  m,
const poly  q,
int &  lp,
const  poly,
const ring  r 
)

for p_Minus_mm_Mult_qq in pInline2.h

Definition at line 150 of file old.gring.cc.

152 {
153  poly mc = p_Neg( p_Copy(m, r), r );
154  poly mmc = nc_mm_Mult_pp( mc, q, r );
155  p_Delete(&mc, r);
156 
157  int org_p=pLength(p);
158  int org_q=pLength(q);
159 
160  p = p_Add_q(p, mmc, r);
161 
162  shorter = pLength(p)-org_p-org_q; // ring independent!
163 
164  return(p);
165 }
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1079
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:908
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:818

◆ nc_p_Plus_mm_Mult_qq()

poly nc_p_Plus_mm_Mult_qq ( poly  p,
const poly  m,
const poly  q,
int &  lp,
const int  ,
const ring  r 
)

Definition at line 168 of file old.gring.cc.

170 {
171  p = p_Add_q(p, nc_mm_Mult_pp( m, q, r ), r);
172 
173  lp = pLength(p);
174 
175  return(p);
176 }

◆ nc_p_ProcsSet()

void nc_p_ProcsSet ( ring  rGR,
p_Procs_s p_Procs 
)

Definition at line 3179 of file old.gring.cc.

3180 {
3181  assume(rIsPluralRing(rGR));
3182  assume(p_Procs!=NULL);
3183 
3184  gnc_p_ProcsSet(rGR, p_Procs);
3185 
3186  if(rIsSCA(rGR) && ncExtensions(SCAMASK) )
3187  {
3188  sca_p_ProcsSet(rGR, p_Procs);
3189  }
3190 
3191  if( ncExtensions(NOPLURALMASK) )
3193 
3194  if(!rIsSCA(rGR) && !ncExtensions(NOFORMULAMASK))
3196 
3197 }
static bool rIsSCA(const ring r)
Definition: nc.h:190
const int NOPLURALMASK
Definition: nc.h:338
const int NOFORMULAMASK
Definition: nc.h:339
const int SCAMASK
Definition: nc.h:324
void sca_p_ProcsSet(ring rGR, p_Procs_s *p_Procs)
Definition: sca.cc:1225
bool ncInitSpecialPowersMultiplication(ring r)
Definition: ncSAFormula.cc:50
BOOLEAN ncInitSpecialPairMultiplication(ring r)
Definition: ncSAMult.cc:266
bool ncExtensions(int iMask)
Definition: old.gring.cc:94
static void gnc_p_ProcsSet(ring rGR, p_Procs_s *p_Procs)
Definition: old.gring.cc:3115

◆ nc_PolyPolyRed()

void nc_PolyPolyRed ( poly &  b,
poly  p,
number *  c,
const ring  r 
)

Definition at line 2230 of file old.gring.cc.

2231 {
2232 #if 0
2233  nc_PolyPolyRedOld(b, p, c, r);
2234 #else
2235  nc_PolyPolyRedNew(b, p, c, r);
2236 #endif
2237 }
void nc_PolyPolyRedNew(poly &b, poly p, number *c, const ring r)
Definition: old.gring.cc:2130
void nc_PolyPolyRedOld(poly &b, poly p, number *c, const ring r)
Definition: old.gring.cc:2096

◆ nc_PrintMat()

matrix nc_PrintMat ( int  a,
int  b,
ring  r,
int  metric 
)

returns matrix with the info on noncomm multiplication

Definition at line 2394 of file old.gring.cc.

2395 {
2396 
2397  if ( (a==b) || !rIsPluralRing(r) ) return(NULL);
2398  int i;
2399  int j;
2400  if (a>b) {j=b; i=a;}
2401  else {j=a; i=b;}
2402  /* i<j */
2403  int rN=r->N;
2404  int size=r->GetNC()->MTsize[UPMATELEM(i,j,rN)];
2405  matrix M = r->GetNC()->MT[UPMATELEM(i,j,rN)];
2406  /* return(M); */
2407 /*
2408  int sizeofres;
2409  if (metric==0)
2410  {
2411  sizeofres=sizeof(int);
2412  }
2413  if (metric==1)
2414  {
2415  sizeofres=sizeof(number);
2416  }
2417 */
2419  int s;
2420  int t;
2421  int length;
2422  long totdeg;
2423  poly p;
2424  for(s=1;s<=size;s++)
2425  {
2426  for(t=1;t<=size;t++)
2427  {
2428  p=MATELEM(M,s,t);
2429  if (p==NULL)
2430  {
2431  MATELEM(res,s,t)=0;
2432  }
2433  else
2434  {
2435  length = pLength(p);
2436  if (metric==0) /* length */
2437  {
2438  MATELEM(res,s,t)= p_ISet(length,r);
2439  }
2440  else if (metric==1) /* sum of deg divided by the length */
2441  {
2442  totdeg=0;
2443  while (p!=NULL)
2444  {
2445  totdeg=totdeg+p_Deg(p,r);
2446  pIter(p);
2447  }
2448  number ntd = n_Init(totdeg, r->cf);
2449  number nln = n_Init(length, r->cf);
2450  number nres= n_Div(ntd,nln, r->cf);
2451  n_Delete(&ntd, r->cf);
2452  n_Delete(&nln, r->cf);
2453  MATELEM(res,s,t)=p_NSet(nres,r);
2454  }
2455  }
2456  }
2457  }
2458  return(res);
2459 }
int size(const CanonicalForm &f, const Variable &v)
int size ( const CanonicalForm & f, const Variable & v )
Definition: cf_ops.cc:600
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of 'a' and 'b', i.e., a/b; raises an error if 'b' is not invertible in r exceptio...
Definition: coeffs.h:615
const CanonicalForm int s
Definition: facAbsFact.cc:51
CanonicalForm res
Definition: facAbsFact.cc:60
static BOOLEAN length(leftv result, leftv arg)
Definition: interval.cc:257
#define UPMATELEM(i, j, nVar)
Definition: nc.h:36
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1293
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1465
long p_Deg(poly a, const ring r)
Definition: p_polys.cc:583
#define M
Definition: sirandom.c:25

◆ nc_pSubst()

poly nc_pSubst ( poly  p,
int  n,
poly  e,
const ring  r 
)

substitute the n-th variable by e in p destroy p e is not a constant

Definition at line 3203 of file old.gring.cc.

3204 {
3205  int rN = r->N;
3206  int *PRE = (int *)omAlloc0((rN+1)*sizeof(int));
3207  int *SUF = (int *)omAlloc0((rN+1)*sizeof(int));
3208  int i,pow;
3209  number C;
3210  poly suf,pre;
3211  poly res = NULL;
3212  poly out = NULL;
3213  while ( p!= NULL )
3214  {
3215  C = p_GetCoeff(p, r);
3216  p_GetExpV(p, PRE, r); /* faster splitting? */
3217  pow = PRE[n]; PRE[n]=0;
3218  res = NULL;
3219  if (pow!=0)
3220  {
3221  for (i=n+1; i<=rN; i++)
3222  {
3223  SUF[i] = PRE[i];
3224  PRE[i] = 0;
3225  }
3226  res = p_Power(p_Copy(e, r),pow, r);
3227  /* multiply with prefix */
3228  pre = p_One(r);
3229  p_SetExpV(pre,PRE, r);
3230  p_Setm(pre, r);
3231  res = nc_mm_Mult_p(pre,res, r);
3232  /* multiply with suffix */
3233  suf = p_One(r);
3234  p_SetExpV(suf,SUF, r);
3235  p_Setm(suf, r);
3236  res = p_Mult_mm(res,suf, r);
3237  res = __p_Mult_nn(res,C, r);
3238  p_SetComp(res,PRE[0], r);
3239  }
3240  else /* pow==0 */
3241  {
3242  res = p_Head(p, r);
3243  }
3244  p = p_LmDeleteAndNext(p, r);
3245  out = p_Add_q(out,res, r);
3246  }
3247  freeT(PRE,rN);
3248  freeT(SUF,rN);
3249  return(out);
3250 }
Rational pow(const Rational &a, int e)
Definition: GMPrat.cc:411
static poly nc_mm_Mult_p(const poly m, poly p, const ring r)
Definition: nc.h:233
poly p_Power(poly p, int i, const ring r)
Definition: p_polys.cc:2189
poly p_One(const ring r)
Definition: p_polys.cc:1309
static void p_SetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1516
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition: p_polys.h:832
static poly p_Mult_mm(poly p, poly m, const ring r)
Definition: p_polys.h:1023

◆ nc_rComplete()

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

Definition at line 5647 of file ring.cc.

5652 {
5653 // NOTE: Originally used only by idElimination to transfer NC structure to dest
5654 // ring created by dirty hack (without nc_CallPlural)
5655  rTest(src);
5656 
5657  assume(!rIsPluralRing(dest)); // destination must be a newly constructed commutative ring
5658 
5659  if (!rIsPluralRing(src))
5660  {
5661  return FALSE;
5662  }
5663 
5664  const int N = dest->N;
5665 
5666  assume(src->N == N);
5667 
5668 // ring save = currRing;
5669 
5670 // if (dest != save)
5671 // rChangeCurrRing(dest);
5672 
5673  const ring srcBase = src;
5674 
5675  assume( n_SetMap(srcBase->cf,dest->cf) == n_SetMap(dest->cf,dest->cf) ); // currRing is important here!
5676 
5677  matrix C = mpNew(N,N); // ring independent
5678  matrix D = mpNew(N,N);
5679 
5680  matrix C0 = src->GetNC()->C;
5681  matrix D0 = src->GetNC()->D;
5682 
5683  // map C and D into dest
5684  for (int i = 1; i < N; i++)
5685  {
5686  for (int j = i + 1; j <= N; j++)
5687  {
5688  const number n = n_Copy(p_GetCoeff(MATELEM(C0,i,j), srcBase), srcBase->cf); // src, mapping for coeffs into currRing = dest!
5689  const poly p = p_NSet(n, dest);
5690  MATELEM(C,i,j) = p;
5691  if (MATELEM(D0,i,j) != NULL)
5692  MATELEM(D,i,j) = prCopyR(MATELEM(D0,i,j), srcBase, dest); // ?
5693  }
5694  }
5695  /* One must test C and D _only_ in r->GetNC()->basering!!! not in r!!! */
5696 
5697  id_Test((ideal)C, dest);
5698  id_Test((ideal)D, dest);
5699 
5700  if (nc_CallPlural(C, D, NULL, NULL, dest, bSetupQuotient, false, true, dest)) // also takes care about quotient ideal
5701  {
5702  //WarnS("Error transferring non-commutative structure");
5703  // error message should be in the interpreter interface
5704 
5705  mp_Delete(&C, dest);
5706  mp_Delete(&D, dest);
5707 
5708 // if (currRing != save)
5709 // rChangeCurrRing(save);
5710 
5711  return TRUE;
5712  }
5713 
5714 // mp_Delete(&C, dest); // used by nc_CallPlural!
5715 // mp_Delete(&D, dest);
5716 
5717 // if (dest != save)
5718 // rChangeCurrRing(save);
5719 
5720  assume(rIsPluralRing(dest));
5721  return FALSE;
5722 }
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:451
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
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
poly prCopyR(poly p, ring src_r, ring dest_r)
Definition: prCopy.cc:34

◆ nc_rCopy()

bool nc_rCopy ( ring  res,
const ring  r,
bool  bSetupQuotient 
)

Definition at line 3003 of file old.gring.cc.

3004 {
3005  if (nc_CallPlural(r->GetNC()->C, r->GetNC()->D, NULL, NULL, res, bSetupQuotient, true, true, r))
3006  {
3007  WarnS("Error occurred while coping/setuping the NC structure!"); // No reaction!???
3008  return true; // error
3009  }
3010 
3011  return false;
3012 }
BOOLEAN nc_CallPlural(matrix CCC, matrix DDD, poly CCN, poly DDN, ring r, bool bSetupQuotient, bool bCopyInput, bool bBeQuiet, ring curr, bool dummy_ring)
returns TRUE if there were errors analyze inputs, check them for consistency detects nc_type,...
Definition: old.gring.cc:2682

◆ nc_ReduceSpoly()

static poly nc_ReduceSpoly ( const poly  p1,
poly  p2,
const ring  r 
)
inlinestatic

Definition at line 254 of file nc.h.

255 {
256  assume(rIsPluralRing(r));
257  assume(r->GetNC()->p_Procs.ReduceSPoly!=NULL);
258 #ifdef PDEBUG
259 // assume(p_LmDivisibleBy(p1, p2, r));
260 #endif
261  return r->GetNC()->p_Procs.ReduceSPoly(p1, p2, r);
262 }

◆ nc_rKill()

void nc_rKill ( ring  r)

complete destructor

Definition at line 2475 of file old.gring.cc.

2477 {
2478  if( r->GetNC()->GetGlobalMultiplier() != NULL )
2479  {
2480  delete r->GetNC()->GetGlobalMultiplier();
2481  r->GetNC()->GetGlobalMultiplier() = NULL;
2482  }
2483 
2484  if( r->GetNC()->GetFormulaPowerMultiplier() != NULL )
2485  {
2486  delete r->GetNC()->GetFormulaPowerMultiplier();
2487  r->GetNC()->GetFormulaPowerMultiplier() = NULL;
2488  }
2489 
2490 
2491  int i,j;
2492  int rN=r->N;
2493  if ( rN > 1 )
2494  {
2495  for(i=1;i<rN;i++)
2496  {
2497  for(j=i+1;j<=rN;j++)
2498  {
2499  id_Delete((ideal *)&(r->GetNC()->MT[UPMATELEM(i,j,rN)]),r);
2500  }
2501  }
2502  omFreeSize((ADDRESS)r->GetNC()->MT,rN*(rN-1)/2*sizeof(matrix));
2503  omFreeSize((ADDRESS)r->GetNC()->MTsize,rN*(rN-1)/2*sizeof(int));
2504  id_Delete((ideal *)&(r->GetNC()->COM),r);
2505  }
2506  id_Delete((ideal *)&(r->GetNC()->C),r);
2507  id_Delete((ideal *)&(r->GetNC()->D),r);
2508 
2509  if( rIsSCA(r) && (r->GetNC()->SCAQuotient() != NULL) )
2510  {
2511  id_Delete(&r->GetNC()->SCAQuotient(), r); // Custom SCA destructor!!!
2512  }
2513 
2514 
2515  nc_CleanUp(r);
2516 }
void * ADDRESS
Definition: auxiliary.h:119
void nc_CleanUp(nc_struct *p)
Definition: old.gring.cc:2461
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix

◆ nc_SetupQuotient()

bool nc_SetupQuotient ( ring  rGR,
const ring  rG = NULL,
bool  bCopy = false 
)

Definition at line 3403 of file old.gring.cc.

3404 {
3405  if( rGR->qideal == NULL )
3406  return false; // no quotient = no work! done!? What about factors of SCA?
3407 
3408  bool ret = true;
3409  // currently only super-commutative extension deals with factors.
3410 
3411  if( ncExtensions(SCAMASK) )
3412  {
3413  bool sca_ret = sca_SetupQuotient(rGR, rG, bCopy);
3414 
3415  if(sca_ret) // yes it was dealt with!
3416  ret = false;
3417  }
3418 
3419  if( bCopy )
3420  {
3421  assume(rIsPluralRing(rGR) == rIsPluralRing(rG));
3422  assume((rGR->qideal==NULL) == (rG->qideal==NULL));
3423  assume(rIsSCA(rGR) == rIsSCA(rG));
3424  assume(ncRingType(rGR) == ncRingType(rG));
3425  }
3426 
3427  return ret;
3428 }
bool sca_SetupQuotient(ring rGR, ring rG, bool bCopy)
Definition: sca.cc:911

◆ ncExtensions()

bool ncExtensions ( int  iMask)

Definition at line 94 of file old.gring.cc.

95 {
96  return ((getNCExtensions() & iMask) == iMask);
97 }
int & getNCExtensions()
Definition: old.gring.cc:82

◆ ncRingType() [1/4]

static nc_type& ncRingType ( nc_struct p)
inlinestatic

Definition at line 159 of file nc.h.

160 {
161  assume(p!=NULL);
162  return (p->ncRingType());
163 }

◆ ncRingType() [2/4]

static void ncRingType ( nc_struct p,
nc_type  t 
)
inlinestatic

Definition at line 179 of file nc.h.

180 {
181  assume(p!=NULL);
182  ncRingType(p) = t;
183 }

◆ ncRingType() [3/4]

static nc_type ncRingType ( ring  r)
inlinestatic

Definition at line 165 of file nc.h.

166 {
167  if(rIsPluralRing(r))
168  return (ncRingType(r->GetNC()));
169  else
170  return (nc_error);
171 }

◆ ncRingType() [4/4]

static void ncRingType ( ring  r,
nc_type  t 
)
inlinestatic

Definition at line 173 of file nc.h.

174 {
175  assume((r != NULL) && (r->GetNC() != NULL));
176  ncRingType(r->GetNC()) = t;
177 }

◆ pOppose()

poly pOppose ( ring  Rop_src,
poly  p,
const ring  Rop_dst 
)

opposes a vector p from Rop to currRing (dst!)

Definition at line 3342 of file old.gring.cc.

3343 {
3344  /* the simplest case:*/
3345  if ( Rop == dst ) return(p_Copy(p, dst));
3346  /* check Rop == rOpposite(currRing) */
3347 
3348 
3349  if ( !rIsLikeOpposite(dst, Rop) )
3350  {
3351  WarnS("an opposite ring should be used");
3352  return NULL;
3353  }
3354 
3355  nMapFunc nMap = n_SetMap(Rop->cf, dst->cf); // reverse?
3356 
3357  /* nMapFunc nMap = nSetMap(Rop);*/
3358  /* since we know that basefields coinside! */
3359 
3360  // coinside???
3361 
3362  int *perm=(int *)omAlloc0((Rop->N+1)*sizeof(int));
3363  if (!p_IsConstant(p, Rop))
3364  {
3365  /* we know perm exactly */
3366  int i;
3367  for(i=1; i<=Rop->N; i++)
3368  {
3369  perm[i] = Rop->N+1-i;
3370  }
3371  }
3372  poly res = p_PermPoly(p, perm, Rop, dst, nMap);
3373  omFreeSize((ADDRESS)perm,(Rop->N+1)*sizeof(int));
3374 
3375  p_Test(res, dst);
3376 
3377  return res;
3378 }
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition: coeffs.h:73
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:4163

◆ rIsLikeOpposite()

BOOLEAN rIsLikeOpposite ( ring  rBase,
ring  rCandidate 
)

checks whether rings rBase and rCandidate could be opposite to each other returns TRUE if it is so

Definition at line 3315 of file old.gring.cc.

3316 {
3317  /* the same basefield */
3318  int diagnose = TRUE;
3319  nMapFunc nMap = n_SetMap(rCandidate->cf, rBase->cf); // reverse?
3320 
3321 ////// if (nMap != nCopy) diagnose = FALSE;
3322  if (nMap == NULL) diagnose = FALSE;
3323 
3324 
3325  /* same number of variables */
3326  if (rBase->N != rCandidate->N) diagnose = FALSE;
3327  /* nc and comm ring */
3328  if ( rIsPluralRing(rBase) != rIsPluralRing(rCandidate) ) diagnose = FALSE;
3329  /* both are qrings */
3330  /* NO CHECK, since it is used in building opposite qring */
3331  /* if ( ((rBase->qideal != NULL) && (rCandidate->qideal == NULL)) */
3332  /* || ((rBase->qideal == NULL) && (rCandidate->qideal != NULL)) ) */
3333  /* diagnose = FALSE; */
3334  /* TODO: varnames are e->E etc */
3335  return diagnose;
3336 }

◆ rIsSCA()

static bool rIsSCA ( const ring  r)
inlinestatic

Definition at line 190 of file nc.h.

191 {
192 #ifdef HAVE_PLURAL
193  return rIsPluralRing(r) && (ncRingType(r) == nc_exterior);
194 #else
195  return false;
196 #endif
197 }

◆ setNCExtensions()

int setNCExtensions ( int  iMask)

Definition at line 87 of file old.gring.cc.

88 {
89  const int iOld = getNCExtensions();
90  getNCExtensions() = iMask;
91  return (iOld);
92 }

Variable Documentation

◆ GENERICMASK

const int GENERICMASK = 0x000

Definition at line 323 of file nc.h.

◆ NOCACHEMASK

const int NOCACHEMASK = 0x008

Definition at line 340 of file nc.h.

◆ NOFORMULAMASK

const int NOFORMULAMASK =0x004

Definition at line 339 of file nc.h.

◆ NOPLURALMASK

const int NOPLURALMASK = 0x002

Definition at line 338 of file nc.h.

◆ SCAMASK

const int SCAMASK = 0x001

Definition at line 324 of file nc.h.

◆ TESTSYZSCAMASK

const int TESTSYZSCAMASK = 0x0100 | SCAMASK

Definition at line 342 of file nc.h.