Data Structures | Macros | Typedefs | Enumerations | 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]
 1-based access to matrix More...
 
#define MATELEM0(mat, i, j)   ((mat)->m)[MATCOLS((mat)) * (i) + (j)]
 0-based access to matrix More...
 
#define SMATELEM(A, i, j, R)   p_Vec2Poly(A->m[j],i+1,R)
 

Typedefs

typedef ip_smatrixmatrix
 

Enumerations

enum  DetVariant {
  DetDefault =0, DetBareiss, DetSBareiss, DetMu,
  DetFactory
}
 

Functions

matrix mpNew (int r, int c)
 create a r x c zero-matrix More...
 
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_Det (matrix a, const ring r, DetVariant d=DetDefault)
 
poly mp_DetBareiss (matrix a, const ring r)
 returns the determinant of the matrix m; uses Bareiss algorithm More...
 
poly mp_DetMu (matrix A, const ring R)
 
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)
 
matrix mp_CoeffProcId (ideal I, 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 sm_Add (ideal a, ideal b, const ring R)
 
ideal sm_Sub (ideal a, ideal b, const ring R)
 
ideal sm_Mult (ideal a, ideal b, const ring R)
 
ideal sm_Flatten (ideal a, const ring R)
 
ideal sm_UnFlatten (ideal a, int col, const ring R)
 
poly sm_Trace (ideal a, const ring R)
 
int sm_Compare (ideal a, ideal b, const ring R)
 
BOOLEAN sm_Equal (ideal a, ideal b, const ring R)
 
ideal sm_Tensor (ideal A, ideal B, const ring r)
 
poly sm_Det (ideal I, const ring, DetVariant d=DetDefault)
 
DetVariant mp_GetAlgorithmDet (matrix m, const ring r)
 
DetVariant mp_GetAlgorithmDet (const char *s)
 

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]

1-based access to matrix

Definition at line 29 of file matpol.h.

◆ MATELEM0

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

0-based access to matrix

Definition at line 31 of file matpol.h.

◆ MATROWS

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

Definition at line 26 of file matpol.h.

◆ SMATELEM

#define SMATELEM (   A,
  i,
  j,
  R 
)    p_Vec2Poly(A->m[j],i+1,R)

Definition at line 122 of file matpol.h.

Typedef Documentation

◆ matrix

typedef ip_smatrix* matrix

Definition at line 43 of file matpol.h.

Enumeration Type Documentation

◆ DetVariant

enum DetVariant
Enumerator
DetDefault 
DetBareiss 
DetSBareiss 
DetMu 
DetFactory 

Definition at line 34 of file matpol.h.

35 {
36  DetDefault=0,
37  DetBareiss,
39  DetMu,
41 };
Definition: matpol.h:39

Function Documentation

◆ iiStringMatrix()

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

Definition at line 855 of file matpol.cc.

856 {
857  int i,ii = MATROWS(im);
858  int j,jj = MATCOLS(im);
859  poly *pp = im->m;
860  char ch_s[2];
861  ch_s[0]=ch;
862  ch_s[1]='\0';
863 
864  StringSetS("");
865 
866  for (i=0; i<ii; i++)
867  {
868  for (j=0; j<jj; j++)
869  {
870  p_String0(*pp++, r);
871  StringAppendS(ch_s);
872  if (dim > 1) StringAppendS("\n");
873  }
874  }
875  char *s=StringEndS();
876  s[strlen(s)- (dim > 1 ? 2 : 1)]='\0';
877  return s;
878 }
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:248
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:179
#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 834 of file matpol.cc.

835 {
836  int i,ii = MATROWS(im)-1;
837  int j,jj = MATCOLS(im)-1;
838  poly *pp = im->m;
839 
840  for (i=0; i<=ii; i++)
841  {
842  for (j=0; j<=jj; j++)
843  {
844  if (spaces>0)
845  Print("%-*.*s",spaces,spaces," ");
846  if (dim == 2) Print("%s[%u,%u]=",n,i+1,j+1);
847  else if (dim == 1) Print("%s[%u]=",n,j+1);
848  else if (dim == 0) Print("%s=",n);
849  if ((i<ii)||(j<jj)) p_Write(*pp++, r);
850  else p_Write0(*pp, r);
851  }
852  }
853 }
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:248
int dim(ideal I, ring r)
int i
Definition: cfEzgcd.cc:125
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:239
#define MATCOLS(i)
Definition: matpol.h:27
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:249
#define MATROWS(i)
Definition: matpol.h:26

◆ mp_Add()

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

Definition at line 179 of file matpol.cc.

180 {
181  int k, n = a->nrows, m = a->ncols;
182  if ((n != b->nrows) || (m != b->ncols))
183  {
184 /*
185 * Werror("cannot add %dx%d matrix and %dx%d matrix",
186 * m,n,b->cols(),b->rows());
187 */
188  return NULL;
189  }
190  matrix c = mpNew(n,m);
191  for (k=m*n-1; k>=0; k--)
192  c->m[k] = p_Add_q(p_Copy(a->m[k], R), p_Copy(b->m[k], R), R);
193  return c;
194 }
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:811
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:37
#define NULL
Definition: omList.c:12
#define R
Definition: sirandom.c:26
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:891

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

582 {
583  poly* s;
584  poly p;
585  int sl,i,j;
586  int l=0;
587  poly sel=mp_Select(v,mon, R);
588 
589  p_Vec2Polys(sel,&s,&sl, R);
590  for (i=0; i<sl; i++)
591  l=si_max(l,pLength(s[i]));
592  *c=mpNew(sl,l);
593  *m=mpNew(sl,l);
594  poly h;
595  int isConst;
596  for (j=1; j<=sl;j++)
597  {
598  p=s[j-1];
599  if (p_IsConstant(p, R)) /*p != NULL */
600  {
601  isConst=-1;
602  i=l;
603  }
604  else
605  {
606  isConst=1;
607  i=1;
608  }
609  while(p!=NULL)
610  {
611  h = p_Head(p, R);
612  MATELEM(*m,j,i) = h;
613  i+=isConst;
614  p = p->next;
615  }
616  }
617  while (v!=NULL)
618  {
619  i = 1;
620  j = __p_GetComp(v, R);
621  loop
622  {
623  poly mp=MATELEM(*m,j,i);
624  if (mp!=NULL)
625  {
626  h = mp_Exdiv(v, mp /*MATELEM(*m,j,i)*/, mp, R);
627  if (h!=NULL)
628  {
629  p_SetComp(h,0, R);
630  MATELEM(*c,j,i) = p_Add_q(MATELEM(*c,j,i), h, R);
631  break;
632  }
633  }
634  if (i < l)
635  i++;
636  else
637  break;
638  }
639  v = v->next;
640  }
641 }
#define __p_GetComp(p, r)
Definition: monomials.h:63
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:748
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:246
static poly mp_Exdiv(poly m, poly d, poly vars, const ring)
Definition: matpol.cc:561
#define loop
Definition: structs.h:80
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:824
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1927
void p_Vec2Polys(poly v, poly **p, int *len, const ring r)
Definition: p_polys.cc:3582
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:191
Variable next() const
Definition: factory.h:137
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:12
#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:891
static Poly * h
Definition: janet.cc:971
int l
Definition: cfEzgcd.cc:93
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29

◆ mp_CoeffProc()

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

Definition at line 399 of file matpol.cc.

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

◆ mp_CoeffProcId()

matrix mp_CoeffProcId ( ideal  I,
poly  vars,
const ring  R 
)

Definition at line 476 of file matpol.cc.

477 {
478  assume(vars!=NULL);
479  poly sel, h;
480  int l, i;
481  int pos_of_1 = -1;
482  matrix co;
483 
484  if (idIs0(I))
485  {
486  co = mpNew(IDELEMS(I)+1,1);
487  MATELEM(co,1,1) = p_One(R);
488  return co;
489  }
490  sel = mp_SelectId(I, vars, R);
491  l = pLength(sel);
492  co = mpNew(IDELEMS(I)+1, l);
493 
495  {
496  for (i=l; i>=1; i--)
497  {
498  h = sel;
499  pIter(sel);
500  pNext(h)=NULL;
501  MATELEM(co,1,i) = h;
502  //MATELEM(co,2,i) = NULL;
503  if (p_IsConstant(h, R)) pos_of_1 = i;
504  }
505  }
506  else
507  {
508  for (i=1; i<=l; i++)
509  {
510  h = sel;
511  pIter(sel);
512  pNext(h)=NULL;
513  MATELEM(co,1,i) = h;
514  //MATELEM(co,2,i) = NULL;
515  if (p_IsConstant(h, R)) pos_of_1 = i;
516  }
517  }
518  for(int j=0;j<IDELEMS(I);j++)
519  {
520  poly f=I->m[j];
521  while (f!=NULL)
522  {
523  i = 1;
524  loop
525  {
526  if (i!=pos_of_1)
527  {
528  h = mp_Exdiv(f, MATELEM(co,1,i),vars, R);
529  if (h!=NULL)
530  {
531  MATELEM(co,j+2,i) = p_Add_q(MATELEM(co,j+2,i), h, R);
532  break;
533  }
534  }
535  if (i == l)
536  {
537  // check monom 1 last:
538  if (pos_of_1 != -1)
539  {
540  h = mp_Exdiv(f, MATELEM(co,1,pos_of_1),vars, R);
541  if (h!=NULL)
542  {
543  MATELEM(co,j+2,pos_of_1) = p_Add_q(MATELEM(co,j+2,pos_of_1), h, R);
544  }
545  }
546  break;
547  }
548  i ++;
549  }
550  pIter(f);
551  }
552  }
553  return co;
554 }
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition: ring.h:755
int j
Definition: facHensel.cc:105
static poly mp_SelectId(ideal I, poly what, const ring R)
Definition: matpol.cc:766
static poly mp_Exdiv(poly m, poly d, poly vars, const ring)
Definition: matpol.cc:561
#define loop
Definition: structs.h:80
#define pIter(p)
Definition: monomials.h:37
poly p_One(const ring r)
Definition: p_polys.cc:1303
#define assume(x)
Definition: mod2.h:390
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1927
FILE * f
Definition: checklibs.c:9
int i
Definition: cfEzgcd.cc:125
static unsigned pLength(poly a)
Definition: p_polys.h:191
#define IDELEMS(i)
Definition: simpleideals.h:23
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
#define NULL
Definition: omList.c:12
#define R
Definition: sirandom.c:26
#define pNext(p)
Definition: monomials.h:36
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:891
static Poly * h
Definition: janet.cc:971
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
int l
Definition: cfEzgcd.cc:93
#define MATELEM(mat, i, j)
1-based access to matrix
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 313 of file matpol.cc.

314 {
315  poly h,f;
316  int l, i, c, m=0;
317  /* look for maximal power m of x_var in I */
318  for (i=IDELEMS(I)-1; i>=0; i--)
319  {
320  f=I->m[i];
321  while (f!=NULL)
322  {
323  l=p_GetExp(f,var, R);
324  if (l>m) m=l;
325  pIter(f);
326  }
327  }
328  matrix co=mpNew((m+1)*I->rank,IDELEMS(I));
329  /* divide each monomial by a power of x_var,
330  * remember the power in l and the component in c*/
331  for (i=IDELEMS(I)-1; i>=0; i--)
332  {
333  f=I->m[i];
334  I->m[i]=NULL;
335  while (f!=NULL)
336  {
337  l=p_GetExp(f,var, R);
338  p_SetExp(f,var,0, R);
339  c=si_max((int)p_GetComp(f, R),1);
340  p_SetComp(f,0, R);
341  p_Setm(f, R);
342  /* now add the resulting monomial to co*/
343  h=pNext(f);
344  pNext(f)=NULL;
345  //MATELEM(co,c*(m+1)-l,i+1)
346  // =p_Add_q(MATELEM(co,c*(m+1)-l,i+1),f, R);
347  MATELEM(co,(c-1)*(m+1)+l+1,i+1)
348  =p_Add_q(MATELEM(co,(c-1)*(m+1)+l+1,i+1),f, R);
349  /* iterate f*/
350  f=h;
351  }
352  }
353  id_Delete(&I, R);
354  return co;
355 }
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:246
#define p_GetComp(p, r)
Definition: monomials.h:64
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define pIter(p)
Definition: monomials.h:37
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:468
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:23
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
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:487
#define NULL
Definition: omList.c:12
#define R
Definition: sirandom.c:26
#define pNext(p)
Definition: monomials.h:36
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:232
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:891
static Poly * h
Definition: janet.cc:971
int l
Definition: cfEzgcd.cc:93
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29

◆ mp_Compare()

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

Definition at line 643 of file matpol.cc.

644 {
645  if (MATCOLS(a)<MATCOLS(b)) return -1;
646  else if (MATCOLS(a)>MATCOLS(b)) return 1;
647  if (MATROWS(a)<MATROWS(b)) return -1;
648  else if (MATROWS(a)<MATROWS(b)) return 1;
649 
650  unsigned ii=MATCOLS(a)*MATROWS(a)-1;
651  unsigned j=0;
652  int r=0;
653  while (j<=ii)
654  {
655  r=p_Compare(a->m[j],b->m[j],R);
656  if (r!=0) return r;
657  j++;
658  }
659  return r;
660 }
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:4812
#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 85 of file matpol.cc.

86 {
87  id_Test((ideal)a, rSrc);
88 
89  poly t;
90  int i, m=MATROWS(a), n=MATCOLS(a);
91 
92  matrix b = mpNew(m, n);
93 
94  for (i=m*n-1; i>=0; i--)
95  {
96  t = a->m[i];
97  if (t!=NULL)
98  {
99  b->m[i] = prCopyR_NoSort(t, rSrc, rDst);
100  p_Normalize(b->m[i], rDst);
101  }
102  }
103  b->rank=a->rank;
104 
105  id_Test((ideal)b, rDst);
106 
107  return b;
108 }
poly prCopyR_NoSort(poly p, ring src_r, ring dest_r)
Definition: prCopy.cc:76
#define id_Test(A, lR)
Definition: simpleideals.h:79
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:37
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3732
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:12
#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 64 of file matpol.cc.

65 {
66  id_Test((ideal)a, r);
67  poly t;
68  int i, m=MATROWS(a), n=MATCOLS(a);
69  matrix b = mpNew(m, n);
70 
71  for (i=m*n-1; i>=0; i--)
72  {
73  t = a->m[i];
74  if (t!=NULL)
75  {
76  p_Normalize(t, r);
77  b->m[i] = p_Copy(t, r);
78  }
79  }
80  b->rank=a->rank;
81  return b;
82 }
#define id_Test(A, lR)
Definition: simpleideals.h:79
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
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:37
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3732
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:12
#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 880 of file matpol.cc.

881 {
882  id_Delete((ideal *) a, r);
883 }
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix

◆ mp_Det()

poly mp_Det ( matrix  a,
const ring  r,
DetVariant  d = DetDefault 
)

Definition at line 2143 of file matpol.cc.

2144 {
2145  if ((MATCOLS(a)==0)
2146  && (MATROWS(a)==0))
2147  return p_One(r);
2148  if (d==DetDefault) d=mp_GetAlgorithmDet(a,r);
2149  switch (d)
2150  {
2151  case DetBareiss: return mp_DetBareiss(a,r);
2152  case DetMu: return mp_DetMu(a,r);
2153  case DetFactory: return singclap_det(a,r);
2154  case DetSBareiss:
2155  {
2156  ideal I=id_Matrix2Module(mp_Copy(a, r),r);
2157  poly p=sm_CallDet(I, r);
2158  id_Delete(&I, r);
2159  return p;
2160  }
2161  default:
2162  WerrorS("unknown algorithm for det");
2163  }
2164 }
poly sm_CallDet(ideal I, const ring R)
Definition: sparsmat.cc:302
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
poly singclap_det(const matrix m, const ring s)
Definition: clapsing.cc:1637
void WerrorS(const char *s)
Definition: feFopen.cc:24
Definition: matpol.h:39
poly p_One(const ring r)
Definition: p_polys.cc:1303
#define MATCOLS(i)
Definition: matpol.h:27
poly mp_DetMu(matrix A, const ring R)
Definition: matpol.cc:2070
DetVariant mp_GetAlgorithmDet(matrix m, const ring r)
Definition: matpol.cc:2112
poly mp_DetBareiss(matrix a, const ring r)
returns the determinant of the matrix m; uses Bareiss algorithm
Definition: matpol.cc:1676
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition: matpol.cc:64
#define MATROWS(i)
Definition: matpol.h:26
int p
Definition: cfModGcd.cc:4019
ideal id_Matrix2Module(matrix mat, const ring R)
converts mat to module, destroys mat

◆ mp_DetBareiss()

poly mp_DetBareiss ( matrix  a,
const ring  r 
)

returns the determinant of the matrix m; uses Bareiss algorithm

Definition at line 1676 of file matpol.cc.

1677 {
1678  int s;
1679  poly div, res;
1680  if (MATROWS(a) != MATCOLS(a))
1681  {
1682  Werror("det of %d x %d matrix",MATROWS(a),MATCOLS(a));
1683  return NULL;
1684  }
1685  matrix c = mp_Copy(a,r);
1686  mp_permmatrix *Bareiss = new mp_permmatrix(c,r);
1687  row_col_weight w(Bareiss->mpGetRdim(), Bareiss->mpGetCdim());
1688 
1689  /* Bareiss */
1690  div = NULL;
1691  while(Bareiss->mpPivotBareiss(&w))
1692  {
1693  Bareiss->mpElimBareiss(div);
1694  div = Bareiss->mpGetElem(Bareiss->mpGetRdim(), Bareiss->mpGetCdim());
1695  }
1696  Bareiss->mpRowReorder();
1697  Bareiss->mpColReorder();
1698  Bareiss->mpSaveArray();
1699  s = Bareiss->mpGetSign();
1700  delete Bareiss;
1701 
1702  /* result */
1703  res = MATELEM(c,1,1);
1704  MATELEM(c,1,1) = NULL;
1705  id_Delete((ideal *)&c,r);
1706  if (s < 0)
1707  res = p_Neg(res,r);
1708  return res;
1709 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
void mpElimBareiss(poly)
Definition: matpol.cc:1244
int mpGetSign()
Definition: matpol.cc:950
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
void mpSaveArray()
Definition: matpol.cc:952
int mpPivotBareiss(row_col_weight *)
Definition: matpol.cc:1159
void mpRowReorder()
Definition: matpol.cc:1119
void mpColReorder()
Definition: matpol.cc:1098
CanonicalForm res
Definition: facAbsFact.cc:64
int mpGetCdim()
Definition: matpol.cc:949
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:12
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:64
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1042
int mpGetRdim()
Definition: matpol.cc:948
#define MATROWS(i)
Definition: matpol.h:26
poly mpGetElem(int, int)
Definition: matpol.cc:1236
void Werror(const char *fmt,...)
Definition: reporter.cc:189
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29

◆ mp_DetMu()

poly mp_DetMu ( matrix  A,
const ring  R 
)

Definition at line 2070 of file matpol.cc.

2071 {
2072  int n=MATROWS(A);
2073  assume(MATCOLS(A)==n);
2074  /*
2075  * Intput:
2076  * int n: Dimension der Matrix
2077  * int A: n*n Matrix
2078  *
2079  * Berechnet n-1 mal: X = mu(X)*A
2080  *
2081  * Output: det(A)
2082  */
2083 
2084  //speichere A ab:
2085  matrix workA=mp_Copy(A,R);
2086 
2087  // berechen X = mu(X)*A
2088  matrix X;
2089  for (int i = n-1; i >0; i--)
2090  {
2091  X=mu(workA,R);
2092  id_Delete((ideal*)&workA,R);
2093  workA=mp_Mult(X,A,R);
2094  id_Delete((ideal*)&X,R);
2095  }
2096 
2097  // berrechne det(A)
2098  poly res;
2099  if (n%2 == 0)
2100  {
2101  res=p_Neg(MATELEM0(workA,0,0),R);
2102  }
2103  else
2104  {
2105  res=MATELEM0(workA,0,0);
2106  }
2107  MATELEM0(workA,0,0)=NULL;
2108  id_Delete((ideal*)&workA,R);
2109  return res;
2110 }
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define MATELEM0(mat, i, j)
0-based access to matrix
Definition: matpol.h:31
static matrix mu(matrix A, const ring R)
Definition: matpol.cc:2032
CanonicalForm res
Definition: facAbsFact.cc:64
#define assume(x)
Definition: mod2.h:390
int i
Definition: cfEzgcd.cc:125
matrix mp_Mult(matrix a, matrix b, const ring R)
Definition: matpol.cc:213
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:12
#define R
Definition: sirandom.c:26
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition: matpol.cc:64
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1042
#define MATROWS(i)
Definition: matpol.h:26

◆ mp_Equal()

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

Definition at line 662 of file matpol.cc.

663 {
664  if ((MATCOLS(a)!=MATCOLS(b)) || (MATROWS(a)!=MATROWS(b)))
665  return FALSE;
666  int i=MATCOLS(a)*MATROWS(a)-1;
667  while (i>=0)
668  {
669  if (a->m[i]==NULL)
670  {
671  if (b->m[i]!=NULL) return FALSE;
672  }
673  else if (b->m[i]==NULL) return FALSE;
674  else if (p_Cmp(a->m[i],b->m[i], R)!=0) return FALSE;
675  i--;
676  }
677  i=MATCOLS(a)*MATROWS(a)-1;
678  while (i>=0)
679  {
680  if(!p_EqualPolys(a->m[i],b->m[i], R)) return FALSE;
681  i--;
682  }
683  return TRUE;
684 }
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1651
#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:4418
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:12
#define R
Definition: sirandom.c:26
#define MATROWS(i)
Definition: matpol.h:26

◆ mp_GetAlgorithmDet() [1/2]

DetVariant mp_GetAlgorithmDet ( matrix  m,
const ring  r 
)

Definition at line 2112 of file matpol.cc.

2113 {
2114  if (MATROWS(m)+2*r->N>20+5*rField_is_Zp(r)) return DetMu;
2115  if (MATROWS(m)<10+5*rField_is_Zp(r)) return DetSBareiss;
2116  BOOLEAN isConst=TRUE;
2117  int s=0;
2118  for(int i=MATCOLS(m)*MATROWS(m)-1;i>=0;i--)
2119  {
2120  poly p=m->m[i];
2121  if (p!=NULL)
2122  {
2123  if(!p_IsConstant(p,r)) isConst=FALSE;
2124  s++;
2125  }
2126  }
2127  if (isConst && rField_is_Q(r)) return DetFactory;
2128  if (s*2<MATCOLS(m)*MATROWS(m)) // few entries
2129  return DetSBareiss;
2130  return DetMu;
2131 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
Definition: matpol.h:39
poly * m
Definition: matpol.h:18
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1927
int i
Definition: cfEzgcd.cc:125
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:501
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:495
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:12
#define MATROWS(i)
Definition: matpol.h:26
int p
Definition: cfModGcd.cc:4019
int BOOLEAN
Definition: auxiliary.h:85

◆ mp_GetAlgorithmDet() [2/2]

DetVariant mp_GetAlgorithmDet ( const char *  s)

Definition at line 2132 of file matpol.cc.

2133 {
2134  if (strcmp(s,"Bareiss")==0) return DetBareiss;
2135  if (strcmp(s,"SBareiss")==0) return DetSBareiss;
2136  if (strcmp(s,"Mu")==0) return DetMu;
2137  if (strcmp(s,"Factory")==0) return DetFactory;
2138  WarnS("unknown method for det");
2139  return DetDefault;
2140 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
Definition: matpol.h:39
#define WarnS
Definition: emacs.cc:78

◆ mp_InitI()

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

make it a v * unit matrix

Definition at line 129 of file matpol.cc.

130 {
131  return mp_InitP(r, c, p_ISet(v, R), R);
132 }
matrix mp_InitP(int r, int c, poly p, const ring R)
make it a p * unit matrix
Definition: matpol.cc:113
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:1287

◆ mp_InitP()

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

make it a p * unit matrix

Definition at line 113 of file matpol.cc.

114 {
115  matrix rc = mpNew(r,c);
116  int i=si_min(r,c), n = c*(i-1)+i-1, inc = c+1;
117 
118  p_Normalize(p, R);
119  while (n>0)
120  {
121  rc->m[n] = p_Copy(p, R);
122  n -= inc;
123  }
124  rc->m[0]=p;
125  return rc;
126 }
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:811
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:37
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3732
#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 816 of file matpol.cc.

817 {
818  if(MATROWS(U)!=MATCOLS(U))
819  return FALSE;
820  for(int i=MATCOLS(U);i>=1;i--)
821  {
822  for(int j=MATCOLS(U); j>=1; j--)
823  {
824  if (i==j)
825  {
826  if (!p_IsUnit(MATELEM(U,i,i), R)) return FALSE;
827  }
828  else if (MATELEM(U,i,j)!=NULL) return FALSE;
829  }
830  }
831  return TRUE;
832 }
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:1954
#define TRUE
Definition: auxiliary.h:98
int i
Definition: cfEzgcd.cc:125
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:12
#define R
Definition: sirandom.c:26
#define MATROWS(i)
Definition: matpol.h:26
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29

◆ mp_MinorToResult()

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

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

Definition at line 1507 of file matpol.cc.

1509 {
1510  poly *q1;
1511  int e=IDELEMS(result);
1512  int i,j;
1513 
1514  if (R != NULL)
1515  {
1516  for (i=r-1;i>=0;i--)
1517  {
1518  q1 = &(a->m)[i*a->ncols];
1519  //for (j=c-1;j>=0;j--)
1520  //{
1521  // if (q1[j]!=NULL) q1[j] = kNF(R,currRing->qideal,q1[j]);
1522  //}
1523  }
1524  }
1525  for (i=r-1;i>=0;i--)
1526  {
1527  q1 = &(a->m)[i*a->ncols];
1528  for (j=c-1;j>=0;j--)
1529  {
1530  if (q1[j]!=NULL)
1531  {
1532  if (elems>=e)
1533  {
1534  pEnlargeSet(&(result->m),e,e);
1535  e += e;
1536  IDELEMS(result) =e;
1537  }
1538  result->m[elems] = q1[j];
1539  q1[j] = NULL;
1540  elems++;
1541  }
1542  }
1543  }
1544 }
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:23
#define NULL
Definition: omList.c:12
void pEnlargeSet(poly **p, int l, int increment)
Definition: p_polys.cc:3656
#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 362 of file matpol.cc.

363 {
364  /* clear contents of m*/
365  int k,l;
366  for (k=MATROWS(m);k>0;k--)
367  {
368  for(l=MATCOLS(m);l>0;l--)
369  {
370  p_Delete(&MATELEM(m,k,l), R);
371  }
372  }
373  omfreeSize((ADDRESS)m->m,MATROWS(m)*MATCOLS(m)*sizeof(poly));
374  /* allocate monoms in the right size r x MATROWS(c)*/
375  m->m=(poly*)omAlloc0(r*MATROWS(c)*sizeof(poly));
376  MATROWS(m)=r;
377  MATCOLS(m)=MATROWS(c);
378  m->rank=r;
379  /* the maximal power p of x_var: MATCOLS(m)=r*(p+1) */
380  int p=MATCOLS(m)/r-1;
381  /* fill in the powers of x_var=h*/
382  poly h=p_One(R);
383  for(k=r;k>0; k--)
384  {
385  MATELEM(m,k,k*(p+1))=p_One(R);
386  }
387  for(l=p;l>=0; l--)
388  {
389  p_SetExp(h,var,p-l, R);
390  p_Setm(h, R);
391  for(k=r;k>0; k--)
392  {
393  MATELEM(m,k,k*(p+1)-l)=p_Copy(h, R);
394  }
395  }
396  p_Delete(&h, R);
397 }
#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:811
poly * m
Definition: matpol.h:18
poly p_One(const ring r)
Definition: p_polys.cc:1303
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:856
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:487
#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:232
#define MATROWS(i)
Definition: matpol.h:26
int p
Definition: cfModGcd.cc:4019
static Poly * h
Definition: janet.cc:971
#define omAlloc0(size)
Definition: omAllocDecl.h:211
int l
Definition: cfEzgcd.cc:93
long rank
Definition: matpol.h:19
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29

◆ mp_Mult()

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

Definition at line 213 of file matpol.cc.

214 {
215  int i, j, k;
216  int m = MATROWS(a);
217  int p = MATCOLS(a);
218  int q = MATCOLS(b);
219 
220  if (p!=MATROWS(b))
221  {
222 /*
223 * Werror("cannot multiply %dx%d matrix and %dx%d matrix",
224 * m,p,b->rows(),q);
225 */
226  return NULL;
227  }
228  matrix c = mpNew(m,q);
229 
230  for (i=0; i<m; i++)
231  {
232  for (k=0; k<p; k++)
233  {
234  poly aik;
235  if ((aik=MATELEM0(a,i,k))!=NULL)
236  {
237  for (j=0; j<q; j++)
238  {
239  poly bkj;
240  if ((bkj=MATELEM0(b,k,j))!=NULL)
241  {
242  poly *cij=&(MATELEM0(c,i,j));
243  poly s = pp_Mult_qq(aik /*MATELEM0(a,i,k)*/, bkj/*MATELEM0(b,k,j)*/, R);
244  (*cij)/*MATELEM0(c,i,j)*/ = p_Add_q((*cij) /*MATELEM0(c,i,j)*/ ,s, R);
245  }
246  }
247  }
248  }
249  }
250  for(i=m*q-1;i>=0;i--) p_Normalize(c->m[i], R);
251  return c;
252 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
int j
Definition: facHensel.cc:105
#define MATELEM0(mat, i, j)
0-based access to matrix
Definition: matpol.h:31
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:1086
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:37
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3732
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:12
#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:891

◆ mp_MultI()

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

c = f*a

Definition at line 135 of file matpol.cc.

136 {
137  int k, n = a->nrows, m = a->ncols;
138  poly p = p_ISet(f, R);
139  matrix c = mpNew(n,m);
140 
141  for (k=m*n-1; k>0; k--)
142  c->m[k] = pp_Mult_qq(a->m[k], p, R);
143  c->m[0] = p_Mult_q(p_Copy(a->m[0], R), p, R);
144  return c;
145 }
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:811
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:1086
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:37
#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:1287
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1049

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

149 {
150  int k, n = a->nrows, m = a->ncols;
151 
152  p_Normalize(p, R);
153  for (k=m*n-1; k>0; k--)
154  {
155  if (a->m[k]!=NULL)
156  a->m[k] = p_Mult_q(a->m[k], p_Copy(p, R), R);
157  }
158  a->m[0] = p_Mult_q(a->m[0], p, R);
159  return a;
160 }
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:811
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:3732
#define NULL
Definition: omList.c:12
#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:1049

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

1605 {
1606  int k;
1607  int kr=lr-1,kc=lc-1;
1608  matrix nextLevel=mpNew(kr,kc);
1609 
1610  loop
1611  {
1612 /*--- look for an optimal row and bring it to last position ------------*/
1613  if(mp_PrepareRow(a,lr,lc,r)==0) break;
1614 /*--- now take all pivots from the last row ------------*/
1615  k = lc;
1616  loop
1617  {
1618  if(mp_PreparePiv(a,lr,k,r)==0) break;
1619  mp_ElimBar(a,nextLevel,barDiv,lr,k,r);
1620  k--;
1621  if (ar>1)
1622  {
1623  mp_RecMin(ar-1,result,elems,nextLevel,kr,k,a->m[kr*a->ncols+k],R,r);
1624  mp_PartClean(nextLevel,kr,k, r);
1625  }
1626  else mp_MinorToResult(result,elems,nextLevel,kr,k,R,r);
1627  if (ar>k-1) break;
1628  }
1629  if (ar>=kr) break;
1630 /*--- now we have to take out the last row...------------*/
1631  lr = kr;
1632  kr--;
1633  }
1634  mpFinalClean(nextLevel);
1635 }
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:1603
static void mp_ElimBar(matrix a0, matrix re, poly div, int lr, int lc, const ring R)
Definition: matpol.cc:1449
static void mpFinalClean(matrix a)
Definition: matpol.cc:1595
static int mp_PrepareRow(matrix a, int lr, int lc, const ring R)
Definition: matpol.cc:1381
int k
Definition: cfEzgcd.cc:92
static void mp_PartClean(matrix a, int lr, int lc, const ring R)
Definition: matpol.cc:804
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:1507
#define loop
Definition: structs.h:80
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:1439
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:37
#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 196 of file matpol.cc.

197 {
198  int k, n = a->nrows, m = a->ncols;
199  if ((n != b->nrows) || (m != b->ncols))
200  {
201 /*
202 * Werror("cannot sub %dx%d matrix and %dx%d matrix",
203 * m,n,b->cols(),b->rows());
204 */
205  return NULL;
206  }
207  matrix c = mpNew(n,m);
208  for (k=m*n-1; k>=0; k--)
209  c->m[k] = p_Sub(p_Copy(a->m[k], R), p_Copy(b->m[k], R), R);
210  return c;
211 }
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:1965
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
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:37
#define NULL
Definition: omList.c:12
#define R
Definition: sirandom.c:26

◆ mp_Trace()

poly mp_Trace ( matrix  a,
const ring  r 
)

Definition at line 275 of file matpol.cc.

276 {
277  int i;
278  int n = (MATCOLS(a)<MATROWS(a)) ? MATCOLS(a) : MATROWS(a);
279  poly t = NULL;
280 
281  for (i=1; i<=n; i++)
282  t = p_Add_q(t, p_Copy(MATELEM(a,i,i), R), R);
283  return t;
284 }
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
int i
Definition: cfEzgcd.cc:125
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:12
#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:891
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29

◆ mp_Transp()

matrix mp_Transp ( matrix  a,
const ring  r 
)

Definition at line 254 of file matpol.cc.

255 {
256  int i, j, r = MATROWS(a), c = MATCOLS(a);
257  poly *p;
258  matrix b = mpNew(c,r);
259 
260  p = b->m;
261  for (i=0; i<c; i++)
262  {
263  for (j=0; j<r; j++)
264  {
265  if (a->m[j*c+i]!=NULL) *p = p_Copy(a->m[j*c+i], R);
266  p++;
267  }
268  }
269  return b;
270 }
int j
Definition: facHensel.cc:105
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
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:37
#define MATCOLS(i)
Definition: matpol.h:27
#define NULL
Definition: omList.c:12
#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 1751 of file matpol.cc.

1752 {
1753  int i,j,k,l;
1754  int *rowchoise,*colchoise;
1755  BOOLEAN rowch,colch;
1756  matrix result;
1757  matrix tmp;
1758  poly p;
1759 
1760  i = binom(a->nrows,ar);
1761  j = binom(a->ncols,ar);
1762 
1763  rowchoise=(int *)omAlloc(ar*sizeof(int));
1764  colchoise=(int *)omAlloc(ar*sizeof(int));
1765  result = mpNew(i,j);
1766  tmp = mpNew(ar,ar);
1767  l = 1; /* k,l:the index in result*/
1768  idInitChoise(ar,1,a->nrows,&rowch,rowchoise);
1769  while (!rowch)
1770  {
1771  k=1;
1772  idInitChoise(ar,1,a->ncols,&colch,colchoise);
1773  while (!colch)
1774  {
1775  for (i=1; i<=ar; i++)
1776  {
1777  for (j=1; j<=ar; j++)
1778  {
1779  MATELEM(tmp,i,j) = MATELEM(a,rowchoise[i-1],colchoise[j-1]);
1780  }
1781  }
1782  p = mp_DetBareiss(tmp, R);
1783  if ((k+l) & 1) p=p_Neg(p, R);
1784  MATELEM(result,l,k) = p;
1785  k++;
1786  idGetNextChoise(ar,a->ncols,&colch,colchoise);
1787  }
1788  idGetNextChoise(ar,a->nrows,&rowch,rowchoise);
1789  l++;
1790  }
1791 
1792  /*delete the matrix tmp*/
1793  for (i=1; i<=ar; i++)
1794  {
1795  for (j=1; j<=ar; j++) MATELEM(tmp,i,j) = NULL;
1796  }
1797  id_Delete((ideal *) &tmp, R);
1798  return (result);
1799 }
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:37
#define NULL
Definition: omList.c:12
#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:1676
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1042
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)
1-based access to matrix
Definition: matpol.h:29

◆ mpNew()

matrix mpNew ( int  r,
int  c 
)

create a r x c zero-matrix

Definition at line 37 of file matpol.cc.

38 {
39  int rr=r;
40  if (rr<=0) rr=1;
41  //if ( (((int)(MAX_INT_VAL/sizeof(poly))) / rr) <= c)
42  //{
43  // Werror("internal error: creating matrix[%d][%d]",r,c);
44  // return NULL;
45  //}
47  rc->nrows = r;
48  rc->ncols = c;
49  rc->rank = r;
50  if ((c != 0)&&(r!=0))
51  {
52  size_t s=((size_t)r)*((size_t)c)*sizeof(poly);
53  rc->m = (poly*)omAlloc0(s);
54  //if (rc->m==NULL)
55  //{
56  // Werror("internal error: creating matrix[%d][%d]",r,c);
57  // return NULL;
58  //}
59  }
60  return rc;
61 }
#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:27
poly * m
Definition: matpol.h:18
int nrows
Definition: matpol.h:20
ip_smatrix * matrix
Definition: matpol.h:43
#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 165 of file matpol.cc.

166 {
167  int k, n = a->nrows, m = a->ncols;
168 
169  p_Normalize(p, R);
170  for (k=m*n-1; k>0; k--)
171  {
172  if (a->m[k]!=NULL)
173  a->m[k] = p_Mult_q(p_Copy(p, R), a->m[k], R);
174  }
175  a->m[0] = p_Mult_q(p, a->m[0], R);
176  return a;
177 }
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:811
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:3732
#define NULL
Definition: omList.c:12
#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:1049

◆ sm_Add()

ideal sm_Add ( ideal  a,
ideal  b,
const ring  R 
)

Definition at line 1871 of file matpol.cc.

1872 {
1873  assume(IDELEMS(a)==IDELEMS(b));
1874  assume(a->rank==b->rank);
1875  ideal c=idInit(IDELEMS(a),a->rank);
1876  for (int k=IDELEMS(a)-1; k>=0; k--)
1877  c->m[k] = p_Add_q(p_Copy(a->m[k], R), p_Copy(b->m[k], R), R);
1878  return c;
1879 }
int k
Definition: cfEzgcd.cc:92
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
CanonicalForm b
Definition: cfModGcd.cc:4044
#define assume(x)
Definition: mod2.h:390
#define IDELEMS(i)
Definition: simpleideals.h:23
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define R
Definition: sirandom.c:26
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:891

◆ sm_Compare()

int sm_Compare ( ideal  a,
ideal  b,
const ring  R 
)

Definition at line 1984 of file matpol.cc.

1985 {
1986  if (IDELEMS(a)<IDELEMS(b)) return -1;
1987  else if (IDELEMS(a)>IDELEMS(b)) return 1;
1988  if ((a->rank)<(b->rank)) return -1;
1989  else if ((a->rank)<(b->rank)) return 1;
1990 
1991  unsigned ii=IDELEMS(a)-1;
1992  unsigned j=0;
1993  int r=0;
1994  while (j<=ii)
1995  {
1996  r=p_Compare(a->m[j],b->m[j],R);
1997  if (r!=0) return r;
1998  j++;
1999  }
2000  return r;
2001 }
int j
Definition: facHensel.cc:105
CanonicalForm b
Definition: cfModGcd.cc:4044
int p_Compare(const poly a, const poly b, const ring R)
Definition: p_polys.cc:4812
#define IDELEMS(i)
Definition: simpleideals.h:23
#define R
Definition: sirandom.c:26

◆ sm_Det()

poly sm_Det ( ideal  I,
const ring  ,
DetVariant  d = DetDefault 
)

Definition at line 2166 of file matpol.cc.

2167 {
2168  if ((MATCOLS(a)==0)
2169  && (MATROWS(a)==0))
2170  return p_One(r);
2171  if (d==DetDefault) d=mp_GetAlgorithmDet((matrix)a,r);
2172  if (d==DetSBareiss) return sm_CallDet(a,r);
2173  matrix m=id_Module2Matrix(id_Copy(a,r),r);
2174  poly p=mp_Det(m,r,d);
2175  id_Delete((ideal *)&m,r);
2176  return p;
2177 }
ideal id_Copy(ideal h1, const ring r)
copy an ideal
poly sm_CallDet(ideal I, const ring R)
Definition: sparsmat.cc:302
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
poly p_One(const ring r)
Definition: p_polys.cc:1303
poly mp_Det(matrix a, const ring r, DetVariant d)
Definition: matpol.cc:2143
int m
Definition: cfEzgcd.cc:121
matrix id_Module2Matrix(ideal mod, const ring R)
#define MATCOLS(i)
Definition: matpol.h:27
DetVariant mp_GetAlgorithmDet(matrix m, const ring r)
Definition: matpol.cc:2112
#define MATROWS(i)
Definition: matpol.h:26
int p
Definition: cfModGcd.cc:4019

◆ sm_Equal()

BOOLEAN sm_Equal ( ideal  a,
ideal  b,
const ring  R 
)

Definition at line 2003 of file matpol.cc.

2004 {
2005  if ((a->rank!=b->rank) || (IDELEMS(a)!=IDELEMS(b)))
2006  return FALSE;
2007  int i=IDELEMS(a)-1;
2008  while (i>=0)
2009  {
2010  if (a->m[i]==NULL)
2011  {
2012  if (b->m[i]!=NULL) return FALSE;
2013  }
2014  else if (b->m[i]==NULL) return FALSE;
2015  else if (p_Cmp(a->m[i],b->m[i], R)!=0) return FALSE;
2016  i--;
2017  }
2018  i=IDELEMS(a)-1;
2019  while (i>=0)
2020  {
2021  if(!p_EqualPolys(a->m[i],b->m[i], R)) return FALSE;
2022  i--;
2023  }
2024  return TRUE;
2025 }
static int p_Cmp(poly p1, poly p2, ring r)
Definition: p_polys.h:1651
#define FALSE
Definition: auxiliary.h:94
#define TRUE
Definition: auxiliary.h:98
CanonicalForm b
Definition: cfModGcd.cc:4044
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition: p_polys.cc:4418
#define NULL
Definition: omList.c:12
#define R
Definition: sirandom.c:26

◆ sm_Flatten()

ideal sm_Flatten ( ideal  a,
const ring  R 
)

Definition at line 1926 of file matpol.cc.

1927 {
1928  if (IDELEMS(a)==0) return id_Copy(a,R);
1929  ideal res=idInit(1,IDELEMS(a)*a->rank);
1930  for(int i=0;i<IDELEMS(a);i++)
1931  {
1932  if(a->m[i]!=NULL)
1933  {
1934  poly p=p_Copy(a->m[i],R);
1935  if (i==0) res->m[0]=p;
1936  else
1937  {
1938  p_Shift(&p,i*a->rank,R);
1939  res->m[0]=p_Add_q(res->m[0],p,R);
1940  }
1941  }
1942  }
1943  return res;
1944 }
ideal id_Copy(ideal h1, const ring r)
copy an ideal
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
CanonicalForm res
Definition: facAbsFact.cc:64
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition: p_polys.cc:4612
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define NULL
Definition: omList.c:12
#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:891

◆ sm_Mult()

ideal sm_Mult ( ideal  a,
ideal  b,
const ring  R 
)

Definition at line 1891 of file matpol.cc.

1892 {
1893  int i, j, k;
1894  int m = a->rank;
1895  int p = IDELEMS(a);
1896  int q = IDELEMS(b);
1897 
1898  assume (IDELEMS(a)==b->rank);
1899  ideal c = idInit(q,m);
1900 
1901  for (i=0; i<m; i++)
1902  {
1903  for (k=0; k<p; k++)
1904  {
1905  poly aik;
1906  if ((aik=SMATELEM(a,i,k,R))!=NULL)
1907  {
1908  for (j=0; j<q; j++)
1909  {
1910  poly bkj=SMATELEM(b,k,j,R);
1911  if (bkj!=NULL)
1912  {
1913  poly s = p_Mult_q(p_Copy(aik,R) /*SMATELEM(a,i,k)*/, bkj/*SMATELEM(b,k,j)*/, R);
1914  if (s!=NULL) p_SetComp(s,i+1,R);
1915  c->m[j]=p_Add_q(c->m[j],s, R);
1916  }
1917  }
1918  p_Delete(&aik,R);
1919  }
1920  }
1921  }
1922  for(i=q-1;i>=0;i--) p_Normalize(c->m[i], R);
1923  return c;
1924 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
int j
Definition: facHensel.cc:105
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:246
int k
Definition: cfEzgcd.cc:92
#define SMATELEM(A, i, j, R)
Definition: matpol.h:122
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
CanonicalForm b
Definition: cfModGcd.cc:4044
#define assume(x)
Definition: mod2.h:390
int m
Definition: cfEzgcd.cc:121
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
void p_Normalize(poly p, const ring r)
Definition: p_polys.cc:3732
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:856
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define NULL
Definition: omList.c:12
#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:891
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1049

◆ sm_Sub()

ideal sm_Sub ( ideal  a,
ideal  b,
const ring  R 
)

Definition at line 1881 of file matpol.cc.

1882 {
1883  assume(IDELEMS(a)==IDELEMS(b));
1884  assume(a->rank==b->rank);
1885  ideal c=idInit(IDELEMS(a),a->rank);
1886  for (int k=IDELEMS(a)-1; k>=0; k--)
1887  c->m[k] = p_Sub(p_Copy(a->m[k], R), p_Copy(b->m[k], R), R);
1888  return c;
1889 }
int k
Definition: cfEzgcd.cc:92
poly p_Sub(poly p1, poly p2, const ring r)
Definition: p_polys.cc:1965
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
CanonicalForm b
Definition: cfModGcd.cc:4044
#define assume(x)
Definition: mod2.h:390
#define IDELEMS(i)
Definition: simpleideals.h:23
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define R
Definition: sirandom.c:26

◆ sm_Tensor()

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

Definition at line 1831 of file matpol.cc.

1832 {
1833  // size of the result m*p x n*q
1834  int n=IDELEMS(A); // m x n
1835  int m=A->rank;
1836  int q=IDELEMS(B); // p x q
1837  int p=B->rank;
1838  ideal res=idInit(n*q,m*p);
1839  poly *a=(poly*)omAlloc(m*sizeof(poly));
1840  for(int i=0; i<n; i++)
1841  {
1842  memset(a,0,m*sizeof(poly));
1843  p_Vec2Array(A->m[i],a,m,r);
1844  for(int j=0;j<m;j++)
1845  {
1846  if (a[j]!=NULL)
1847  {
1848  ideal sm=sm_MultAndShift(a[j], // A_i_j
1849  B,
1850  j*p, // shift j*p down
1851  r);
1852  sm_AddSubMat(res,sm,i*q,r); // add this columns to col i*q ff
1853  id_Delete(&sm,r); // delete the now empty ideal
1854  }
1855  }
1856  }
1857  omFreeSize(a,m*sizeof(poly));
1858  return res;
1859 }
int j
Definition: facHensel.cc:105
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
static void sm_AddSubMat(ideal res, ideal sm, int col, const ring r)
Definition: matpol.cc:1822
#define omAlloc(size)
Definition: omAllocDecl.h:210
static ideal sm_MultAndShift(poly f, ideal B, int s, const ring r)
Definition: matpol.cc:1803
void p_Vec2Array(poly v, poly *p, int len, const ring r)
vector to already allocated array (len>=p_MaxComp(v,r))
Definition: p_polys.cc:3552
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:23
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define NULL
Definition: omList.c:12
b *CanonicalForm B
Definition: facBivar.cc:52
int p
Definition: cfModGcd.cc:4019

◆ sm_Trace()

poly sm_Trace ( ideal  a,
const ring  R 
)

Definition at line 1973 of file matpol.cc.

1974 {
1975  int i;
1976  int n = (IDELEMS(a)<a->rank) ? IDELEMS(a) : a->rank;
1977  poly t = NULL;
1978 
1979  for (i=0; i<=n; i++)
1980  t = p_Add_q(t, p_Copy(SMATELEM(a,i,i,R), R), R);
1981  return t;
1982 }
#define SMATELEM(A, i, j, R)
Definition: matpol.h:122
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
int i
Definition: cfEzgcd.cc:125
#define IDELEMS(i)
Definition: simpleideals.h:23
#define NULL
Definition: omList.c:12
#define R
Definition: sirandom.c:26
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:891

◆ sm_UnFlatten()

ideal sm_UnFlatten ( ideal  a,
int  col,
const ring  R 
)

Definition at line 1946 of file matpol.cc.

1947 {
1948  if ((IDELEMS(a)!=1)
1949  ||((a->rank % col)!=0))
1950  {
1951  Werror("wrong format: %d x %d for unflatten",(int)a->rank,IDELEMS(a));
1952  return NULL;
1953  }
1954  int row=a->rank/col;
1955  ideal res=idInit(col,row);
1956  poly p=a->m[0];
1957  while(p!=NULL)
1958  {
1959  poly h=p_Head(p,R);
1960  int comp=p_GetComp(h,R);
1961  int c=(comp-1)/row;
1962  int r=comp%row; if (r==0) r=row;
1963  p_SetComp(h,r,R); p_SetmComp(h,R);
1964  res->m[c]=p_Add_q(res->m[c],h,R);
1965  pIter(p);
1966  }
1967  return res;
1968 }
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:246
#define p_GetComp(p, r)
Definition: monomials.h:64
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
#define pIter(p)
Definition: monomials.h:37
static poly p_Head(poly p, const ring r)
Definition: p_polys.h:824
CanonicalForm res
Definition: facAbsFact.cc:64
#define IDELEMS(i)
Definition: simpleideals.h:23
#define p_SetmComp
Definition: p_polys.h:243
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35
#define NULL
Definition: omList.c:12
#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:891
static Poly * h
Definition: janet.cc:971
void Werror(const char *fmt,...)
Definition: reporter.cc:189

◆ TraceOfProd()

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

Definition at line 289 of file matpol.cc.

290 {
291  int i, j;
292  poly p, t = NULL;
293 
294  for (i=1; i<=n; i++)
295  {
296  for (j=1; j<=n; j++)
297  {
298  p = pp_Mult_qq(MATELEM(a,i,j), MATELEM(b,j,i), R);
299  t = p_Add_q(t, p, R);
300  }
301  }
302  return t;
303 }
int j
Definition: facHensel.cc:105
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1086
int i
Definition: cfEzgcd.cc:125
#define NULL
Definition: omList.c:12
#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:891
#define MATELEM(mat, i, j)
1-based access to matrix
Definition: matpol.h:29

Variable Documentation

◆ ip_smatrix_bin

omBin ip_smatrix_bin