Loading...
Searching...
No Matches
tgb_sparse_matrix Class Reference

`#include <tgbgauss.h>`

## Public Member Functions

void | sort_rows ()
| tgb_sparse_matrix (int i, int j, ring rarg)
| ~tgb_sparse_matrix ()
int | get_rows ()
int | get_columns ()
void | print ()
void | row_normalize (int row)
void | row_content (int row)
void | perm_rows (int i, int j)
void | set (int i, int j, number n)
number | get (int i, int j)
BOOLEAN | is_zero_entry (int i, int j)
void | free_row (int row, BOOLEAN free_non_zeros=TRUE)
int | min_col_not_zero_in_row (int row)
int | next_col_not_zero (int row, int pre)
BOOLEAN | zero_row (int row)
void | mult_row (int row, number factor)
void | add_lambda_times_row (int add_to, int summand, number factor)
int | non_zero_entries (int row)

## Private Attributes

ring | r
mac_poly * | mp
int | columns
int | rows
BOOLEAN | free_numbers

## Friends

poly | free_row_to_poly (tgb_sparse_matrix *mat, int row, poly *monoms, int monom_index)
void | init_with_mac_poly (tgb_sparse_matrix *mat, int row, mac_poly m)

## Detailed Description

Definition at line 60 of file tgbgauss.h.

## Constructor & Destructor Documentation

## tgb_sparse_matrix()

tgb_sparse_matrix::tgb_sparse_matrix | ( | int | i,
|  | int | j,
|  | ring | rarg )

Definition at line 645 of file tgbgauss.cc.

{
mp=(mac_poly*) omAlloc(i*sizeof (mac_poly));;
int z;
for(z=0;z<i;z++)
{
mp[z]=NULL;
}
columns=j;
rows=i;
free_numbers=FALSE;
r=rarg;
}
FALSE
#define FALSE
Definition auxiliary.h:97
i
int i
Definition cfEzgcd.cc:132
tgb_sparse_matrix::columns
int columns
Definition tgbgauss.h:65
tgb_sparse_matrix::rows
int rows
Definition tgbgauss.h:66
tgb_sparse_matrix::r
ring r
Definition tgbgauss.h:63
tgb_sparse_matrix::free_numbers
BOOLEAN free_numbers
Definition tgbgauss.h:67
tgb_sparse_matrix::mp
mac_poly * mp
Definition tgbgauss.h:64
j
int j
Definition facHensel.cc:110
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
NULL
#define NULL
Definition omList.c:12
mac_poly
mac_poly_r * mac_poly
Definition tgbgauss.h:58

## ~tgb_sparse_matrix()

tgb_sparse_matrix::~tgb_sparse_matrix | ( |  | ) |

Definition at line 659 of file tgbgauss.cc.

{
int z;
for(z=0;z<rows;z++)
{
if(mp[z]!=NULL)
{
if(free_numbers)
{
mac_destroy(mp[z]);
}
else {
while(mp[z]!=NULL)
{
mac_poly next=mp[z]->next;
delete mp[z];
mp[z]=next;
}
}
}
}
omfree(mp);
}
next
ListNode * next
Definition janet.h:31
omfree
#define omfree(addr)
Definition omAllocDecl.h:237
mac_destroy
void mac_destroy(mac_poly p)
Definition tgbgauss.cc:113

## Member Function Documentation

## add_lambda_times_row()

void tgb_sparse_matrix::add_lambda_times_row | ( | int | add_to,
|  | int | summand,
|  | number | factor )

Definition at line 909 of file tgbgauss.cc.

{
mp[add_to]= mac_p_add_ff_qq(mp[add_to], factor,mp[summand]);
}
factor
CanonicalForm factor
Definition facAbsFact.cc:97
mac_p_add_ff_qq
mac_poly mac_p_add_ff_qq(mac_poly a, number f, mac_poly b)
Definition tgbgauss.cc:16

## free_row()

void tgb_sparse_matrix::free_row | ( | int | row,
|  | BOOLEAN | free_non_zeros = TRUE )

Definition at line 928 of file tgbgauss.cc.

{
if(free_non_zeros)
mac_destroy(mp[row]);
else
{
while(mp[row]!=NULL)
{
mac_poly next=mp[row]->next;
delete mp[row];
mp[row]=next;
}
}
mp[row]=NULL;
}

## get()

number tgb_sparse_matrix::get | ( | int | i,
|  | int | j )

Definition at line 766 of file tgbgauss.cc.

{
assume(i<rows);
assume(j<columns);
mac_poly rr=mp[i];
while((rr!=NULL)&&(rr->exp<j))
rr=rr->next;
if ((rr==NULL)||(rr->exp>j))
{
number n=nInit(0);
return n;
}
assume(rr->exp==j);
return rr->coef;
}
mac_poly_r::next
mac_poly_r * next
Definition tgbgauss.h:51
mac_poly_r::coef
number coef
Definition tgbgauss.h:50
mac_poly_r::exp
int exp
Definition tgbgauss.h:52
assume
#define assume(x)
Definition mod2.h:389
nInit
#define nInit(i)
Definition numbers.h:24

## get_columns()

int tgb_sparse_matrix::get_columns | ( |  | ) |

Definition at line 761 of file tgbgauss.cc.

{
return columns;
}

## get_rows()

int tgb_sparse_matrix::get_rows | ( |  | ) |

Definition at line 756 of file tgbgauss.cc.

{
return rows;
}

## is_zero_entry()

BOOLEAN tgb_sparse_matrix::is_zero_entry | ( | int | i,
|  | int | j )

Definition at line 782 of file tgbgauss.cc.

{
assume(i<rows);
assume(j<columns);
mac_poly rr=mp[i];
while((rr!=NULL)&&(rr->exp<j))
rr=rr->next;
if ((rr==NULL)||(rr->exp>j))
{
return TRUE;
}
assume(!nIsZero(rr->coef));
assume(rr->exp==j);
return FALSE;
}
TRUE
#define TRUE
Definition auxiliary.h:101
nIsZero
#define nIsZero(n)
Definition numbers.h:19

## min_col_not_zero_in_row()

int tgb_sparse_matrix::min_col_not_zero_in_row | ( | int | row | ) |

Definition at line 798 of file tgbgauss.cc.

{
if(mp[row]!=NULL)
{
assume(!nIsZero(mp[row]->coef));
return mp[row]->exp;
}
else
return columns;//error code
}

## mult_row()

void tgb_sparse_matrix::mult_row | ( | int | row,
|  | number | factor )

Definition at line 914 of file tgbgauss.cc.

{
if (nIsZero(factor))
{
mac_destroy(mp[row]);
mp[row]=NULL;
return;
}
if(nIsOne(factor))
return;
mac_mult_cons(mp[row],factor);
}
nIsOne
#define nIsOne(n)
Definition numbers.h:25
mac_mult_cons
void mac_mult_cons(mac_poly p, number c)
Definition tgbgauss.cc:91

## next_col_not_zero()

int tgb_sparse_matrix::next_col_not_zero | ( | int | row,
|  | int | pre )

Definition at line 809 of file tgbgauss.cc.

{
mac_poly rr=mp[row];
while((rr!=NULL)&&(rr->exp<=pre))
rr=rr->next;
if(rr!=NULL)
{
assume(!nIsZero(rr->coef));
return rr->exp;
}
return columns;//error code
}

## non_zero_entries()

int tgb_sparse_matrix::non_zero_entries | ( | int | row | ) |

Definition at line 903 of file tgbgauss.cc.

{
return mac_length(mp[row]);
}
mac_length
int mac_length(mac_poly p)
Definition tgbgauss.cc:102

## perm_rows()

void tgb_sparse_matrix::perm_rows | ( | int | i,
|  | int | j )

inline

Definition at line 80 of file tgbgauss.h.

{
mac_poly h;
h=mp[i];
mp[i]=mp[j];
mp[j]=h;
}
h
STATIC_VAR Poly * h
Definition janet.cc:971

## print()

void tgb_sparse_matrix::print | ( |  | ) |

Definition at line 698 of file tgbgauss.cc.

{
int i;
int j;
PrintLn();
for(i=0;i<rows;i++)
{
PrintS("(");
for(j=0;j<columns;j++)
{
StringSetS("");
number n=get(i,j);
n_Write(n,currRing->cf);
char *s=StringEndS();
PrintS(s);
omFree(s);
PrintS("\t");
}
PrintS(")\n");
}
}
tgb_sparse_matrix::get
number get(int i, int j)
Definition tgbgauss.cc:766
n_Write
static FORCE_INLINE void n_Write(number n, const coeffs r, const BOOLEAN bShortOut=TRUE)
Definition coeffs.h:594
s
const CanonicalForm int s
Definition facAbsFact.cc:51
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
StringSetS
void StringSetS(const char *st)
Definition reporter.cc:128
PrintS
void PrintS(const char *s)
Definition reporter.cc:288
StringEndS
char * StringEndS()
Definition reporter.cc:151
PrintLn
void PrintLn()
Definition reporter.cc:314

## row_content()

void tgb_sparse_matrix::row_content | ( | int | row | ) |

Definition at line 847 of file tgbgauss.cc.

{
mac_poly ph=mp[row];
number h,d;
mac_poly p;
if(TEST_OPT_CONTENTSB) return;
if(ph->next==NULL)
{
nDelete(&ph->coef);
ph->coef=nInit(1);
}
else
{
nNormalize(ph->coef);
if(!nGreaterZero(ph->coef))
{
p=ph;
while(p!=NULL)
{
p->coef=nInpNeg(p->coef);
p=p->next;
}
}
if (currRing->cf->cfGcd==ndGcd) return;
h=nCopy(ph->coef);
p = ph->next;
while (p!=NULL)
{
nNormalize(p->coef);
d=n_Gcd(h,p->coef,currRing->cf);
nDelete(&h);
h = d;
if(nIsOne(h))
{
break;
}
p=p->next;
}
p = ph;
//number tmp;
if(!nIsOne(h))
{
while (p!=NULL)
{
d = nExactDiv(p->coef,h);
nDelete(&p->coef);
p->coef=d;
p=p->next;
}
}
nDelete(&h);
}
}
p
int p
Definition cfModGcd.cc:4086
n_Gcd
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of 'a' and 'b' in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ,...
Definition coeffs.h:667
ndGcd
number ndGcd(number, number, const coeffs r)
Definition numbers.cc:193
nDelete
#define nDelete(n)
Definition numbers.h:16
nInpNeg
#define nInpNeg(n)
Definition numbers.h:21
nCopy
#define nCopy(n)
Definition numbers.h:15
nExactDiv
#define nExactDiv(a, b)
Definition numbers.h:34
nGreaterZero
#define nGreaterZero(n)
Definition numbers.h:27
nNormalize
#define nNormalize(n)
Definition numbers.h:30
TEST_OPT_CONTENTSB
#define TEST_OPT_CONTENTSB
Definition options.h:129

## row_normalize()

void tgb_sparse_matrix::row_normalize | ( | int | row | ) |

Definition at line 831 of file tgbgauss.cc.

{
if (!rField_has_simple_inverse(r)) /* Z/p, GF(p,n), R, long R/C */
{
mac_poly m=mp[row];
while (m!=NULL)
{
#ifndef SING_NDEBUG
if (currRing==r) {nTest(m->coef);}
#endif
n_Normalize(m->coef,r->cf);
m=m->next;
}
}
}
m
int m
Definition cfEzgcd.cc:128
n_Normalize
static FORCE_INLINE void n_Normalize(number &n, const coeffs r)
inplace-normalization of n; produces some canonical representation of n;
Definition coeffs.h:581
nTest
#define nTest(a)
Definition numbers.h:35
rField_has_simple_inverse
static BOOLEAN rField_has_simple_inverse(const ring r)
Definition ring.h:554

## set()

void tgb_sparse_matrix::set | ( | int | i,
|  | int | j,
|  | number | n )

Definition at line 721 of file tgbgauss.cc.

{
assume(i<rows);
assume(j<columns);
mac_poly* set_this=&mp[i];
// while(((*set_this)!=NULL)&&((*set_this)\AD>exp<j))
while(((*set_this)!=NULL) && ((*set_this)->exp<j))
set_this=&((*set_this)->next);
if (((*set_this)==NULL)||((*set_this)->exp>j))
{
if (nIsZero(n)) return;
mac_poly old=(*set_this);
(*set_this)=new mac_poly_r();
(*set_this)->exp=j;
(*set_this)->coef=n;
(*set_this)->next=old;
return;
}
assume((*set_this)->exp==j);
if(!nIsZero(n))
{
nDelete(&(*set_this)->coef);
(*set_this)->coef=n;
}
else
{
nDelete(&(*set_this)->coef);
mac_poly dt=(*set_this);
(*set_this)=dt->next;
delete dt;
}
return;
}

## sort_rows()

void tgb_sparse_matrix::sort_rows | ( |  | ) |

Definition at line 693 of file tgbgauss.cc.

{
qsort(mp,rows,sizeof(mac_poly),row_cmp_gen);
}
row_cmp_gen
static int row_cmp_gen(const void *a, const void *b)
Definition tgbgauss.cc:683

## zero_row()

BOOLEAN tgb_sparse_matrix::zero_row | ( | int | row | ) |

Definition at line 822 of file tgbgauss.cc.

{
assume((mp[row]==NULL)||(!nIsZero(mp[row]->coef)));
if (mp[row]==NULL)
return TRUE;
else
return FALSE;
}

## Friends And Related Symbol Documentation

## free_row_to_poly

poly free_row_to_poly | ( | tgb_sparse_matrix * | mat,
|  | int | row,
|  | poly * | monoms,
|  | int | monom_index )

friend

Definition at line 3128 of file tgb.cc.

{
poly p = NULL;
poly *set_this = &p;
mac_poly r = mat->mp[row];
mat->mp[row] = NULL;
while(r)
{
(*set_this) = pLmInit (monoms[monom_index - 1 - r->exp]);
pSetCoeff ((*set_this), r->coef);
set_this = &((*set_this)->next);
mac_poly old = r;
r = r->next;
delete old;
}
return p;
}
pSetCoeff
#define pSetCoeff(p, n)
deletes old coeff before setting the new one
Definition polys.h:32
pLmInit
#define pLmInit(p)
like pInit, except that expvector is initialized to that of p, p must be != NULL
Definition polys.h:65

## init_with_mac_poly

void init_with_mac_poly | ( | tgb_sparse_matrix * | mat,
|  | int | row,
|  | mac_poly | m )

friend

Definition at line 3113 of file tgb.cc.

{
assume (mat->mp[row] == NULL);
mat->mp[row] = m;
#ifdef TGB_DEBUG
mac_poly r = m;
while(r)
{
assume (r->exp < mat->columns);
r = r->next;
}
#endif
}

## Field Documentation

## columns

int tgb_sparse_matrix::columns

private

Definition at line 65 of file tgbgauss.h.

## free_numbers

BOOLEAN tgb_sparse_matrix::free_numbers

private

Definition at line 67 of file tgbgauss.h.

## mp

mac_poly* tgb_sparse_matrix::mp

private

Definition at line 64 of file tgbgauss.h.

## r

ring tgb_sparse_matrix::r

private

Definition at line 63 of file tgbgauss.h.

## rows

int tgb_sparse_matrix::rows

private

Definition at line 66 of file tgbgauss.h.

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

- kernel/GBEngine/tgbgauss.h
- kernel/GBEngine/tgbgauss.cc