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=',')
 

Variables

omBin ip_smatrix_bin
 

Macro Definition Documentation

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

Definition at line 28 of file matpol.h.

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

Definition at line 29 of file matpol.h.

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

Definition at line 27 of file matpol.h.

Typedef Documentation

typedef ip_smatrix* matrix

Definition at line 32 of file matpol.h.

Function Documentation

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

Definition at line 760 of file matpol.cc.

761 {
762  int i,ii = MATROWS(im);
763  int j,jj = MATCOLS(im);
764  poly *pp = im->m;
765  char ch_s[2];
766  ch_s[0]=ch;
767  ch_s[1]='\0';
768 
769  StringSetS("");
770 
771  for (i=0; i<ii; i++)
772  {
773  for (j=0; j<jj; j++)
774  {
775  p_String0(*pp++, r);
776  StringAppendS(ch_s);
777  if (dim > 1) StringAppendS("\n");
778  }
779  }
780  char *s=StringEndS();
781  s[strlen(s)- (dim > 1 ? 2 : 1)]='\0';
782  return s;
783 }
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
void iiWriteMatrix ( matrix  im,
const char *  n,
int  dim,
const ring  r,
int  spaces 
)

set spaces to zero by default

Definition at line 739 of file matpol.cc.

740 {
741  int i,ii = MATROWS(im)-1;
742  int j,jj = MATCOLS(im)-1;
743  poly *pp = im->m;
744 
745  for (i=0; i<=ii; i++)
746  {
747  for (j=0; j<=jj; j++)
748  {
749  if (spaces>0)
750  Print("%-*.*s",spaces,spaces," ");
751  if (dim == 2) Print("%s[%u,%u]=",n,i+1,j+1);
752  else if (dim == 1) Print("%s[%u]=",n,j+1);
753  else if (dim == 0) Print("%s=",n);
754  if ((i<ii)||(j<jj)) p_Write(*pp++, r);
755  else p_Write0(*pp, r);
756  }
757  }
758 }
#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
matrix mp_Add ( matrix  a,
matrix  b,
const ring  r 
)

Definition at line 190 of file matpol.cc.

191 {
192  int k, n = a->nrows, m = a->ncols;
193  if ((n != b->nrows) || (m != b->ncols))
194  {
195 /*
196 * Werror("cannot add %dx%d matrix and %dx%d matrix",
197 * m,n,b->cols(),b->rows());
198 */
199  return NULL;
200  }
201  matrix c = mpNew(n,m);
202  for (k=m*n-1; k>=0; k--)
203  c->m[k] = p_Add_q(p_Copy(a->m[k], R), p_Copy(b->m[k], R), R);
204  return c;
205 }
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:811
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:48
#define NULL
Definition: omList.c:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:884
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 516 of file matpol.cc.

517 {
518  poly* s;
519  poly p;
520  int sl,i,j;
521  int l=0;
522  poly sel=mp_Select(v,mon, R);
523 
524  p_Vec2Polys(sel,&s,&sl, R);
525  for (i=0; i<sl; i++)
526  l=si_max(l,pLength(s[i]));
527  *c=mpNew(sl,l);
528  *m=mpNew(sl,l);
529  poly h;
530  int isConst;
531  for (j=1; j<=sl;j++)
532  {
533  p=s[j-1];
534  if (p_IsConstant(p, R)) /*p != NULL */
535  {
536  isConst=-1;
537  i=l;
538  }
539  else
540  {
541  isConst=1;
542  i=1;
543  }
544  while(p!=NULL)
545  {
546  h = p_Head(p, R);
547  MATELEM(*m,j,i) = h;
548  i+=isConst;
549  p = p->next;
550  }
551  }
552  while (v!=NULL)
553  {
554  i = 1;
555  j = p_GetComp(v, R);
556  loop
557  {
558  poly mp=MATELEM(*m,j,i);
559  if (mp!=NULL)
560  {
561  h = mp_Exdiv(v, mp /*MATELEM(*m,j,i)*/, mp, R);
562  if (h!=NULL)
563  {
564  p_SetComp(h,0, R);
565  MATELEM(*c,j,i) = p_Add_q(MATELEM(*c,j,i), h, R);
566  break;
567  }
568  }
569  if (i < l)
570  i++;
571  else
572  break;
573  }
574  v = v->next;
575  }
576 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
static poly mp_Select(poly fro, poly what, const ring)
Definition: matpol.cc:675
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:236
#define p_GetComp(p, r)
Definition: monomials.h:72
static poly mp_Exdiv(poly m, poly d, poly vars, const ring)
Definition: matpol.cc:496
static int pLength(poly a)
Definition: p_polys.h:189
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:819
Variable next() const
Definition: variable.h:52
int j
Definition: myNF.cc:70
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1784
void p_Vec2Polys(poly v, poly **p, int *len, const ring r)
Definition: p_polys.cc:3459
const ring R
Definition: DebugPrint.cc:36
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
int i
Definition: cfEzgcd.cc:123
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:48
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:884
static Poly * h
Definition: janet.cc:978
int l
Definition: cfEzgcd.cc:94
#define MATELEM(mat, i, j)
Definition: matpol.h:29
matrix mp_CoeffProc ( poly  f,
poly  vars,
const ring  r 
)

Definition at line 414 of file matpol.cc.

415 {
416  assume(vars!=NULL);
417  poly sel, h;
418  int l, i;
419  int pos_of_1 = -1;
420  matrix co;
421 
422  if (f==NULL)
423  {
424  co = mpNew(2, 1);
425  MATELEM(co,1,1) = p_One(R);
426  MATELEM(co,2,1) = NULL;
427  return co;
428  }
429  sel = mp_Select(f, vars, R);
430  l = pLength(sel);
431  co = mpNew(2, l);
432 
434  {
435  for (i=l; i>=1; i--)
436  {
437  h = sel;
438  pIter(sel);
439  pNext(h)=NULL;
440  MATELEM(co,1,i) = h;
441  MATELEM(co,2,i) = NULL;
442  if (p_IsConstant(h, R)) pos_of_1 = i;
443  }
444  }
445  else
446  {
447  for (i=1; i<=l; i++)
448  {
449  h = sel;
450  pIter(sel);
451  pNext(h)=NULL;
452  MATELEM(co,1,i) = h;
453  MATELEM(co,2,i) = NULL;
454  if (p_IsConstant(h, R)) pos_of_1 = i;
455  }
456  }
457  while (f!=NULL)
458  {
459  i = 1;
460  loop
461  {
462  if (i!=pos_of_1)
463  {
464  h = mp_Exdiv(f, MATELEM(co,1,i),vars, R);
465  if (h!=NULL)
466  {
467  MATELEM(co,2,i) = p_Add_q(MATELEM(co,2,i), h, R);
468  break;
469  }
470  }
471  if (i == l)
472  {
473  // check monom 1 last:
474  if (pos_of_1 != -1)
475  {
476  h = mp_Exdiv(f, MATELEM(co,1,pos_of_1),vars, R);
477  if (h!=NULL)
478  {
479  MATELEM(co,2,pos_of_1) = p_Add_q(MATELEM(co,2,pos_of_1), h, R);
480  }
481  }
482  break;
483  }
484  i ++;
485  }
486  pIter(f);
487  }
488  return co;
489 }
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:753
static poly mp_Select(poly fro, poly what, const ring)
Definition: matpol.cc:675
loop
Definition: myNF.cc:98
f
Definition: cfModGcd.cc:4022
static poly mp_Exdiv(poly m, poly d, poly vars, const ring)
Definition: matpol.cc:496
static int pLength(poly a)
Definition: p_polys.h:189
#define pIter(p)
Definition: monomials.h:44
poly p_One(const ring r)
Definition: p_polys.cc:1318
#define assume(x)
Definition: mod2.h:405
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1784
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:48
#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:884
static Poly * h
Definition: janet.cc:978
int l
Definition: cfEzgcd.cc:94
#define MATELEM(mat, i, j)
Definition: matpol.h:29
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 327 of file matpol.cc.

328 {
329  poly h,f;
330  int l, i, c, m=0;
331  matrix co;
332  /* look for maximal power m of x_var in I */
333  for (i=IDELEMS(I)-1; i>=0; i--)
334  {
335  f=I->m[i];
336  while (f!=NULL)
337  {
338  l=p_GetExp(f,var, R);
339  if (l>m) m=l;
340  pIter(f);
341  }
342  }
343  co=mpNew((m+1)*I->rank,IDELEMS(I));
344  /* divide each monomial by a power of x_var,
345  * remember the power in l and the component in c*/
346  for (i=IDELEMS(I)-1; i>=0; i--)
347  {
348  f=I->m[i];
349  I->m[i]=NULL;
350  while (f!=NULL)
351  {
352  l=p_GetExp(f,var, R);
353  p_SetExp(f,var,0, R);
354  c=si_max((int)p_GetComp(f, R),1);
355  p_SetComp(f,0, R);
356  p_Setm(f, R);
357  /* now add the resulting monomial to co*/
358  h=pNext(f);
359  pNext(f)=NULL;
360  //MATELEM(co,c*(m+1)-l,i+1)
361  // =p_Add_q(MATELEM(co,c*(m+1)-l,i+1),f, R);
362  MATELEM(co,(c-1)*(m+1)+l+1,i+1)
363  =p_Add_q(MATELEM(co,(c-1)*(m+1)+l+1,i+1),f, R);
364  /* iterate f*/
365  f=h;
366  }
367  }
368  id_Delete(&I, R);
369  return co;
370 }
f
Definition: cfModGcd.cc:4022
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:236
#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:465
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:166
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:48
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:484
#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:436
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:884
static Poly * h
Definition: janet.cc:978
int l
Definition: cfEzgcd.cc:94
#define MATELEM(mat, i, j)
Definition: matpol.h:29
matrix mp_Copy ( const matrix  a,
const ring  rSrc,
const ring  rDst 
)

copies matrix a from rSrc into rDst

Definition at line 96 of file matpol.cc.

97 {
98  id_Test((ideal)a, rSrc);
99 
100  poly t;
101  int i, m=MATROWS(a), n=MATCOLS(a);
102 
103  matrix b = mpNew(m, n);
104 
105  for (i=m*n-1; i>=0; i--)
106  {
107  t = a->m[i];
108  if (t!=NULL)
109  {
110  b->m[i] = prCopyR_NoSort(t, rSrc, rDst);
111  p_Normalize(b->m[i], rDst);
112  }
113  }
114  b->rank=a->rank;
115 
116  id_Test((ideal)b, rDst);
117 
118  return b;
119 }
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:48
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3621
#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
matrix mp_Copy ( matrix  a,
const ring  r 
)

copies matrix a (from ring r to r)

Definition at line 75 of file matpol.cc.

76 {
77  id_Test((ideal)a, r);
78  poly t;
79  int i, m=MATROWS(a), n=MATCOLS(a);
80  matrix b = mpNew(m, n);
81 
82  for (i=m*n-1; i>=0; i--)
83  {
84  t = a->m[i];
85  if (t!=NULL)
86  {
87  p_Normalize(t, r);
88  b->m[i] = p_Copy(t, r);
89  }
90  }
91  b->rank=a->rank;
92  return b;
93 }
#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:811
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:48
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3621
#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
void mp_Delete ( matrix a,
const ring  r 
)

Definition at line 785 of file matpol.cc.

786 {
787  id_Delete((ideal *) a, r);
788 }
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
const ring r
Definition: syzextra.cc:208
poly mp_DetBareiss ( matrix  a,
const ring  r 
)

returns the determinant of the matrix m; uses Bareiss algorithm

Definition at line 1581 of file matpol.cc.

1582 {
1583  int s;
1584  poly div, res;
1585  if (MATROWS(a) != MATCOLS(a))
1586  {
1587  Werror("det of %d x %d matrix",MATROWS(a),MATCOLS(a));
1588  return NULL;
1589  }
1590  matrix c = mp_Copy(a,r);
1591  mp_permmatrix *Bareiss = new mp_permmatrix(c,r);
1592  row_col_weight w(Bareiss->mpGetRdim(), Bareiss->mpGetCdim());
1593 
1594  /* Bareiss */
1595  div = NULL;
1596  while(Bareiss->mpPivotBareiss(&w))
1597  {
1598  Bareiss->mpElimBareiss(div);
1599  div = Bareiss->mpGetElem(Bareiss->mpGetRdim(), Bareiss->mpGetCdim());
1600  }
1601  Bareiss->mpRowReorder();
1602  Bareiss->mpColReorder();
1603  Bareiss->mpSaveArray();
1604  s = Bareiss->mpGetSign();
1605  delete Bareiss;
1606 
1607  /* result */
1608  res = MATELEM(c,1,1);
1609  MATELEM(c,1,1) = NULL;
1610  id_Delete((ideal *)&c,r);
1611  if (s < 0)
1612  res = p_Neg(res,r);
1613  return res;
1614 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
void mpElimBareiss(poly)
Definition: matpol.cc:1149
int mpGetSign()
Definition: matpol.cc:855
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void mpSaveArray()
Definition: matpol.cc:857
int mpPivotBareiss(row_col_weight *)
Definition: matpol.cc:1064
void mpRowReorder()
Definition: matpol.cc:1024
poly res
Definition: myNF.cc:322
void mpColReorder()
Definition: matpol.cc:1003
const ring r
Definition: syzextra.cc:208
int mpGetCdim()
Definition: matpol.cc:854
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:75
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1018
int mpGetRdim()
Definition: matpol.cc:853
#define MATROWS(i)
Definition: matpol.h:27
polyrec * poly
Definition: hilb.h:10
poly mpGetElem(int, int)
Definition: matpol.cc:1141
void Werror(const char *fmt,...)
Definition: reporter.cc:199
#define MATELEM(mat, i, j)
Definition: matpol.h:29
BOOLEAN mp_Equal ( matrix  a,
matrix  b,
const ring  r 
)

Definition at line 579 of file matpol.cc.

580 {
581  if ((MATCOLS(a)!=MATCOLS(b)) || (MATROWS(a)!=MATROWS(b)))
582  return FALSE;
583  int i=MATCOLS(a)*MATROWS(b)-1;
584  while (i>=0)
585  {
586  if (a->m[i]==NULL)
587  {
588  if (b->m[i]!=NULL) return FALSE;
589  }
590  else
591  if (b->m[i]==NULL) return FALSE;
592  else if (p_Cmp(a->m[i],b->m[i], R)!=0) return FALSE;
593  i--;
594  }
595  i=MATCOLS(a)*MATROWS(b)-1;
596  while (i>=0)
597  {
598 #if 0
599  poly tt=p_Sub(p_Copy(a->m[i], R),p_Copy(b->m[i], R), R);
600  if (tt!=NULL)
601  {
602  p_Delete(&tt, R);
603  return FALSE;
604  }
605 #else
606  if(!p_EqualPolys(a->m[i],b->m[i], R)) return FALSE;
607 #endif
608  i--;
609  }
610  return TRUE;
611 }
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1523
#define FALSE
Definition: auxiliary.h:140
#define TRUE
Definition: auxiliary.h:144
poly p_Sub(poly p1, poly p2, const ring r)
Definition: p_polys.cc:1901
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
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:4289
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
#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
matrix mp_InitI ( int  r,
int  c,
int  v,
const ring  R 
)

make it a v * unit matrix

Definition at line 140 of file matpol.cc.

141 {
142  return mp_InitP(r, c, p_ISet(v, R), R);
143 }
matrix mp_InitP(int r, int c, poly p, const ring R)
make it a p * unit matrix
Definition: matpol.cc:124
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:1302
matrix mp_InitP ( int  r,
int  c,
poly  p,
const ring  R 
)

make it a p * unit matrix

Definition at line 124 of file matpol.cc.

125 {
126  matrix rc = mpNew(r,c);
127  int i=si_min(r,c), n = c*(i-1)+i-1, inc = c+1;
128 
129  p_Normalize(p, R);
130  while (n>0)
131  {
132  rc->m[n] = p_Copy(p, R);
133  n -= inc;
134  }
135  rc->m[0]=p;
136  return rc;
137 }
static int si_min(const int a, const int b)
Definition: auxiliary.h:167
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:811
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:48
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3621
BOOLEAN mp_IsDiagUnit ( matrix  U,
const ring  r 
)

Definition at line 721 of file matpol.cc.

722 {
723  if(MATROWS(U)!=MATCOLS(U))
724  return FALSE;
725  for(int i=MATCOLS(U);i>=1;i--)
726  {
727  for(int j=MATCOLS(U); j>=1; j--)
728  {
729  if (i==j)
730  {
731  if (!p_IsUnit(MATELEM(U,i,i), R)) return FALSE;
732  }
733  else if (MATELEM(U,i,j)!=NULL) return FALSE;
734  }
735  }
736  return TRUE;
737 }
#define FALSE
Definition: auxiliary.h:140
static BOOLEAN p_IsUnit(const poly p, const ring r)
Definition: p_polys.h:1811
#define TRUE
Definition: auxiliary.h:144
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
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 1412 of file matpol.cc.

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

Definition at line 377 of file matpol.cc.

378 {
379  /* clear contents of m*/
380  int k,l;
381  for (k=MATROWS(m);k>0;k--)
382  {
383  for(l=MATCOLS(m);l>0;l--)
384  {
385  p_Delete(&MATELEM(m,k,l), R);
386  }
387  }
388  omfreeSize((ADDRESS)m->m,MATROWS(m)*MATCOLS(m)*sizeof(poly));
389  /* allocate monoms in the right size r x MATROWS(c)*/
390  m->m=(poly*)omAlloc0(r*MATROWS(c)*sizeof(poly));
391  MATROWS(m)=r;
392  MATCOLS(m)=MATROWS(c);
393  m->rank=r;
394  /* the maximal power p of x_var: MATCOLS(m)=r*(p+1) */
395  int p=MATCOLS(m)/r-1;
396  /* fill in the powers of x_var=h*/
397  poly h=p_One(R);
398  for(k=r;k>0; k--)
399  {
400  MATELEM(m,k,k*(p+1))=p_One(R);
401  }
402  for(l=p;l>=0; l--)
403  {
404  p_SetExp(h,var,p-l, R);
405  p_Setm(h, R);
406  for(k=r;k>0; k--)
407  {
408  MATELEM(m,k,k*(p+1)-l)=p_Copy(h, R);
409  }
410  }
411  p_Delete(&h, R);
412 }
return P p
Definition: myNF.cc:203
#define omfreeSize(addr, size)
Definition: omAllocDecl.h:236
void * ADDRESS
Definition: auxiliary.h:161
int k
Definition: cfEzgcd.cc:93
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
poly * m
Definition: matpol.h:19
const ring r
Definition: syzextra.cc:208
poly p_One(const ring r)
Definition: p_polys.cc:1318
const ring R
Definition: DebugPrint.cc:36
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
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:484
#define MATCOLS(i)
Definition: matpol.h:28
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:436
#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
matrix mp_Mult ( matrix  a,
matrix  b,
const ring  r 
)

Definition at line 224 of file matpol.cc.

225 {
226  int i, j, k;
227  int m = MATROWS(a);
228  int p = MATCOLS(a);
229  int q = MATCOLS(b);
230 
231  if (p!=MATROWS(b))
232  {
233 /*
234 * Werror("cannot multiply %dx%d matrix and %dx%d matrix",
235 * m,p,b->rows(),q);
236 */
237  return NULL;
238  }
239  matrix c = mpNew(m,q);
240 
241  for (i=1; i<=m; i++)
242  {
243  for (k=1; k<=p; k++)
244  {
245  poly aik;
246  if ((aik=MATELEM(a,i,k))!=NULL)
247  {
248  for (j=1; j<=q; j++)
249  {
250  poly bkj;
251  if ((bkj=MATELEM(b,k,j))!=NULL)
252  {
253  poly *cij=&(MATELEM(c,i,j));
254  poly s = pp_Mult_qq(aik /*MATELEM(a,i,k)*/, bkj/*MATELEM(b,k,j)*/, R);
255  if (/*MATELEM(c,i,j)*/ (*cij)==NULL) (*cij)=s;
256  else (*cij) = p_Add_q((*cij) /*MATELEM(c,i,j)*/ ,s, R);
257  }
258  }
259  }
260  // pNormalize(t);
261  // MATELEM(c,i,j) = t;
262  }
263  }
264  for(i=m*q-1;i>=0;i--) p_Normalize(c->m[i], R);
265  return c;
266 }
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:1075
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:48
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3621
#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:884
#define MATELEM(mat, i, j)
Definition: matpol.h:29
matrix mp_MultI ( matrix  a,
int  f,
const ring  r 
)

c = f*a

Definition at line 146 of file matpol.cc.

147 {
148  int k, n = a->nrows, m = a->ncols;
149  poly p = p_ISet(f, R);
150  matrix c = mpNew(n,m);
151 
152  for (k=m*n-1; k>0; k--)
153  c->m[k] = pp_Mult_qq(a->m[k], p, R);
154  c->m[0] = p_Mult_q(p_Copy(a->m[0], R), p, R);
155  return c;
156 }
int ncols
Definition: matpol.h:22
return P p
Definition: myNF.cc:203
f
Definition: cfModGcd.cc:4022
int k
Definition: cfEzgcd.cc:93
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
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:1075
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:48
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:1302
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1025
matrix mp_MultP ( matrix  a,
poly  p,
const ring  r 
)

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

Definition at line 159 of file matpol.cc.

160 {
161  int k, n = a->nrows, m = a->ncols;
162 
163  p_Normalize(p, R);
164  for (k=m*n-1; k>0; k--)
165  {
166  if (a->m[k]!=NULL)
167  a->m[k] = p_Mult_q(a->m[k], p_Copy(p, R), R);
168  }
169  a->m[0] = p_Mult_q(a->m[0], p, R);
170  return a;
171 }
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:811
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:3621
#define NULL
Definition: omList.c:10
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1025
static matrix mp_New ( int  r,
int  c 
)
inlinestatic

Definition at line 35 of file matpol.h.

35 { return mpNew(r,c); }
const ring r
Definition: syzextra.cc:208
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:48
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 1508 of file matpol.cc.

1510 {
1511  int k;
1512  int kr=lr-1,kc=lc-1;
1513  matrix nextLevel=mpNew(kr,kc);
1514 
1515  loop
1516  {
1517 /*--- look for an optimal row and bring it to last position ------------*/
1518  if(mp_PrepareRow(a,lr,lc,r)==0) break;
1519 /*--- now take all pivots from the last row ------------*/
1520  k = lc;
1521  loop
1522  {
1523  if(mp_PreparePiv(a,lr,k,r)==0) break;
1524  mp_ElimBar(a,nextLevel,barDiv,lr,k,r);
1525  k--;
1526  if (ar>1)
1527  {
1528  mp_RecMin(ar-1,result,elems,nextLevel,kr,k,a->m[kr*a->ncols+k],R,r);
1529  mp_PartClean(nextLevel,kr,k, r);
1530  }
1531  else mp_MinorToResult(result,elems,nextLevel,kr,k,R,r);
1532  if (ar>k-1) break;
1533  }
1534  if (ar>=kr) break;
1535 /*--- now we have to take out the last row...------------*/
1536  lr = kr;
1537  kr--;
1538  }
1539  mpFinalClean(nextLevel);
1540 }
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:1508
static void mp_ElimBar(matrix a0, matrix re, poly div, int lr, int lc, const ring R)
Definition: matpol.cc:1354
static void mpFinalClean(matrix a)
Definition: matpol.cc:1500
static int mp_PrepareRow(matrix a, int lr, int lc, const ring R)
Definition: matpol.cc:1286
int k
Definition: cfEzgcd.cc:93
static void mp_PartClean(matrix a, int lr, int lc, const ring R)
Definition: matpol.cc:709
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:1412
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:1344
const ring R
Definition: DebugPrint.cc:36
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:48
return result
Definition: facAbsBiFact.cc:76
matrix mp_Sub ( matrix  a,
matrix  b,
const ring  r 
)

Definition at line 207 of file matpol.cc.

208 {
209  int k, n = a->nrows, m = a->ncols;
210  if ((n != b->nrows) || (m != b->ncols))
211  {
212 /*
213 * Werror("cannot sub %dx%d matrix and %dx%d matrix",
214 * m,n,b->cols(),b->rows());
215 */
216  return NULL;
217  }
218  matrix c = mpNew(n,m);
219  for (k=m*n-1; k>=0; k--)
220  c->m[k] = p_Sub(p_Copy(a->m[k], R), p_Copy(b->m[k], R), R);
221  return c;
222 }
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:1901
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
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:48
#define NULL
Definition: omList.c:10
poly mp_Trace ( matrix  a,
const ring  r 
)

Definition at line 289 of file matpol.cc.

290 {
291  int i;
292  int n = (MATCOLS(a)<MATROWS(a)) ? MATCOLS(a) : MATROWS(a);
293  poly t = NULL;
294 
295  for (i=1; i<=n; i++)
296  t = p_Add_q(t, p_Copy(MATELEM(a,i,i), R), R);
297  return t;
298 }
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
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:884
#define MATELEM(mat, i, j)
Definition: matpol.h:29
matrix mp_Transp ( matrix  a,
const ring  r 
)

Definition at line 268 of file matpol.cc.

269 {
270  int i, j, r = MATROWS(a), c = MATCOLS(a);
271  poly *p;
272  matrix b = mpNew(c,r);
273 
274  p = b->m;
275  for (i=0; i<c; i++)
276  {
277  for (j=0; j<r; j++)
278  {
279  if (a->m[j*c+i]!=NULL) *p = p_Copy(a->m[j*c+i], R);
280  p++;
281  }
282  }
283  return b;
284 }
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:811
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:48
#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
matrix mp_Wedge ( matrix  a,
int  ar,
const ring  r 
)

Definition at line 1656 of file matpol.cc.

1657 {
1658  int i,j,k,l;
1659  int *rowchoise,*colchoise;
1660  BOOLEAN rowch,colch;
1661  matrix result;
1662  matrix tmp;
1663  poly p;
1664 
1665  i = binom(a->nrows,ar);
1666  j = binom(a->ncols,ar);
1667 
1668  rowchoise=(int *)omAlloc(ar*sizeof(int));
1669  colchoise=(int *)omAlloc(ar*sizeof(int));
1670  result = mpNew(i,j);
1671  tmp = mpNew(ar,ar);
1672  l = 1; /* k,l:the index in result*/
1673  idInitChoise(ar,1,a->nrows,&rowch,rowchoise);
1674  while (!rowch)
1675  {
1676  k=1;
1677  idInitChoise(ar,1,a->ncols,&colch,colchoise);
1678  while (!colch)
1679  {
1680  for (i=1; i<=ar; i++)
1681  {
1682  for (j=1; j<=ar; j++)
1683  {
1684  MATELEM(tmp,i,j) = MATELEM(a,rowchoise[i-1],colchoise[j-1]);
1685  }
1686  }
1687  p = mp_DetBareiss(tmp, R);
1688  if ((k+l) & 1) p=p_Neg(p, R);
1689  MATELEM(result,l,k) = p;
1690  k++;
1691  idGetNextChoise(ar,a->ncols,&colch,colchoise);
1692  }
1693  idGetNextChoise(ar,a->nrows,&rowch,rowchoise);
1694  l++;
1695  }
1696 
1697  /*delete the matrix tmp*/
1698  for (i=1; i<=ar; i++)
1699  {
1700  for (j=1; j<=ar; j++) MATELEM(tmp,i,j) = NULL;
1701  }
1702  id_Delete((ideal *) &tmp, R);
1703  return (result);
1704 }
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:48
#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:1581
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1018
polyrec * poly
Definition: hilb.h:10
int BOOLEAN
Definition: auxiliary.h:131
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
matrix mpNew ( int  r,
int  c 
)

create a r x c zero-matrix

Definition at line 48 of file matpol.cc.

49 {
50  int rr=r;
51  if (rr<=0) rr=1;
52  if ( (((int)(MAX_INT_VAL/sizeof(poly))) / rr) <= c)
53  {
54  Werror("internal error: creating matrix[%d][%d]",r,c);
55  return NULL;
56  }
58  rc->nrows = r;
59  rc->ncols = c;
60  rc->rank = r;
61  if ((c != 0)&&(r!=0))
62  {
63  int s=r*c*sizeof(poly);
64  rc->m = (poly*)omAlloc0(s);
65  //if (rc->m==NULL)
66  //{
67  // Werror("internal error: creating matrix[%d][%d]",r,c);
68  // return NULL;
69  //}
70  }
71  return rc;
72 }
#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
const int MAX_INT_VAL
Definition: mylimits.h:12
#define NULL
Definition: omList.c:10
polyrec * poly
Definition: hilb.h:10
void Werror(const char *fmt,...)
Definition: reporter.cc:199
#define omAlloc0(size)
Definition: omAllocDecl.h:211
long rank
Definition: matpol.h:20
matrix pMultMp ( poly  p,
matrix  a,
const ring  r 
)

Definition at line 176 of file matpol.cc.

177 {
178  int k, n = a->nrows, m = a->ncols;
179 
180  p_Normalize(p, R);
181  for (k=m*n-1; k>0; k--)
182  {
183  if (a->m[k]!=NULL)
184  a->m[k] = p_Mult_q(p_Copy(p, R), a->m[k], R);
185  }
186  a->m[0] = p_Mult_q(p, a->m[0], R);
187  return a;
188 }
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:811
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:3621
#define NULL
Definition: omList.c:10
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1025
poly TraceOfProd ( matrix  a,
matrix  b,
int  n,
const ring  r 
)

Definition at line 303 of file matpol.cc.

304 {
305  int i, j;
306  poly p, t = NULL;
307 
308  for (i=1; i<=n; i++)
309  {
310  for (j=1; j<=n; j++)
311  {
312  p = pp_Mult_qq(MATELEM(a,i,j), MATELEM(b,j,i), R);
313  t = p_Add_q(t, p, R);
314  }
315  }
316  return t;
317 }
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:1075
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:884
#define MATELEM(mat, i, j)
Definition: matpol.h:29

Variable Documentation

omBin ip_smatrix_bin