16#pragma GCC push_options
17#pragma GCC optimize ("wrapv")
52 for (
int i=0;
i<
l;
i++)
66 if ((
col == 1)&&(not_mat))
122 v = (
int*)
omAlloc0(new_length*
sizeof(
int));
138 for (
int i = 0;
i <
rows();
i++)
141 for (
int j = 0;
j <
cols();
j++)
181 if (intop == 0)
return;
195 if (intop == 0)
return;
208 if ((
col!=1) ||(op->
cols()!=1))
243 if (
v[
i] <o)
return -1;
244 if (
v[
i] >o)
return 1;
259 for (
i=0;
i<mn;
i++) (*iv)[
i] = (*a)[
i] + (*b)[
i];
264 for(
i=mn;
i<ma;
i++) (*iv)[
i] = (*a)[
i];
268 for(
i=mn;
i<ma;
i++) (*iv)[
i] = (*b)[
i];
273 if (mn != ma)
return NULL;
275 for (
i=0;
i<mn*a->
cols();
i++) { (*iv)[
i] += (*b)[
i]; }
290 for(
i=
b->rows()+
s-1;
i>=
s;
i--)
291 (*iv)[
i] += (*b)[
i-
s];
307 for (
i=0;
i<mn;
i++) (*iv)[
i] = (*a)[
i] - (*b)[
i];
312 for(
i=mn;
i<ma;
i++) (*iv)[
i] = (*a)[
i];
316 for(
i=mn;
i<ma;
i++) (*iv)[
i] = -(*b)[
i];
321 if (mn != ma)
return NULL;
323 for (
i=0;
i<mn*a->
cols();
i++) { (*iv)[
i] -= (*b)[
i]; }
334 (*iv)[
j*r+
i] = (*o)[
i*c+
j];
353 rb =
b->rows(), cb =
b->cols();
355 if (ca != rb)
return NULL;
356 iv =
new intvec(ra, cb, 0);
363 sum += (*a)[
i*ca+
k]*(*b)[
k*cb+
j];
395static int ivGcd(
int,
int);
406 int rpiv, colpos=0, rowpos=0;
407 int ia=ready, ie=all;
415 rpiv =
ivColPivot(imat, colpos, rowpos, ia, ie);
427 if (ia==imat->
cols())
434 ivReduce(imat, rpiv, colpos, ia, ie);
453 for (r=1;r<=dimtr;r++)
460 for (r=dimtr;r>0;r--)
488 if (
IMATELEM(*imat,rowpos,colpos)!=0)
490 for (rpiv=ready+1;rpiv<=all;rpiv++)
526 for (
j=rpiv-1;
j>=rowpos;
j--)
536 int tgcd, ce, m1, m2,
j,
i;
537 int piv =
IMATELEM(*imat,rpiv,colpos);
539 for (
j=all;
j>ready;
j--)
548 tgcd =
ivGcd(m1, m2);
554 for (
i=imat->
cols();
i>colpos;
i--)
570 for (
j=ready+1;
j<=all;
j++)
572 for (
i=imat->
cols();
i>colpos;
i--)
579 for (
l=imat->
cols();
l>colpos;
l--)
598 if (
i<colpos)
return;
600 if (tgcd<0) tgcd = -tgcd;
605 if (
m!=0) tgcd=
ivGcd(tgcd,
m);
609 for (
i=imat->
cols();
i>=colpos;
i--)
614 intvec *perm,
int pos,
int r,
int c)
616 int piv, cp,
g,
i,
j,
k,
s;
618 for (
i=c;
i>(*perm)[r];
i--)
675 Warn(
" %d linear independent solutions\n",r);
694 int &
l,
int &
j,
int pos)
708 for(
k=
h->rows()-1;
k>=0;
k--)
734 for(
k=
w->rows()-1;
k>=0;
k--)
744 for(
k=
w->rows()-1;
k>=0;
k--)
753 for (
i=
w->rows()-1;
i>=0;
i--)
770 for (
i=
w->rows()-1;
i>=0;
i--)
776 for (
i=
w->rows()-1;
i>=0;
i--)
785 for (
i=
w->rows()-1;
i>=0;
i--)
787 if ((*
w)[
i]<0)
return -1;
789 for (
i=
w->rows()-1;
i>=0;
i--)
808 if (tgcd<0) tgcd = -tgcd;
813 if (
m!=0) tgcd=
ivGcd(tgcd,
m);
817 for (
i=
w->rows()-1;
i>=0;
i--)
825 int c = ac +
b->cols();
int r =
si_max(a->
rows(),
b->rows());
834 for (
i=1;
i<=
b->rows();
i++)
836 for(
j=1;
j<=
b->cols();
j++)
846 for(
int i=0;
i<
p;
i++) (*iv)[
i]=
v[
i];
851#pragma GCC pop_options
static int si_max(const int a, const int b)
static int si_min(const int a, const int b)
intvec * delete_pos(int p)
void resize(int new_length)
void operator%=(int intop)
void show(int mat=0, int spaces=0) const
void operator/=(int intop)
void operator+=(int intop)
char * String(int dim=2) const
int compare(const intvec *o) const
char * ivString(int not_mat=1, int spaces=0, int dim=2) const
void operator*=(int intop)
void operator-=(int intop)
const CanonicalForm int s
intvec * ivSub(intvec *a, intvec *b)
static void ivRowContent(intvec *, int, int)
static void ivOptRecursive(intvec *, intvec *, intvec *, int &, int &, int)
static intvec * ivOptimizeKern(intvec *)
static int ivGcd(int, int)
intvec * ivConcat(intvec *a, intvec *b)
static void ivOptSolve(intvec *, intvec *, int &, int &)
void ivTriangIntern(intvec *imat, int &ready, int &all)
static void ivKernFromRow(intvec *, intvec *, intvec *, int, int, int)
static int ivColPivot(intvec *, int, int, int, int)
intvec * ivAddShift(intvec *a, intvec *b, int s)
static void ivSetRow(intvec *, int, int)
static void ivFreeRow(intvec *, int, int)
intvec * ivSolveKern(intvec *imat, int dimtr)
static void ivZeroElim(intvec *, int, int, int &)
intvec * ivAdd(intvec *a, intvec *b)
static int ivL1Norm(intvec *)
static void ivSaveRow(intvec *, int)
static void ivContent(intvec *)
intvec * ivMult(intvec *a, intvec *b)
intvec * ivTranp(intvec *o)
static int ivCondNumber(intvec *, int)
static void ivNegRow(intvec *, int)
static void ivReduce(intvec *, int, int, int, int)
#define IMATELEM(M, I, J)
#define omFreeSize(addr, size)
#define omCheckAddr(addr)
#define omRealloc0Size(addr, o_size, size)
void StringSetS(const char *st)
void StringAppendS(const char *st)
void PrintNSpaces(const int n)
void PrintS(const char *s)