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 1506 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 1512 of file tgb_internal.h.

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

1526 {
1527 omfree(rows);
1529 }
#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 1662 of file tgb_internal.h.

1663{
1664 //row>=r, col>=c
1665
1666 while(c<ncols)
1667 {
1668 int i;
1669 for(i=r;i<nrows;i++)
1670 {
1671 assume(startIndices[i]>=c);
1672 if (startIndices[i]==c)
1673 {
1674 //r=i;
1675 if (r!=i)
1676 permRows(r,i);
1677 return TRUE;
1678 }
1679 }
1680 c++;
1681 }
1682 return FALSE;
1683}
#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 1658 of file tgb_internal.h.

1659{
1660 return startIndices[row];
1661}

◆ multiplyRow()

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

Definition at line 1540 of file tgb_internal.h.

1541 {
1542 int i;
1543 number_type* row_array=rows[row];
1544 if(currRing->cf->ch<=NV_MAX_PRIME)
1545 {
1546 for(i=startIndices[row];i<ncols;i++)
1547 {
1548 row_array[i]=F4mat_to_number_type(npMult((number)(long) row_array[i],(number)(long) coef,currRing->cf));
1549 }
1550 }
1551 else
1552 {
1553 for(i=startIndices[row];i<ncols;i++)
1554 {
1555 row_array[i]=F4mat_to_number_type(nvMult((number)(long) row_array[i],(number)(long) coef,currRing->cf));
1556 }
1557 }
1558 }
#define NV_MAX_PRIME
Definition: modulop.h:29
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 1531 of file tgb_internal.h.

1532 {
1533 number_type* h=rows[i];
1534 rows[i]=rows[j];
1535 rows[j]=h;
1536 int hs=startIndices[i];
1538 startIndices[j]=hs;
1539 }
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 1559 of file tgb_internal.h.

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

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

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

◆ nrows

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

Definition at line 1511 of file tgb_internal.h.

◆ rows

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

Definition at line 1685 of file tgb_internal.h.

◆ startIndices

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

Definition at line 1686 of file tgb_internal.h.


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