32static poly
mp_Exdiv ( poly
m, poly d, poly vars,
const ring);
33static poly
mp_Select (poly fro, poly what,
const ring);
34static poly
mp_SelectId (ideal I, poly what,
const ring
R);
45 size_t s=((size_t)r)*((
size_t)c)*
sizeof(poly);
64 for (
long i=(
long)
m*(
long)n-1;
i>=0;
i--)
70 b->m[
i] = p_Copy(t, r);
87 for (
i=
m*n-1;
i>=0;
i--)
109 int i=si_min(r,c), n = c*(
i-1)+
i-1, inc = c+1;
114 rc->
m[n] = p_Copy(
p,
R);
134 for (
k=
m*n-1;
k>0;
k--)
135 c->
m[
k] = pp_Mult_qq(a->
m[
k],
p,
R);
136 c->
m[0] = p_Mult_q(p_Copy(a->
m[0],
R),
p,
R);
146 for (
k=
m*n-1;
k>0;
k--)
149 a->
m[
k] = p_Mult_q(a->
m[
k], p_Copy(
p,
R),
R);
151 a->
m[0] = p_Mult_q(a->
m[0],
p,
R);
163 for (
k=
m*n-1;
k>0;
k--)
166 a->
m[
k] = p_Mult_q(p_Copy(
p,
R), a->
m[
k],
R);
168 a->
m[0] = p_Mult_q(
p, a->
m[0],
R);
175 if ((n !=
b->nrows) || (
m !=
b->ncols))
184 for (
k=
m*n-1;
k>=0;
k--)
185 c->
m[
k] = p_Add_q(p_Copy(a->
m[
k],
R), p_Copy(
b->m[
k],
R),
R);
192 if ((n !=
b->nrows) || (
m !=
b->ncols))
201 for (
k=
m*n-1;
k>=0;
k--)
236 poly
s = pp_Mult_qq(aik , bkj,
R);
237 (*cij) = p_Add_q((*cij) ,
s,
R);
292 t = p_Add_q(t,
p,
R);
316 l=p_GetExp(
f,var,
R);
330 l=p_GetExp(
f,var,
R);
331 p_SetExp(
f,var,0,
R);
382 p_SetExp(
h,var,
p-
l,
R);
411 if (rHasLocalOrMixedOrdering(
R))
420 if (p_IsConstant(
h,
R)) pos_of_1 =
i;
432 if (p_IsConstant(
h,
R)) pos_of_1 =
i;
487 if (rHasLocalOrMixedOrdering(
R))
496 if (p_IsConstant(
h,
R)) pos_of_1 =
i;
508 if (p_IsConstant(
h,
R)) pos_of_1 =
i;
554static poly
mp_Exdiv ( poly
m, poly d, poly vars,
const ring
R)
557 poly
h = p_Head(
m,
R);
558 for (
i=1;
i<=rVar(
R);
i++)
560 if (p_GetExp(vars,
i,
R) > 0)
562 if (p_GetExp(d,
i,
R) != p_GetExp(
h,
i,
R))
584 l=si_max(
l,pLength(
s[
i]));
592 if (p_IsConstant(
p,
R))
668 else if (p_Cmp(a->
m[
i],
b->m[
i],
R)!=0)
return FALSE;
689 if (p1==
NULL)
return p2;
690 if (p2==
NULL)
return p1;
696 c = p_Cmp(a1, a2,
R);
750 for (
i=1;
i<=rVar(
R);
i++)
751 p_SetExp(
h,
i, p_GetExp(fro,
i,
R) * p_GetExp(what,
i,
R),
R);
771 for (
i=1;
i<=rVar(
R);
i++)
772 p_SetExp(
h,
i, p_GetExp(fro,
i,
R) * p_GetExp(what,
i,
R),
R);
803 for (
i=lr-1;
i>=0;
i--)
806 for (
j=
lc-1;
j>=0;
j--)
if(q1[
j]) p_Delete(&q1[
j],
R);
834 for (
i=0;
i<=ii;
i++)
836 for (
j=0;
j<=jj;
j++)
839 Print(
"%-*.*s",spaces,spaces,
" ");
841 else if (
dim == 1)
Print(
"%s[%u]=",n,
j+1);
870 s[strlen(
s)- (
dim > 1 ? 2 : 1)]=
'\0';
986 athis[
j] = p_Copy(
p,
_R);
1057 for (
j=
a_n-1;
j>= 0;
j--)
1107 while (
qcol[j2] !=
j) j2++;
1128 while (
qrow[i2] !=
i) i2++;
1156 int i,
j, iopt, jopt;
1157 float sum, f1, f2, fo, r, ro, lp;
1158 float *dr = C->
wrow, *dc = C->
wcol;
1207 f1 = ro * (dc[
j]-lp);
1210 f2 = lp * (sum - ro - dc[
j]);
1240 poly piv, elim, q1, q2, *
ap, *a;
1251 elim = p_Neg(elim,
_R);
1262 p_Delete(&a[jj],
_R);
1263 q2 = p_Add_q(q2, q1,
_R);
1266 else if (a[jj] !=
NULL)
1284 p_Delete(&a[jj],
_R);
1303 res = (float)n_Size(pGetCoeff(
p),r->cf);
1304 for (
i=r->N;
i>0;
i--)
1306 if(p_GetExp(
p,
i,r)!=0)
1318 res += (float)n_Size(pGetCoeff(
p),r->cf)+2.0;
1336 for (
i=lr-1;
i>=0;
i--)
1340 for (
j=
lc-1;
j>=0;
j--)
1345 if ((f2!=0.0) && (f2<f1))
1360 poly* a1 = &a2[a->
ncols*(pos-1)];
1362 a2 = &a2[a->
ncols*(lr-1)];
1363 for (
j=
lc-1;
j>=0;
j--)
1396 q1 = &(a->
m)[(lr-1)*a->
ncols];
1397 for (
j=
lc-1;
j>=0;
j--)
1418 poly* a1 = &a2[pos-1];
1446 poly *
b = a0->
m, *
x = re->
m;
1447 poly piv, elim, q1, *
ap, *a, *q;
1452 for(
j=c-1;
j>=0;
j--)
1454 for(
i=r-1;
i>=0;
i--)
1461 for (
j=c-1;
j>=0;
j--)
1470 q1 = p_Add_q(q1,q2,
R);
1485 for (
j=c-1;
j>=0;
j--)
1502 ideal
R,
const ring)
1510 for (
i=r-1;
i>=0;
i--)
1519 for (
i=r-1;
i>=0;
i--)
1522 for (
j=c-1;
j>=0;
j--)
1598 poly barDiv, ideal
R,
const ring r)
1601 int kr=lr-1,kc=
lc-1;
1748 int *rowchoise,*colchoise;
1757 rowchoise=(
int *)
omAlloc(ar*
sizeof(
int));
1758 colchoise=(
int *)
omAlloc(ar*
sizeof(
int));
1769 for (
i=1;
i<=ar;
i++)
1771 for (
j=1;
j<=ar;
j++)
1777 if ((
k+
l) & 1)
p=p_Neg(
p,
R);
1787 for (
i=1;
i<=ar;
i++)
1804 for(
int j=0;
j<q;
j++)
1806 poly
h=pp_Mult_qq(
f,
B->m[
j],r);
1822 res->m[col+
i]=p_Add_q(
res->m[col+
i],sm->m[
i],r);
1835 poly *a=(poly*)
omAlloc(
m*
sizeof(poly));
1836 for(
int i=0;
i<n;
i++)
1838 memset(a,0,
m*
sizeof(poly));
1840 for(
int j=0;
j<
m;
j++)
1873 c->m[
k] = p_Add_q(p_Copy(a->m[
k],
R), p_Copy(
b->m[
k],
R),
R);
1883 c->m[
k] =
p_Sub(p_Copy(a->m[
k],
R), p_Copy(
b->m[
k],
R),
R);
1909 poly
s = p_Mult_q(p_Copy(aik,
R) , bkj,
R);
1911 c->m[
j]=p_Add_q(c->m[
j],
s,
R);
1930 poly
p=p_Copy(a->m[
i],
R);
1931 if (
i==0)
res->m[0]=
p;
1945 ||((a->rank % col)!=0))
1947 Werror(
"wrong format: %d x %d for unflatten",(
int)a->rank,
IDELEMS(a));
1950 int row=a->rank/col;
1958 int r=
comp%row;
if (r==0) r=row;
1975 for (
i=0;
i<=n;
i++)
1984 if ((a->rank)<(
b->rank))
return -1;
1985 else if ((a->rank)<(
b->rank))
return 1;
2011 else if (p_Cmp(a->m[
i],
b->m[
i],
R)!=0)
return FALSE;
2047 for (
int i = n-1;
i >= 0;
i--)
2055 for (
int i = n-1;
i >=0;
i--)
2057 for (
int j =
i+1;
j < n;
j++)
2085 for (
int i = n-1;
i >0;
i--)
2119 if(!p_IsConstant(
p,r)) isConst=
FALSE;
2123 if (isConst && rField_is_Q(r))
return DetFactory;
2132 if (strcmp(
s,
"Mu")==0)
return DetMu;
2134 WarnS(
"unknown method for det");
2158 WerrorS(
"unknown algorithm for det");
void mu(int **points, int sizePoints)
poly singclap_det(const matrix m, const ring s)
int mpPivotRow(row_col_weight *, int)
void mpSetElem(poly, int, int)
int mpPivotBareiss(row_col_weight *)
void mpColWeight(float *)
void mpToIntvec(intvec *)
void mpRowWeight(float *)
const CanonicalForm int s
const Variable & v
< [in] a sqrfree bivariate poly
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
void WerrorS(const char *s)
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
ideal id_Copy(ideal h1, const ring r)
copy an ideal
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
void idInitChoise(int r, int beg, int end, BOOLEAN *endch, int *choise)
BOOLEAN mp_IsDiagUnit(matrix U, const ring R)
matrix mp_Wedge(matrix a, int ar, const ring R)
static poly mp_SelectId(ideal I, poly what, const ring R)
static void mp_PartClean(matrix a, int lr, int lc, const ring R)
matrix mp_Transp(matrix a, const ring R)
ideal sm_Tensor(ideal A, ideal B, const ring r)
static ideal sm_MultAndShift(poly f, ideal B, int s, const ring r)
ideal sm_UnFlatten(ideal a, int col, const ring R)
int sm_Compare(ideal a, ideal b, const ring R)
ideal sm_Add(ideal a, ideal b, const ring R)
static poly mp_Exdiv(poly m, poly d, poly vars, const ring)
poly sm_Trace(ideal a, const ring R)
matrix mp_CoeffProc(poly f, poly vars, const ring R)
matrix pMultMp(poly p, matrix a, const ring R)
void mp_Delete(matrix *a, const ring r)
void mp_Monomials(matrix c, int r, int var, matrix m, const ring R)
DetVariant mp_GetAlgorithmDet(matrix m, const ring r)
static float mp_PolyWeight(poly p, const ring r)
static int mp_PivRow(matrix a, int lr, int lc, const ring r)
matrix mp_InitI(int r, int c, int v, const ring R)
make it a v * unit matrix
static void mpSwapCol(matrix a, int pos, int lr, int lc)
matrix mp_CoeffProcId(ideal I, poly vars, const ring R)
poly sm_Det(ideal a, const ring r, DetVariant d)
static poly p_Insert(poly p1, poly p2, const ring R)
static int mp_PrepareRow(matrix a, int lr, int lc, const ring R)
matrix mp_MultI(matrix a, long f, const ring R)
c = f*a
ideal sm_Sub(ideal a, ideal b, const ring R)
ideal sm_Mult(ideal a, ideal b, const ring R)
static void mpFinalClean(matrix a)
matrix mp_Sub(matrix a, matrix b, const ring R)
poly mp_Det(matrix a, const ring r, DetVariant d)
matrix mpNew(int r, int c)
create a r x c zero-matrix
int mp_Compare(matrix a, matrix b, const ring R)
poly TraceOfProd(matrix a, matrix b, int n, const ring R)
BOOLEAN sm_Equal(ideal a, ideal b, const ring R)
static void mp_ElimBar(matrix a0, matrix re, poly div, int lr, int lc, const ring R)
static void mpReplace(int j, int n, int &sign, int *perm)
matrix mp_Mult(matrix a, matrix b, const ring R)
BOOLEAN mp_Equal(matrix a, matrix b, 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
void mp_Coef2(poly v, poly mon, matrix *c, matrix *m, const ring R)
corresponds to Macauley's coef: the exponent vector of vars has to contain the variables,...
matrix mp_MultP(matrix a, poly p, const ring R)
multiply a matrix 'a' by a poly 'p', destroy the args
char * iiStringMatrix(matrix im, int dim, const ring r, char ch)
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
matrix mp_Add(matrix a, matrix b, const ring R)
matrix mp_InitP(int r, int c, poly p, const ring R)
make it a p * unit matrix
static poly mp_Select(poly fro, poly what, const ring)
static int mp_PreparePiv(matrix a, int lr, int lc, const ring r)
void iiWriteMatrix(matrix im, const char *n, int dim, const ring r, int spaces)
set spaces to zero by default
poly mp_DetMu(matrix A, const ring R)
static void sm_AddSubMat(ideal res, ideal sm, int col, const ring r)
void mp_MinorToResult(ideal result, int &elems, matrix a, int r, int c, ideal R, const ring)
entries of a are minors and go to result (only if not in R)
ideal sm_Flatten(ideal a, const ring R)
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
static int mp_PivBar(matrix a, int lr, int lc, const ring r)
static void mpSwapRow(matrix a, int pos, int lr, int lc)
poly mp_DetBareiss(matrix a, const ring r)
returns the determinant of the matrix m; uses Bareiss algorithm
poly mp_Trace(matrix a, const ring R)
#define MATELEM(mat, i, j)
1-based access to matrix
#define MATELEM0(mat, i, j)
0-based access to matrix
#define SMATELEM(A, i, j, R)
#define __p_GetComp(p, r)
#define omFreeSize(addr, size)
#define omFreeBin(addr, bin)
#define omfreeSize(addr, size)
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
void p_Vec2Polys(poly v, poly **p, int *len, const ring r)
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
void p_Normalize(poly p, const ring r)
int p_Compare(const poly a, const poly b, const ring R)
poly p_Sub(poly p1, poly p2, const ring r)
void pEnlargeSet(poly **p, int l, int increment)
void p_Vec2Array(poly v, poly *p, int len, const ring r)
vector to already allocated array (len>=p_MaxComp(v,r))
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
void p_String0(poly p, ring lmRing, ring tailRing)
print p according to ShortOut in lmRing & tailRing
void p_Write(poly p, ring lmRing, ring tailRing)
void p_Write0(poly p, ring lmRing, ring tailRing)
poly prCopyR_NoSort(poly p, ring src_r, ring dest_r)
void StringSetS(const char *st)
void StringAppendS(const char *st)
void Werror(const char *fmt,...)
int status int void size_t count
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
matrix id_Module2Matrix(ideal mod, const ring R)
ideal id_Matrix2Module(matrix mat, const ring R)
converts mat to module, destroys mat
poly sm_MultDiv(poly a, poly b, const poly c, const ring R)
poly sm_CallDet(ideal I, const ring R)
void sm_SpecialPolyDiv(poly a, poly b, const ring R)