Data Structures | Macros | Typedefs | Functions | Variables
matpol.h File Reference
#include <polys/monomials/ring.h>

Go to the source code of this file.

Data Structures

class  ip_smatrix
 

Macros

#define MATROWS(i)   ((i)->nrows)
 
#define MATCOLS(i)   ((i)->ncols)
 
#define MATELEM(mat, i, j)   ((mat)->m)[MATCOLS((mat)) * ((i)-1) + (j)-1]
 

Typedefs

typedef ip_smatrixmatrix
 

Functions

matrix mpNew (int r, int c)
 create a r x c zero-matrix More...
 
static matrix mp_New (int r, int c)
 
void mp_Delete (matrix *a, const ring r)
 
matrix mp_Copy (const matrix a, const ring rSrc, const ring rDst)
 copies matrix a from rSrc into rDst More...
 
matrix mp_Copy (matrix a, const ring r)
 copies matrix a (from ring r to r) More...
 
matrix mp_InitP (int r, int c, poly p, const ring R)
 make it a p * unit matrix More...
 
matrix mp_InitI (int r, int c, int v, const ring R)
 make it a v * unit matrix More...
 
matrix mp_MultI (matrix a, int f, const ring r)
 c = f*a More...
 
matrix mp_MultP (matrix a, poly p, const ring r)
 multiply a matrix 'a' by a poly 'p', destroy the args More...
 
matrix pMultMp (poly p, matrix a, const ring r)
 
matrix mp_Add (matrix a, matrix b, const ring r)
 
matrix mp_Sub (matrix a, matrix b, const ring r)
 
matrix mp_Mult (matrix a, matrix b, const ring r)
 
matrix mp_Transp (matrix a, const ring r)
 
BOOLEAN mp_Equal (matrix a, matrix b, const ring r)
 
poly mp_Trace (matrix a, const ring r)
 
poly TraceOfProd (matrix a, matrix b, int n, const ring r)
 
matrix mp_Wedge (matrix a, int ar, const ring r)
 
poly mp_DetBareiss (matrix a, const ring r)
 returns the determinant of the matrix m; uses Bareiss algorithm More...
 
void mp_Monomials (matrix c, int r, int var, matrix m, const ring R)
 
matrix mp_Coeffs (ideal I, int var, const ring r)
 corresponds to Maple's coeffs: var has to be the number of a variable More...
 
matrix mp_CoeffProc (poly f, poly vars, const ring r)
 
void mp_Coef2 (poly v, poly vars, matrix *c, matrix *m, const ring r)
 corresponds to Macauley's coef: the exponent vector of vars has to contain the variables, eg 'xy'; then the poly f is searched for monomials in x and y, these monimials are written to the first row of the matrix co. the second row of co contains the respective factors in f. Thus f = sum co[1,i]*co[2,i], i = 1..cols, rows equals 2. More...
 
void mp_RecMin (int, ideal, int &, matrix, int, int, poly, ideal, const ring)
 for minors with Bareiss More...
 
void mp_MinorToResult (ideal, int &, matrix, int, int, ideal, const ring)
 entries of a are minors and go to result (only if not in R) More...
 
BOOLEAN mp_IsDiagUnit (matrix U, const ring r)
 
void iiWriteMatrix (matrix im, const char *n, int dim, const ring r, int spaces)
 set spaces to zero by default More...
 
char * iiStringMatrix (matrix im, int dim, const ring r, char ch=',')
 
int mp_Compare (matrix a, matrix b, const ring r)
 
ideal mp_Tensor (ideal A, ideal B, const ring r)
 

Variables

omBin ip_smatrix_bin
 

Macro Definition Documentation

◆ MATCOLS

#define MATCOLS (   i)    ((i)->ncols)

Definition at line 28 of file matpol.h.

◆ MATELEM

#define MATELEM (   mat,
  i,
  j 
)    ((mat)->m)[MATCOLS((mat)) * ((i)-1) + (j)-1]

Definition at line 29 of file matpol.h.

◆ MATROWS

#define MATROWS (   i)    ((i)->nrows)

Definition at line 27 of file matpol.h.

Typedef Documentation

◆ matrix

typedef ip_smatrix* matrix

Definition at line 32 of file matpol.h.

Function Documentation

◆ iiStringMatrix()

char* iiStringMatrix ( matrix  im,
int  dim,
const ring  r,
char  ch = ',' 
)

Definition at line 764 of file matpol.cc.

765 {
766  int i,ii = MATROWS(im);
767  int j,jj = MATCOLS(im);
768  poly *pp = im->m;
769  char ch_s[2];
770  ch_s[0]=ch;
771  ch_s[1]='\0';
772 
773  StringSetS("");
774 
775  for (i=0; i<ii; i++)
776  {
777  for (j=0; j<jj; j++)
778  {
779  p_String0(*pp++, r);
780  StringAppendS(ch_s);
781  if (dim > 1) StringAppendS("\n");
782  }
783  }
784  char *s=StringEndS();
785  s[strlen(s)- (dim > 1 ? 2 : 1)]='\0';
786  return s;
787 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
char * StringEndS()
Definition: reporter.cc:151
poly pp
Definition: myNF.cc:296
poly * m
Definition: matpol.h:19
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
void StringSetS(const char *st)
Definition: reporter.cc:128
void StringAppendS(const char *st)
Definition: reporter.cc:107
int dim(ideal I, ring r)
int i
Definition: cfEzgcd.cc:123
#define MATCOLS(i)
Definition: matpol.h:28
void p_String0(poly p, ring lmRing, ring tailRing)
print p according to ShortOut in lmRing & tailRing
Definition: polys0.cc:136
#define MATROWS(i)
Definition: matpol.h:27
polyrec * poly
Definition: hilb.h:10

◆ iiWriteMatrix()

void iiWriteMatrix ( matrix  im,
const char *  n,
int  dim,
const ring  r,
int  spaces 
)

set spaces to zero by default

Definition at line 743 of file matpol.cc.

744 {
745  int i,ii = MATROWS(im)-1;
746  int j,jj = MATCOLS(im)-1;
747  poly *pp = im->m;
748 
749  for (i=0; i<=ii; i++)
750  {
751  for (j=0; j<=jj; j++)
752  {
753  if (spaces>0)
754  Print("%-*.*s",spaces,spaces," ");
755  if (dim == 2) Print("%s[%u,%u]=",n,i+1,j+1);
756  else if (dim == 1) Print("%s[%u]=",n,j+1);
757  else if (dim == 0) Print("%s=",n);
758  if ((i<ii)||(j<jj)) p_Write(*pp++, r);
759  else p_Write0(*pp, r);
760  }
761  }
762 }
#define Print
Definition: emacs.cc:83
poly pp
Definition: myNF.cc:296
poly * m
Definition: matpol.h:19
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
int dim(ideal I, ring r)
int i
Definition: cfEzgcd.cc:123
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:196
#define MATCOLS(i)
Definition: matpol.h:28
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:206
#define MATROWS(i)
Definition: matpol.h:27
polyrec * poly
Definition: hilb.h:10

◆ mp_Add()

matrix mp_Add ( matrix  a,
matrix  b,
const ring  r 
)

Definition at line 186 of file matpol.cc.

187 {
188  int k, n = a->nrows, m = a->ncols;
189  if ((n != b->nrows) || (m != b->ncols))
190  {
191 /*
192 * Werror("cannot add %dx%d matrix and %dx%d matrix",
193 * m,n,b->cols(),b->rows());
194 */
195  return NULL;
196  }
197  matrix c = mpNew(n,m);
198  for (k=m*n-1; k>=0; k--)
199  c->m[k] = p_Add_q(p_Copy(a->m[k], R), p_Copy(b->m[k], R), R);
200  return c;
201 }
const poly a
Definition: syzextra.cc:212
int k
Definition: cfEzgcd.cc:93
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
poly * m
Definition: matpol.h:19
const ring R
Definition: DebugPrint.cc:36
int m
Definition: cfEzgcd.cc:119
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
#define NULL
Definition: omList.c:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
const poly b
Definition: syzextra.cc:213

◆ mp_Coef2()

void mp_Coef2 ( poly  v,
poly  vars,
matrix c,
matrix m,
const ring  r 
)

corresponds to Macauley's coef: the exponent vector of vars has to contain the variables, eg 'xy'; then the poly f is searched for monomials in x and y, these monimials are written to the first row of the matrix co. the second row of co contains the respective factors in f. Thus f = sum co[1,i]*co[2,i], i = 1..cols, rows equals 2.

Definition at line 512 of file matpol.cc.

513 {
514  poly* s;
515  poly p;
516  int sl,i,j;
517  int l=0;
518  poly sel=mp_Select(v,mon, R);
519 
520  p_Vec2Polys(sel,&s,&sl, R);
521  for (i=0; i<sl; i++)
522  l=si_max(l,pLength(s[i]));
523  *c=mpNew(sl,l);
524  *m=mpNew(sl,l);
525  poly h;
526  int isConst;
527  for (j=1; j<=sl;j++)
528  {
529  p=s[j-1];
530  if (p_IsConstant(p, R)) /*p != NULL */
531  {
532  isConst=-1;
533  i=l;
534  }
535  else
536  {
537  isConst=1;
538  i=1;
539  }
540  while(p!=NULL)
541  {
542  h = p_Head(p, R);
543  MATELEM(*m,j,i) = h;
544  i+=isConst;
545  p = p->next;
546  }
547  }
548  while (v!=NULL)
549  {
550  i = 1;
551  j = p_GetComp(v, R);
552  loop
553  {
554  poly mp=MATELEM(*m,j,i);
555  if (mp!=NULL)
556  {
557  h = mp_Exdiv(v, mp /*MATELEM(*m,j,i)*/, mp, R);
558  if (h!=NULL)
559  {
560  p_SetComp(h,0, R);
561  MATELEM(*c,j,i) = p_Add_q(MATELEM(*c,j,i), h, R);
562  break;
563  }
564  }
565  if (i < l)
566  i++;
567  else
568  break;
569  }
570  v = v->next;
571  }
572 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
static poly mp_Select(poly fro, poly what, const ring)
Definition: matpol.cc:679
loop
Definition: myNF.cc:98
return P p
Definition: myNF.cc:203
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:242
#define p_GetComp(p, r)
Definition: monomials.h:72
static poly mp_Exdiv(poly m, poly d, poly vars, const ring)
Definition: matpol.cc:492
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:812
int j
Definition: myNF.cc:70
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1876
void p_Vec2Polys(poly v, poly **p, int *len, const ring r)
Definition: p_polys.cc:3521
const ring R
Definition: DebugPrint.cc:36
int m
Definition: cfEzgcd.cc:119
static int si_max(const int a, const int b)
Definition: auxiliary.h:120
int i
Definition: cfEzgcd.cc:123
static unsigned pLength(poly a)
Definition: p_polys.h:189
Variable next() const
Definition: factory.h:135
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
static Poly * h
Definition: janet.cc:978
int l
Definition: cfEzgcd.cc:94
#define MATELEM(mat, i, j)
Definition: matpol.h:29

◆ mp_CoeffProc()

matrix mp_CoeffProc ( poly  f,
poly  vars,
const ring  r 
)

Definition at line 410 of file matpol.cc.

411 {
412  assume(vars!=NULL);
413  poly sel, h;
414  int l, i;
415  int pos_of_1 = -1;
416  matrix co;
417 
418  if (f==NULL)
419  {
420  co = mpNew(2, 1);
421  MATELEM(co,1,1) = p_One(R);
422  MATELEM(co,2,1) = NULL;
423  return co;
424  }
425  sel = mp_Select(f, vars, R);
426  l = pLength(sel);
427  co = mpNew(2, l);
428 
430  {
431  for (i=l; i>=1; i--)
432  {
433  h = sel;
434  pIter(sel);
435  pNext(h)=NULL;
436  MATELEM(co,1,i) = h;
437  MATELEM(co,2,i) = NULL;
438  if (p_IsConstant(h, R)) pos_of_1 = i;
439  }
440  }
441  else
442  {
443  for (i=1; i<=l; i++)
444  {
445  h = sel;
446  pIter(sel);
447  pNext(h)=NULL;
448  MATELEM(co,1,i) = h;
449  MATELEM(co,2,i) = NULL;
450  if (p_IsConstant(h, R)) pos_of_1 = i;
451  }
452  }
453  while (f!=NULL)
454  {
455  i = 1;
456  loop
457  {
458  if (i!=pos_of_1)
459  {
460  h = mp_Exdiv(f, MATELEM(co,1,i),vars, R);
461  if (h!=NULL)
462  {
463  MATELEM(co,2,i) = p_Add_q(MATELEM(co,2,i), h, R);
464  break;
465  }
466  }
467  if (i == l)
468  {
469  // check monom 1 last:
470  if (pos_of_1 != -1)
471  {
472  h = mp_Exdiv(f, MATELEM(co,1,pos_of_1),vars, R);
473  if (h!=NULL)
474  {
475  MATELEM(co,2,pos_of_1) = p_Add_q(MATELEM(co,2,pos_of_1), h, R);
476  }
477  }
478  break;
479  }
480  i ++;
481  }
482  pIter(f);
483  }
484  return co;
485 }
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:752
static poly mp_Select(poly fro, poly what, const ring)
Definition: matpol.cc:679
loop
Definition: myNF.cc:98
static poly mp_Exdiv(poly m, poly d, poly vars, const ring)
Definition: matpol.cc:492
#define pIter(p)
Definition: monomials.h:44
poly p_One(const ring r)
Definition: p_polys.cc:1314
#define assume(x)
Definition: mod2.h:394
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1876
const ring R
Definition: DebugPrint.cc:36
FILE * f
Definition: checklibs.c:9
int i
Definition: cfEzgcd.cc:123
static unsigned pLength(poly a)
Definition: p_polys.h:189
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
static Poly * h
Definition: janet.cc:978
int l
Definition: cfEzgcd.cc:94
#define MATELEM(mat, i, j)
Definition: matpol.h:29

◆ mp_Coeffs()

matrix mp_Coeffs ( ideal  I,
int  var,
const ring  r 
)

corresponds to Maple's coeffs: var has to be the number of a variable

Definition at line 323 of file matpol.cc.

324 {
325  poly h,f;
326  int l, i, c, m=0;
327  matrix co;
328  /* look for maximal power m of x_var in I */
329  for (i=IDELEMS(I)-1; i>=0; i--)
330  {
331  f=I->m[i];
332  while (f!=NULL)
333  {
334  l=p_GetExp(f,var, R);
335  if (l>m) m=l;
336  pIter(f);
337  }
338  }
339  co=mpNew((m+1)*I->rank,IDELEMS(I));
340  /* divide each monomial by a power of x_var,
341  * remember the power in l and the component in c*/
342  for (i=IDELEMS(I)-1; i>=0; i--)
343  {
344  f=I->m[i];
345  I->m[i]=NULL;
346  while (f!=NULL)
347  {
348  l=p_GetExp(f,var, R);
349  p_SetExp(f,var,0, R);
350  c=si_max((int)p_GetComp(f, R),1);
351  p_SetComp(f,0, R);
352  p_Setm(f, R);
353  /* now add the resulting monomial to co*/
354  h=pNext(f);
355  pNext(f)=NULL;
356  //MATELEM(co,c*(m+1)-l,i+1)
357  // =p_Add_q(MATELEM(co,c*(m+1)-l,i+1),f, R);
358  MATELEM(co,(c-1)*(m+1)+l+1,i+1)
359  =p_Add_q(MATELEM(co,(c-1)*(m+1)+l+1,i+1),f, R);
360  /* iterate f*/
361  f=h;
362  }
363  }
364  id_Delete(&I, R);
365  return co;
366 }
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:242
#define p_GetComp(p, r)
Definition: monomials.h:72
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define pIter(p)
Definition: monomials.h:44
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:464
const ring R
Definition: DebugPrint.cc:36
int m
Definition: cfEzgcd.cc:119
static int si_max(const int a, const int b)
Definition: auxiliary.h:120
FILE * f
Definition: checklibs.c:9
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:483
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
static Poly * h
Definition: janet.cc:978
int l
Definition: cfEzgcd.cc:94
#define MATELEM(mat, i, j)
Definition: matpol.h:29

◆ mp_Compare()

int mp_Compare ( matrix  a,
matrix  b,
const ring  r 
)

Definition at line 574 of file matpol.cc.

575 {
576  if (MATCOLS(a)<MATCOLS(b)) return -1;
577  else if (MATCOLS(a)>MATCOLS(b)) return 1;
578  if (MATROWS(a)<MATROWS(b)) return -1;
579  else if (MATROWS(a)<MATROWS(b)) return 1;
580 
581  unsigned ii=MATCOLS(a)*MATROWS(a)-1;
582  unsigned j=0;
583  int r=0;
584  while (j<=ii)
585  {
586  r=p_Compare(a->m[j],b->m[j],R);
587  if (r!=0) return r;
588  j++;
589  }
590  return r;
591 }
const poly a
Definition: syzextra.cc:212
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
const ring R
Definition: DebugPrint.cc:36
int p_Compare(const poly a, const poly b, const ring R)
Definition: p_polys.cc:4760
#define MATCOLS(i)
Definition: matpol.h:28
#define MATROWS(i)
Definition: matpol.h:27
const poly b
Definition: syzextra.cc:213

◆ mp_Copy() [1/2]

matrix mp_Copy ( const matrix  a,
const ring  rSrc,
const ring  rDst 
)

copies matrix a from rSrc into rDst

Definition at line 92 of file matpol.cc.

93 {
94  id_Test((ideal)a, rSrc);
95 
96  poly t;
97  int i, m=MATROWS(a), n=MATCOLS(a);
98 
99  matrix b = mpNew(m, n);
100 
101  for (i=m*n-1; i>=0; i--)
102  {
103  t = a->m[i];
104  if (t!=NULL)
105  {
106  b->m[i] = prCopyR_NoSort(t, rSrc, rDst);
107  p_Normalize(b->m[i], rDst);
108  }
109  }
110  b->rank=a->rank;
111 
112  id_Test((ideal)b, rDst);
113 
114  return b;
115 }
poly prCopyR_NoSort(poly p, ring src_r, ring dest_r)
Definition: prCopy.cc:78
const poly a
Definition: syzextra.cc:212
#define id_Test(A, lR)
Definition: simpleideals.h:80
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3680
#define MATCOLS(i)
Definition: matpol.h:28
#define NULL
Definition: omList.c:10
#define MATROWS(i)
Definition: matpol.h:27
polyrec * poly
Definition: hilb.h:10
const poly b
Definition: syzextra.cc:213

◆ mp_Copy() [2/2]

matrix mp_Copy ( matrix  a,
const ring  r 
)

copies matrix a (from ring r to r)

Definition at line 71 of file matpol.cc.

72 {
73  id_Test((ideal)a, r);
74  poly t;
75  int i, m=MATROWS(a), n=MATCOLS(a);
76  matrix b = mpNew(m, n);
77 
78  for (i=m*n-1; i>=0; i--)
79  {
80  t = a->m[i];
81  if (t!=NULL)
82  {
83  p_Normalize(t, r);
84  b->m[i] = p_Copy(t, r);
85  }
86  }
87  b->rank=a->rank;
88  return b;
89 }
const poly a
Definition: syzextra.cc:212
#define id_Test(A, lR)
Definition: simpleideals.h:80
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
const ring r
Definition: syzextra.cc:208
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3680
#define MATCOLS(i)
Definition: matpol.h:28
#define NULL
Definition: omList.c:10
#define MATROWS(i)
Definition: matpol.h:27
polyrec * poly
Definition: hilb.h:10
const poly b
Definition: syzextra.cc:213

◆ mp_Delete()

void mp_Delete ( matrix a,
const ring  r 
)

Definition at line 789 of file matpol.cc.

790 {
791  id_Delete((ideal *) a, r);
792 }
const poly a
Definition: syzextra.cc:212
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
const ring r
Definition: syzextra.cc:208

◆ mp_DetBareiss()

poly mp_DetBareiss ( matrix  a,
const ring  r 
)

returns the determinant of the matrix m; uses Bareiss algorithm

Definition at line 1585 of file matpol.cc.

1586 {
1587  int s;
1588  poly div, res;
1589  if (MATROWS(a) != MATCOLS(a))
1590  {
1591  Werror("det of %d x %d matrix",MATROWS(a),MATCOLS(a));
1592  return NULL;
1593  }
1594  matrix c = mp_Copy(a,r);
1595  mp_permmatrix *Bareiss = new mp_permmatrix(c,r);
1596  row_col_weight w(Bareiss->mpGetRdim(), Bareiss->mpGetCdim());
1597 
1598  /* Bareiss */
1599  div = NULL;
1600  while(Bareiss->mpPivotBareiss(&w))
1601  {
1602  Bareiss->mpElimBareiss(div);
1603  div = Bareiss->mpGetElem(Bareiss->mpGetRdim(), Bareiss->mpGetCdim());
1604  }
1605  Bareiss->mpRowReorder();
1606  Bareiss->mpColReorder();
1607  Bareiss->mpSaveArray();
1608  s = Bareiss->mpGetSign();
1609  delete Bareiss;
1610 
1611  /* result */
1612  res = MATELEM(c,1,1);
1613  MATELEM(c,1,1) = NULL;
1614  id_Delete((ideal *)&c,r);
1615  if (s < 0)
1616  res = p_Neg(res,r);
1617  return res;
1618 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
void mpElimBareiss(poly)
Definition: matpol.cc:1153
const poly a
Definition: syzextra.cc:212
int mpGetSign()
Definition: matpol.cc:859
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void mpSaveArray()
Definition: matpol.cc:861
int mpPivotBareiss(row_col_weight *)
Definition: matpol.cc:1068
void mpRowReorder()
Definition: matpol.cc:1028
poly res
Definition: myNF.cc:322
void mpColReorder()
Definition: matpol.cc:1007
const ring r
Definition: syzextra.cc:208
int mpGetCdim()
Definition: matpol.cc:858
CF_NO_INLINE CanonicalForm div(const CanonicalForm &, const CanonicalForm &)
CF_INLINE CanonicalForm div, mod ( const CanonicalForm & lhs, const CanonicalForm & rhs ) ...
Definition: cf_inline.cc:553
#define MATCOLS(i)
Definition: matpol.h:28
#define NULL
Definition: omList.c:10
const CanonicalForm & w
Definition: facAbsFact.cc:55
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition: matpol.cc:71
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1013
int mpGetRdim()
Definition: matpol.cc:857
#define MATROWS(i)
Definition: matpol.h:27
polyrec * poly
Definition: hilb.h:10
poly mpGetElem(int, int)
Definition: matpol.cc:1145
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define MATELEM(mat, i, j)
Definition: matpol.h:29

◆ mp_Equal()

BOOLEAN mp_Equal ( matrix  a,
matrix  b,
const ring  r 
)

Definition at line 593 of file matpol.cc.

594 {
595  if ((MATCOLS(a)!=MATCOLS(b)) || (MATROWS(a)!=MATROWS(b)))
596  return FALSE;
597  int i=MATCOLS(a)*MATROWS(a)-1;
598  while (i>=0)
599  {
600  if (a->m[i]==NULL)
601  {
602  if (b->m[i]!=NULL) return FALSE;
603  }
604  else if (b->m[i]==NULL) return FALSE;
605  else if (p_Cmp(a->m[i],b->m[i], R)!=0) return FALSE;
606  i--;
607  }
608  i=MATCOLS(a)*MATROWS(a)-1;
609  while (i>=0)
610  {
611  if(!p_EqualPolys(a->m[i],b->m[i], R)) return FALSE;
612  i--;
613  }
614  return TRUE;
615 }
const poly a
Definition: syzextra.cc:212
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1615
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
const ring R
Definition: DebugPrint.cc:36
int i
Definition: cfEzgcd.cc:123
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4367
#define MATCOLS(i)
Definition: matpol.h:28
#define NULL
Definition: omList.c:10
#define MATROWS(i)
Definition: matpol.h:27
const poly b
Definition: syzextra.cc:213

◆ mp_InitI()

matrix mp_InitI ( int  r,
int  c,
int  v,
const ring  R 
)

make it a v * unit matrix

Definition at line 136 of file matpol.cc.

137 {
138  return mp_InitP(r, c, p_ISet(v, R), R);
139 }
matrix mp_InitP(int r, int c, poly p, const ring R)
make it a p * unit matrix
Definition: matpol.cc:120
const ring r
Definition: syzextra.cc:208
const ring R
Definition: DebugPrint.cc:36
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1298

◆ mp_InitP()

matrix mp_InitP ( int  r,
int  c,
poly  p,
const ring  R 
)

make it a p * unit matrix

Definition at line 120 of file matpol.cc.

121 {
122  matrix rc = mpNew(r,c);
123  int i=si_min(r,c), n = c*(i-1)+i-1, inc = c+1;
124 
125  p_Normalize(p, R);
126  while (n>0)
127  {
128  rc->m[n] = p_Copy(p, R);
129  n -= inc;
130  }
131  rc->m[0]=p;
132  return rc;
133 }
static int si_min(const int a, const int b)
Definition: auxiliary.h:121
return P p
Definition: myNF.cc:203
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
poly * m
Definition: matpol.h:19
const ring r
Definition: syzextra.cc:208
const ring R
Definition: DebugPrint.cc:36
int i
Definition: cfEzgcd.cc:123
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3680

◆ mp_IsDiagUnit()

BOOLEAN mp_IsDiagUnit ( matrix  U,
const ring  r 
)

Definition at line 725 of file matpol.cc.

726 {
727  if(MATROWS(U)!=MATCOLS(U))
728  return FALSE;
729  for(int i=MATCOLS(U);i>=1;i--)
730  {
731  for(int j=MATCOLS(U); j>=1; j--)
732  {
733  if (i==j)
734  {
735  if (!p_IsUnit(MATELEM(U,i,i), R)) return FALSE;
736  }
737  else if (MATELEM(U,i,j)!=NULL) return FALSE;
738  }
739  }
740  return TRUE;
741 }
#define FALSE
Definition: auxiliary.h:94
static BOOLEAN p_IsUnit(const poly p, const ring r)
Definition: p_polys.h:1903
#define TRUE
Definition: auxiliary.h:98
int j
Definition: myNF.cc:70
const ring R
Definition: DebugPrint.cc:36
int i
Definition: cfEzgcd.cc:123
#define MATCOLS(i)
Definition: matpol.h:28
#define NULL
Definition: omList.c:10
#define MATROWS(i)
Definition: matpol.h:27
#define MATELEM(mat, i, j)
Definition: matpol.h:29

◆ mp_MinorToResult()

void mp_MinorToResult ( ideal  ,
int &  ,
matrix  ,
int  ,
int  ,
ideal  ,
const ring   
)

entries of a are minors and go to result (only if not in R)

Definition at line 1416 of file matpol.cc.

1418 {
1419  poly *q1;
1420  int e=IDELEMS(result);
1421  int i,j;
1422 
1423  if (R != NULL)
1424  {
1425  for (i=r-1;i>=0;i--)
1426  {
1427  q1 = &(a->m)[i*a->ncols];
1428  //for (j=c-1;j>=0;j--)
1429  //{
1430  // if (q1[j]!=NULL) q1[j] = kNF(R,currRing->qideal,q1[j]);
1431  //}
1432  }
1433  }
1434  for (i=r-1;i>=0;i--)
1435  {
1436  q1 = &(a->m)[i*a->ncols];
1437  for (j=c-1;j>=0;j--)
1438  {
1439  if (q1[j]!=NULL)
1440  {
1441  if (elems>=e)
1442  {
1443  pEnlargeSet(&(result->m),e,e);
1444  e += e;
1445  IDELEMS(result) =e;
1446  }
1447  result->m[elems] = q1[j];
1448  q1[j] = NULL;
1449  elems++;
1450  }
1451  }
1452  }
1453 }
const poly a
Definition: syzextra.cc:212
const ring r
Definition: syzextra.cc:208
for(int i=0;i< R->ExpL_Size;i++) Print("%09lx "
Definition: cfEzgcd.cc:66
int j
Definition: myNF.cc:70
const ring R
Definition: DebugPrint.cc:36
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
#define NULL
Definition: omList.c:10
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3602
polyrec * poly
Definition: hilb.h:10
return result
Definition: facAbsBiFact.cc:76

◆ mp_Monomials()

void mp_Monomials ( matrix  c,
int  r,
int  var,
matrix  m,
const ring  R 
)

Definition at line 373 of file matpol.cc.

374 {
375  /* clear contents of m*/
376  int k,l;
377  for (k=MATROWS(m);k>0;k--)
378  {
379  for(l=MATCOLS(m);l>0;l--)
380  {
381  p_Delete(&MATELEM(m,k,l), R);
382  }
383  }
384  omfreeSize((ADDRESS)m->m,MATROWS(m)*MATCOLS(m)*sizeof(poly));
385  /* allocate monoms in the right size r x MATROWS(c)*/
386  m->m=(poly*)omAlloc0(r*MATROWS(c)*sizeof(poly));
387  MATROWS(m)=r;
388  MATCOLS(m)=MATROWS(c);
389  m->rank=r;
390  /* the maximal power p of x_var: MATCOLS(m)=r*(p+1) */
391  int p=MATCOLS(m)/r-1;
392  /* fill in the powers of x_var=h*/
393  poly h=p_One(R);
394  for(k=r;k>0; k--)
395  {
396  MATELEM(m,k,k*(p+1))=p_One(R);
397  }
398  for(l=p;l>=0; l--)
399  {
400  p_SetExp(h,var,p-l, R);
401  p_Setm(h, R);
402  for(k=r;k>0; k--)
403  {
404  MATELEM(m,k,k*(p+1)-l)=p_Copy(h, R);
405  }
406  }
407  p_Delete(&h, R);
408 }
return P p
Definition: myNF.cc:203
#define omfreeSize(addr, size)
Definition: omAllocDecl.h:236
void * ADDRESS
Definition: auxiliary.h:115
int k
Definition: cfEzgcd.cc:93
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
const ring r
Definition: syzextra.cc:208
poly p_One(const ring r)
Definition: p_polys.cc:1314
const ring R
Definition: DebugPrint.cc:36
int m
Definition: cfEzgcd.cc:119
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:483
#define MATCOLS(i)
Definition: matpol.h:28
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
#define MATROWS(i)
Definition: matpol.h:27
polyrec * poly
Definition: hilb.h:10
static Poly * h
Definition: janet.cc:978
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:94
#define MATELEM(mat, i, j)
Definition: matpol.h:29

◆ mp_Mult()

matrix mp_Mult ( matrix  a,
matrix  b,
const ring  r 
)

Definition at line 220 of file matpol.cc.

221 {
222  int i, j, k;
223  int m = MATROWS(a);
224  int p = MATCOLS(a);
225  int q = MATCOLS(b);
226 
227  if (p!=MATROWS(b))
228  {
229 /*
230 * Werror("cannot multiply %dx%d matrix and %dx%d matrix",
231 * m,p,b->rows(),q);
232 */
233  return NULL;
234  }
235  matrix c = mpNew(m,q);
236 
237  for (i=1; i<=m; i++)
238  {
239  for (k=1; k<=p; k++)
240  {
241  poly aik;
242  if ((aik=MATELEM(a,i,k))!=NULL)
243  {
244  for (j=1; j<=q; j++)
245  {
246  poly bkj;
247  if ((bkj=MATELEM(b,k,j))!=NULL)
248  {
249  poly *cij=&(MATELEM(c,i,j));
250  poly s = pp_Mult_qq(aik /*MATELEM(a,i,k)*/, bkj/*MATELEM(b,k,j)*/, R);
251  if (/*MATELEM(c,i,j)*/ (*cij)==NULL) (*cij)=s;
252  else (*cij) = p_Add_q((*cij) /*MATELEM(c,i,j)*/ ,s, R);
253  }
254  }
255  }
256  // pNormalize(t);
257  // MATELEM(c,i,j) = t;
258  }
259  }
260  for(i=m*q-1;i>=0;i--) p_Normalize(c->m[i], R);
261  return c;
262 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
const poly a
Definition: syzextra.cc:212
return P p
Definition: myNF.cc:203
int k
Definition: cfEzgcd.cc:93
poly * m
Definition: matpol.h:19
int j
Definition: myNF.cc:70
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1070
const ring R
Definition: DebugPrint.cc:36
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3680
#define MATCOLS(i)
Definition: matpol.h:28
#define NULL
Definition: omList.c:10
#define MATROWS(i)
Definition: matpol.h:27
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
const poly b
Definition: syzextra.cc:213
#define MATELEM(mat, i, j)
Definition: matpol.h:29

◆ mp_MultI()

matrix mp_MultI ( matrix  a,
int  f,
const ring  r 
)

c = f*a

Definition at line 142 of file matpol.cc.

143 {
144  int k, n = a->nrows, m = a->ncols;
145  poly p = p_ISet(f, R);
146  matrix c = mpNew(n,m);
147 
148  for (k=m*n-1; k>0; k--)
149  c->m[k] = pp_Mult_qq(a->m[k], p, R);
150  c->m[0] = p_Mult_q(p_Copy(a->m[0], R), p, R);
151  return c;
152 }
const poly a
Definition: syzextra.cc:212
return P p
Definition: myNF.cc:203
int k
Definition: cfEzgcd.cc:93
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
poly * m
Definition: matpol.h:19
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1070
const ring R
Definition: DebugPrint.cc:36
int m
Definition: cfEzgcd.cc:119
FILE * f
Definition: checklibs.c:9
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
polyrec * poly
Definition: hilb.h:10
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1298
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1020

◆ mp_MultP()

matrix mp_MultP ( matrix  a,
poly  p,
const ring  r 
)

multiply a matrix 'a' by a poly 'p', destroy the args

Definition at line 155 of file matpol.cc.

156 {
157  int k, n = a->nrows, m = a->ncols;
158 
159  p_Normalize(p, R);
160  for (k=m*n-1; k>0; k--)
161  {
162  if (a->m[k]!=NULL)
163  a->m[k] = p_Mult_q(a->m[k], p_Copy(p, R), R);
164  }
165  a->m[0] = p_Mult_q(a->m[0], p, R);
166  return a;
167 }
const poly a
Definition: syzextra.cc:212
return P p
Definition: myNF.cc:203
int k
Definition: cfEzgcd.cc:93
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
const ring R
Definition: DebugPrint.cc:36
int m
Definition: cfEzgcd.cc:119
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3680
#define NULL
Definition: omList.c:10
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1020

◆ mp_New()

static matrix mp_New ( int  r,
int  c 
)
inlinestatic

Definition at line 35 of file matpol.h.

35 { return mpNew(r,c); }
const ring r
Definition: syzextra.cc:208
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44

◆ mp_RecMin()

void mp_RecMin ( int  ar,
ideal  result,
int &  elems,
matrix  a,
int  lr,
int  lc,
poly  barDiv,
ideal  R,
const ring  r 
)

for minors with Bareiss

for minors with Bareiss

Definition at line 1512 of file matpol.cc.

1514 {
1515  int k;
1516  int kr=lr-1,kc=lc-1;
1517  matrix nextLevel=mpNew(kr,kc);
1518 
1519  loop
1520  {
1521 /*--- look for an optimal row and bring it to last position ------------*/
1522  if(mp_PrepareRow(a,lr,lc,r)==0) break;
1523 /*--- now take all pivots from the last row ------------*/
1524  k = lc;
1525  loop
1526  {
1527  if(mp_PreparePiv(a,lr,k,r)==0) break;
1528  mp_ElimBar(a,nextLevel,barDiv,lr,k,r);
1529  k--;
1530  if (ar>1)
1531  {
1532  mp_RecMin(ar-1,result,elems,nextLevel,kr,k,a->m[kr*a->ncols+k],R,r);
1533  mp_PartClean(nextLevel,kr,k, r);
1534  }
1535  else mp_MinorToResult(result,elems,nextLevel,kr,k,R,r);
1536  if (ar>k-1) break;
1537  }
1538  if (ar>=kr) break;
1539 /*--- now we have to take out the last row...------------*/
1540  lr = kr;
1541  kr--;
1542  }
1543  mpFinalClean(nextLevel);
1544 }
const poly a
Definition: syzextra.cc:212
loop
Definition: myNF.cc:98
void mp_RecMin(int ar, ideal result, int &elems, matrix a, int lr, int lc, poly barDiv, ideal R, const ring r)
produces recursively the ideal of all arxar-minors of a
Definition: matpol.cc:1512
static void mp_ElimBar(matrix a0, matrix re, poly div, int lr, int lc, const ring R)
Definition: matpol.cc:1358
static void mpFinalClean(matrix a)
Definition: matpol.cc:1504
static int mp_PrepareRow(matrix a, int lr, int lc, const ring R)
Definition: matpol.cc:1290
int k
Definition: cfEzgcd.cc:93
static void mp_PartClean(matrix a, int lr, int lc, const ring R)
Definition: matpol.cc:713
void mp_MinorToResult(ideal result, int &elems, matrix a, int r, int c, ideal R, const ring)
entries of a are minors and go to result (only if not in R)
Definition: matpol.cc:1416
CanonicalForm lc(const CanonicalForm &f)
const ring r
Definition: syzextra.cc:208
static int mp_PreparePiv(matrix a, int lr, int lc, const ring r)
Definition: matpol.cc:1348
const ring R
Definition: DebugPrint.cc:36
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
return result
Definition: facAbsBiFact.cc:76

◆ mp_Sub()

matrix mp_Sub ( matrix  a,
matrix  b,
const ring  r 
)

Definition at line 203 of file matpol.cc.

204 {
205  int k, n = a->nrows, m = a->ncols;
206  if ((n != b->nrows) || (m != b->ncols))
207  {
208 /*
209 * Werror("cannot sub %dx%d matrix and %dx%d matrix",
210 * m,n,b->cols(),b->rows());
211 */
212  return NULL;
213  }
214  matrix c = mpNew(n,m);
215  for (k=m*n-1; k>=0; k--)
216  c->m[k] = p_Sub(p_Copy(a->m[k], R), p_Copy(b->m[k], R), R);
217  return c;
218 }
const poly a
Definition: syzextra.cc:212
int k
Definition: cfEzgcd.cc:93
poly p_Sub(poly p1, poly p2, const ring r)
Definition: p_polys.cc:1951
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
poly * m
Definition: matpol.h:19
const ring R
Definition: DebugPrint.cc:36
int m
Definition: cfEzgcd.cc:119
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
#define NULL
Definition: omList.c:10
const poly b
Definition: syzextra.cc:213

◆ mp_Tensor()

ideal mp_Tensor ( ideal  A,
ideal  B,
const ring  r 
)

Definition at line 1757 of file matpol.cc.

1758 {
1759  // size of the result n*q x m*p
1760  int n=IDELEMS(A); // m x n
1761  int m=A->rank;
1762  int q=IDELEMS(B); // p x q
1763  int p=B->rank;
1764  ideal res=idInit(n*q,m*p);
1765  poly *a=(poly*)omAlloc(m*sizeof(poly));
1766  for(int i=0; i<n; i++)
1767  {
1768  memset(a,0,m*sizeof(poly));
1769  p_DecomposeComp(p_Copy(A->m[i],r),a,m,r);
1770  for(int j=0;j<m;j++)
1771  {
1772  if (a[j]!=NULL)
1773  {
1774  ideal sm=mp_MultAndShift(a[j], // A_i_j
1775  B,
1776  j*p, // shift j*p down
1777  r);
1778  mp_AddSubMat(res,sm,i*q,r); // add this columns to col i*q ff
1779  id_Delete(&sm,r); // delete the now empty ideal
1780  }
1781  }
1782  }
1783  omFreeSize(a,m*sizeof(poly));
1784  return res;
1785 }
const poly a
Definition: syzextra.cc:212
return P p
Definition: myNF.cc:203
static ideal mp_MultAndShift(poly f, ideal B, int s, const ring r)
Definition: matpol.cc:1729
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
static void p_DecomposeComp(poly p, poly *a, int l, const ring r)
Definition: matpol.cc:1710
#define omAlloc(size)
Definition: omAllocDecl.h:210
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
#define A
Definition: sirandom.c:23
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
#define NULL
Definition: omList.c:10
b *CanonicalForm B
Definition: facBivar.cc:51
static void mp_AddSubMat(ideal res, ideal sm, int col, const ring r)
Definition: matpol.cc:1748
polyrec * poly
Definition: hilb.h:10

◆ mp_Trace()

poly mp_Trace ( matrix  a,
const ring  r 
)

Definition at line 285 of file matpol.cc.

286 {
287  int i;
288  int n = (MATCOLS(a)<MATROWS(a)) ? MATCOLS(a) : MATROWS(a);
289  poly t = NULL;
290 
291  for (i=1; i<=n; i++)
292  t = p_Add_q(t, p_Copy(MATELEM(a,i,i), R), R);
293  return t;
294 }
const poly a
Definition: syzextra.cc:212
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
const ring R
Definition: DebugPrint.cc:36
int i
Definition: cfEzgcd.cc:123
#define MATCOLS(i)
Definition: matpol.h:28
#define NULL
Definition: omList.c:10
#define MATROWS(i)
Definition: matpol.h:27
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
#define MATELEM(mat, i, j)
Definition: matpol.h:29

◆ mp_Transp()

matrix mp_Transp ( matrix  a,
const ring  r 
)

Definition at line 264 of file matpol.cc.

265 {
266  int i, j, r = MATROWS(a), c = MATCOLS(a);
267  poly *p;
268  matrix b = mpNew(c,r);
269 
270  p = b->m;
271  for (i=0; i<c; i++)
272  {
273  for (j=0; j<r; j++)
274  {
275  if (a->m[j*c+i]!=NULL) *p = p_Copy(a->m[j*c+i], R);
276  p++;
277  }
278  }
279  return b;
280 }
const poly a
Definition: syzextra.cc:212
return P p
Definition: myNF.cc:203
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
const ring R
Definition: DebugPrint.cc:36
int i
Definition: cfEzgcd.cc:123
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
#define MATCOLS(i)
Definition: matpol.h:28
#define NULL
Definition: omList.c:10
#define MATROWS(i)
Definition: matpol.h:27
polyrec * poly
Definition: hilb.h:10
const poly b
Definition: syzextra.cc:213

◆ mp_Wedge()

matrix mp_Wedge ( matrix  a,
int  ar,
const ring  r 
)

Definition at line 1660 of file matpol.cc.

1661 {
1662  int i,j,k,l;
1663  int *rowchoise,*colchoise;
1664  BOOLEAN rowch,colch;
1665  matrix result;
1666  matrix tmp;
1667  poly p;
1668 
1669  i = binom(a->nrows,ar);
1670  j = binom(a->ncols,ar);
1671 
1672  rowchoise=(int *)omAlloc(ar*sizeof(int));
1673  colchoise=(int *)omAlloc(ar*sizeof(int));
1674  result = mpNew(i,j);
1675  tmp = mpNew(ar,ar);
1676  l = 1; /* k,l:the index in result*/
1677  idInitChoise(ar,1,a->nrows,&rowch,rowchoise);
1678  while (!rowch)
1679  {
1680  k=1;
1681  idInitChoise(ar,1,a->ncols,&colch,colchoise);
1682  while (!colch)
1683  {
1684  for (i=1; i<=ar; i++)
1685  {
1686  for (j=1; j<=ar; j++)
1687  {
1688  MATELEM(tmp,i,j) = MATELEM(a,rowchoise[i-1],colchoise[j-1]);
1689  }
1690  }
1691  p = mp_DetBareiss(tmp, R);
1692  if ((k+l) & 1) p=p_Neg(p, R);
1693  MATELEM(result,l,k) = p;
1694  k++;
1695  idGetNextChoise(ar,a->ncols,&colch,colchoise);
1696  }
1697  idGetNextChoise(ar,a->nrows,&rowch,rowchoise);
1698  l++;
1699  }
1700 
1701  /*delete the matrix tmp*/
1702  for (i=1; i<=ar; i++)
1703  {
1704  for (j=1; j<=ar; j++) MATELEM(tmp,i,j) = NULL;
1705  }
1706  id_Delete((ideal *) &tmp, R);
1707  return (result);
1708 }
const poly a
Definition: syzextra.cc:212
return P p
Definition: myNF.cc:203
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
int k
Definition: cfEzgcd.cc:93
#define omAlloc(size)
Definition: omAllocDecl.h:210
int j
Definition: myNF.cc:70
const ring R
Definition: DebugPrint.cc:36
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
int i
Definition: cfEzgcd.cc:123
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:44
#define NULL
Definition: omList.c:10
void idInitChoise(int r, int beg, int end, BOOLEAN *endch, int *choise)
poly mp_DetBareiss(matrix a, const ring r)
returns the determinant of the matrix m; uses Bareiss algorithm
Definition: matpol.cc:1585
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1013
polyrec * poly
Definition: hilb.h:10
int BOOLEAN
Definition: auxiliary.h:85
int binom(int n, int r)
return result
Definition: facAbsBiFact.cc:76
int l
Definition: cfEzgcd.cc:94
#define MATELEM(mat, i, j)
Definition: matpol.h:29

◆ mpNew()

matrix mpNew ( int  r,
int  c 
)

create a r x c zero-matrix

Definition at line 44 of file matpol.cc.

45 {
46  int rr=r;
47  if (rr<=0) rr=1;
48  //if ( (((int)(MAX_INT_VAL/sizeof(poly))) / rr) <= c)
49  //{
50  // Werror("internal error: creating matrix[%d][%d]",r,c);
51  // return NULL;
52  //}
54  rc->nrows = r;
55  rc->ncols = c;
56  rc->rank = r;
57  if ((c != 0)&&(r!=0))
58  {
59  size_t s=((size_t)r)*((size_t)c)*sizeof(poly);
60  rc->m = (poly*)omAlloc0(s);
61  //if (rc->m==NULL)
62  //{
63  // Werror("internal error: creating matrix[%d][%d]",r,c);
64  // return NULL;
65  //}
66  }
67  return rc;
68 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
const CanonicalForm int s
Definition: facAbsFact.cc:55
int ncols
Definition: matpol.h:22
omBin sip_sideal_bin
Definition: simpleideals.cc:30
poly * m
Definition: matpol.h:19
const ring r
Definition: syzextra.cc:208
int nrows
Definition: matpol.h:21
ip_smatrix * matrix
polyrec * poly
Definition: hilb.h:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211
long rank
Definition: matpol.h:20

◆ pMultMp()

matrix pMultMp ( poly  p,
matrix  a,
const ring  r 
)

Definition at line 172 of file matpol.cc.

173 {
174  int k, n = a->nrows, m = a->ncols;
175 
176  p_Normalize(p, R);
177  for (k=m*n-1; k>0; k--)
178  {
179  if (a->m[k]!=NULL)
180  a->m[k] = p_Mult_q(p_Copy(p, R), a->m[k], R);
181  }
182  a->m[0] = p_Mult_q(p, a->m[0], R);
183  return a;
184 }
const poly a
Definition: syzextra.cc:212
return P p
Definition: myNF.cc:203
int k
Definition: cfEzgcd.cc:93
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:804
const ring R
Definition: DebugPrint.cc:36
int m
Definition: cfEzgcd.cc:119
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3680
#define NULL
Definition: omList.c:10
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1020

◆ TraceOfProd()

poly TraceOfProd ( matrix  a,
matrix  b,
int  n,
const ring  r 
)

Definition at line 299 of file matpol.cc.

300 {
301  int i, j;
302  poly p, t = NULL;
303 
304  for (i=1; i<=n; i++)
305  {
306  for (j=1; j<=n; j++)
307  {
308  p = pp_Mult_qq(MATELEM(a,i,j), MATELEM(b,j,i), R);
309  t = p_Add_q(t, p, R);
310  }
311  }
312  return t;
313 }
const poly a
Definition: syzextra.cc:212
return P p
Definition: myNF.cc:203
int j
Definition: myNF.cc:70
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1070
const ring R
Definition: DebugPrint.cc:36
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877
const poly b
Definition: syzextra.cc:213
#define MATELEM(mat, i, j)
Definition: matpol.h:29

Variable Documentation

◆ ip_smatrix_bin

omBin ip_smatrix_bin