My Project  UNKNOWN_GIT_VERSION
Public Member Functions | Data Fields | Protected Attributes | Friends
ModPMatrixProxyOnArray< number_type > Class Template Reference

#include <tgb_internal.h>

Public Member Functions

 ModPMatrixProxyOnArray (number_type *array, int nnrows, int nncols)
 
 ~ModPMatrixProxyOnArray ()
 
void permRows (int i, int j)
 
void multiplyRow (int row, number_type coef)
 
void reduceOtherRowsForward (int r)
 
void updateStartIndex (int row, int lower_bound)
 
int getStartIndex (int row)
 
BOOLEAN findPivot (int &r, int &c)
 

Data Fields

int ncols
 
int nrows
 

Protected Attributes

number_type ** rows
 
int * startIndices
 

Friends

class ModPMatrixBackSubstProxyOnArray< number_type >
 

Detailed Description

template<class number_type>
class ModPMatrixProxyOnArray< number_type >

Definition at line 1522 of file tgb_internal.h.

Constructor & Destructor Documentation

◆ ModPMatrixProxyOnArray()

template<class number_type >
ModPMatrixProxyOnArray< number_type >::ModPMatrixProxyOnArray ( number_type *  array,
int  nnrows,
int  nncols 
)
inline

Definition at line 1528 of file tgb_internal.h.

1529  {
1530  this->ncols=nncols;
1531  this->nrows=nnrows;
1532  rows=(number_type**) omalloc((size_t)nnrows*sizeof(number_type*));
1533  startIndices=(int*)omalloc((size_t)nnrows*sizeof(int));
1534  int i;
1535  for(i=0;i<nnrows;i++)
1536  {
1537  rows[i]=array+((long)i*(long)nncols);
1538  updateStartIndex(i,-1);
1539  }
1540  }
int i
Definition: cfEzgcd.cc:125
void updateStartIndex(int row, int lower_bound)
#define omalloc(size)
Definition: omAllocDecl.h:228

◆ ~ModPMatrixProxyOnArray()

template<class number_type >
ModPMatrixProxyOnArray< number_type >::~ModPMatrixProxyOnArray ( )
inline

Definition at line 1541 of file tgb_internal.h.

1542  {
1543  omfree(rows);
1545  }
#define omfree(addr)
Definition: omAllocDecl.h:237

Member Function Documentation

◆ findPivot()

template<class number_type >
BOOLEAN ModPMatrixProxyOnArray< number_type >::findPivot ( int &  r,
int &  c 
)
inline

Definition at line 1633 of file tgb_internal.h.

1634  {
1635  //row>=r, col>=c
1636 
1637  while(c<ncols)
1638  {
1639  int i;
1640  for(i=r;i<nrows;i++)
1641  {
1642  assume(startIndices[i]>=c);
1643  if (startIndices[i]==c)
1644  {
1645  //r=i;
1646  if (r!=i)
1647  permRows(r,i);
1648  return TRUE;
1649  }
1650  }
1651  c++;
1652  }
1653  return FALSE;
1654  }
#define TRUE
Definition: auxiliary.h:98
#define FALSE
Definition: auxiliary.h:94
void permRows(int i, int j)
#define assume(x)
Definition: mod2.h:390

◆ getStartIndex()

template<class number_type >
int ModPMatrixProxyOnArray< number_type >::getStartIndex ( int  row)
inline

Definition at line 1629 of file tgb_internal.h.

1630  {
1631  return startIndices[row];
1632  }

◆ multiplyRow()

template<class number_type >
void ModPMatrixProxyOnArray< number_type >::multiplyRow ( int  row,
number_type  coef 
)
inline

Definition at line 1556 of file tgb_internal.h.

1557  {
1558  int i;
1559  number_type* row_array=rows[row];
1560  for(i=startIndices[row];i<ncols;i++)
1561  {
1562  row_array[i]=F4mat_to_number_type(npMult((number)(long) row_array[i],(number)(long) coef,currRing->cf));
1563  }
1564  }
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define npMult
Definition: tgb_internal.h:78
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:428

◆ permRows()

template<class number_type >
void ModPMatrixProxyOnArray< number_type >::permRows ( int  i,
int  j 
)
inline

Definition at line 1547 of file tgb_internal.h.

1548  {
1549  number_type* h=rows[i];
1550  rows[i]=rows[j];
1551  rows[j]=h;
1552  int hs=startIndices[i];
1554  startIndices[j]=hs;
1555  }
int j
Definition: facHensel.cc:105
static Poly * h
Definition: janet.cc:972

◆ reduceOtherRowsForward()

template<class number_type >
void ModPMatrixProxyOnArray< number_type >::reduceOtherRowsForward ( int  r)
inline

Definition at line 1565 of file tgb_internal.h.

1566  {
1567  //assume rows "under r" have bigger or equal start index
1568  number_type* row_array=rows[r];
1569  number_type zero=F4mat_to_number_type((number)0 /*npInit(0, currRing)*/);
1570  int start=startIndices[r];
1571  number_type coef=row_array[start];
1572  assume(start<ncols);
1573  int other_row;
1574  assume(!(npIsZero((number)(long) row_array[start],currRing->cf)));
1575  if (!(npIsOne((number)(long) coef,currRing->cf)))
1576  multiplyRow(r,F4mat_to_number_type(npInvers((number)(long) coef,currRing->cf)));
1577  assume(npIsOne((number)(long) row_array[start],currRing->cf));
1578  int lastIndex=modP_lastIndexRow(row_array, ncols);
1579  number minus_one=npInit(-1, currRing->cf);
1580  for (other_row=r+1;other_row<nrows;other_row++)
1581  {
1582  assume(startIndices[other_row]>=start);
1583  if (startIndices[other_row]==start)
1584  {
1585  int i;
1586  number_type* other_row_array=rows[other_row];
1587  number coef2=npNeg((number)(long) other_row_array[start],currRing->cf);
1588  if (coef2==minus_one)
1589  {
1590  for(i=start;i<=lastIndex;i++)
1591  {
1592  if (row_array[i]!=zero)
1593  { STATISTIC(n_Sub);
1594  other_row_array[i]=F4mat_to_number_type(npSubM((number)(long) other_row_array[i], (number)(long) row_array[i],currRing->cf));
1595  }
1596 
1597  }
1598  }
1599  else
1600  {
1601  //assume(FALSE);
1602  for(i=start;i<=lastIndex;i++)
1603  {
1604  if (row_array[i]!=zero)
1605  { STATISTIC(n_Add);
1606  other_row_array[i]=F4mat_to_number_type(npAddM(npMult(coef2,(number)(long) row_array[i],currRing->cf),(number)(long) other_row_array[i],currRing->cf));
1607  }
1608 
1609  }
1610  }
1611  updateStartIndex(other_row,start);
1612  assume(npIsZero((number)(long) other_row_array[start],currRing->cf));
1613  }
1614  }
1615  }
void multiplyRow(int row, number_type coef)
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition: coeffs.h:656
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition: coeffs.h:669
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:125
static number npSubM(number a, number b, const coeffs r)
Definition: modulop.h:135
#define STATISTIC(f)
Definition: numstats.h:16
#define npIsZero
Definition: tgb_internal.h:76
#define npNeg
Definition: tgb_internal.h:73
#define npInvers
Definition: tgb_internal.h:74
#define npInit
Definition: tgb_internal.h:72
#define npIsOne
Definition: tgb_internal.h:75
int modP_lastIndexRow(number_type *row, int ncols)

◆ updateStartIndex()

template<class number_type >
void ModPMatrixProxyOnArray< number_type >::updateStartIndex ( int  row,
int  lower_bound 
)
inline

Definition at line 1616 of file tgb_internal.h.

1617  {
1618  number_type* row_array=rows[row];
1619  assume((lower_bound<0)||(npIsZero((number)(long) row_array[lower_bound],currRing->cf)));
1620  int i;
1621  //number_type zero=npInit(0);
1622  for(i=lower_bound+1;i<ncols;i++)
1623  {
1624  if (!(row_array[i]==0))
1625  break;
1626  }
1627  startIndices[row]=i;
1628  }

Friends And Related Function Documentation

◆ ModPMatrixBackSubstProxyOnArray< number_type >

template<class number_type >
friend class ModPMatrixBackSubstProxyOnArray< number_type >
friend

Definition at line 1190 of file tgb_internal.h.

Field Documentation

◆ ncols

template<class number_type >
int ModPMatrixProxyOnArray< number_type >::ncols

Definition at line 1527 of file tgb_internal.h.

◆ nrows

template<class number_type >
int ModPMatrixProxyOnArray< number_type >::nrows

Definition at line 1527 of file tgb_internal.h.

◆ rows

template<class number_type >
number_type** ModPMatrixProxyOnArray< number_type >::rows
protected

Definition at line 1656 of file tgb_internal.h.

◆ startIndices

template<class number_type >
int* ModPMatrixProxyOnArray< number_type >::startIndices
protected

Definition at line 1657 of file tgb_internal.h.


The documentation for this class was generated from the following file: