Loading...
Searching...
No Matches
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)
#define | MATCOLS(i)
#define | MATELEM(mat, i, j)
| 1-based access to matrix
#define | MATELEM0(mat, i, j)
| 0-based access to matrix
#define | mp_New(r, c, R)
#define | SMATELEM(A, i, j, R)

## Typedefs

typedef ip_smatrix * | matrix

## Enumerations

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

## Functions

matrix | mpNew (int r, int c)
| create a r x c zero-matrix
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
matrix | mp_Copy (matrix a, const ring r)
| copies matrix a (from ring r to r)
matrix | mp_InitP (int r, int c, poly p, const ring R)
| make it a p * unit matrix
matrix | mp_InitI (int r, int c, int v, const ring R)
| make it a v * unit matrix
matrix | mp_MultI (matrix a, long f, const ring r)
| c = f*a
matrix | mp_MultP (matrix a, poly p, const ring r)
| multiply a matrix 'a' by a poly 'p', destroy the args
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
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
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 monomials 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.
void | mp_RecMin (int, ideal, int &, matrix, int, int, poly, ideal, const ring)
| for minors with Bareiss
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)
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
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

EXTERN_VAR omBin | ip_smatrix_bin

## Macro Definition Documentation

## MATCOLS

#define MATCOLS | ( |  | i | ) |

Value:
((i)->ncols)
i
int i
Definition cfEzgcd.cc:132

Definition at line 27 of file matpol.h.

## MATELEM

#define MATELEM | ( |  | mat,
|  |  | i,
|  |  | j )

Value:
((mat)->m)[(long)MATCOLS((mat)) * (long)((i)-1) + (long)(j)-1]
j
int j
Definition facHensel.cc:110
MATCOLS
#define MATCOLS(i)
Definition matpol.h:27

1-based access to matrix

Definition at line 29 of file matpol.h.

## MATELEM0

#define MATELEM0 | ( |  | mat,
|  |  | i,
|  |  | j )

Value:
((mat)->m)[(long)MATCOLS((mat)) * (long)(i) + (long)(j)]

0-based access to matrix

Definition at line 31 of file matpol.h.

## MATROWS

#define MATROWS | ( |  | i | ) |

Value:
((i)->nrows)

Definition at line 26 of file matpol.h.

## mp_New

#define mp_New | ( |  | r,
|  |  | c,
|  |  | R )

Value:
mpNew(r,c)
mpNew
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37

Definition at line 46 of file matpol.h.

## SMATELEM

#define SMATELEM | ( |  | A,
|  |  | i,
|  |  | j,
|  |  | R )

Value:
p_Vec2Poly(A->m[j],i+1,R)
p_Vec2Poly
poly p_Vec2Poly(poly v, int k, const ring r)
Definition p_polys.cc:3698
R
#define R
Definition sirandom.c:27
A
#define A
Definition sirandom.c:24

Definition at line 123 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.

{
DetDefault=0,
DetBareiss,
DetSBareiss,
DetMu,
DetFactory
};
DetFactory
@ DetFactory
Definition matpol.h:40
DetBareiss
@ DetBareiss
Definition matpol.h:37
DetDefault
@ DetDefault
Definition matpol.h:36
DetSBareiss
@ DetSBareiss
Definition matpol.h:38
DetMu
@ DetMu
Definition matpol.h:39

## Function Documentation

## iiStringMatrix()

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

Definition at line 849 of file matpol.cc.

{
int i,ii = MATROWS(im);
int j,jj = MATCOLS(im);
poly *pp = im->m;
char ch_s[2];
ch_s[0]=ch;
ch_s[1]='\0';
StringSetS("");
for (i=0; i<ii; i++)
{
for (j=0; j<jj; j++)
{
p_String0(*pp++, r);
StringAppendS(ch_s);
if (dim > 1) StringAppendS("\n");
}
}
char *s=StringEndS();
s[strlen(s)- (dim > 1 ? 2 : 1)]='\0';
return s;
}
pp
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f ).
Definition cf_gcd.cc:676
ip_smatrix::m
poly * m
Definition matpol.h:18
s
const CanonicalForm int s
Definition facAbsFact.cc:51
MATROWS
#define MATROWS(i)
Definition matpol.h:26
p_String0
void p_String0(poly p, ring lmRing, ring tailRing)
print p according to ShortOut in lmRing & tailRing
Definition polys0.cc:223
StringSetS
void StringSetS(const char *st)
Definition reporter.cc:128
StringAppendS
void StringAppendS(const char *st)
Definition reporter.cc:107
StringEndS
char * StringEndS()
Definition reporter.cc:151
dim
int dim(ideal I, ring r)
Definition tropicalStrategy.cc:23

## iiWriteMatrix()

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

set spaces to zero by default

Definition at line 828 of file matpol.cc.

{
int i,ii = MATROWS(im)-1;
int j,jj = MATCOLS(im)-1;
poly *pp = im->m;
for (i=0; i<=ii; i++)
{
for (j=0; j<=jj; j++)
{
if (spaces>0)
Print("%-*.*s",spaces,spaces," ");
if (dim == 2) Print("%s[%u,%u]=",n,i+1,j+1);
else if (dim == 1) Print("%s[%u]=",n,j+1);
else if (dim == 0) Print("%s=",n);
if ((i<ii)||(j<jj)) p_Write(*pp++, r);
else p_Write0(*pp, r);
}
}
}
Print
#define Print
Definition emacs.cc:80
p_Write
void p_Write(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:342
p_Write0
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:332

## mp_Add()

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

Definition at line 172 of file matpol.cc.

{
int k, n = a->nrows, m = a->ncols;
if ((n != b->nrows) || (m != b->ncols))
{
/*
* Werror("cannot add %dx%d matrix and %dx%d matrix",
* m,n,b->cols(),b->rows());
*/
return NULL;
}
matrix c = mpNew(n,m);
for (k=m*n-1; k>=0; k--)
c->m[k] = p_Add_q(p_Copy(a->m[k], R), p_Copy(b->m[k], R), R);
return c;
}
m
int m
Definition cfEzgcd.cc:128
k
int k
Definition cfEzgcd.cc:99
b
CanonicalForm b
Definition cfModGcd.cc:4111
ip_smatrix::nrows
int nrows
Definition matpol.h:20
ip_smatrix::ncols
int ncols
Definition matpol.h:21
matrix
ip_smatrix * matrix
Definition matpol.h:43
NULL
#define NULL
Definition omList.c:12
p_Add_q
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
p_Copy
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848

## 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 monomials 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 574 of file matpol.cc.

{
poly* s;
poly p;
int sl,i,j;
int l=0;
poly sel=mp_Select(v,mon, R);
p_Vec2Polys(sel,&s,&sl, R);
for (i=0; i<sl; i++)
l=si_max(l,pLength(s[i]));
*c=mpNew(sl,l);
*m=mpNew(sl,l);
poly h;
int isConst;
for (j=1; j<=sl;j++)
{
p=s[j-1];
if (p_IsConstant(p, R)) /*p != NULL */
{
isConst=-1;
i=l;
}
else
{
isConst=1;
i=1;
}
while(p!=NULL)
{
h = p_Head(p, R);
MATELEM(*m,j,i) = h;
i+=isConst;
p = p->next;
}
}
while (v!=NULL)
{
i = 1;
j = __p_GetComp(v, R);
loop
{
poly mp=MATELEM(*m,j,i);
if (mp!=NULL)
{
h = mp_Exdiv(v, mp /*MATELEM(*m,j,i)*/, mp, R);
if (h!=NULL)
{
p_SetComp(h,0, R);
MATELEM(*c,j,i) = p_Add_q(MATELEM(*c,j,i), h, R);
break;
}
}
if (i < l)
i++;
else
break;
}
v = v->next;
}
omFree(s);
}
si_max
static int si_max(const int a, const int b)
Definition auxiliary.h:125
l
int l
Definition cfEzgcd.cc:100
p
int p
Definition cfModGcd.cc:4086
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
h
STATIC_VAR Poly * h
Definition janet.cc:971
mp_Exdiv
static poly mp_Exdiv(poly m, poly d, poly vars, const ring)
Definition matpol.cc:554
mp_Select
static poly mp_Select(poly fro, poly what, const ring)
Definition matpol.cc:742
MATELEM
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
__p_GetComp
#define __p_GetComp(p, r)
Definition monomials.h:63
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
p_Vec2Polys
void p_Vec2Polys(poly v, poly **p, int *len, const ring r)
Definition p_polys.cc:3750
pLength
static int pLength(poly a)
Definition p_polys.h:190
p_SetComp
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition p_polys.h:249
p_Head
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition p_polys.h:862
p_IsConstant
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition p_polys.h:1985
loop
#define loop
Definition structs.h:71

## mp_CoeffProc()

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

Definition at line 392 of file matpol.cc.

{
assume(vars!=NULL);
poly sel, h;
int l, i;
int pos_of_1 = -1;
matrix co;
if (f==NULL)
{
co = mpNew(2, 1);
MATELEM(co,1,1) = p_One(R);
//MATELEM(co,2,1) = NULL;
return co;
}
sel = mp_Select(f, vars, R);
l = pLength(sel);
co = mpNew(2, l);
if (rHasLocalOrMixedOrdering(R))
{
for (i=l; i>=1; i--)
{
h = sel;
pIter(sel);
pNext(h)=NULL;
MATELEM(co,1,i) = h;
//MATELEM(co,2,i) = NULL;
if (p_IsConstant(h, R)) pos_of_1 = i;
}
}
else
{
for (i=1; i<=l; i++)
{
h = sel;
pIter(sel);
pNext(h)=NULL;
MATELEM(co,1,i) = h;
//MATELEM(co,2,i) = NULL;
if (p_IsConstant(h, R)) pos_of_1 = i;
}
}
while (f!=NULL)
{
i = 1;
loop
{
if (i!=pos_of_1)
{
h = mp_Exdiv(f, MATELEM(co,1,i),vars, R);
if (h!=NULL)
{
MATELEM(co,2,i) = p_Add_q(MATELEM(co,2,i), h, R);
break;
}
}
if (i == l)
{
// check monom 1 last:
if (pos_of_1 != -1)
{
h = mp_Exdiv(f, MATELEM(co,1,pos_of_1),vars, R);
if (h!=NULL)
{
MATELEM(co,2,pos_of_1) = p_Add_q(MATELEM(co,2,pos_of_1), h, R);
}
}
break;
}
i ++;
}
pIter(f);
}
return co;
}
f
FILE * f
Definition checklibs.c:9
assume
#define assume(x)
Definition mod2.h:389
pIter
#define pIter(p)
Definition monomials.h:37
pNext
#define pNext(p)
Definition monomials.h:36
p_One
poly p_One(const ring r)
Definition p_polys.cc:1314
rHasLocalOrMixedOrdering
static BOOLEAN rHasLocalOrMixedOrdering(const ring r)
Definition ring.h:769

## mp_CoeffProcId()

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

Definition at line 469 of file matpol.cc.

{
assume(vars!=NULL);
poly sel, h;
int l, i;
int pos_of_1 = -1;
matrix co;
if (idIs0(I))
{
co = mpNew(IDELEMS(I)+1,1);
MATELEM(co,1,1) = p_One(R);
return co;
}
sel = mp_SelectId(I, vars, R);
l = pLength(sel);
co = mpNew(IDELEMS(I)+1, l);
if (rHasLocalOrMixedOrdering(R))
{
for (i=l; i>=1; i--)
{
h = sel;
pIter(sel);
pNext(h)=NULL;
MATELEM(co,1,i) = h;
//MATELEM(co,2,i) = NULL;
if (p_IsConstant(h, R)) pos_of_1 = i;
}
}
else
{
for (i=1; i<=l; i++)
{
h = sel;
pIter(sel);
pNext(h)=NULL;
MATELEM(co,1,i) = h;
//MATELEM(co,2,i) = NULL;
if (p_IsConstant(h, R)) pos_of_1 = i;
}
}
for(int j=0;j<IDELEMS(I);j++)
{
poly f=I->m[j];
while (f!=NULL)
{
i = 1;
loop
{
if (i!=pos_of_1)
{
h = mp_Exdiv(f, MATELEM(co,1,i),vars, R);
if (h!=NULL)
{
MATELEM(co,j+2,i) = p_Add_q(MATELEM(co,j+2,i), h, R);
break;
}
}
if (i == l)
{
// check monom 1 last:
if (pos_of_1 != -1)
{
h = mp_Exdiv(f, MATELEM(co,1,pos_of_1),vars, R);
if (h!=NULL)
{
MATELEM(co,j+2,pos_of_1) = p_Add_q(MATELEM(co,j+2,pos_of_1), h, R);
}
}
break;
}
i ++;
}
pIter(f);
}
}
return co;
}
idIs0
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
Definition simpleideals.cc:960
mp_SelectId
static poly mp_SelectId(ideal I, poly what, const ring R)
Definition matpol.cc:760
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23

## 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 306 of file matpol.cc.

{
poly h,f;
int l, i, c, m=0;
/* look for maximal power m of x_var in I */
for (i=IDELEMS(I)-1; i>=0; i--)
{
f=I->m[i];
while (f!=NULL)
{
l=p_GetExp(f,var, R);
if (l>m) m=l;
pIter(f);
}
}
matrix co=mpNew((m+1)*I->rank,IDELEMS(I));
/* divide each monomial by a power of x_var,
* remember the power in l and the component in c*/
for (i=IDELEMS(I)-1; i>=0; i--)
{
f=I->m[i];
I->m[i]=NULL;
while (f!=NULL)
{
l=p_GetExp(f,var, R);
p_SetExp(f,var,0, R);
c=si_max((int)p_GetComp(f, R),1);
p_SetComp(f,0, R);
p_Setm(f, R);
/* now add the resulting monomial to co*/
h=pNext(f);
pNext(f)=NULL;
//MATELEM(co,c*(m+1)-l,i+1)
// =p_Add_q(MATELEM(co,c*(m+1)-l,i+1),f, R);
MATELEM(co,(c-1)*(m+1)+l+1,i+1)
=p_Add_q(MATELEM(co,(c-1)*(m+1)+l+1,i+1),f, R);
/* iterate f*/
f=h;
}
}
id_Delete(&I, R);
return co;
}
p_GetComp
#define p_GetComp(p, r)
Definition monomials.h:64
p_SetExp
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition p_polys.h:490
p_Setm
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
p_GetExp
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition p_polys.h:471
id_Delete
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
Definition simpleideals.cc:123

## mp_Compare()

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

Definition at line 637 of file matpol.cc.

{
if (MATCOLS(a)<MATCOLS(b)) return -1;
else if (MATCOLS(a)>MATCOLS(b)) return 1;
if (MATROWS(a)<MATROWS(b)) return -1;
else if (MATROWS(a)<MATROWS(b)) return 1;
unsigned ii=MATCOLS(a)*MATROWS(a)-1;
unsigned j=0;
int r=0;
while (j<=ii)
{
r=p_Compare(a->m[j],b->m[j],R);
if (r!=0) return r;
j++;
}
return r;
}
p_Compare
int p_Compare(const poly a, const poly b, const ring R)
Definition p_polys.cc:5050

## 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 78 of file matpol.cc.

{
id_Test((ideal)a, rSrc);
poly t;
int i, m=MATROWS(a), n=MATCOLS(a);
matrix b = mpNew(m, n);
for (i=m*n-1; i>=0; i--)
{
t = a->m[i];
if (t!=NULL)
{
b->m[i] = prCopyR_NoSort(t, rSrc, rDst);
p_Normalize(b->m[i], rDst);
}
}
b->rank=a->rank;
id_Test((ideal)b, rDst);
return b;
}
ip_smatrix::rank
long rank
Definition matpol.h:19
p_Normalize
void p_Normalize(poly p, const ring r)
Definition p_polys.cc:3939
prCopyR_NoSort
poly prCopyR_NoSort(poly p, ring src_r, ring dest_r)
Definition prCopy.cc:77
id_Test
#define id_Test(A, lR)
Definition simpleideals.h:89

## mp_Copy() [2/2]

matrix mp_Copy | ( | matrix | a,
|  | const ring | r )

copies matrix a (from ring r to r)

Definition at line 57 of file matpol.cc.

{
id_Test((ideal)a, r);
poly t;
int m=MATROWS(a), n=MATCOLS(a);
matrix b = mpNew(m, n);
for (long i=(long)m*(long)n-1; i>=0; i--)
{
t = a->m[i];
if (t!=NULL)
{
p_Normalize(t, r);
b->m[i] = p_Copy(t, r);
}
}
b->rank=a->rank;
return b;
}

## mp_Delete()

void mp_Delete | ( | matrix * | a,
|  | const ring | r )

Definition at line 874 of file matpol.cc.

{
id_Delete((ideal *) a, r);
}

## mp_Det()

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

Definition at line 2139 of file matpol.cc.

{
if ((MATCOLS(a)==0)
&& (MATROWS(a)==0))
return p_One(r);
if (d==DetDefault) d=mp_GetAlgorithmDet(a,r);
switch (d)
{
case DetBareiss: return mp_DetBareiss(a,r);
case DetMu: return mp_DetMu(a,r);
case DetFactory: return singclap_det(a,r);
case DetSBareiss:
{
ideal I=id_Matrix2Module(mp_Copy(a, r),r);
poly p=sm_CallDet(I, r);
id_Delete(&I, r);
return p;
}
default:
WerrorS("unknown algorithm for det");
return NULL;
}
}
singclap_det
poly singclap_det(const matrix m, const ring s)
Definition clapsing.cc:1811
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
mp_GetAlgorithmDet
DetVariant mp_GetAlgorithmDet(matrix m, const ring r)
Definition matpol.cc:2108
mp_Copy
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
Definition matpol.cc:57
mp_DetMu
poly mp_DetMu(matrix A, const ring R)
Definition matpol.cc:2066
mp_DetBareiss
poly mp_DetBareiss(matrix a, const ring r)
returns the determinant of the matrix m; uses Bareiss algorithm
Definition matpol.cc:1670
id_Matrix2Module
ideal id_Matrix2Module(matrix mat, const ring R)
converts mat to module, destroys mat
Definition simpleideals.cc:1560
sm_CallDet
poly sm_CallDet(ideal I, const ring R)
Definition sparsmat.cc:302

## mp_DetBareiss()

poly mp_DetBareiss | ( | matrix | a,
|  | const ring | r )

returns the determinant of the matrix m; uses Bareiss algorithm

Definition at line 1670 of file matpol.cc.

{
int s;
poly div, res;
if (MATROWS(a) != MATCOLS(a))
{
Werror("det of %d x %d matrix",MATROWS(a),MATCOLS(a));
return NULL;
}
matrix c = mp_Copy(a,r);
mp_permmatrix *Bareiss = new mp_permmatrix(c,r);
row_col_weight w(Bareiss->mpGetRdim(), Bareiss->mpGetCdim());
/* Bareiss */
div = NULL;
while(Bareiss->mpPivotBareiss(&w))
{
Bareiss->mpElimBareiss(div);
div = Bareiss->mpGetElem(Bareiss->mpGetRdim(), Bareiss->mpGetCdim());
}
Bareiss->mpRowReorder();
Bareiss->mpColReorder();
Bareiss->mpSaveArray();
s = Bareiss->mpGetSign();
delete Bareiss;
/* result */
res = MATELEM(c,1,1);
MATELEM(c,1,1) = NULL;
id_Delete((ideal *)&c,r);
if (s < 0)
res = p_Neg(res,r);
return res;
}
div
CF_NO_INLINE FACTORY_PUBLIC CanonicalForm div(const CanonicalForm &, const CanonicalForm &)
mp_permmatrix
Definition matpol.cc:920
mp_permmatrix::mpGetCdim
int mpGetCdim()
Definition matpol.cc:943
mp_permmatrix::mpRowReorder
void mpRowReorder()
Definition matpol.cc:1113
mp_permmatrix::mpGetElem
poly mpGetElem(int, int)
Definition matpol.cc:1230
mp_permmatrix::mpColReorder
void mpColReorder()
Definition matpol.cc:1092
mp_permmatrix::mpSaveArray
void mpSaveArray()
Definition matpol.cc:946
mp_permmatrix::mpElimBareiss
void mpElimBareiss(poly)
Definition matpol.cc:1238
mp_permmatrix::mpPivotBareiss
int mpPivotBareiss(row_col_weight *)
Definition matpol.cc:1153
mp_permmatrix::mpGetRdim
int mpGetRdim()
Definition matpol.cc:942
mp_permmatrix::mpGetSign
int mpGetSign()
Definition matpol.cc:944
row_col_weight
Definition matpol.cc:883
res
CanonicalForm res
Definition facAbsFact.cc:60
w
const CanonicalForm & w
Definition facAbsFact.cc:51
p_Neg
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1114
Werror
void Werror(const char *fmt,...)
Definition reporter.cc:189

## mp_DetMu()

poly mp_DetMu | ( | matrix | A,
|  | const ring | R )

Definition at line 2066 of file matpol.cc.

{
int n=MATROWS(A);
assume(MATCOLS(A)==n);
/*
* Input:
* int n: Dimension der Matrix
* int A: n*n Matrix
*
* Berechnet n-1 mal: X = mu(X)*A
*
* Output: det(A)
*/
//speichere A ab:
matrix workA=mp_Copy(A,R);
// berechen X = mu(X)*A
matrix X;
for (int i = n-1; i >0; i--)
{
X=mu(workA,R);
id_Delete((ideal*)&workA,R);
workA=mp_Mult(X,A,R);
id_Delete((ideal*)&X,R);
}
// berrechne det(A)
poly res;
if (n%2 == 0)
{
res=p_Neg(MATELEM0(workA,0,0),R);
}
else
{
res=MATELEM0(workA,0,0);
}
MATELEM0(workA,0,0)=NULL;
id_Delete((ideal*)&workA,R);
return res;
}
mu
static matrix mu(matrix A, const ring R)
Definition matpol.cc:2028
mp_Mult
matrix mp_Mult(matrix a, matrix b, const ring R)
Definition matpol.cc:206
MATELEM0
#define MATELEM0(mat, i, j)
0-based access to matrix
Definition matpol.h:31

## mp_Equal()

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

Definition at line 656 of file matpol.cc.

{
if ((MATCOLS(a)!=MATCOLS(b)) || (MATROWS(a)!=MATROWS(b)))
return FALSE;
int i=MATCOLS(a)*MATROWS(a)-1;
while (i>=0)
{
if (a->m[i]==NULL)
{
if (b->m[i]!=NULL) return FALSE;
}
else if (b->m[i]==NULL) return FALSE;
else if (p_Cmp(a->m[i],b->m[i], R)!=0) return FALSE;
i--;
}
i=MATCOLS(a)*MATROWS(a)-1;
while (i>=0)
{
if(!p_EqualPolys(a->m[i],b->m[i], R)) return FALSE;
i--;
}
return TRUE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
p_EqualPolys
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
Definition p_polys.cc:4666
p_Cmp
static int p_Cmp(poly p1, poly p2, ring r)
Definition p_polys.h:1748

## mp_GetAlgorithmDet() [1/2]

DetVariant mp_GetAlgorithmDet | ( | const char * | s | ) |

Definition at line 2128 of file matpol.cc.

{
if (strcmp(s,"Bareiss")==0) return DetBareiss;
if (strcmp(s,"SBareiss")==0) return DetSBareiss;
if (strcmp(s,"Mu")==0) return DetMu;
if (strcmp(s,"Factory")==0) return DetFactory;
WarnS("unknown method for det");
return DetDefault;
}
WarnS
#define WarnS
Definition emacs.cc:78

## mp_GetAlgorithmDet() [2/2]

DetVariant mp_GetAlgorithmDet | ( | matrix | m,
|  | const ring | r )

Definition at line 2108 of file matpol.cc.

{
if (MATROWS(m)+2*r->N>20+5*rField_is_Zp(r)) return DetMu;
if (MATROWS(m)<10+5*rField_is_Zp(r)) return DetSBareiss;
BOOLEAN isConst=TRUE;
int s=0;
for(int i=MATCOLS(m)*MATROWS(m)-1;i>=0;i--)
{
poly p=m->m[i];
if (p!=NULL)
{
if(!p_IsConstant(p,r)) isConst=FALSE;
s++;
}
}
if (isConst && rField_is_Q(r)) return DetFactory;
if (s*2<MATCOLS(m)*MATROWS(m)) // few entries
return DetSBareiss;
return DetMu;
}
BOOLEAN
int BOOLEAN
Definition auxiliary.h:88
rField_is_Zp
static BOOLEAN rField_is_Zp(const ring r)
Definition ring.h:506
rField_is_Q
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:512

## mp_InitI()

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

make it a v * unit matrix

Definition at line 122 of file matpol.cc.

{
return mp_InitP(r, c, p_ISet(v, R), R);
}
mp_InitP
matrix mp_InitP(int r, int c, poly p, const ring R)
make it a p * unit matrix
Definition matpol.cc:106
p_ISet
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition p_polys.cc:1298

## mp_InitP()

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

make it a p * unit matrix

Definition at line 106 of file matpol.cc.

{
matrix rc = mpNew(r,c);
int i=si_min(r,c), n = c*(i-1)+i-1, inc = c+1;
p_Normalize(p, R);
while (n>0)
{
rc->m[n] = p_Copy(p, R);
n -= inc;
}
rc->m[0]=p;
return rc;
}
si_min
static int si_min(const int a, const int b)
Definition auxiliary.h:126

## mp_IsDiagUnit()

BOOLEAN mp_IsDiagUnit | ( | matrix | U,
|  | const ring | r )

Definition at line 810 of file matpol.cc.

{
if(MATROWS(U)!=MATCOLS(U))
return FALSE;
for(int i=MATCOLS(U);i>=1;i--)
{
for(int j=MATCOLS(U); j>=1; j--)
{
if (i==j)
{
if (!p_IsUnit(MATELEM(U,i,i), R)) return FALSE;
}
else if (MATELEM(U,i,j)!=NULL) return FALSE;
}
}
return TRUE;
}
p_IsUnit
static BOOLEAN p_IsUnit(const poly p, const ring r)
Definition p_polys.h:2012

## mp_MinorToResult()

void mp_MinorToResult | ( | ideal | result,
|  | int & | elems,
|  | matrix | a,
|  | int | r,
|  | int | c,
|  | ideal | R,
|  | const ring | )

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

Definition at line 1501 of file matpol.cc.

{
poly *q1;
int e=IDELEMS(result);
int i,j;
if (R != NULL)
{
for (i=r-1;i>=0;i--)
{
q1 = &(a->m)[i*a->ncols];
//for (j=c-1;j>=0;j--)
//{
// if (q1[j]!=NULL) q1[j] = kNF(R,currRing->qideal,q1[j]);
//}
}
}
for (i=r-1;i>=0;i--)
{
q1 = &(a->m)[i*a->ncols];
for (j=c-1;j>=0;j--)
{
if (q1[j]!=NULL)
{
if (elems>=e)
{
pEnlargeSet(&(result->m),e,e);
e += e;
IDELEMS(result) =e;
}
result->m[elems] = q1[j];
q1[j] = NULL;
elems++;
}
}
}
}
result
return result
Definition facAbsBiFact.cc:76
pEnlargeSet
void pEnlargeSet(poly **p, int l, int increment)
Definition p_polys.cc:3821

## mp_Monomials()

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

Definition at line 355 of file matpol.cc.

{
/* clear contents of m*/
int k,l;
for (k=MATROWS(m);k>0;k--)
{
for(l=MATCOLS(m);l>0;l--)
{
p_Delete(&MATELEM(m,k,l), R);
}
}
omfreeSize((ADDRESS)m->m,MATROWS(m)*MATCOLS(m)*sizeof(poly));
/* allocate monoms in the right size r x MATROWS(c)*/
m->m=(poly*)omAlloc0(r*MATROWS(c)*sizeof(poly));
MATROWS(m)=r;
MATCOLS(m)=MATROWS(c);
m->rank=r;
/* the maximal power p of x_var: MATCOLS(m)=r*(p+1) */
int p=MATCOLS(m)/r-1;
/* fill in the powers of x_var=h*/
poly h=p_One(R);
for(k=r;k>0; k--)
{
MATELEM(m,k,k*(p+1))=p_One(R);
}
for(l=p;l>=0; l--)
{
p_SetExp(h,var,p-l, R);
p_Setm(h, R);
for(k=r;k>0; k--)
{
MATELEM(m,k,k*(p+1)-l)=p_Copy(h, R);
}
}
p_Delete(&h, R);
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211
omfreeSize
#define omfreeSize(addr, size)
Definition omAllocDecl.h:236
p_Delete
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903

## mp_Mult()

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

Definition at line 206 of file matpol.cc.

{
int i, j, k;
int m = MATROWS(a);
int p = MATCOLS(a);
int q = MATCOLS(b);
if (p!=MATROWS(b))
{
/*
* Werror("cannot multiply %dx%d matrix and %dx%d matrix",
* m,p,b->rows(),q);
*/
return NULL;
}
matrix c = mpNew(m,q);
for (i=0; i<m; i++)
{
for (k=0; k<p; k++)
{
poly aik;
if ((aik=MATELEM0(a,i,k))!=NULL)
{
for (j=0; j<q; j++)
{
poly bkj;
if ((bkj=MATELEM0(b,k,j))!=NULL)
{
poly *cij=&(MATELEM0(c,i,j));
poly s = pp_Mult_qq(aik /*MATELEM0(a,i,k)*/, bkj/*MATELEM0(b,k,j)*/, R);
(*cij)/*MATELEM0(c,i,j)*/ = p_Add_q((*cij) /*MATELEM0(c,i,j)*/ ,s, R);
}
}
}
}
}
for(i=m*q-1;i>=0;i--) p_Normalize(c->m[i], R);
return c;
}
pp_Mult_qq
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition p_polys.h:1167

## mp_MultI()

matrix mp_MultI | ( | matrix | a,
|  | long | f,
|  | const ring | r )

c = f*a

Definition at line 128 of file matpol.cc.

{
int k, n = a->nrows, m = a->ncols;
poly p = p_ISet(f, R);
matrix c = mpNew(n,m);
for (k=m*n-1; k>0; k--)
c->m[k] = pp_Mult_qq(a->m[k], p, R);
c->m[0] = p_Mult_q(p_Copy(a->m[0], R), p, R);
return c;
}
p_Mult_q
static poly p_Mult_q(poly p, poly q, const ring r)
Definition p_polys.h:1125

## 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 141 of file matpol.cc.

{
int k, n = a->nrows, m = a->ncols;
p_Normalize(p, R);
for (k=m*n-1; k>0; k--)
{
if (a->m[k]!=NULL)
a->m[k] = p_Mult_q(a->m[k], p_Copy(p, R), R);
}
a->m[0] = p_Mult_q(a->m[0], p, R);
return a;
}

## 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 1597 of file matpol.cc.

{
int k;
int kr=lr-1,kc=lc-1;
matrix nextLevel=mpNew(kr,kc);
loop
{
/*--- look for an optimal row and bring it to last position ------------*/
if(mp_PrepareRow(a,lr,lc,r)==0) break;
/*--- now take all pivots from the last row ------------*/
k = lc;
loop
{
if(mp_PreparePiv(a,lr,k,r)==0) break;
mp_ElimBar(a,nextLevel,barDiv,lr,k,r);
k--;
if (ar>1)
{
mp_RecMin(ar-1,result,elems,nextLevel,kr,k,a->m[kr*a->ncols+k],R,r);
mp_PartClean(nextLevel,kr,k, r);
}
else mp_MinorToResult(result,elems,nextLevel,kr,k,R,r);
if (ar>k-1) break;
}
if (ar>=kr) break;
/*--- now we have to take out the last row...------------*/
lr = kr;
kr--;
}
mpFinalClean(nextLevel);
}
lc
CanonicalForm lc(const CanonicalForm &f)
Definition canonicalform.h:304
mp_PartClean
static void mp_PartClean(matrix a, int lr, int lc, const ring R)
Definition matpol.cc:798
mp_PrepareRow
static int mp_PrepareRow(matrix a, int lr, int lc, const ring R)
Definition matpol.cc:1375
mpFinalClean
static void mpFinalClean(matrix a)
Definition matpol.cc:1589
mp_ElimBar
static void mp_ElimBar(matrix a0, matrix re, poly div, int lr, int lc, const ring R)
Definition matpol.cc:1443
mp_PreparePiv
static int mp_PreparePiv(matrix a, int lr, int lc, const ring r)
Definition matpol.cc:1433
mp_MinorToResult
void mp_MinorToResult(ideal result, int &elems, matrix a, int r, int c, ideal R, const ring)
entries of a are minors and go to result (only if not in R)
Definition matpol.cc:1501
mp_RecMin
void mp_RecMin(int ar, ideal result, int &elems, matrix a, int lr, int lc, poly barDiv, ideal R, const ring r)
produces recursively the ideal of all arxar-minors of a
Definition matpol.cc:1597

## mp_Sub()

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

Definition at line 189 of file matpol.cc.

{
int k, n = a->nrows, m = a->ncols;
if ((n != b->nrows) || (m != b->ncols))
{
/*
* Werror("cannot sub %dx%d matrix and %dx%d matrix",
* m,n,b->cols(),b->rows());
*/
return NULL;
}
matrix c = mpNew(n,m);
for (k=m*n-1; k>=0; k--)
c->m[k] = p_Sub(p_Copy(a->m[k], R), p_Copy(b->m[k], R), R);
return c;
}
p_Sub
poly p_Sub(poly p1, poly p2, const ring r)
Definition p_polys.cc:1994

## mp_Trace()

poly mp_Trace | ( | matrix | a,
|  | const ring | r )

Definition at line 268 of file matpol.cc.

{
int i;
int n = (MATCOLS(a)<MATROWS(a)) ? MATCOLS(a) : MATROWS(a);
poly t = NULL;
for (i=1; i<=n; i++)
t = p_Add_q(t, p_Copy(MATELEM(a,i,i), R), R);
return t;
}

## mp_Transp()

matrix mp_Transp | ( | matrix | a,
|  | const ring | r )

Definition at line 247 of file matpol.cc.

{
int i, j, r = MATROWS(a), c = MATCOLS(a);
poly *p;
matrix b = mpNew(c,r);
p = b->m;
for (i=0; i<c; i++)
{
for (j=0; j<r; j++)
{
if (a->m[j*c+i]!=NULL) *p = p_Copy(a->m[j*c+i], R);
p++;
}
}
return b;
}

## mp_Wedge()

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

Definition at line 1745 of file matpol.cc.

{
int i,j,k,l;
int *rowchoise,*colchoise;
BOOLEAN rowch,colch;
matrix result;
matrix tmp;
poly p;
i = binom(a->nrows,ar);
j = binom(a->ncols,ar);
rowchoise=(int *)omAlloc(ar*sizeof(int));
colchoise=(int *)omAlloc(ar*sizeof(int));
result = mpNew(i,j);
tmp = mpNew(ar,ar);
l = 1; /* k,l:the index in result*/
idInitChoise(ar,1,a->nrows,&rowch,rowchoise);
while (!rowch)
{
k=1;
idInitChoise(ar,1,a->ncols,&colch,colchoise);
while (!colch)
{
for (i=1; i<=ar; i++)
{
for (j=1; j<=ar; j++)
{
MATELEM(tmp,i,j) = MATELEM(a,rowchoise[i-1],colchoise[j-1]);
}
}
p = mp_DetBareiss(tmp, R);
if ((k+l) & 1) p=p_Neg(p, R);
MATELEM(result,l,k) = p;
k++;
idGetNextChoise(ar,a->ncols,&colch,colchoise);
}
idGetNextChoise(ar,a->nrows,&rowch,rowchoise);
l++;
}
/*delete the matrix tmp*/
for (i=1; i<=ar; i++)
{
for (j=1; j<=ar; j++) MATELEM(tmp,i,j) = NULL;
}
id_Delete((ideal *) &tmp, R);
omFree(colchoise);
omFree(rowchoise);
return (result);
}
binom
int binom(int n, int r)
Definition simpleideals.cc:1212
idGetNextChoise
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
Definition simpleideals.cc:1154
idInitChoise
void idInitChoise(int r, int beg, int end, BOOLEAN *endch, int *choise)
Definition simpleideals.cc:1132
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210

## mpNew()

matrix mpNew | ( | int | r,
|  | int | c )

create a r x c zero-matrix

Definition at line 37 of file matpol.cc.

{
matrix rc = (matrix)omAllocBin(sip_sideal_bin);
rc->nrows = r;
rc->ncols = c;
rc->rank = r;
if ((c != 0)&&(r!=0))
{
size_t s=((size_t)r)*((size_t)c)*sizeof(poly);
rc->m = (poly*)omAlloc0(s);
//if (rc->m==NULL)
//{
// Werror("internal error: creating matrix[%d][%d]",r,c);
// return NULL;
//}
}
return rc;
}
omAllocBin
#define omAllocBin(bin)
Definition omAllocDecl.h:205
sip_sideal_bin
VAR omBin sip_sideal_bin
Definition simpleideals.cc:27

## pMultMp()

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

Definition at line 158 of file matpol.cc.

{
int k, n = a->nrows, m = a->ncols;
p_Normalize(p, R);
for (k=m*n-1; k>0; k--)
{
if (a->m[k]!=NULL)
a->m[k] = p_Mult_q(p_Copy(p, R), a->m[k], R);
}
a->m[0] = p_Mult_q(p, a->m[0], R);
return a;
}

## sm_Add()

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

Definition at line 1867 of file matpol.cc.

{
assume(IDELEMS(a)==IDELEMS(b));
assume(a->rank==b->rank);
ideal c=idInit(IDELEMS(a),a->rank);
for (int k=IDELEMS(a)-1; k>=0; k--)
c->m[k] = p_Add_q(p_Copy(a->m[k], R), p_Copy(b->m[k], R), R);
return c;
}
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition simpleideals.cc:35

## sm_Compare()

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

Definition at line 1980 of file matpol.cc.

{
if (IDELEMS(a)<IDELEMS(b)) return -1;
else if (IDELEMS(a)>IDELEMS(b)) return 1;
if ((a->rank)<(b->rank)) return -1;
else if ((a->rank)<(b->rank)) return 1;
unsigned ii=IDELEMS(a)-1;
unsigned j=0;
int r=0;
while (j<=ii)
{
r=p_Compare(a->m[j],b->m[j],R);
if (r!=0) return r;
j++;
}
return r;
}

## sm_Det()

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

Definition at line 2163 of file matpol.cc.

{
if ((MATCOLS(a)==0)
&& (MATROWS(a)==0))
return p_One(r);
if (d==DetDefault) d=mp_GetAlgorithmDet((matrix)a,r);
if (d==DetSBareiss) return sm_CallDet(a,r);
matrix m=id_Module2Matrix(id_Copy(a,r),r);
poly p=mp_Det(m,r,d);
id_Delete((ideal *)&m,r);
return p;
}
id_Copy
ideal id_Copy(ideal h1, const ring r)
copy an ideal
Definition simpleideals.cc:542
mp_Det
poly mp_Det(matrix a, const ring r, DetVariant d)
Definition matpol.cc:2139
id_Module2Matrix
matrix id_Module2Matrix(ideal mod, const ring R)
Definition simpleideals.cc:1594

## sm_Equal()

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

Definition at line 1999 of file matpol.cc.

{
if ((a->rank!=b->rank) || (IDELEMS(a)!=IDELEMS(b)))
return FALSE;
int i=IDELEMS(a)-1;
while (i>=0)
{
if (a->m[i]==NULL)
{
if (b->m[i]!=NULL) return FALSE;
}
else if (b->m[i]==NULL) return FALSE;
else if (p_Cmp(a->m[i],b->m[i], R)!=0) return FALSE;
i--;
}
i=IDELEMS(a)-1;
while (i>=0)
{
if(!p_EqualPolys(a->m[i],b->m[i], R)) return FALSE;
i--;
}
return TRUE;
}

## sm_Flatten()

ideal sm_Flatten | ( | ideal | a,
|  | const ring | R )

Definition at line 1922 of file matpol.cc.

{
if (IDELEMS(a)==0) return id_Copy(a,R);
ideal res=idInit(1,IDELEMS(a)*a->rank);
for(int i=0;i<IDELEMS(a);i++)
{
if(a->m[i]!=NULL)
{
poly p=p_Copy(a->m[i],R);
if (i==0) res->m[0]=p;
else
{
p_Shift(&p,i*a->rank,R);
res->m[0]=p_Add_q(res->m[0],p,R);
}
}
}
return res;
}
p_Shift
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
Definition p_polys.cc:4860

## sm_Mult()

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

Definition at line 1887 of file matpol.cc.

{
int i, j, k;
int m = a->rank;
int p = IDELEMS(a);
int q = IDELEMS(b);
assume (IDELEMS(a)==b->rank);
ideal c = idInit(q,m);
for (i=0; i<m; i++)
{
for (k=0; k<p; k++)
{
poly aik;
if ((aik=SMATELEM(a,i,k,R))!=NULL)
{
for (j=0; j<q; j++)
{
poly bkj=SMATELEM(b,k,j,R);
if (bkj!=NULL)
{
poly s = p_Mult_q(p_Copy(aik,R) /*SMATELEM(a,i,k)*/, bkj/*SMATELEM(b,k,j)*/, R);
if (s!=NULL) p_SetComp(s,i+1,R);
c->m[j]=p_Add_q(c->m[j],s, R);
}
}
p_Delete(&aik,R);
}
}
}
for(i=q-1;i>=0;i--) p_Normalize(c->m[i], R);
return c;
}
SMATELEM
#define SMATELEM(A, i, j, R)
Definition matpol.h:123

## sm_Sub()

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

Definition at line 1877 of file matpol.cc.

{
assume(IDELEMS(a)==IDELEMS(b));
assume(a->rank==b->rank);
ideal c=idInit(IDELEMS(a),a->rank);
for (int k=IDELEMS(a)-1; k>=0; k--)
c->m[k] = p_Sub(p_Copy(a->m[k], R), p_Copy(b->m[k], R), R);
return c;
}

## sm_Tensor()

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

Definition at line 1827 of file matpol.cc.

{
// size of the result m*p x n*q
int n=IDELEMS(A); // m x n
int m=A->rank;
int q=IDELEMS(B); // p x q
int p=B->rank;
ideal res=idInit(n*q,m*p);
poly *a=(poly*)omAlloc(m*sizeof(poly));
for(int i=0; i<n; i++)
{
memset(a,0,m*sizeof(poly));
p_Vec2Array(A->m[i],a,m,r);
for(int j=0;j<m;j++)
{
if (a[j]!=NULL)
{
ideal sm=sm_MultAndShift(a[j], // A_i_j
B,
j*p, // shift j*p down
r);
sm_AddSubMat(res,sm,i*q,r); // add this columns to col i*q ff
id_Delete(&sm,r); // delete the now empty ideal
}
}
}
omFreeSize(a,m*sizeof(poly));
return res;
}
B
b *CanonicalForm B
Definition facBivar.cc:52
sm_MultAndShift
static ideal sm_MultAndShift(poly f, ideal B, int s, const ring r)
Definition matpol.cc:1799
sm_AddSubMat
static void sm_AddSubMat(ideal res, ideal sm, int col, const ring r)
Definition matpol.cc:1818
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
p_Vec2Array
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:3720

## sm_Trace()

poly sm_Trace | ( | ideal | a,
|  | const ring | R )

Definition at line 1969 of file matpol.cc.

{
int i;
int n = (IDELEMS(a)<a->rank) ? IDELEMS(a) : a->rank;
poly t = NULL;
for (i=0; i<=n; i++)
t = p_Add_q(t, p_Copy(SMATELEM(a,i,i,R), R), R);
return t;
}

## sm_UnFlatten()

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

Definition at line 1942 of file matpol.cc.

{
if ((IDELEMS(a)!=1)
||((a->rank % col)!=0))
{
Werror("wrong format: %d x %d for unflatten",(int)a->rank,IDELEMS(a));
return NULL;
}
int row=a->rank/col;
ideal res=idInit(col,row);
poly p=a->m[0];
while(p!=NULL)
{
poly h=p_Head(p,R);
int comp=p_GetComp(h,R);
int c=(comp-1)/row;
int r=comp%row; if (r==0) r=row;
p_SetComp(h,r,R); p_SetmComp(h,R);
res->m[c]=p_Add_q(res->m[c],h,R);
pIter(p);
}
return res;
}
comp
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
Definition facSparseHensel.h:25
p_SetmComp
#define p_SetmComp
Definition p_polys.h:246

## TraceOfProd()

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

Definition at line 282 of file matpol.cc.

{
int i, j;
poly p, t = NULL;
for (i=1; i<=n; i++)
{
for (j=1; j<=n; j++)
{
p = pp_Mult_qq(MATELEM(a,i,j), MATELEM(b,j,i), R);
t = p_Add_q(t, p, R);
}
}
return t;
}

## Variable Documentation

## ip_smatrix_bin

EXTERN_VAR omBin ip_smatrix_bin

Definition at line 105 of file matpol.h.