17 #pragma GCC push_options 18 #pragma GCC optimize ("wrapv") 53 for (
int i=0;
i<
l;
i++)
67 if ((
col == 1)&&(not_mat))
123 v = (
int*)
omAlloc0(new_length*
sizeof(
int));
139 for (
int i = 0;
i <
rows();
i++)
142 for (
int j = 0;
j <
cols();
j++)
182 if (intop == 0)
return;
196 if (intop == 0)
return;
209 if ((
col!=1) ||(op->
cols()!=1))
231 for (; i<op->
rows(); i++)
244 if (
v[
i] <o)
return -1;
245 if (
v[
i] >o)
return 1;
260 for (i=0; i<mn; i++) (*iv)[
i] = (*a)[
i] + (*b)[
i];
265 for(i=mn; i<ma; i++) (*iv)[
i] = (*a)[
i];
269 for(i=mn; i<ma; i++) (*iv)[
i] = (*b)[
i];
274 if (mn != ma)
return NULL;
276 for (i=0; i<mn*a->
cols(); i++) { (*iv)[
i] += (*b)[
i]; }
290 for (i=0; i<mn; i++) (*iv)[
i] = (*a)[
i] - (*b)[
i];
295 for(i=mn; i<ma; i++) (*iv)[
i] = (*a)[
i];
299 for(i=mn; i<ma; i++) (*iv)[
i] = -(*b)[
i];
304 if (mn != ma)
return NULL;
306 for (i=0; i<mn*a->
cols(); i++) { (*iv)[
i] -= (*b)[
i]; }
317 (*iv)[j*r+
i] = (*o)[i*c+
j];
338 if (ca != rb)
return NULL;
339 iv =
new intvec(ra, cb, 0);
346 sum += (*a)[i*ca+
k]*(*b)[k*cb+
j];
378 static int ivGcd(
int,
int);
389 int rpiv, colpos=0, rowpos=0;
390 int ia=ready, ie=all;
398 rpiv =
ivColPivot(imat, colpos, rowpos, ia, ie);
410 if (ia==imat->
cols())
417 ivReduce(imat, rpiv, colpos, ia, ie);
436 for (r=1;r<=dimtr;r++)
443 for (r=dimtr;r>0;r--)
471 if (
IMATELEM(*imat,rowpos,colpos)!=0)
473 for (rpiv=ready+1;rpiv<=all;rpiv++)
484 for (i=imat->
cols();i!=0;i--)
492 for (i=imat->
cols();i!=0;i--)
500 for (i=imat->
cols();i!=0;i--)
509 for (j=rpiv-1;j>=rowpos;j--)
511 for (i=imat->
cols();i!=0;i--)
519 int tgcd, ce, m1, m2,
j,
i;
520 int piv =
IMATELEM(*imat,rpiv,colpos);
522 for (j=all;j>ready;j--)
531 tgcd =
ivGcd(m1, m2);
537 for (i=imat->
cols();i>colpos;i--)
553 for (j=ready+1;j<=all;j++)
555 for (i=imat->
cols();i>colpos;i--)
562 for (l=imat->
cols();l>colpos;l--)
581 if (i<colpos)
return;
583 if (tgcd<0) tgcd = -tgcd;
588 if (m!=0) tgcd=
ivGcd(tgcd, m);
592 for (i=imat->
cols();i>=colpos;i--)
597 intvec *perm,
int pos,
int r,
int c)
599 int piv, cp,
g,
i,
j,
k,
s;
601 for (i=c;i>(*perm)[
r];i--)
658 Warn(
" %d linear independent solutions\n",
r);
677 int &
l,
int &
j,
int pos)
691 for(k=h->
rows()-1;k>=0;k--)
717 for(k=w->
rows()-1;k>=0;k--)
727 for(k=w->
rows()-1;k>=0;k--)
736 for (i=w->
rows()-1;i>=0;i--)
770 if ((*w)[
i]<0)
return -1;
791 if (tgcd<0) tgcd = -tgcd;
796 if (m!=0) tgcd=
ivGcd(tgcd, m);
800 for (i=w->
rows()-1;i>=0;i--)
812 for (i=1; i<=a->
rows(); i++)
817 for (i=1; i<=b->
rows(); i++)
819 for(j=1; j<=b->
cols(); j++)
825 #pragma GCC pop_options int compare(const intvec *o) const
void operator-=(int intop)
#define omRealloc0Size(addr, o_size, size)
const CanonicalForm int s
static void ivNegRow(intvec *, int)
void resize(int new_length)
char * ivString(int not_mat=1, int spaces=0, int dim=2) const
static intvec * ivOptimizeKern(intvec *)
static int si_min(const int a, const int b)
static void ivZeroElim(intvec *, int, int, int &)
static int ivL1Norm(intvec *)
static int ivGcd(int, int)
#define omFreeSize(addr, size)
void operator/=(int intop)
static void ivFreeRow(intvec *, int, int)
intvec * ivSub(intvec *a, intvec *b)
intvec * ivTranp(intvec *o)
static void ivSaveRow(intvec *, int)
void operator+=(int intop)
static void ivContent(intvec *)
static int ivColPivot(intvec *, int, int, int, int)
void operator%=(int intop)
void ivTriangIntern(intvec *imat, int &ready, int &all)
void StringSetS(const char *st)
void operator*=(int intop)
void StringAppendS(const char *st)
static int si_max(const int a, const int b)
void PrintS(const char *s)
static void ivOptRecursive(intvec *, intvec *, intvec *, int &, int &, int)
intvec * ivConcat(intvec *a, intvec *b)
static void ivReduce(intvec *, int, int, int, int)
static void ivSetRow(intvec *, int, int)
intvec * ivMult(intvec *a, intvec *b)
char * String(int dim=2) const
static void ivKernFromRow(intvec *, intvec *, intvec *, int, int, int)
void show(int mat=0, int spaces=0) const
intvec * ivSolveKern(intvec *imat, int dimtr)
static void ivOptSolve(intvec *, intvec *, int &, int &)
#define omCheckAddr(addr)
static void ivRowContent(intvec *, int, int)
static int ivCondNumber(intvec *, int)
#define IMATELEM(M, I, J)
void PrintNSpaces(const int n)
intvec * ivAdd(intvec *a, intvec *b)