Data Structures | Macros | Functions
intvec.h File Reference
#include <string.h>
#include <omalloc/omalloc.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

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

Definition at line 77 of file intvec.h.

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

Definition at line 161 of file intvec.h.

Function Documentation

intvec* ivAdd ( intvec a,
intvec b 
)

Definition at line 276 of file intvec.cc.

277 {
278  intvec * iv;
279  int mn, ma, i;
280  if (a->cols() != b->cols()) return NULL;
281  mn = si_min(a->rows(),b->rows());
282  ma = si_max(a->rows(),b->rows());
283  if (a->cols() == 1)
284  {
285  iv = new intvec(ma);
286  for (i=0; i<mn; i++) (*iv)[i] = (*a)[i] + (*b)[i];
287  if (ma > mn)
288  {
289  if (ma == a->rows())
290  {
291  for(i=mn; i<ma; i++) (*iv)[i] = (*a)[i];
292  }
293  else
294  {
295  for(i=mn; i<ma; i++) (*iv)[i] = (*b)[i];
296  }
297  }
298  return iv;
299  }
300  if (mn != ma) return NULL;
301  iv = new intvec(a);
302  for (i=0; i<mn*a->cols(); i++) { (*iv)[i] += (*b)[i]; }
303  return iv;
304 }
static int si_min(const int a, const int b)
Definition: auxiliary.h:167
Definition: intvec.h:16
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
int cols() const
Definition: intvec.h:87
int rows() const
Definition: intvec.h:88
intvec* ivConcat ( intvec a,
intvec b 
)

Definition at line 831 of file intvec.cc.

832 {
833  int ac=a->cols();
834  int c = ac + b->cols(); int r = si_max(a->rows(),b->rows());
835  intvec * ab = new intvec(r,c,0);
836 
837  int i,j;
838  for (i=1; i<=a->rows(); i++)
839  {
840  for(j=1; j<=ac; j++)
841  IMATELEM(*ab,i,j) = IMATELEM(*a,i,j);
842  }
843  for (i=1; i<=b->rows(); i++)
844  {
845  for(j=1; j<=b->cols(); j++)
846  IMATELEM(*ab,i,j+ac) = IMATELEM(*b,i,j);
847  }
848  return ab;
849 }
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:16
int j
Definition: myNF.cc:70
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: intvec.h:87
int rows() const
Definition: intvec.h:88
#define IMATELEM(M, I, J)
Definition: intvec.h:77
intvec* ivCopy ( const intvec o)
inline

Definition at line 137 of file intvec.h.

138 {
139  if( o != NULL )
140  return new intvec(o);
141 
142  return NULL;
143 }
Definition: intvec.h:16
#define NULL
Definition: omList.c:10
intvec* ivMult ( intvec a,
intvec b 
)

Definition at line 358 of file intvec.cc.

359 {
360  int i, j, k, sum,
361  ra = a->rows(), ca = a->cols(),
362  rb = b->rows(), cb = b->cols();
363  intvec * iv;
364  if (ca != rb) return NULL;
365  iv = new intvec(ra, cb, 0);
366  for (i=0; i<ra; i++)
367  {
368  for (j=0; j<cb; j++)
369  {
370  sum = 0;
371  for (k=0; k<ca; k++)
372  sum += (*a)[i*ca+k]*(*b)[k*cb+j];
373  (*iv)[i*cb+j] = sum;
374  }
375  }
376  return iv;
377 }
int k
Definition: cfEzgcd.cc:93
Definition: intvec.h:16
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
int cols() const
Definition: intvec.h:87
int rows() const
Definition: intvec.h:88
intvec* ivSolveKern ( intvec imat,
int  ready 
)

Definition at line 451 of file intvec.cc.

452 {
453  int d=imat->cols();
454  int kdim=d-dimtr;
455  intvec *perm = new intvec(dimtr+1);
456  intvec *kern = new intvec(kdim,d,0);
457  intvec *res;
458  int c, cp, r, t;
459 
460  t = kdim;
461  c = 1;
462  for (r=1;r<=dimtr;r++)
463  {
464  while (IMATELEM(*imat,r,c)==0) c++;
465  (*perm)[r] = c;
466  c++;
467  }
468  c = d;
469  for (r=dimtr;r>0;r--)
470  {
471  cp = (*perm)[r];
472  if (cp!=c)
473  {
474  ivKernFromRow(kern, imat, perm, t, r, c);
475  t -= (c-cp);
476  if (t==0)
477  break;
478  c = cp-1;
479  }
480  else
481  c--;
482  }
483  if (kdim>1)
484  res = ivOptimizeKern(kern);
485  else
486  res = ivTranp(kern);
487  delete kern;
488  delete perm;
489  return res;
490 }
static intvec * ivOptimizeKern(intvec *)
Definition: intvec.cc:678
intvec * ivTranp(intvec *o)
Definition: intvec.cc:336
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:16
int cols() const
Definition: intvec.h:87
static void ivKernFromRow(intvec *, intvec *, intvec *, int, int, int)
Definition: intvec.cc:622
int perm[100]
#define IMATELEM(M, I, J)
Definition: intvec.h:77
intvec* ivSub ( intvec a,
intvec b 
)

Definition at line 306 of file intvec.cc.

307 {
308  intvec * iv;
309  int mn, ma, i;
310  if (a->cols() != b->cols()) return NULL;
311  mn = si_min(a->rows(),b->rows());
312  ma = si_max(a->rows(),b->rows());
313  if (a->cols() == 1)
314  {
315  iv = new intvec(ma);
316  for (i=0; i<mn; i++) (*iv)[i] = (*a)[i] - (*b)[i];
317  if (ma > mn)
318  {
319  if (ma == a->rows())
320  {
321  for(i=mn; i<ma; i++) (*iv)[i] = (*a)[i];
322  }
323  else
324  {
325  for(i=mn; i<ma; i++) (*iv)[i] = -(*b)[i];
326  }
327  }
328  return iv;
329  }
330  if (mn != ma) return NULL;
331  iv = new intvec(a);
332  for (i=0; i<mn*a->cols(); i++) { (*iv)[i] -= (*b)[i]; }
333  return iv;
334 }
static int si_min(const int a, const int b)
Definition: auxiliary.h:167
Definition: intvec.h:16
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
int cols() const
Definition: intvec.h:87
int rows() const
Definition: intvec.h:88
int ivTrace ( intvec o)

Definition at line 348 of file intvec.cc.

349 {
350  int i, s = 0, m = si_min(o->rows(),o->cols()), c = o->cols();
351  for (i=0; i<m; i++)
352  {
353  s += (*o)[i*c+i];
354  }
355  return s;
356 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
static int si_min(const int a, const int b)
Definition: auxiliary.h:167
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: intvec.h:87
int rows() const
Definition: intvec.h:88
intvec* ivTranp ( intvec o)

Definition at line 336 of file intvec.cc.

337 {
338  int i, j, r = o->rows(), c = o->cols();
339  intvec * iv= new intvec(c, r, 0);
340  for (i=0; i<r; i++)
341  {
342  for (j=0; j<c; j++)
343  (*iv)[j*r+i] = (*o)[i*c+j];
344  }
345  return iv;
346 }
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:16
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: intvec.h:87
int rows() const
Definition: intvec.h:88
void ivTriangIntern ( intvec imat,
int &  ready,
int &  all 
)

Definition at line 413 of file intvec.cc.

414 {
415  int rpiv, colpos=0, rowpos=0;
416  int ia=ready, ie=all;
417 
418  do
419  {
420  rowpos++;
421  do
422  {
423  colpos++;
424  rpiv = ivColPivot(imat, colpos, rowpos, ia, ie);
425  } while (rpiv==0);
426  if (rpiv>ia)
427  {
428  if (rowpos!=rpiv)
429  {
430  ivSaveRow(imat, rpiv);
431  ivFreeRow(imat, rowpos, rpiv);
432  ivSetRow(imat, rowpos, colpos);
433  rpiv = rowpos;
434  }
435  ia++;
436  if (ia==imat->cols())
437  {
438  ready = ia;
439  all = ie;
440  return;
441  }
442  }
443  ivReduce(imat, rpiv, colpos, ia, ie);
444  ivZeroElim(imat, colpos, ia, ie);
445  } while (ie>ia);
446  ready = ia;
447  all = ie;
448 }
static void ivZeroElim(intvec *, int, int, int &)
Definition: intvec.cc:573
static void ivFreeRow(intvec *, int, int)
Definition: intvec.cc:531
static void ivSaveRow(intvec *, int)
Definition: intvec.cc:514
static int ivColPivot(intvec *, int, int, int, int)
Definition: intvec.cc:493
static void ivReduce(intvec *, int, int, int, int)
Definition: intvec.cc:542
static void ivSetRow(intvec *, int, int)
Definition: intvec.cc:522
int cols() const
Definition: intvec.h:87