Data Structures | Macros | Functions
intvec.h File Reference
#include <string.h>
#include <omalloc/omallocClass.h>
#include <reporter/reporter.h>

Go to the source code of this file.

Data Structures

class  intvec
 

Macros

#define IMATELEM(M, I, J)   (M)[(I-1)*(M).cols()+J-1]
 
#define ivTest(v)   do {} while (0)
 

Functions

intvecivCopy (const intvec *o)
 
intvecivAdd (intvec *a, intvec *b)
 
intvecivSub (intvec *a, intvec *b)
 
intvecivTranp (intvec *o)
 
int ivTrace (intvec *o)
 
intvecivMult (intvec *a, intvec *b)
 
void ivTriangIntern (intvec *imat, int &ready, int &all)
 
intvecivSolveKern (intvec *imat, int ready)
 
intvecivConcat (intvec *a, intvec *b)
 

Macro Definition Documentation

◆ IMATELEM

#define IMATELEM (   M,
  I,
 
)    (M)[(I-1)*(M).cols()+J-1]

Definition at line 77 of file intvec.h.

◆ ivTest

#define ivTest (   v)    do {} while (0)

Definition at line 149 of file intvec.h.

Function Documentation

◆ ivAdd()

intvec* ivAdd ( intvec a,
intvec b 
)

Definition at line 250 of file intvec.cc.

251 {
252  intvec * iv;
253  int mn, ma, i;
254  if (a->cols() != b->cols()) return NULL;
255  mn = si_min(a->rows(),b->rows());
256  ma = si_max(a->rows(),b->rows());
257  if (a->cols() == 1)
258  {
259  iv = new intvec(ma);
260  for (i=0; i<mn; i++) (*iv)[i] = (*a)[i] + (*b)[i];
261  if (ma > mn)
262  {
263  if (ma == a->rows())
264  {
265  for(i=mn; i<ma; i++) (*iv)[i] = (*a)[i];
266  }
267  else
268  {
269  for(i=mn; i<ma; i++) (*iv)[i] = (*b)[i];
270  }
271  }
272  return iv;
273  }
274  if (mn != ma) return NULL;
275  iv = new intvec(a);
276  for (i=0; i<mn*a->cols(); i++) { (*iv)[i] += (*b)[i]; }
277  return iv;
278 }
const poly a
Definition: syzextra.cc:212
static int si_min(const int a, const int b)
Definition: auxiliary.h:121
Definition: intvec.h:14
static int si_max(const int a, const int b)
Definition: auxiliary.h:120
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
const poly b
Definition: syzextra.cc:213

◆ ivConcat()

intvec* ivConcat ( intvec a,
intvec b 
)

Definition at line 805 of file intvec.cc.

806 {
807  int ac=a->cols();
808  int c = ac + b->cols(); int r = si_max(a->rows(),b->rows());
809  intvec * ab = new intvec(r,c,0);
810 
811  int i,j;
812  for (i=1; i<=a->rows(); i++)
813  {
814  for(j=1; j<=ac; j++)
815  IMATELEM(*ab,i,j) = IMATELEM(*a,i,j);
816  }
817  for (i=1; i<=b->rows(); i++)
818  {
819  for(j=1; j<=b->cols(); j++)
820  IMATELEM(*ab,i,j+ac) = IMATELEM(*b,i,j);
821  }
822  return ab;
823 }
const poly a
Definition: syzextra.cc:212
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:14
int j
Definition: myNF.cc:70
static int si_max(const int a, const int b)
Definition: auxiliary.h:120
int i
Definition: cfEzgcd.cc:123
#define IMATELEM(M, I, J)
Definition: intvec.h:77
const poly b
Definition: syzextra.cc:213

◆ ivCopy()

intvec* ivCopy ( const intvec o)
inline

Definition at line 126 of file intvec.h.

127 {
128  if( o != NULL )
129  return new intvec(o);
130  return NULL;
131 }
Definition: intvec.h:14
#define NULL
Definition: omList.c:10

◆ ivMult()

intvec* ivMult ( intvec a,
intvec b 
)

Definition at line 332 of file intvec.cc.

333 {
334  int i, j, k, sum,
335  ra = a->rows(), ca = a->cols(),
336  rb = b->rows(), cb = b->cols();
337  intvec * iv;
338  if (ca != rb) return NULL;
339  iv = new intvec(ra, cb, 0);
340  for (i=0; i<ra; i++)
341  {
342  for (j=0; j<cb; j++)
343  {
344  sum = 0;
345  for (k=0; k<ca; k++)
346  sum += (*a)[i*ca+k]*(*b)[k*cb+j];
347  (*iv)[i*cb+j] = sum;
348  }
349  }
350  return iv;
351 }
const poly a
Definition: syzextra.cc:212
int k
Definition: cfEzgcd.cc:93
Definition: intvec.h:14
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
const poly b
Definition: syzextra.cc:213

◆ ivSolveKern()

intvec* ivSolveKern ( intvec imat,
int  ready 
)

Definition at line 425 of file intvec.cc.

426 {
427  int d=imat->cols();
428  int kdim=d-dimtr;
429  intvec *perm = new intvec(dimtr+1);
430  intvec *kern = new intvec(kdim,d,0);
431  intvec *res;
432  int c, cp, r, t;
433 
434  t = kdim;
435  c = 1;
436  for (r=1;r<=dimtr;r++)
437  {
438  while (IMATELEM(*imat,r,c)==0) c++;
439  (*perm)[r] = c;
440  c++;
441  }
442  c = d;
443  for (r=dimtr;r>0;r--)
444  {
445  cp = (*perm)[r];
446  if (cp!=c)
447  {
448  ivKernFromRow(kern, imat, perm, t, r, c);
449  t -= (c-cp);
450  if (t==0)
451  break;
452  c = cp-1;
453  }
454  else
455  c--;
456  }
457  if (kdim>1)
458  res = ivOptimizeKern(kern);
459  else
460  res = ivTranp(kern);
461  delete kern;
462  delete perm;
463  return res;
464 }
static intvec * ivOptimizeKern(intvec *)
Definition: intvec.cc:652
intvec * ivTranp(intvec *o)
Definition: intvec.cc:310
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:14
static void ivKernFromRow(intvec *, intvec *, intvec *, int, int, int)
Definition: intvec.cc:596
int cols() const
Definition: intvec.h:87
#define IMATELEM(M, I, J)
Definition: intvec.h:77

◆ ivSub()

intvec* ivSub ( intvec a,
intvec b 
)

Definition at line 280 of file intvec.cc.

281 {
282  intvec * iv;
283  int mn, ma, i;
284  if (a->cols() != b->cols()) return NULL;
285  mn = si_min(a->rows(),b->rows());
286  ma = si_max(a->rows(),b->rows());
287  if (a->cols() == 1)
288  {
289  iv = new intvec(ma);
290  for (i=0; i<mn; i++) (*iv)[i] = (*a)[i] - (*b)[i];
291  if (ma > mn)
292  {
293  if (ma == a->rows())
294  {
295  for(i=mn; i<ma; i++) (*iv)[i] = (*a)[i];
296  }
297  else
298  {
299  for(i=mn; i<ma; i++) (*iv)[i] = -(*b)[i];
300  }
301  }
302  return iv;
303  }
304  if (mn != ma) return NULL;
305  iv = new intvec(a);
306  for (i=0; i<mn*a->cols(); i++) { (*iv)[i] -= (*b)[i]; }
307  return iv;
308 }
const poly a
Definition: syzextra.cc:212
static int si_min(const int a, const int b)
Definition: auxiliary.h:121
Definition: intvec.h:14
static int si_max(const int a, const int b)
Definition: auxiliary.h:120
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
const poly b
Definition: syzextra.cc:213

◆ ivTrace()

int ivTrace ( intvec o)

Definition at line 322 of file intvec.cc.

323 {
324  int i, s = 0, m = si_min(o->rows(),o->cols()), c = o->cols();
325  for (i=0; i<m; i++)
326  {
327  s += (*o)[i*c+i];
328  }
329  return s;
330 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
static int si_min(const int a, const int b)
Definition: auxiliary.h:121
int rows() const
Definition: intvec.h:88
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: intvec.h:87

◆ ivTranp()

intvec* ivTranp ( intvec o)

Definition at line 310 of file intvec.cc.

311 {
312  int i, j, r = o->rows(), c = o->cols();
313  intvec * iv= new intvec(c, r, 0);
314  for (i=0; i<r; i++)
315  {
316  for (j=0; j<c; j++)
317  (*iv)[j*r+i] = (*o)[i*c+j];
318  }
319  return iv;
320 }
int rows() const
Definition: intvec.h:88
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:14
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: intvec.h:87

◆ ivTriangIntern()

void ivTriangIntern ( intvec imat,
int &  ready,
int &  all 
)

Definition at line 387 of file intvec.cc.

388 {
389  int rpiv, colpos=0, rowpos=0;
390  int ia=ready, ie=all;
391 
392  do
393  {
394  rowpos++;
395  do
396  {
397  colpos++;
398  rpiv = ivColPivot(imat, colpos, rowpos, ia, ie);
399  } while (rpiv==0);
400  if (rpiv>ia)
401  {
402  if (rowpos!=rpiv)
403  {
404  ivSaveRow(imat, rpiv);
405  ivFreeRow(imat, rowpos, rpiv);
406  ivSetRow(imat, rowpos, colpos);
407  rpiv = rowpos;
408  }
409  ia++;
410  if (ia==imat->cols())
411  {
412  ready = ia;
413  all = ie;
414  return;
415  }
416  }
417  ivReduce(imat, rpiv, colpos, ia, ie);
418  ivZeroElim(imat, colpos, ia, ie);
419  } while (ie>ia);
420  ready = ia;
421  all = ie;
422 }
static void ivZeroElim(intvec *, int, int, int &)
Definition: intvec.cc:547
static void ivFreeRow(intvec *, int, int)
Definition: intvec.cc:505
static void ivSaveRow(intvec *, int)
Definition: intvec.cc:488
static int ivColPivot(intvec *, int, int, int, int)
Definition: intvec.cc:467
static void ivReduce(intvec *, int, int, int, int)
Definition: intvec.cc:516
static void ivSetRow(intvec *, int, int)
Definition: intvec.cc:496
int cols() const
Definition: intvec.h:87