32 static poly
mp_Exdiv ( poly
m, poly d, poly vars,
const ring);
33 static poly
mp_Select (poly fro, poly what,
const ring);
34 static poly
mp_SelectId (ideal I, poly what,
const ring
R);
52 size_t s=((size_t)r)*((size_t)c)*
sizeof(poly);
71 for (i=m*n-1; i>=0; i--)
94 for (i=m*n-1; i>=0; i--)
116 int i=
si_min(r,c), n = c*(i-1)+i-1, inc = c+1;
141 for (k=
m*n-1; k>0; k--)
153 for (k=
m*n-1; k>0; k--)
170 for (k=
m*n-1; k>0; k--)
191 for (k=
m*n-1; k>=0; k--)
208 for (k=
m*n-1; k>=0; k--)
244 (*cij) =
p_Add_q((*cij) ,s, R);
318 for (i=
IDELEMS(I)-1; i>=0; i--)
331 for (i=
IDELEMS(I)-1; i>=0; i--)
347 MATELEM(co,(c-1)*(m+1)+l+1,i+1)
561 static poly
mp_Exdiv ( poly
m, poly d, poly vars,
const ring
R)
565 for (i=1; i<=
rVar(R); i++)
695 if (p1==
NULL)
return p2;
696 if (p2==
NULL)
return p1;
702 c =
p_Cmp(a1, a2, R);
756 for (i=1; i<=
rVar(R); i++)
777 for (i=1; i<=
rVar(R); i++)
809 for (i=lr-1;i>=0;i--)
812 for (j=lc-1;j>=0;j--)
if(q1[j])
p_Delete(&q1[j], R);
840 for (i=0; i<=ii; i++)
842 for (j=0; j<=jj; j++)
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);
876 s[strlen(s)- (dim > 1 ? 2 : 1)]=
'\0';
928 int a_m, a_n, s_m, s_n,
sign, piv_s;
934 {
return &(Xarray[a_n*qrow[r]]); }
936 {
return &(Xarray[qcol[c]]); }
937 void mpRowWeight(
float *);
938 void mpColWeight(
float *);
939 void mpRowSwap(
int,
int);
940 void mpColSwap(
int,
int);
951 void mpSetSearch(
int s);
953 poly mpGetElem(
int,
int);
954 void mpSetElem(poly,
int,
int);
955 void mpDelElem(
int,
int);
956 void mpElimBareiss(poly);
959 void mpToIntvec(
intvec *);
983 for (i=
a_m-1; i>=0; i--)
987 for (j=
a_n-1; j>=0; j--)
1008 for (k=
a_m*
a_n-1; k>=0; k--)
1023 for (j=
s_n; j>=0; j--)
1027 for(i=
s_m; i>=0; i--)
1042 for (i=
s_m; i>=0; i--)
1046 for(j=
s_n; j>=0; j--)
1063 for (j=
a_n-1; j>= 0; j--)
1078 for (i=0; i<
k; i+=
a_n)
1094 for (k=
a_m-1; k>=0; k--)
qrow[k] = k;
1095 for (k=
a_n-1; k>=0; k--)
qcol[k] = k;
1106 for (j=
a_n-1; j>=
k; j--)
1113 while (
qcol[j2] != j) j2++;
1127 for (i=
a_m-1; i>=
k; i--)
1134 while (
qrow[i2] != i) i2++;
1162 int i,
j, iopt, jopt;
1163 float sum, f1, f2, fo, r, ro, lp;
1164 float *dr = C->
wrow, *dc = C->
wcol;
1176 for(i=
s_m; i>=0; i--)
1200 for(i=
s_m; i>=0; i--)
1202 for(i=
s_m; i>=0; i--)
1206 for(j=
s_n; j>=0; j--)
1213 f1 = ro * (dc[
j]-lp);
1216 f2 = lp * (sum - ro - dc[
j]);
1246 poly piv, elim, q1, q2, *
ap, *a;
1251 for(i=
s_m-1; i>=0; i--)
1254 elim = a[qcol[
s_n]];
1258 for (j=
s_n-1; j>=0; j--)
1272 else if (a[jj] !=
NULL)
1276 if ((q2!=
NULL) && div)
1284 for (j=
s_n-1; j>=0; j--)
1310 for (i=r->N;i>0;i--)
1342 for (i=lr-1;i>=0;i--)
1344 q1 = &(a->
m)[i*a->
ncols];
1346 for (j=lc-1;j>=0;j--)
1351 if ((f2!=0.0) && (f2<f1))
1366 poly* a1 = &a2[a->
ncols*(pos-1)];
1368 a2 = &a2[a->
ncols*(lr-1)];
1369 for (j=lc-1; j>=0; j--)
1402 q1 = &(a->
m)[(lr-1)*a->
ncols];
1403 for (j=lc-1;j>=0;j--)
1424 poly* a1 = &a2[pos-1];
1452 poly *
b = a0->
m, *
x = re->
m;
1453 poly piv, elim, q1, *
ap, *a, *q;
1456 ap = &b[r*a0->
ncols];
1458 for(j=c-1; j>=0; j--)
1460 for(i=r-1; i>=0; i--)
1462 a = &b[i*a0->
ncols];
1467 for (j=c-1; j>=0; j--)
1479 else if (ap[j] !=
NULL)
1491 for (j=c-1; j>=0; j--)
1508 ideal
R,
const ring)
1516 for (i=r-1;i>=0;i--)
1518 q1 = &(a->
m)[i*a->
ncols];
1525 for (i=r-1;i>=0;i--)
1527 q1 = &(a->
m)[i*a->
ncols];
1528 for (j=c-1;j>=0;j--)
1538 result->m[elems] = q1[
j];
1604 poly barDiv, ideal
R,
const ring r)
1607 int kr=lr-1,kc=lc-1;
1754 int *rowchoise,*colchoise;
1763 rowchoise=(
int *)
omAlloc(ar*
sizeof(
int));
1764 colchoise=(
int *)
omAlloc(ar*
sizeof(
int));
1765 result =
mpNew(i,j);
1775 for (i=1; i<=ar; i++)
1777 for (j=1; j<=ar; j++)
1783 if ((k+l) & 1) p=
p_Neg(p, R);
1793 for (i=1; i<=ar; i++)
1808 for(
int j=0;
j<q;
j++)
1826 res->m[col+
i]=
p_Add_q(res->m[col+
i],sm->m[
i],r);
1839 poly *a=(poly*)
omAlloc(m*
sizeof(poly));
1840 for(
int i=0;
i<n;
i++)
1842 memset(a,0,m*
sizeof(poly));
1844 for(
int j=0;
j<
m;
j++)
1874 assume(a->rank==b->rank);
1884 assume(a->rank==b->rank);
1935 if (
i==0) res->m[0]=
p;
1939 res->m[0]=
p_Add_q(res->m[0],p,R);
1949 ||((a->rank % col)!=0))
1951 Werror(
"wrong format: %d x %d for unflatten",(
int)a->rank,
IDELEMS(a));
1954 int row=a->rank/col;
1962 int r=comp%row;
if (r==0) r=row;
1964 res->m[c]=
p_Add_q(res->m[c],h,R);
1979 for (i=0; i<=n; i++)
1988 if ((a->rank)<(b->rank))
return -1;
1989 else if ((a->rank)<(b->rank))
return 1;
2015 else if (
p_Cmp(a->m[i],b->m[i], R)!=0)
return FALSE;
2051 for (
int i = n-1;
i >= 0;
i--)
2059 for (
int i = n-1;
i >=0;
i--)
2061 for (
int j =
i+1;
j < n;
j++)
2089 for (
int i = n-1;
i >0;
i--)
2134 if (strcmp(s,
"Bareiss")==0)
return DetBareiss;
2136 if (strcmp(s,
"Mu")==0)
return DetMu;
2137 if (strcmp(s,
"Factory")==0)
return DetFactory;
2138 WarnS(
"unknown method for det");
2162 WerrorS(
"unknown algorithm for det");
BOOLEAN rHasLocalOrMixedOrdering(const ring r)
int status int void size_t count
#define __p_GetComp(p, r)
ideal sm_UnFlatten(ideal a, int col, const ring R)
matrix mp_CoeffProc(poly f, poly vars, const ring R)
const CanonicalForm int s
void sm_SpecialPolyDiv(poly a, poly b, const ring R)
poly prCopyR_NoSort(poly p, ring src_r, ring dest_r)
static int p_Cmp(poly p1, poly p2, ring r)
int sm_Compare(ideal a, ideal b, const ring R)
static poly mp_Select(poly fro, poly what, const ring)
static int si_min(const int a, const int b)
matrix mp_InitP(int r, int c, poly p, const ring R)
make it a p * unit matrix
ideal id_Copy(ideal h1, const ring r)
copy an ideal
static int mp_PivBar(matrix a, int lr, int lc, 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
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
poly sm_CallDet(ideal I, const ring R)
poly mp_Trace(matrix 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 void mp_ElimBar(matrix a0, matrix re, poly div, int lr, int lc, const ring R)
static poly mp_SelectId(ideal I, poly what, const ring R)
#define omFreeSize(addr, size)
static BOOLEAN p_IsUnit(const poly p, const ring r)
static short rVar(const ring r)
#define rVar(r) (r->N)
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define omfreeSize(addr, size)
void mpColWeight(float *)
static void mpFinalClean(matrix a)
#define MATELEM0(mat, i, j)
0-based access to matrix
static poly mp_Exdiv(poly m, poly d, poly vars, const ring)
static int mp_PrepareRow(matrix a, int lr, int lc, const ring R)
static matrix mu(matrix A, const ring R)
poly singclap_det(const matrix m, const ring s)
ideal sm_Sub(ideal a, ideal b, const ring R)
void WerrorS(const char *s)
void mpRowWeight(float *)
static void sm_AddSubMat(ideal res, ideal sm, int col, const ring r)
static void mp_PartClean(matrix a, int lr, int lc, 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)
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
int mpPivotBareiss(row_col_weight *)
poly p_Sub(poly p1, poly p2, const ring r)
#define SMATELEM(A, i, j, R)
static poly p_Copy(poly p, const ring r)
returns a copy of p
void iiWriteMatrix(matrix im, const char *n, int dim, const ring r, int spaces)
set spaces to zero by default
int comp(const CanonicalForm &A, const CanonicalForm &B)
compare polynomials
static ideal sm_MultAndShift(poly f, ideal B, int s, const ring r)
static void mpSwapCol(matrix a, int pos, int lr, int lc)
static void mpReplace(int j, int n, int &sign, int *perm)
matrix mp_Transp(matrix a, const ring R)
static poly p_Head(poly p, const ring r)
copy the i(leading) term of p
void p_Vec2Array(poly v, poly *p, int len, const ring r)
vector to already allocated array (len>=p_MaxComp(v,r))
static int mp_PreparePiv(matrix a, int lr, int lc, const ring r)
matrix mp_Wedge(matrix a, int ar, const ring R)
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
static BOOLEAN p_IsConstant(const poly p, const ring r)
void StringSetS(const char *st)
for(int i=0;i<=n;i++) degsf[i]
static poly pp_Mult_qq(poly p, poly q, const ring r)
void StringAppendS(const char *st)
matrix mp_MultI(matrix a, int f, const ring R)
c = f*a
poly mp_Det(matrix a, const ring r, DetVariant d)
BOOLEAN sm_Equal(ideal a, ideal b, const ring R)
void p_Vec2Polys(poly v, poly **p, int *len, const ring r)
ideal sm_Tensor(ideal A, ideal B, const ring r)
ideal sm_Flatten(ideal a, const ring R)
void idGetNextChoise(int r, int end, BOOLEAN *endch, int *choise)
matrix pMultMp(poly p, matrix a, const ring R)
static int si_max(const int a, const int b)
int p_Compare(const poly a, const poly b, const ring R)
static BOOLEAN rField_is_Q(const ring r)
matrix id_Module2Matrix(ideal mod, const ring R)
static unsigned pLength(poly a)
void mp_Delete(matrix *a, const ring r)
matrix mp_CoeffProcId(ideal I, poly vars, const ring R)
BOOLEAN p_EqualPolys(poly p1, poly p2, const ring r)
static BOOLEAN rField_is_Zp(const ring r)
void p_Shift(poly *p, int i, const ring r)
shifts components of the vector p by i
matrix mpNew(int r, int c)
create a r x c zero-matrix
void p_Normalize(poly p, const ring r)
void p_Write0(poly p, ring lmRing, ring tailRing)
static void p_Delete(poly *p, const ring r)
matrix mp_MultP(matrix a, poly p, const ring R)
multiply a matrix 'a' by a poly 'p', destroy the args
ideal idInit(int idsize, int rank)
initialise an ideal / module
const Variable & v
< [in] a sqrfree bivariate poly
matrix mp_Mult(matrix a, matrix b, const ring R)
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
static void mpSwapRow(matrix a, int pos, int lr, int lc)
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, 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.
matrix mp_InitI(int r, int c, int v, const ring R)
make it a v * unit matrix
void mp_Monomials(matrix c, int r, int var, matrix m, const ring R)
matrix mp_Add(matrix a, matrix b, const ring R)
poly mp_DetMu(matrix A, const ring R)
void pEnlargeSet(poly **p, int l, int increment)
DetVariant mp_GetAlgorithmDet(matrix m, const ring r)
poly sm_Det(ideal a, const ring r, DetVariant d)
poly sm_Trace(ideal a, const ring R)
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
BOOLEAN mp_IsDiagUnit(matrix U, const ring R)
static void p_Setm(poly p, const ring r)
poly sm_MultDiv(poly a, poly b, const poly c, const ring R)
BOOLEAN mp_Equal(matrix a, matrix b, const ring R)
matrix mp_Copy(matrix a, const ring r)
copies matrix a (from ring r to r)
ideal sm_Add(ideal a, ideal b, const ring R)
static poly p_Neg(poly p, const ring r)
static void p_LmDelete(poly p, const ring r)
int mp_Compare(matrix a, matrix b, const ring R)
void p_String0(poly p, ring lmRing, ring tailRing)
print p according to ShortOut in lmRing & tailRing
poly TraceOfProd(matrix a, matrix b, int n, const ring R)
void p_Write(poly p, ring lmRing, ring tailRing)
matrix mp_Sub(matrix a, matrix b, const ring R)
ideal sm_Mult(ideal a, ideal b, const ring R)
static poly p_Add_q(poly p, poly q, const ring r)
#define omFreeBin(addr, bin)
char * iiStringMatrix(matrix im, int dim, const ring r, char ch)
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
static float mp_PolyWeight(poly p, const ring r)
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
ideal id_Matrix2Module(matrix mat, const ring R)
converts mat to module, destroys mat
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
static poly p_Mult_q(poly p, poly q, const ring r)
static poly p_Insert(poly p1, poly p2, const ring R)
void Werror(const char *fmt,...)
#define MATELEM(mat, i, j)
1-based access to matrix
static int mp_PivRow(matrix a, int lr, int lc, const ring r)