My Project
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 1505 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 1511 of file tgb_internal.h.

1512  {
1513  this->ncols=nncols;
1514  this->nrows=nnrows;
1515  rows=(number_type**) omalloc((size_t)nnrows*sizeof(number_type*));
1516  startIndices=(int*)omalloc((size_t)nnrows*sizeof(int));
1517  int i;
1518  for(i=0;i<nnrows;i++)
1519  {
1520  rows[i]=array+((long)i*(long)nncols);
1521  updateStartIndex(i,-1);
1522  }
1523  }
int i
Definition: cfEzgcd.cc:132
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 1524 of file tgb_internal.h.

1525  {
1526  omfree(rows);
1528  }
#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 1661 of file tgb_internal.h.

1662 {
1663  //row>=r, col>=c
1664 
1665  while(c<ncols)
1666  {
1667  int i;
1668  for(i=r;i<nrows;i++)
1669  {
1670  assume(startIndices[i]>=c);
1671  if (startIndices[i]==c)
1672  {
1673  //r=i;
1674  if (r!=i)
1675  permRows(r,i);
1676  return TRUE;
1677  }
1678  }
1679  c++;
1680  }
1681  return FALSE;
1682 }
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
void permRows(int i, int j)
#define assume(x)
Definition: mod2.h:387

◆ getStartIndex()

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

Definition at line 1657 of file tgb_internal.h.

1658 {
1659  return startIndices[row];
1660 }

◆ multiplyRow()

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

Definition at line 1539 of file tgb_internal.h.

1540  {
1541  int i;
1542  number_type* row_array=rows[row];
1543  if(currRing->cf->ch<=NV_MAX_PRIME)
1544  {
1545  for(i=startIndices[row];i<ncols;i++)
1546  {
1547  row_array[i]=F4mat_to_number_type(npMult((number)(long) row_array[i],(number)(long) coef,currRing->cf));
1548  }
1549  }
1550  else
1551  {
1552  for(i=startIndices[row];i<ncols;i++)
1553  {
1554  row_array[i]=F4mat_to_number_type(nvMult((number)(long) row_array[i],(number)(long) coef,currRing->cf));
1555  }
1556  }
1557  }
#define NV_MAX_PRIME
Definition: modulop.h:37
static number nvMult(number a, number b, const coeffs r)
Definition: modulop_inl.h:50
static number npMult(number a, number b, const coeffs r)
Definition: modulop_inl.h:12
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
#define F4mat_to_number_type(a)
Definition: tgb_internal.h:414

◆ permRows()

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

Definition at line 1530 of file tgb_internal.h.

1531  {
1532  number_type* h=rows[i];
1533  rows[i]=rows[j];
1534  rows[j]=h;
1535  int hs=startIndices[i];
1537  startIndices[j]=hs;
1538  }
int j
Definition: facHensel.cc:110
STATIC_VAR Poly * h
Definition: janet.cc:971

◆ reduceOtherRowsForward()

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

Definition at line 1558 of file tgb_internal.h.

1559  {
1560  //assume rows "under r" have bigger or equal start index
1561  number_type* row_array=rows[r];
1562  number_type zero=F4mat_to_number_type((number)0 /*npInit(0, currRing)*/);
1563  int start=startIndices[r];
1564  number_type coef=row_array[start];
1565  assume(start<ncols);
1566  int other_row;
1567  assume(!(npIsZero((number)(long) row_array[start],currRing->cf)));
1568  if (!(npIsOne((number)(long) coef,currRing->cf)))
1569  multiplyRow(r,F4mat_to_number_type(npInversM((number)(long) coef,currRing->cf)));
1570  assume(npIsOne((number)(long) row_array[start],currRing->cf));
1571  int lastIndex=modP_lastIndexRow(row_array, ncols);
1572  number minus_one=npInit(-1, currRing->cf);
1573  if(currRing->cf->ch<=NV_MAX_PRIME)
1574  {
1575  for (other_row=r+1;other_row<nrows;other_row++)
1576  {
1577  assume(startIndices[other_row]>=start);
1578  if (startIndices[other_row]==start)
1579  {
1580  int i;
1581  number_type* other_row_array=rows[other_row];
1582  number coef2=npNegM((number)(long) other_row_array[start],currRing->cf);
1583  if (coef2==minus_one)
1584  {
1585  for(i=start;i<=lastIndex;i++)
1586  {
1587  if (row_array[i]!=zero)
1588  {
1589  other_row_array[i]=F4mat_to_number_type(npSubM((number)(long) other_row_array[i], (number)(long) row_array[i],currRing->cf));
1590  }
1591  }
1592  }
1593  else
1594  {
1595  for(i=start;i<=lastIndex;i++)
1596  {
1597  if (row_array[i]!=zero)
1598  {
1599  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));
1600  }
1601  }
1602  }
1603  updateStartIndex(other_row,start);
1604  assume(npIsZero((number)(long) other_row_array[start],currRing->cf));
1605  }
1606  }
1607  }
1608  else /* ch>NV_MAX_PRIME*/
1609  {
1610  for (other_row=r+1;other_row<nrows;other_row++)
1611  {
1612  assume(startIndices[other_row]>=start);
1613  if (startIndices[other_row]==start)
1614  {
1615  int i;
1616  number_type* other_row_array=rows[other_row];
1617  number coef2=npNegM((number)(long) other_row_array[start],currRing->cf);
1618  if (coef2==minus_one)
1619  {
1620  for(i=start;i<=lastIndex;i++)
1621  {
1622  if (row_array[i]!=zero)
1623  {
1624  other_row_array[i]=F4mat_to_number_type(npSubM((number)(long) other_row_array[i], (number)(long) row_array[i],currRing->cf));
1625  }
1626  }
1627  }
1628  else
1629  {
1630  for(i=start;i<=lastIndex;i++)
1631  {
1632  if (row_array[i]!=zero)
1633  {
1634  other_row_array[i]=F4mat_to_number_type(npAddM(nvMult(coef2,(number)(long) row_array[i],currRing->cf),(number)(long) other_row_array[i],currRing->cf));
1635  }
1636  }
1637  }
1638  updateStartIndex(other_row,start);
1639  assume(npIsZero((number)(long) other_row_array[start],currRing->cf));
1640  }
1641  }
1642  }
1643 }
void multiplyRow(int row, number_type coef)
static BOOLEAN npIsOne(number a, const coeffs)
Definition: modulop.h:179
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:124
static number npNegM(number a, const coeffs r)
Definition: modulop.h:174
static number npInversM(number c, const coeffs r)
Definition: modulop.h:223
static number npSubM(number a, number b, const coeffs r)
Definition: modulop.h:134
static number npInit(long i, const coeffs r)
Definition: modulop_inl.h:27
static BOOLEAN npIsZero(number a, const coeffs r)
Definition: modulop_inl.h:38
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 1644 of file tgb_internal.h.

1645 {
1646  number_type* row_array=rows[row];
1647  assume((lower_bound<0)||(npIsZero((number)(long) row_array[lower_bound],currRing->cf)));
1648  int i;
1649  //number_type zero=npInit(0);
1650  for(i=lower_bound+1;i<ncols;i++)
1651  {
1652  if (!(row_array[i]==0))
1653  break;
1654  }
1655  startIndices[row]=i;
1656 }

Friends And Related Function Documentation

◆ ModPMatrixBackSubstProxyOnArray< number_type >

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

Definition at line 1174 of file tgb_internal.h.

Field Documentation

◆ ncols

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

Definition at line 1510 of file tgb_internal.h.

◆ nrows

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

Definition at line 1510 of file tgb_internal.h.

◆ rows

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

Definition at line 1684 of file tgb_internal.h.

◆ startIndices

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

Definition at line 1685 of file tgb_internal.h.


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