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 27 of file matpol.h.

◆ MATELEM

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

Definition at line 28 of file matpol.h.

◆ MATROWS

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

Definition at line 26 of file matpol.h.

Typedef Documentation

◆ matrix

typedef ip_smatrix* matrix

Definition at line 31 of file matpol.h.

Function Documentation

◆ iiStringMatrix()

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

Definition at line 755 of file matpol.cc.

756 {
757  int i,ii = MATROWS(im);
758  int j,jj = MATCOLS(im);
759  poly *pp = im->m;
760  char ch_s[2];
761  ch_s[0]=ch;
762  ch_s[1]='\0';
763 
764  StringSetS("");
765 
766  for (i=0; i<ii; i++)
767  {
768  for (j=0; j<jj; j++)
769  {
770  p_String0(*pp++, r);
771  StringAppendS(ch_s);
772  if (dim > 1) StringAppendS("\n");
773  }
774  }
775  char *s=StringEndS();
776  s[strlen(s)- (dim > 1 ? 2 : 1)]='\0';
777  return s;
778 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
int j
Definition: facHensel.cc:105
char * StringEndS()
Definition: reporter.cc:151
poly * m
Definition: matpol.h:18
void StringSetS(const char *st)
Definition: reporter.cc:128
void StringAppendS(const char *st)
Definition: reporter.cc:107
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:253
int dim(ideal I, ring r)
int i
Definition: cfEzgcd.cc:125
#define MATCOLS(i)
Definition: matpol.h:27
void p_String0(poly p, ring lmRing, ring tailRing)
print p according to ShortOut in lmRing & tailRing
Definition: polys0.cc:134
#define MATROWS(i)
Definition: matpol.h:26

◆ iiWriteMatrix()

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

set spaces to zero by default

Definition at line 734 of file matpol.cc.

735 {
736  int i,ii = MATROWS(im)-1;
737  int j,jj = MATCOLS(im)-1;
738  poly *pp = im->m;
739 
740  for (i=0; i<=ii; i++)
741  {
742  for (j=0; j<=jj; j++)
743  {
744  if (spaces>0)
745  Print("%-*.*s",spaces,spaces," ");
746  if (dim == 2) Print("%s[%u,%u]=",n,i+1,j+1);
747  else if (dim == 1) Print("%s[%u]=",n,j+1);
748  else if (dim == 0) Print("%s=",n);
749  if ((i<ii)||(j<jj)) p_Write(*pp++, r);
750  else p_Write0(*pp, r);
751  }
752  }
753 }
int j
Definition: facHensel.cc:105
#define Print
Definition: emacs.cc:80
poly * m
Definition: matpol.h:18
CanonicalForm pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition: cf_gcd.cc:253
int dim(ideal I, ring r)
int i
Definition: cfEzgcd.cc:125
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:194
#define MATCOLS(i)
Definition: matpol.h:27
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:204
#define MATROWS(i)
Definition: matpol.h:26

◆ mp_Add()

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

Definition at line 178 of file matpol.cc.

179 {
180  int k, n = a->nrows, m = a->ncols;
181  if ((n != b->nrows) || (m != b->ncols))
182  {
183 /*
184 * Werror("cannot add %dx%d matrix and %dx%d matrix",
185 * m,n,b->cols(),b->rows());
186 */
187  return NULL;
188  }
189  matrix c = mpNew(n,m);
190  for (k=m*n-1; k>=0; k--)
191  c->m[k] = p_Add_q(p_Copy(a->m[k], R), p_Copy(b->m[k], R), R);
192  return c;
193 }
int ncols
Definition: matpol.h:21
int k
Definition: cfEzgcd.cc:92
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
poly * m
Definition: matpol.h:18
int nrows
Definition: matpol.h:20
int m
Definition: cfEzgcd.cc:121
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892

◆ 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 503 of file matpol.cc.

504 {
505  poly* s;
506  poly p;
507  int sl,i,j;
508  int l=0;
509  poly sel=mp_Select(v,mon, R);
510 
511  p_Vec2Polys(sel,&s,&sl, R);
512  for (i=0; i<sl; i++)
513  l=si_max(l,pLength(s[i]));
514  *c=mpNew(sl,l);
515  *m=mpNew(sl,l);
516  poly h;
517  int isConst;
518  for (j=1; j<=sl;j++)
519  {
520  p=s[j-1];
521  if (p_IsConstant(p, R)) /*p != NULL */
522  {
523  isConst=-1;
524  i=l;
525  }
526  else
527  {
528  isConst=1;
529  i=1;
530  }
531  while(p!=NULL)
532  {
533  h = p_Head(p, R);
534  MATELEM(*m,j,i) = h;
535  i+=isConst;
536  p = p->next;
537  }
538  }
539  while (v!=NULL)
540  {
541  i = 1;
542  j = __p_GetComp(v, R);
543  loop
544  {
545  poly mp=MATELEM(*m,j,i);
546  if (mp!=NULL)
547  {
548  h = mp_Exdiv(v, mp /*MATELEM(*m,j,i)*/, mp, R);
549  if (h!=NULL)
550  {
551  p_SetComp(h,0, R);
552  MATELEM(*c,j,i) = p_Add_q(MATELEM(*c,j,i), h, R);
553  break;
554  }
555  }
556  if (i < l)
557  i++;
558  else
559  break;
560  }
561  v = v->next;
562  }
563 }
#define __p_GetComp(p, r)
Definition: monomials.h:70
const CanonicalForm int s
Definition: facAbsFact.cc:55
int j
Definition: facHensel.cc:105
static poly mp_Select(poly fro, poly what, const ring)
Definition: matpol.cc:670
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
static poly mp_Exdiv(poly m, poly d, poly vars, const ring)
Definition: matpol.cc:483
#define loop
Definition: structs.h:78
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:825
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
void p_Vec2Polys(poly v, poly **p, int *len, const ring r)
Definition: p_polys.cc:3527
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
int i
Definition: cfEzgcd.cc:125
static unsigned pLength(poly a)
Definition: p_polys.h:192
Variable next() const
Definition: factory.h:137
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
int p
Definition: cfModGcd.cc:4019
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
static Poly * h
Definition: janet.cc:972
int l
Definition: cfEzgcd.cc:93
#define MATELEM(mat, i, j)
Definition: matpol.h:28

◆ mp_CoeffProc()

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

Definition at line 401 of file matpol.cc.

402 {
403  assume(vars!=NULL);
404  poly sel, h;
405  int l, i;
406  int pos_of_1 = -1;
407  matrix co;
408 
409  if (f==NULL)
410  {
411  co = mpNew(2, 1);
412  MATELEM(co,1,1) = p_One(R);
413  MATELEM(co,2,1) = NULL;
414  return co;
415  }
416  sel = mp_Select(f, vars, R);
417  l = pLength(sel);
418  co = mpNew(2, l);
419 
421  {
422  for (i=l; i>=1; i--)
423  {
424  h = sel;
425  pIter(sel);
426  pNext(h)=NULL;
427  MATELEM(co,1,i) = h;
428  MATELEM(co,2,i) = NULL;
429  if (p_IsConstant(h, R)) pos_of_1 = i;
430  }
431  }
432  else
433  {
434  for (i=1; i<=l; i++)
435  {
436  h = sel;
437  pIter(sel);
438  pNext(h)=NULL;
439  MATELEM(co,1,i) = h;
440  MATELEM(co,2,i) = NULL;
441  if (p_IsConstant(h, R)) pos_of_1 = i;
442  }
443  }
444  while (f!=NULL)
445  {
446  i = 1;
447  loop
448  {
449  if (i!=pos_of_1)
450  {
451  h = mp_Exdiv(f, MATELEM(co,1,i),vars, R);
452  if (h!=NULL)
453  {
454  MATELEM(co,2,i) = p_Add_q(MATELEM(co,2,i), h, R);
455  break;
456  }
457  }
458  if (i == l)
459  {
460  // check monom 1 last:
461  if (pos_of_1 != -1)
462  {
463  h = mp_Exdiv(f, MATELEM(co,1,pos_of_1),vars, R);
464  if (h!=NULL)
465  {
466  MATELEM(co,2,pos_of_1) = p_Add_q(MATELEM(co,2,pos_of_1), h, R);
467  }
468  }
469  break;
470  }
471  i ++;
472  }
473  pIter(f);
474  }
475  return co;
476 }
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:752
static poly mp_Select(poly fro, poly what, const ring)
Definition: matpol.cc:670
static poly mp_Exdiv(poly m, poly d, poly vars, const ring)
Definition: matpol.cc:483
#define loop
Definition: structs.h:78
#define pIter(p)
Definition: monomials.h:44
poly p_One(const ring r)
Definition: p_polys.cc:1305
#define assume(x)
Definition: mod2.h:390
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1923
FILE * f
Definition: checklibs.c:9
int i
Definition: cfEzgcd.cc:125
static unsigned pLength(poly a)
Definition: p_polys.h:192
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
#define pNext(p)
Definition: monomials.h:43
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
static Poly * h
Definition: janet.cc:972
int l
Definition: cfEzgcd.cc:93
#define MATELEM(mat, i, j)
Definition: matpol.h:28

◆ 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 315 of file matpol.cc.

316 {
317  poly h,f;
318  int l, i, c, m=0;
319  /* look for maximal power m of x_var in I */
320  for (i=IDELEMS(I)-1; i>=0; i--)
321  {
322  f=I->m[i];
323  while (f!=NULL)
324  {
325  l=p_GetExp(f,var, R);
326  if (l>m) m=l;
327  pIter(f);
328  }
329  }
330  matrix co=mpNew((m+1)*I->rank,IDELEMS(I));
331  /* divide each monomial by a power of x_var,
332  * remember the power in l and the component in c*/
333  for (i=IDELEMS(I)-1; i>=0; i--)
334  {
335  f=I->m[i];
336  I->m[i]=NULL;
337  while (f!=NULL)
338  {
339  l=p_GetExp(f,var, R);
340  p_SetExp(f,var,0, R);
341  c=si_max((int)p_GetComp(f, R),1);
342  p_SetComp(f,0, R);
343  p_Setm(f, R);
344  /* now add the resulting monomial to co*/
345  h=pNext(f);
346  pNext(f)=NULL;
347  //MATELEM(co,c*(m+1)-l,i+1)
348  // =p_Add_q(MATELEM(co,c*(m+1)-l,i+1),f, R);
349  MATELEM(co,(c-1)*(m+1)+l+1,i+1)
350  =p_Add_q(MATELEM(co,(c-1)*(m+1)+l+1,i+1),f, R);
351  /* iterate f*/
352  f=h;
353  }
354  }
355  id_Delete(&I, R);
356  return co;
357 }
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
#define p_GetComp(p, r)
Definition: monomials.h:71
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:469
int m
Definition: cfEzgcd.cc:121
static int si_max(const int a, const int b)
Definition: auxiliary.h:138
FILE * f
Definition: checklibs.c:9
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:24
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
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:488
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
static Poly * h
Definition: janet.cc:972
int l
Definition: cfEzgcd.cc:93
#define MATELEM(mat, i, j)
Definition: matpol.h:28

◆ mp_Compare()

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

Definition at line 565 of file matpol.cc.

566 {
567  if (MATCOLS(a)<MATCOLS(b)) return -1;
568  else if (MATCOLS(a)>MATCOLS(b)) return 1;
569  if (MATROWS(a)<MATROWS(b)) return -1;
570  else if (MATROWS(a)<MATROWS(b)) return 1;
571 
572  unsigned ii=MATCOLS(a)*MATROWS(a)-1;
573  unsigned j=0;
574  int r=0;
575  while (j<=ii)
576  {
577  r=p_Compare(a->m[j],b->m[j],R);
578  if (r!=0) return r;
579  j++;
580  }
581  return r;
582 }
int j
Definition: facHensel.cc:105
poly * m
Definition: matpol.h:18
int p_Compare(const poly a, const poly b, const ring R)
Definition: p_polys.cc:4790
#define MATCOLS(i)
Definition: matpol.h:27
#define R
Definition: sirandom.c:26
#define MATROWS(i)
Definition: matpol.h:26

◆ 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 84 of file matpol.cc.

85 {
86  id_Test((ideal)a, rSrc);
87 
88  poly t;
89  int i, m=MATROWS(a), n=MATCOLS(a);
90 
91  matrix b = mpNew(m, n);
92 
93  for (i=m*n-1; i>=0; i--)
94  {
95  t = a->m[i];
96  if (t!=NULL)
97  {
98  b->m[i] = prCopyR_NoSort(t, rSrc, rDst);
99  p_Normalize(b->m[i], rDst);
100  }
101  }
102  b->rank=a->rank;
103 
104  id_Test((ideal)b, rDst);
105 
106  return b;
107 }
poly prCopyR_NoSort(poly p, ring src_r, ring dest_r)
Definition: prCopy.cc:77
#define id_Test(A, lR)
Definition: simpleideals.h:80
poly * m
Definition: matpol.h:18
CanonicalForm b
Definition: cfModGcd.cc:4044
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3709
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:10
#define MATROWS(i)
Definition: matpol.h:26
long rank
Definition: matpol.h:19

◆ mp_Copy() [2/2]

matrix mp_Copy ( matrix  a,
const ring  r 
)

copies matrix a (from ring r to r)

Definition at line 63 of file matpol.cc.

64 {
65  id_Test((ideal)a, r);
66  poly t;
67  int i, m=MATROWS(a), n=MATCOLS(a);
68  matrix b = mpNew(m, n);
69 
70  for (i=m*n-1; i>=0; i--)
71  {
72  t = a->m[i];
73  if (t!=NULL)
74  {
75  p_Normalize(t, r);
76  b->m[i] = p_Copy(t, r);
77  }
78  }
79  b->rank=a->rank;
80  return b;
81 }
#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:812
poly * m
Definition: matpol.h:18
CanonicalForm b
Definition: cfModGcd.cc:4044
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3709
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:10
#define MATROWS(i)
Definition: matpol.h:26
long rank
Definition: matpol.h:19

◆ mp_Delete()

void mp_Delete ( matrix a,
const ring  r 
)

Definition at line 780 of file matpol.cc.

781 {
782  id_Delete((ideal *) a, r);
783 }
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix

◆ mp_DetBareiss()

poly mp_DetBareiss ( matrix  a,
const ring  r 
)

returns the determinant of the matrix m; uses Bareiss algorithm

Definition at line 1576 of file matpol.cc.

1577 {
1578  int s;
1579  poly div, res;
1580  if (MATROWS(a) != MATCOLS(a))
1581  {
1582  Werror("det of %d x %d matrix",MATROWS(a),MATCOLS(a));
1583  return NULL;
1584  }
1585  matrix c = mp_Copy(a,r);
1586  mp_permmatrix *Bareiss = new mp_permmatrix(c,r);
1587  row_col_weight w(Bareiss->mpGetRdim(), Bareiss->mpGetCdim());
1588 
1589  /* Bareiss */
1590  div = NULL;
1591  while(Bareiss->mpPivotBareiss(&w))
1592  {
1593  Bareiss->mpElimBareiss(div);
1594  div = Bareiss->mpGetElem(Bareiss->mpGetRdim(), Bareiss->mpGetCdim());
1595  }
1596  Bareiss->mpRowReorder();
1597  Bareiss->mpColReorder();
1598  Bareiss->mpSaveArray();
1599  s = Bareiss->mpGetSign();
1600  delete Bareiss;
1601 
1602  /* result */
1603  res = MATELEM(c,1,1);
1604  MATELEM(c,1,1) = NULL;
1605  id_Delete((ideal *)&c,r);
1606  if (s < 0)
1607  res = p_Neg(res,r);
1608  return res;
1609 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
void mpElimBareiss(poly)
Definition: matpol.cc:1144
int mpGetSign()
Definition: matpol.cc:850
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void mpSaveArray()
Definition: matpol.cc:852
int mpPivotBareiss(row_col_weight *)
Definition: matpol.cc:1059
void mpRowReorder()
Definition: matpol.cc:1019
void mpColReorder()
Definition: matpol.cc:998
CanonicalForm res
Definition: facAbsFact.cc:64
int mpGetCdim()
Definition: matpol.cc:849
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:27
#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:63
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1043
int mpGetRdim()
Definition: matpol.cc:848
#define MATROWS(i)
Definition: matpol.h:26
poly mpGetElem(int, int)
Definition: matpol.cc:1136
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define MATELEM(mat, i, j)
Definition: matpol.h:28

◆ mp_Equal()

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

Definition at line 584 of file matpol.cc.

585 {
586  if ((MATCOLS(a)!=MATCOLS(b)) || (MATROWS(a)!=MATROWS(b)))
587  return FALSE;
588  int i=MATCOLS(a)*MATROWS(a)-1;
589  while (i>=0)
590  {
591  if (a->m[i]==NULL)
592  {
593  if (b->m[i]!=NULL) return FALSE;
594  }
595  else if (b->m[i]==NULL) return FALSE;
596  else if (p_Cmp(a->m[i],b->m[i], R)!=0) return FALSE;
597  i--;
598  }
599  i=MATCOLS(a)*MATROWS(a)-1;
600  while (i>=0)
601  {
602  if(!p_EqualPolys(a->m[i],b->m[i], R)) return FALSE;
603  i--;
604  }
605  return TRUE;
606 }
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1662
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
poly * m
Definition: matpol.h:18
int i
Definition: cfEzgcd.cc:125
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4396
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
#define MATROWS(i)
Definition: matpol.h:26

◆ mp_InitI()

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

make it a v * unit matrix

Definition at line 128 of file matpol.cc.

129 {
130  return mp_InitP(r, c, p_ISet(v, R), R);
131 }
matrix mp_InitP(int r, int c, poly p, const ring R)
make it a p * unit matrix
Definition: matpol.cc:112
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define R
Definition: sirandom.c:26
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1289

◆ mp_InitP()

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

make it a p * unit matrix

Definition at line 112 of file matpol.cc.

113 {
114  matrix rc = mpNew(r,c);
115  int i=si_min(r,c), n = c*(i-1)+i-1, inc = c+1;
116 
117  p_Normalize(p, R);
118  while (n>0)
119  {
120  rc->m[n] = p_Copy(p, R);
121  n -= inc;
122  }
123  rc->m[0]=p;
124  return rc;
125 }
static int si_min(const int a, const int b)
Definition: auxiliary.h:139
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
poly * m
Definition: matpol.h:18
int i
Definition: cfEzgcd.cc:125
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3709
#define R
Definition: sirandom.c:26
int p
Definition: cfModGcd.cc:4019

◆ mp_IsDiagUnit()

BOOLEAN mp_IsDiagUnit ( matrix  U,
const ring  r 
)

Definition at line 716 of file matpol.cc.

717 {
718  if(MATROWS(U)!=MATCOLS(U))
719  return FALSE;
720  for(int i=MATCOLS(U);i>=1;i--)
721  {
722  for(int j=MATCOLS(U); j>=1; j--)
723  {
724  if (i==j)
725  {
726  if (!p_IsUnit(MATELEM(U,i,i), R)) return FALSE;
727  }
728  else if (MATELEM(U,i,j)!=NULL) return FALSE;
729  }
730  }
731  return TRUE;
732 }
int j
Definition: facHensel.cc:105
#define FALSE
Definition: auxiliary.h:94
static BOOLEAN p_IsUnit(const poly p, const ring r)
Definition: p_polys.h:1950
#define TRUE
Definition: auxiliary.h:98
int i
Definition: cfEzgcd.cc:125
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
#define MATROWS(i)
Definition: matpol.h:26
#define MATELEM(mat, i, j)
Definition: matpol.h:28

◆ 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 1407 of file matpol.cc.

1409 {
1410  poly *q1;
1411  int e=IDELEMS(result);
1412  int i,j;
1413 
1414  if (R != NULL)
1415  {
1416  for (i=r-1;i>=0;i--)
1417  {
1418  q1 = &(a->m)[i*a->ncols];
1419  //for (j=c-1;j>=0;j--)
1420  //{
1421  // if (q1[j]!=NULL) q1[j] = kNF(R,currRing->qideal,q1[j]);
1422  //}
1423  }
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)
1431  {
1432  if (elems>=e)
1433  {
1434  pEnlargeSet(&(result->m),e,e);
1435  e += e;
1436  IDELEMS(result) =e;
1437  }
1438  result->m[elems] = q1[j];
1439  q1[j] = NULL;
1440  elems++;
1441  }
1442  }
1443  }
1444 }
int j
Definition: facHensel.cc:105
for(int i=0;i<=n;i++) degsf[i]
Definition: cfEzgcd.cc:65
int i
Definition: cfEzgcd.cc:125
#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:3633
#define R
Definition: sirandom.c:26
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 364 of file matpol.cc.

365 {
366  /* clear contents of m*/
367  int k,l;
368  for (k=MATROWS(m);k>0;k--)
369  {
370  for(l=MATCOLS(m);l>0;l--)
371  {
372  p_Delete(&MATELEM(m,k,l), R);
373  }
374  }
375  omfreeSize((ADDRESS)m->m,MATROWS(m)*MATCOLS(m)*sizeof(poly));
376  /* allocate monoms in the right size r x MATROWS(c)*/
377  m->m=(poly*)omAlloc0(r*MATROWS(c)*sizeof(poly));
378  MATROWS(m)=r;
379  MATCOLS(m)=MATROWS(c);
380  m->rank=r;
381  /* the maximal power p of x_var: MATCOLS(m)=r*(p+1) */
382  int p=MATCOLS(m)/r-1;
383  /* fill in the powers of x_var=h*/
384  poly h=p_One(R);
385  for(k=r;k>0; k--)
386  {
387  MATELEM(m,k,k*(p+1))=p_One(R);
388  }
389  for(l=p;l>=0; l--)
390  {
391  p_SetExp(h,var,p-l, R);
392  p_Setm(h, R);
393  for(k=r;k>0; k--)
394  {
395  MATELEM(m,k,k*(p+1)-l)=p_Copy(h, R);
396  }
397  }
398  p_Delete(&h, R);
399 }
#define omfreeSize(addr, size)
Definition: omAllocDecl.h:236
void * ADDRESS
Definition: auxiliary.h:133
int k
Definition: cfEzgcd.cc:92
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
poly * m
Definition: matpol.h:18
poly p_One(const ring r)
Definition: p_polys.cc:1305
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:857
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:488
#define MATCOLS(i)
Definition: matpol.h:27
#define R
Definition: sirandom.c:26
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
#define MATROWS(i)
Definition: matpol.h:26
int p
Definition: cfModGcd.cc:4019
static Poly * h
Definition: janet.cc:972
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:93
long rank
Definition: matpol.h:19
#define MATELEM(mat, i, j)
Definition: matpol.h:28

◆ mp_Mult()

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

Definition at line 212 of file matpol.cc.

213 {
214  int i, j, k;
215  int m = MATROWS(a);
216  int p = MATCOLS(a);
217  int q = MATCOLS(b);
218 
219  if (p!=MATROWS(b))
220  {
221 /*
222 * Werror("cannot multiply %dx%d matrix and %dx%d matrix",
223 * m,p,b->rows(),q);
224 */
225  return NULL;
226  }
227  matrix c = mpNew(m,q);
228 
229  for (i=1; i<=m; i++)
230  {
231  for (k=1; k<=p; k++)
232  {
233  poly aik;
234  if ((aik=MATELEM(a,i,k))!=NULL)
235  {
236  for (j=1; j<=q; j++)
237  {
238  poly bkj;
239  if ((bkj=MATELEM(b,k,j))!=NULL)
240  {
241  poly *cij=&(MATELEM(c,i,j));
242  poly s = pp_Mult_qq(aik /*MATELEM(a,i,k)*/, bkj/*MATELEM(b,k,j)*/, R);
243  if (/*MATELEM(c,i,j)*/ (*cij)==NULL) (*cij)=s;
244  else (*cij) = p_Add_q((*cij) /*MATELEM(c,i,j)*/ ,s, R);
245  }
246  }
247  }
248  // pNormalize(t);
249  // MATELEM(c,i,j) = t;
250  }
251  }
252  for(i=m*q-1;i>=0;i--) p_Normalize(c->m[i], R);
253  return c;
254 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
int j
Definition: facHensel.cc:105
int k
Definition: cfEzgcd.cc:92
poly * m
Definition: matpol.h:18
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1093
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3709
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
#define MATROWS(i)
Definition: matpol.h:26
int p
Definition: cfModGcd.cc:4019
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
#define MATELEM(mat, i, j)
Definition: matpol.h:28

◆ mp_MultI()

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

c = f*a

Definition at line 134 of file matpol.cc.

135 {
136  int k, n = a->nrows, m = a->ncols;
137  poly p = p_ISet(f, R);
138  matrix c = mpNew(n,m);
139 
140  for (k=m*n-1; k>0; k--)
141  c->m[k] = pp_Mult_qq(a->m[k], p, R);
142  c->m[0] = p_Mult_q(p_Copy(a->m[0], R), p, R);
143  return c;
144 }
int ncols
Definition: matpol.h:21
int k
Definition: cfEzgcd.cc:92
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
poly * m
Definition: matpol.h:18
int nrows
Definition: matpol.h:20
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1093
int m
Definition: cfEzgcd.cc:121
FILE * f
Definition: checklibs.c:9
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
#define R
Definition: sirandom.c:26
int p
Definition: cfModGcd.cc:4019
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition: p_polys.cc:1289
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1050

◆ 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 147 of file matpol.cc.

148 {
149  int k, n = a->nrows, m = a->ncols;
150 
151  p_Normalize(p, R);
152  for (k=m*n-1; k>0; k--)
153  {
154  if (a->m[k]!=NULL)
155  a->m[k] = p_Mult_q(a->m[k], p_Copy(p, R), R);
156  }
157  a->m[0] = p_Mult_q(a->m[0], p, R);
158  return a;
159 }
int ncols
Definition: matpol.h:21
int k
Definition: cfEzgcd.cc:92
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
poly * m
Definition: matpol.h:18
int nrows
Definition: matpol.h:20
int m
Definition: cfEzgcd.cc:121
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3709
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
int p
Definition: cfModGcd.cc:4019
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1050

◆ mp_New()

static matrix mp_New ( int  r,
int  c 
)
inlinestatic

Definition at line 34 of file matpol.h.

34 { return mpNew(r,c); }
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36

◆ 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 1503 of file matpol.cc.

1505 {
1506  int k;
1507  int kr=lr-1,kc=lc-1;
1508  matrix nextLevel=mpNew(kr,kc);
1509 
1510  loop
1511  {
1512 /*--- look for an optimal row and bring it to last position ------------*/
1513  if(mp_PrepareRow(a,lr,lc,r)==0) break;
1514 /*--- now take all pivots from the last row ------------*/
1515  k = lc;
1516  loop
1517  {
1518  if(mp_PreparePiv(a,lr,k,r)==0) break;
1519  mp_ElimBar(a,nextLevel,barDiv,lr,k,r);
1520  k--;
1521  if (ar>1)
1522  {
1523  mp_RecMin(ar-1,result,elems,nextLevel,kr,k,a->m[kr*a->ncols+k],R,r);
1524  mp_PartClean(nextLevel,kr,k, r);
1525  }
1526  else mp_MinorToResult(result,elems,nextLevel,kr,k,R,r);
1527  if (ar>k-1) break;
1528  }
1529  if (ar>=kr) break;
1530 /*--- now we have to take out the last row...------------*/
1531  lr = kr;
1532  kr--;
1533  }
1534  mpFinalClean(nextLevel);
1535 }
int ncols
Definition: matpol.h:21
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:1503
static void mp_ElimBar(matrix a0, matrix re, poly div, int lr, int lc, const ring R)
Definition: matpol.cc:1349
static void mpFinalClean(matrix a)
Definition: matpol.cc:1495
static int mp_PrepareRow(matrix a, int lr, int lc, const ring R)
Definition: matpol.cc:1281
int k
Definition: cfEzgcd.cc:92
static void mp_PartClean(matrix a, int lr, int lc, const ring R)
Definition: matpol.cc:704
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:1407
#define loop
Definition: structs.h:78
CanonicalForm lc(const CanonicalForm &f)
poly * m
Definition: matpol.h:18
static int mp_PreparePiv(matrix a, int lr, int lc, const ring r)
Definition: matpol.cc:1339
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
#define R
Definition: sirandom.c:26
return result
Definition: facAbsBiFact.cc:76

◆ mp_Sub()

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

Definition at line 195 of file matpol.cc.

196 {
197  int k, n = a->nrows, m = a->ncols;
198  if ((n != b->nrows) || (m != b->ncols))
199  {
200 /*
201 * Werror("cannot sub %dx%d matrix and %dx%d matrix",
202 * m,n,b->cols(),b->rows());
203 */
204  return NULL;
205  }
206  matrix c = mpNew(n,m);
207  for (k=m*n-1; k>=0; k--)
208  c->m[k] = p_Sub(p_Copy(a->m[k], R), p_Copy(b->m[k], R), R);
209  return c;
210 }
int ncols
Definition: matpol.h:21
int k
Definition: cfEzgcd.cc:92
poly p_Sub(poly p1, poly p2, const ring r)
Definition: p_polys.cc:1937
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
poly * m
Definition: matpol.h:18
int nrows
Definition: matpol.h:20
int m
Definition: cfEzgcd.cc:121
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26

◆ mp_Tensor()

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

Definition at line 1748 of file matpol.cc.

1749 {
1750  // size of the result n*q x m*p
1751  int n=IDELEMS(A); // m x n
1752  int m=A->rank;
1753  int q=IDELEMS(B); // p x q
1754  int p=B->rank;
1755  ideal res=idInit(n*q,m*p);
1756  poly *a=(poly*)omAlloc(m*sizeof(poly));
1757  for(int i=0; i<n; i++)
1758  {
1759  memset(a,0,m*sizeof(poly));
1760  p_DecomposeComp(p_Copy(A->m[i],r),a,m,r);
1761  for(int j=0;j<m;j++)
1762  {
1763  if (a[j]!=NULL)
1764  {
1765  ideal sm=mp_MultAndShift(a[j], // A_i_j
1766  B,
1767  j*p, // shift j*p down
1768  r);
1769  mp_AddSubMat(res,sm,i*q,r); // add this columns to col i*q ff
1770  id_Delete(&sm,r); // delete the now empty ideal
1771  }
1772  }
1773  }
1774  omFreeSize(a,m*sizeof(poly));
1775  return res;
1776 }
int j
Definition: facHensel.cc:105
static ideal mp_MultAndShift(poly f, ideal B, int s, const ring r)
Definition: matpol.cc:1720
#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:1701
#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:812
CanonicalForm res
Definition: facAbsFact.cc:64
#define A
Definition: sirandom.c:23
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:24
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:37
#define NULL
Definition: omList.c:10
b *CanonicalForm B
Definition: facBivar.cc:52
static void mp_AddSubMat(ideal res, ideal sm, int col, const ring r)
Definition: matpol.cc:1739
int p
Definition: cfModGcd.cc:4019

◆ mp_Trace()

poly mp_Trace ( matrix  a,
const ring  r 
)

Definition at line 277 of file matpol.cc.

278 {
279  int i;
280  int n = (MATCOLS(a)<MATROWS(a)) ? MATCOLS(a) : MATROWS(a);
281  poly t = NULL;
282 
283  for (i=1; i<=n; i++)
284  t = p_Add_q(t, p_Copy(MATELEM(a,i,i), R), R);
285  return t;
286 }
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
int i
Definition: cfEzgcd.cc:125
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
#define MATROWS(i)
Definition: matpol.h:26
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
#define MATELEM(mat, i, j)
Definition: matpol.h:28

◆ mp_Transp()

matrix mp_Transp ( matrix  a,
const ring  r 
)

Definition at line 256 of file matpol.cc.

257 {
258  int i, j, r = MATROWS(a), c = MATCOLS(a);
259  poly *p;
260  matrix b = mpNew(c,r);
261 
262  p = b->m;
263  for (i=0; i<c; i++)
264  {
265  for (j=0; j<r; j++)
266  {
267  if (a->m[j*c+i]!=NULL) *p = p_Copy(a->m[j*c+i], R);
268  p++;
269  }
270  }
271  return b;
272 }
int j
Definition: facHensel.cc:105
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
poly * m
Definition: matpol.h:18
CanonicalForm b
Definition: cfModGcd.cc:4044
int i
Definition: cfEzgcd.cc:125
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
#define MATROWS(i)
Definition: matpol.h:26
int p
Definition: cfModGcd.cc:4019

◆ mp_Wedge()

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

Definition at line 1651 of file matpol.cc.

1652 {
1653  int i,j,k,l;
1654  int *rowchoise,*colchoise;
1655  BOOLEAN rowch,colch;
1656  matrix result;
1657  matrix tmp;
1658  poly p;
1659 
1660  i = binom(a->nrows,ar);
1661  j = binom(a->ncols,ar);
1662 
1663  rowchoise=(int *)omAlloc(ar*sizeof(int));
1664  colchoise=(int *)omAlloc(ar*sizeof(int));
1665  result = mpNew(i,j);
1666  tmp = mpNew(ar,ar);
1667  l = 1; /* k,l:the index in result*/
1668  idInitChoise(ar,1,a->nrows,&rowch,rowchoise);
1669  while (!rowch)
1670  {
1671  k=1;
1672  idInitChoise(ar,1,a->ncols,&colch,colchoise);
1673  while (!colch)
1674  {
1675  for (i=1; i<=ar; i++)
1676  {
1677  for (j=1; j<=ar; j++)
1678  {
1679  MATELEM(tmp,i,j) = MATELEM(a,rowchoise[i-1],colchoise[j-1]);
1680  }
1681  }
1682  p = mp_DetBareiss(tmp, R);
1683  if ((k+l) & 1) p=p_Neg(p, R);
1684  MATELEM(result,l,k) = p;
1685  k++;
1686  idGetNextChoise(ar,a->ncols,&colch,colchoise);
1687  }
1688  idGetNextChoise(ar,a->nrows,&rowch,rowchoise);
1689  l++;
1690  }
1691 
1692  /*delete the matrix tmp*/
1693  for (i=1; i<=ar; i++)
1694  {
1695  for (j=1; j<=ar; j++) MATELEM(tmp,i,j) = NULL;
1696  }
1697  id_Delete((ideal *) &tmp, R);
1698  return (result);
1699 }
int j
Definition: facHensel.cc:105
int ncols
Definition: matpol.h:21
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
int k
Definition: cfEzgcd.cc:92
#define omAlloc(size)
Definition: omAllocDecl.h:210
int nrows
Definition: matpol.h:20
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
int i
Definition: cfEzgcd.cc:125
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:36
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
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:1576
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1043
int p
Definition: cfModGcd.cc:4019
int BOOLEAN
Definition: auxiliary.h:85
int binom(int n, int r)
return result
Definition: facAbsBiFact.cc:76
int l
Definition: cfEzgcd.cc:93
#define MATELEM(mat, i, j)
Definition: matpol.h:28

◆ mpNew()

matrix mpNew ( int  r,
int  c 
)

create a r x c zero-matrix

Definition at line 36 of file matpol.cc.

37 {
38  int rr=r;
39  if (rr<=0) rr=1;
40  //if ( (((int)(MAX_INT_VAL/sizeof(poly))) / rr) <= c)
41  //{
42  // Werror("internal error: creating matrix[%d][%d]",r,c);
43  // return NULL;
44  //}
46  rc->nrows = r;
47  rc->ncols = c;
48  rc->rank = r;
49  if ((c != 0)&&(r!=0))
50  {
51  size_t s=((size_t)r)*((size_t)c)*sizeof(poly);
52  rc->m = (poly*)omAlloc0(s);
53  //if (rc->m==NULL)
54  //{
55  // Werror("internal error: creating matrix[%d][%d]",r,c);
56  // return NULL;
57  //}
58  }
59  return rc;
60 }
#define omAllocBin(bin)
Definition: omAllocDecl.h:205
const CanonicalForm int s
Definition: facAbsFact.cc:55
int ncols
Definition: matpol.h:21
omBin sip_sideal_bin
Definition: simpleideals.cc:29
poly * m
Definition: matpol.h:18
int nrows
Definition: matpol.h:20
ip_smatrix * matrix
Definition: matpol.h:31
#define omAlloc0(size)
Definition: omAllocDecl.h:211
long rank
Definition: matpol.h:19

◆ pMultMp()

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

Definition at line 164 of file matpol.cc.

165 {
166  int k, n = a->nrows, m = a->ncols;
167 
168  p_Normalize(p, R);
169  for (k=m*n-1; k>0; k--)
170  {
171  if (a->m[k]!=NULL)
172  a->m[k] = p_Mult_q(p_Copy(p, R), a->m[k], R);
173  }
174  a->m[0] = p_Mult_q(p, a->m[0], R);
175  return a;
176 }
int ncols
Definition: matpol.h:21
int k
Definition: cfEzgcd.cc:92
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:812
poly * m
Definition: matpol.h:18
int nrows
Definition: matpol.h:20
int m
Definition: cfEzgcd.cc:121
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3709
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
int p
Definition: cfModGcd.cc:4019
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1050

◆ TraceOfProd()

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

Definition at line 291 of file matpol.cc.

292 {
293  int i, j;
294  poly p, t = NULL;
295 
296  for (i=1; i<=n; i++)
297  {
298  for (j=1; j<=n; j++)
299  {
300  p = pp_Mult_qq(MATELEM(a,i,j), MATELEM(b,j,i), R);
301  t = p_Add_q(t, p, R);
302  }
303  }
304  return t;
305 }
int j
Definition: facHensel.cc:105
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1093
int i
Definition: cfEzgcd.cc:125
#define NULL
Definition: omList.c:10
#define R
Definition: sirandom.c:26
int p
Definition: cfModGcd.cc:4019
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:892
#define MATELEM(mat, i, j)
Definition: matpol.h:28

Variable Documentation

◆ ip_smatrix_bin

omBin ip_smatrix_bin