Data Structures | Functions
matpol.cc File Reference
#include <stdio.h>
#include <math.h>
#include <misc/auxiliary.h>
#include <omalloc/omalloc.h>
#include <misc/mylimits.h>
#include <misc/intvec.h>
#include <coeffs/numbers.h>
#include <reporter/reporter.h>
#include "monomials/ring.h"
#include "monomials/p_polys.h"
#include "simpleideals.h"
#include "matpol.h"
#include "prCopy.h"
#include "sparsmat.h"

Go to the source code of this file.

Data Structures

class  row_col_weight
 
class  mp_permmatrix
 

Functions

static poly mp_Exdiv (poly m, poly d, poly vars, const ring)
 
static poly mp_Select (poly fro, poly what, const ring)
 
matrix mpNew (int r, int c)
 create a r x c zero-matrix More...
 
matrix mp_Copy (matrix a, const ring r)
 copies matrix a (from ring r to r) More...
 
matrix mp_Copy (const matrix a, const ring rSrc, const ring rDst)
 copies matrix a from rSrc into rDst 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)
 
poly mp_Trace (matrix a, const ring R)
 
poly TraceOfProd (matrix a, matrix b, int n, 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...
 
void mp_Monomials (matrix c, int r, int var, matrix m, const ring R)
 
matrix mp_CoeffProc (poly f, poly vars, const ring R)
 
void mp_Coef2 (poly v, poly mon, 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...
 
int mp_Compare (matrix a, matrix b, const ring R)
 
BOOLEAN mp_Equal (matrix a, matrix b, const ring R)
 
static poly p_Insert (poly p1, poly p2, const ring R)
 
static void mp_PartClean (matrix a, int lr, int lc, const ring R)
 
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)
 
void mp_Delete (matrix *a, const ring r)
 
static float mp_PolyWeight (poly p, const ring r)
 
static void mpReplace (int j, int n, int &sign, int *perm)
 
static int mp_PivBar (matrix a, int lr, int lc, const ring r)
 
static void mpSwapRow (matrix a, int pos, int lr, int lc)
 
static int mp_PrepareRow (matrix a, int lr, int lc, const ring R)
 
static int mp_PivRow (matrix a, int lr, int lc, const ring r)
 
static void mpSwapCol (matrix a, int pos, int lr, int lc)
 
static int mp_PreparePiv (matrix a, int lr, int lc, const ring r)
 
static void mp_ElimBar (matrix a0, matrix re, poly div, int lr, int lc, const ring R)
 
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) More...
 
static void mpFinalClean (matrix a)
 
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 More...
 
poly mp_DetBareiss (matrix a, const ring r)
 returns the determinant of the matrix m; uses Bareiss algorithm More...
 
matrix mp_Wedge (matrix a, int ar, const ring R)
 
static void p_DecomposeComp (poly p, poly *a, int l, const ring r)
 
static ideal mp_MultAndShift (poly f, ideal B, int s, const ring r)
 
static void mp_AddSubMat (ideal res, ideal sm, int col, const ring r)
 
ideal mp_Tensor (ideal A, ideal B, const ring r)
 

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 }
int ncols
Definition: matpol.h:22
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
int nrows
Definition: matpol.h:21
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

◆ mp_AddSubMat()

static void mp_AddSubMat ( ideal  res,
ideal  sm,
int  col,
const ring  r 
)
static

Definition at line 1748 of file matpol.cc.

1749 {
1750  for(int i=0;i<IDELEMS(sm);i++)
1751  {
1752  res->m[col+i]=p_Add_q(res->m[col+i],sm->m[i],r);
1753  sm->m[i]=NULL;
1754  }
1755 }
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
#define IDELEMS(i)
Definition: simpleideals.h:24
#define NULL
Definition: omList.c:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:877

◆ mp_Coef2()

void mp_Coef2 ( poly  v,
poly  mon,
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
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
poly * m
Definition: matpol.h:19
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 }
poly * m
Definition: matpol.h:19
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

◆ mp_Copy() [1/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 }
#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
poly * m
Definition: matpol.h:19
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
long rank
Definition: matpol.h:20

◆ mp_Copy() [2/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
#define id_Test(A, lR)
Definition: simpleideals.h:80
poly * m
Definition: matpol.h:19
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
long rank
Definition: matpol.h:20

◆ 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 }
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
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_ElimBar()

static void mp_ElimBar ( matrix  a0,
matrix  re,
poly  div,
int  lr,
int  lc,
const ring  R 
)
static

Definition at line 1358 of file matpol.cc.

1359 {
1360  int r=lr-1, c=lc-1;
1361  poly *b = a0->m, *x = re->m;
1362  poly piv, elim, q1, *ap, *a, *q;
1363  int i, j;
1364 
1365  ap = &b[r*a0->ncols];
1366  piv = ap[c];
1367  for(j=c-1; j>=0; j--)
1368  if (ap[j] != NULL) ap[j] = p_Neg(ap[j],R);
1369  for(i=r-1; i>=0; i--)
1370  {
1371  a = &b[i*a0->ncols];
1372  q = &x[i*re->ncols];
1373  if (a[c] != NULL)
1374  {
1375  elim = a[c];
1376  for (j=c-1; j>=0; j--)
1377  {
1378  q1 = NULL;
1379  if (a[j] != NULL)
1380  {
1381  q1 = sm_MultDiv(a[j], piv, div,R);
1382  if (ap[j] != NULL)
1383  {
1384  poly q2 = sm_MultDiv(ap[j], elim, div, R);
1385  q1 = p_Add_q(q1,q2,R);
1386  }
1387  }
1388  else if (ap[j] != NULL)
1389  q1 = sm_MultDiv(ap[j], elim, div, R);
1390  if (q1 != NULL)
1391  {
1392  if (div)
1393  sm_SpecialPolyDiv(q1, div,R);
1394  q[j] = q1;
1395  }
1396  }
1397  }
1398  else
1399  {
1400  for (j=c-1; j>=0; j--)
1401  {
1402  if (a[j] != NULL)
1403  {
1404  q1 = sm_MultDiv(a[j], piv, div, R);
1405  if (div)
1406  sm_SpecialPolyDiv(q1, div, R);
1407  q[j] = q1;
1408  }
1409  }
1410  }
1411  }
1412 }
void sm_SpecialPolyDiv(poly a, poly b, const ring R)
Definition: sparsmat.cc:1893
const poly a
Definition: syzextra.cc:212
int ncols
Definition: matpol.h:22
CanonicalForm lc(const CanonicalForm &f)
poly * m
Definition: matpol.h:19
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
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 NULL
Definition: omList.c:10
Variable x
Definition: cfModGcd.cc:4023
poly sm_MultDiv(poly a, poly b, const poly c, const ring R)
Definition: sparsmat.cc:1812
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1013
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

◆ 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 }
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
poly * m
Definition: matpol.h:19
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

◆ mp_Exdiv()

static poly mp_Exdiv ( poly  m,
poly  d,
poly  vars,
const ring  R 
)
static

Definition at line 492 of file matpol.cc.

493 {
494  int i;
495  poly h = p_Head(m, R);
496  for (i=1; i<=rVar(R); i++)
497  {
498  if (p_GetExp(vars,i, R) > 0)
499  {
500  if (p_GetExp(d,i, R) != p_GetExp(h,i, R))
501  {
502  p_Delete(&h, R);
503  return NULL;
504  }
505  p_SetExp(h,i,0, R);
506  }
507  }
508  p_Setm(h, R);
509  return h;
510 }
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:812
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
int i
Definition: cfEzgcd.cc:123
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 NULL
Definition: omList.c:10
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
polyrec * poly
Definition: hilb.h:10
static Poly * h
Definition: janet.cc:978

◆ 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  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 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 }
int ncols
Definition: matpol.h:22
poly * m
Definition: matpol.h:19
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
poly * m
Definition: matpol.h:19
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
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
long rank
Definition: matpol.h:20
#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
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
#define MATELEM(mat, i, j)
Definition: matpol.h:29

◆ mp_MultAndShift()

static ideal mp_MultAndShift ( poly  f,
ideal  B,
int  s,
const ring  r 
)
static

Definition at line 1729 of file matpol.cc.

1730 {
1731  assume(f!=NULL);
1732  ideal res=idInit(IDELEMS(B),B->rank+s);
1733  int q=IDELEMS(B); // p x q
1734  for(int j=0;j<q;j++)
1735  {
1736  poly h=pp_Mult_qq(f,B->m[j],r);
1737  if (h!=NULL)
1738  {
1739  if (s>0) p_Shift(&h,s,r);
1740  res->m[j]=h;
1741  }
1742  }
1743  p_Delete(&f,r);
1744  return res;
1745 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:394
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1070
FILE * f
Definition: checklibs.c:9
#define IDELEMS(i)
Definition: simpleideals.h:24
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4561
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
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
polyrec * poly
Definition: hilb.h:10
static Poly * h
Definition: janet.cc:978

◆ 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 }
int ncols
Definition: matpol.h:22
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
int nrows
Definition: matpol.h:21
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
int ncols
Definition: matpol.h:22
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
int nrows
Definition: matpol.h:21
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_PartClean()

static void mp_PartClean ( matrix  a,
int  lr,
int  lc,
const ring  R 
)
static

Definition at line 713 of file matpol.cc.

714 {
715  poly *q1;
716  int i,j;
717 
718  for (i=lr-1;i>=0;i--)
719  {
720  q1 = &(a->m)[i*a->ncols];
721  for (j=lc-1;j>=0;j--) if(q1[j]) p_Delete(&q1[j], R);
722  }
723 }
int ncols
Definition: matpol.h:22
CanonicalForm lc(const CanonicalForm &f)
poly * m
Definition: matpol.h:19
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
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:843
polyrec * poly
Definition: hilb.h:10

◆ mp_PivBar()

static int mp_PivBar ( matrix  a,
int  lr,
int  lc,
const ring  r 
)
static

Definition at line 1243 of file matpol.cc.

1244 {
1245  float f1, f2;
1246  poly *q1;
1247  int i,j,io;
1248 
1249  io = -1;
1250  f1 = 1.0e30;
1251  for (i=lr-1;i>=0;i--)
1252  {
1253  q1 = &(a->m)[i*a->ncols];
1254  f2 = 0.0;
1255  for (j=lc-1;j>=0;j--)
1256  {
1257  if (q1[j]!=NULL)
1258  f2 += mp_PolyWeight(q1[j],r);
1259  }
1260  if ((f2!=0.0) && (f2<f1))
1261  {
1262  f1 = f2;
1263  io = i;
1264  }
1265  }
1266  if (io<0) return 0;
1267  else return io+1;
1268 }
int ncols
Definition: matpol.h:22
CanonicalForm lc(const CanonicalForm &f)
poly * m
Definition: matpol.h:19
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
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
polyrec * poly
Definition: hilb.h:10
static float mp_PolyWeight(poly p, const ring r)
Definition: matpol.cc:1211

◆ mp_PivRow()

static int mp_PivRow ( matrix  a,
int  lr,
int  lc,
const ring  r 
)
static

Definition at line 1303 of file matpol.cc.

1304 {
1305  float f1, f2;
1306  poly *q1;
1307  int j,jo;
1308 
1309  jo = -1;
1310  f1 = 1.0e30;
1311  q1 = &(a->m)[(lr-1)*a->ncols];
1312  for (j=lc-1;j>=0;j--)
1313  {
1314  if (q1[j]!=NULL)
1315  {
1316  f2 = mp_PolyWeight(q1[j],r);
1317  if (f2<f1)
1318  {
1319  f1 = f2;
1320  jo = j;
1321  }
1322  }
1323  }
1324  if (jo<0) return 0;
1325  else return jo+1;
1326 }
int ncols
Definition: matpol.h:22
CanonicalForm lc(const CanonicalForm &f)
poly * m
Definition: matpol.h:19
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
#define NULL
Definition: omList.c:10
polyrec * poly
Definition: hilb.h:10
static float mp_PolyWeight(poly p, const ring r)
Definition: matpol.cc:1211

◆ mp_PolyWeight()

static float mp_PolyWeight ( poly  p,
const ring  r 
)
static

Definition at line 1211 of file matpol.cc.

1212 {
1213  int i;
1214  float res;
1215 
1216  if (pNext(p) == NULL)
1217  {
1218  res = (float)n_Size(pGetCoeff(p),r->cf);
1219  for (i=r->N;i>0;i--)
1220  {
1221  if(p_GetExp(p,i,r)!=0)
1222  {
1223  res += 2.0;
1224  break;
1225  }
1226  }
1227  }
1228  else
1229  {
1230  res = 0.0;
1231  do
1232  {
1233  res += (float)n_Size(pGetCoeff(p),r->cf)+2.0;
1234  pIter(p);
1235  }
1236  while (p);
1237  }
1238  return res;
1239 }
return P p
Definition: myNF.cc:203
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
#define pIter(p)
Definition: monomials.h:44
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
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
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition: coeffs.h:574

◆ mp_PreparePiv()

static int mp_PreparePiv ( matrix  a,
int  lr,
int  lc,
const ring  r 
)
static

Definition at line 1348 of file matpol.cc.

1349 {
1350  int c;
1351 
1352  c = mp_PivRow(a, lr, lc,r);
1353  if(c==0) return 0;
1354  if(c<lc) mpSwapCol(a, c, lr, lc);
1355  return 1;
1356 }
CanonicalForm lc(const CanonicalForm &f)
static void mpSwapCol(matrix a, int pos, int lr, int lc)
Definition: matpol.cc:1328
const ring r
Definition: syzextra.cc:208
static int mp_PivRow(matrix a, int lr, int lc, const ring r)
Definition: matpol.cc:1303

◆ mp_PrepareRow()

static int mp_PrepareRow ( matrix  a,
int  lr,
int  lc,
const ring  R 
)
static

Definition at line 1290 of file matpol.cc.

1291 {
1292  int r;
1293 
1294  r = mp_PivBar(a,lr,lc,R);
1295  if(r==0) return 0;
1296  if(r<lr) mpSwapRow(a, r, lr, lc);
1297  return 1;
1298 }
static int mp_PivBar(matrix a, int lr, int lc, const ring r)
Definition: matpol.cc:1243
CanonicalForm lc(const CanonicalForm &f)
const ring r
Definition: syzextra.cc:208
const ring R
Definition: DebugPrint.cc:36
static void mpSwapRow(matrix a, int pos, int lr, int lc)
Definition: matpol.cc:1270

◆ mp_RecMin()

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

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 }
int ncols
Definition: matpol.h:22
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)
poly * m
Definition: matpol.h:19
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_Select()

static poly mp_Select ( poly  fro,
poly  what,
const ring  R 
)
static

Definition at line 679 of file matpol.cc.

680 {
681  int i;
682  poly h, res;
683  res = NULL;
684  while (fro!=NULL)
685  {
686  h = p_One(R);
687  for (i=1; i<=rVar(R); i++)
688  p_SetExp(h,i, p_GetExp(fro,i, R) * p_GetExp(what, i, R), R);
689  p_SetComp(h, p_GetComp(fro, R), R);
690  p_Setm(h, R);
691  res = p_Insert(h, res, R);
692  fro = fro->next;
693  }
694  return res;
695 }
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 short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:583
poly res
Definition: myNF.cc:322
poly p_One(const ring r)
Definition: p_polys.cc:1314
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 i
Definition: cfEzgcd.cc:123
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
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:228
polyrec * poly
Definition: hilb.h:10
static Poly * h
Definition: janet.cc:978
static poly p_Insert(poly p1, poly p2, const ring R)
Definition: matpol.cc:621

◆ 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 }
int ncols
Definition: matpol.h:22
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
int nrows
Definition: matpol.h:21
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

◆ 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 }
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 }
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
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 }
int ncols
Definition: matpol.h:22
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 nrows
Definition: matpol.h:21
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

◆ mpFinalClean()

static void mpFinalClean ( matrix  a)
static

Definition at line 1504 of file matpol.cc.

1505 {
1506  omFreeSize((ADDRESS)a->m,a->nrows*a->ncols*sizeof(poly));
1508 }
int ncols
Definition: matpol.h:22
omBin sip_sideal_bin
Definition: simpleideals.cc:30
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:115
poly * m
Definition: matpol.h:19
int nrows
Definition: matpol.h:21
polyrec * poly
Definition: hilb.h:10
#define omFreeBin(addr, bin)
Definition: omAllocDecl.h:259

◆ 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

◆ mpReplace()

static void mpReplace ( int  j,
int  n,
int &  sign,
int *  perm 
)
static

Definition at line 1053 of file matpol.cc.

1054 {
1055  int k;
1056 
1057  if (j != n)
1058  {
1059  k = perm[n];
1060  perm[n] = perm[j];
1061  perm[j] = k;
1062  sign = -sign;
1063  }
1064 }
int k
Definition: cfEzgcd.cc:93
int j
Definition: myNF.cc:70
static int sign(int x)
Definition: ring.cc:3342

◆ mpSwapCol()

static void mpSwapCol ( matrix  a,
int  pos,
int  lr,
int  lc 
)
static

Definition at line 1328 of file matpol.cc.

1329 {
1330  poly sw;
1331  int j;
1332  poly* a2 = a->m;
1333  poly* a1 = &a2[pos-1];
1334 
1335  a2 = &a2[lc-1];
1336  for (j=a->ncols*(lr-1); j>=0; j-=a->ncols)
1337  {
1338  sw = a1[j];
1339  a1[j] = a2[j];
1340  a2[j] = sw;
1341  }
1342 }
int ncols
Definition: matpol.h:22
CanonicalForm lc(const CanonicalForm &f)
poly * m
Definition: matpol.h:19
int j
Definition: myNF.cc:70
polyrec * poly
Definition: hilb.h:10

◆ mpSwapRow()

static void mpSwapRow ( matrix  a,
int  pos,
int  lr,
int  lc 
)
static

Definition at line 1270 of file matpol.cc.

1271 {
1272  poly sw;
1273  int j;
1274  poly* a2 = a->m;
1275  poly* a1 = &a2[a->ncols*(pos-1)];
1276 
1277  a2 = &a2[a->ncols*(lr-1)];
1278  for (j=lc-1; j>=0; j--)
1279  {
1280  sw = a1[j];
1281  a1[j] = a2[j];
1282  a2[j] = sw;
1283  }
1284 }
int ncols
Definition: matpol.h:22
CanonicalForm lc(const CanonicalForm &f)
poly * m
Definition: matpol.h:19
int j
Definition: myNF.cc:70
polyrec * poly
Definition: hilb.h:10

◆ p_DecomposeComp()

static void p_DecomposeComp ( poly  p,
poly a,
int  l,
const ring  r 
)
static

Definition at line 1710 of file matpol.cc.

1711 {
1712  poly h=p;
1713  while(h!=NULL)
1714  {
1715  poly hh=pNext(h);
1716  pNext(h)=a[p_GetComp(h,r)-1];
1717  a[p_GetComp(h,r)-1]=h;
1718  p_SetComp(h,0,r);
1719  p_SetmComp(h,r);
1720  h=hh;
1721  }
1722  for(int i=0;i<l;i++)
1723  {
1724  if(a[i]!=NULL) a[i]=pReverse(a[i]);
1725  }
1726 }
const poly a
Definition: syzextra.cc:212
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
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
static poly pReverse(poly p)
Definition: p_polys.h:330
#define p_SetmComp
Definition: p_polys.h:239
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
polyrec * poly
Definition: hilb.h:10
static Poly * h
Definition: janet.cc:978
int l
Definition: cfEzgcd.cc:94

◆ p_Insert()

static poly p_Insert ( poly  p1,
poly  p2,
const ring  R 
)
static

Definition at line 621 of file matpol.cc.

622 {
623  poly a1, p, a2, a;
624  int c;
625 
626  if (p1==NULL) return p2;
627  if (p2==NULL) return p1;
628  a1 = p1;
629  a2 = p2;
630  a = p = p_One(R);
631  loop
632  {
633  c = p_Cmp(a1, a2, R);
634  if (c == 1)
635  {
636  a = pNext(a) = a1;
637  pIter(a1);
638  if (a1==NULL)
639  {
640  pNext(a) = a2;
641  break;
642  }
643  }
644  else if (c == -1)
645  {
646  a = pNext(a) = a2;
647  pIter(a2);
648  if (a2==NULL)
649  {
650  pNext(a) = a1;
651  break;
652  }
653  }
654  else
655  {
656  p_LmDelete(&a2, R);
657  a = pNext(a) = a1;
658  pIter(a1);
659  if (a1==NULL)
660  {
661  pNext(a) = a2;
662  break;
663  }
664  else if (a2==NULL)
665  {
666  pNext(a) = a1;
667  break;
668  }
669  }
670  }
671  p_LmDelete(&p, R);
672  return p;
673 }
const poly a
Definition: syzextra.cc:212
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1615
loop
Definition: myNF.cc:98
return P p
Definition: myNF.cc:203
#define pIter(p)
Definition: monomials.h:44
poly p_One(const ring r)
Definition: p_polys.cc:1314
const ring R
Definition: DebugPrint.cc:36
#define NULL
Definition: omList.c:10
#define pNext(p)
Definition: monomials.h:43
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:706
END_NAMESPACE const void * p2
Definition: syzextra.cc:202
polyrec * poly
Definition: hilb.h:10

◆ 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
int ncols
Definition: matpol.h:22
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
int nrows
Definition: matpol.h:21
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 }
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
#define MATELEM(mat, i, j)
Definition: matpol.h:29