Loading...
Searching...
No Matches
intvec.h File Reference
`#include <string.h>`
`#include "misc/auxiliary.h"`
`#include "omalloc/omalloc.h"`
`#include "omalloc/omallocClass.h"`
`#include "coeffs/bigintmat.h"`
`#include "reporter/reporter.h"`

Go to the source code of this file.

## Data Structures

class | intvec

## Macros

#define | IMATELEM(M, I, J)
#define | ivTest(v)

## Functions

intvec * | ivCopy (const intvec *o)
intvec * | ivAdd (intvec *a, intvec *b)
intvec * | ivAddShift (intvec *a, intvec *b, int s)
intvec * | ivSub (intvec *a, intvec *b)
intvec * | ivTranp (intvec *o)
int | ivTrace (intvec *o)
intvec * | ivMult (intvec *a, intvec *b)
void | ivTriangIntern (intvec *imat, int &ready, int &all)
intvec * | ivSolveKern (intvec *imat, int ready)
intvec * | ivConcat (intvec *a, intvec *b)
bigintmat * | iv2biv (intvec *hilb, const coeffs cf)

## Macro Definition Documentation

## IMATELEM

#define IMATELEM | ( |  | M,
|  |  | I,
|  |  | J )

Value:
(M)[(I-1)*(M).cols()+J-1]
M
#define M
Definition sirandom.c:25

Definition at line 86 of file intvec.h.

## ivTest

#define ivTest | ( |  | v | ) |

Value:
do {} while (0)

Definition at line 172 of file intvec.h.

## Function Documentation

## iv2biv()

bigintmat * iv2biv | ( | intvec * | hilb,
|  | const coeffs | cf )

Definition at line 851 of file intvec.cc.

{
bigintmat *hh=NULL;
if (hilb!=NULL)
{
int l=hilb->rows();
hh=new bigintmat(1,l,cf);
for(int i=0;i<l;i++)
{
number tp = n_Init((*hilb)[i], cf);
n_Delete(&BIMATELEM((*hh),1,i+1), cf);
BIMATELEM((*hh),1,i+1)=tp;
}
}
return hh;
}
BIMATELEM
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133
l
int l
Definition cfEzgcd.cc:100
i
int i
Definition cfEzgcd.cc:132
cf
CanonicalForm cf
Definition cfModGcd.cc:4091
bigintmat
Matrices of numbers.
Definition bigintmat.h:51
intvec::rows
int rows() const
Definition intvec.h:97
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:461
n_Init
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition coeffs.h:541
NULL
#define NULL
Definition omList.c:12

## ivAdd()

intvec * ivAdd | ( | intvec * | a,
|  | intvec * | b )

Definition at line 249 of file intvec.cc.

{
intvec * iv;
int mn, ma, i;
if (a->cols() != b->cols()) return NULL;
mn = si_min(a->rows(),b->rows());
ma = si_max(a->rows(),b->rows());
if (a->cols() == 1)
{
iv = new intvec(ma);
for (i=0; i<mn; i++) (*iv)[i] = (*a)[i] + (*b)[i];
if (ma > mn)
{
if (ma == a->rows())
{
for(i=mn; i<ma; i++) (*iv)[i] = (*a)[i];
}
else
{
for(i=mn; i<ma; i++) (*iv)[i] = (*b)[i];
}
}
return iv;
}
if (mn != ma) return NULL;
iv = new intvec(a);
for (i=0; i<mn*a->cols(); i++) { (*iv)[i] += (*b)[i]; }
return iv;
}
si_max
static int si_max(const int a, const int b)
Definition auxiliary.h:125
si_min
static int si_min(const int a, const int b)
Definition auxiliary.h:126
b
CanonicalForm b
Definition cfModGcd.cc:4111
intvec
Definition intvec.h:24
intvec::cols
int cols() const
Definition intvec.h:96

## ivAddShift()

intvec * ivAddShift | ( | intvec * | a,
|  | intvec * | b,
|  | int | s )

Definition at line 279 of file intvec.cc.

{
if (a->cols() != b->cols()) return NULL;
if (a->cols() == 1)
{
int i;
intvec * iv;
int ma = si_max(a->rows(),b->rows()+s);
iv=new intvec(ma);
for (i=a->rows()-1;i>=0;i--)
(*iv)[i] = (*a)[i];
for(i=b->rows()+s-1;i>=s;i--)
(*iv)[i] += (*b)[i-s];
return iv;
}
return NULL;
}
s
const CanonicalForm int s
Definition facAbsFact.cc:51

## ivConcat()

intvec * ivConcat | ( | intvec * | a,
|  | intvec * | b )

Definition at line 822 of file intvec.cc.

{
int ac=a->cols();
int c = ac + b->cols(); int r = si_max(a->rows(),b->rows());
intvec * ab = new intvec(r,c,0);
int i,j;
for (i=1; i<=a->rows(); i++)
{
for(j=1; j<=ac; j++)
IMATELEM(*ab,i,j) = IMATELEM(*a,i,j);
}
for (i=1; i<=b->rows(); i++)
{
for(j=1; j<=b->cols(); j++)
IMATELEM(*ab,i,j+ac) = IMATELEM(*b,i,j);
}
return ab;
}
j
int j
Definition facHensel.cc:110
IMATELEM
#define IMATELEM(M, I, J)
Definition intvec.h:86

## ivCopy()

intvec * ivCopy | ( | const intvec * | o | ) |

inline

Definition at line 146 of file intvec.h.

{
if( o != NULL )
return new intvec(o);
return NULL;
}

## ivMult()

intvec * ivMult | ( | intvec * | a,
|  | intvec * | b )

Definition at line 349 of file intvec.cc.

{
int i, j, k, sum,
ra = a->rows(), ca = a->cols(),
rb = b->rows(), cb = b->cols();
intvec * iv;
if (ca != rb) return NULL;
iv = new intvec(ra, cb, 0);
for (i=0; i<ra; i++)
{
for (j=0; j<cb; j++)
{
sum = 0;
for (k=0; k<ca; k++)
sum += (*a)[i*ca+k]*(*b)[k*cb+j];
(*iv)[i*cb+j] = sum;
}
}
return iv;
}
k
int k
Definition cfEzgcd.cc:99

## ivSolveKern()

intvec * ivSolveKern | ( | intvec * | imat,
|  | int | ready )

Definition at line 442 of file intvec.cc.

{
int d=imat->cols();
int kdim=d-dimtr;
intvec *perm = new intvec(dimtr+1);
intvec *kern = new intvec(kdim,d,0);
intvec *res;
int c, cp, r, t;
t = kdim;
c = 1;
for (r=1;r<=dimtr;r++)
{
while (IMATELEM(*imat,r,c)==0) c++;
(*perm)[r] = c;
c++;
}
c = d;
for (r=dimtr;r>0;r--)
{
cp = (*perm)[r];
if (cp!=c)
{
ivKernFromRow(kern, imat, perm, t, r, c);
t -= (c-cp);
if (t==0)
break;
c = cp-1;
}
else
c--;
}
if (kdim>1)
res = ivOptimizeKern(kern);
else
res = ivTranp(kern);
delete kern;
delete perm;
return res;
}
res
CanonicalForm res
Definition facAbsFact.cc:60
ivOptimizeKern
static intvec * ivOptimizeKern(intvec *)
Definition intvec.cc:669
ivKernFromRow
static void ivKernFromRow(intvec *, intvec *, intvec *, int, int, int)
Definition intvec.cc:613
ivTranp
intvec * ivTranp(intvec *o)
Definition intvec.cc:327

## ivSub()

intvec * ivSub | ( | intvec * | a,
|  | intvec * | b )

Definition at line 297 of file intvec.cc.

{
intvec * iv;
int mn, ma, i;
if (a->cols() != b->cols()) return NULL;
mn = si_min(a->rows(),b->rows());
ma = si_max(a->rows(),b->rows());
if (a->cols() == 1)
{
iv = new intvec(ma);
for (i=0; i<mn; i++) (*iv)[i] = (*a)[i] - (*b)[i];
if (ma > mn)
{
if (ma == a->rows())
{
for(i=mn; i<ma; i++) (*iv)[i] = (*a)[i];
}
else
{
for(i=mn; i<ma; i++) (*iv)[i] = -(*b)[i];
}
}
return iv;
}
if (mn != ma) return NULL;
iv = new intvec(a);
for (i=0; i<mn*a->cols(); i++) { (*iv)[i] -= (*b)[i]; }
return iv;
}

## ivTrace()

int ivTrace | ( | intvec * | o | ) |

Definition at line 339 of file intvec.cc.

{
int i, s = 0, m = si_min(o->rows(),o->cols()), c = o->cols();
for (i=0; i<m; i++)
{
s += (*o)[i*c+i];
}
return s;
}
m
int m
Definition cfEzgcd.cc:128

## ivTranp()

intvec * ivTranp | ( | intvec * | o | ) |

Definition at line 327 of file intvec.cc.

{
int i, j, r = o->rows(), c = o->cols();
intvec * iv= new intvec(c, r, 0);
for (i=0; i<r; i++)
{
for (j=0; j<c; j++)
(*iv)[j*r+i] = (*o)[i*c+j];
}
return iv;
}

## ivTriangIntern()

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

Definition at line 404 of file intvec.cc.

{
int rpiv, colpos=0, rowpos=0;
int ia=ready, ie=all;
do
{
rowpos++;
do
{
colpos++;
rpiv = ivColPivot(imat, colpos, rowpos, ia, ie);
} while (rpiv==0);
if (rpiv>ia)
{
if (rowpos!=rpiv)
{
ivSaveRow(imat, rpiv);
ivFreeRow(imat, rowpos, rpiv);
ivSetRow(imat, rowpos, colpos);
rpiv = rowpos;
}
ia++;
if (ia==imat->cols())
{
ready = ia;
all = ie;
return;
}
}
ivReduce(imat, rpiv, colpos, ia, ie);
ivZeroElim(imat, colpos, ia, ie);
} while (ie>ia);
ready = ia;
all = ie;
}
ivColPivot
static int ivColPivot(intvec *, int, int, int, int)
Definition intvec.cc:484
ivSetRow
static void ivSetRow(intvec *, int, int)
Definition intvec.cc:513
ivFreeRow
static void ivFreeRow(intvec *, int, int)
Definition intvec.cc:522
ivZeroElim
static void ivZeroElim(intvec *, int, int, int &)
Definition intvec.cc:564
ivSaveRow
static void ivSaveRow(intvec *, int)
Definition intvec.cc:505
ivReduce
static void ivReduce(intvec *, int, int, int, int)
Definition intvec.cc:533