Loading...
Searching...
No Matches
spectrum Class Reference

`#include <semic.h>`

## Public Member Functions

| spectrum ()
| Zero constructor.
| spectrum (const spectrum &)
| ~spectrum ()
spectrum | operator= (const spectrum &)
void | copy_new (int)
void | copy_delete (void)
| Delete the memory of a spectrum.
void | copy_zero (void)
| Initialize with zero.
void | copy_shallow (spectrum &spec)
| Initialize shallow from another spectrum.
void | copy_deep (const spectrum &)
int | add_subspectrum (spectrum &, int)
int | next_number (Rational *)
int | next_interval (Rational *, Rational *)
int | numbers_in_interval (Rational &, Rational &, interval_status)
int | mult_spectrum (spectrum &)
int | mult_spectrumh (spectrum &)

## Data Fields

int | mu
int | pg
int | n
Rational * | s
int * | w

## Friends

spectrum | operator+ (const spectrum &s1, const spectrum &s2)
spectrum | operator* (int k, const spectrum &spec)
ostream & | operator<< (ostream &s, const spectrum &spec)

## Detailed Description

Definition at line 63 of file semic.h.

## Constructor & Destructor Documentation

## spectrum() [1/2]

spectrum::spectrum | ( |  | ) |

inline

Zero constructor.

Definition at line 77 of file semic.h.

{
copy_zero( );
}
spectrum::copy_zero
void copy_zero(void)
Initialize with zero.
Definition semic.h:108

## spectrum() [2/2]

spectrum::spectrum | ( | const spectrum & | spec | ) |

Definition at line 36 of file semic.cc.

{
copy_deep( spec );
}
spectrum::copy_deep
void copy_deep(const spectrum &)
Definition semic.cc:103

## ~spectrum()

spectrum::~spectrum | ( |  | ) |

Definition at line 45 of file semic.cc.

{
copy_delete( );
}
spectrum::copy_delete
void copy_delete(void)
Delete the memory of a spectrum.
Definition semic.h:100

## Member Function Documentation

## add_subspectrum()

int spectrum::add_subspectrum | ( | spectrum & | a,
|  | int | k )

Definition at line 279 of file semic.cc.

{
int i,j;
for( i=0, j=0; i<n; i++ )
{
if( s[i] == a.s[j] )
{
w[i] += k*a.w[j];
j++;
}
}
return ( j == a.n ? TRUE : FALSE );
}
TRUE
#define TRUE
Definition auxiliary.h:101
FALSE
#define FALSE
Definition auxiliary.h:97
i
int i
Definition cfEzgcd.cc:132
k
int k
Definition cfEzgcd.cc:99
spectrum::s
Rational * s
Definition semic.h:70
spectrum::n
int n
Definition semic.h:69
spectrum::w
int * w
Definition semic.h:71
j
int j
Definition facHensel.cc:110

## copy_deep()

void spectrum::copy_deep | ( | const spectrum & | spec | ) |

Definition at line 103 of file semic.cc.

{
mu = spec.mu;
pg = spec.pg;
n = spec.n;
copy_new( n );
for( int i=0; i<n; i++ )
{
s[i] = spec.s[i];
w[i] = spec.w[i];
}
}
spectrum::mu
int mu
Definition semic.h:67
spectrum::copy_new
void copy_new(int)
Definition semic.cc:54
spectrum::pg
int pg
Definition semic.h:68

## copy_delete()

void spectrum::copy_delete | ( | void |  | ) |

inline

Delete the memory of a spectrum.

Definition at line 100 of file semic.h.

{
if( s != (Rational*)NULL && n > 0 ) delete [] s;
if( w != (int*)NULL && n > 0 ) delete [] w;
copy_zero( );
}
NULL
#define NULL
Definition omList.c:12

## copy_new()

void spectrum::copy_new | ( | int | k | ) |

Definition at line 54 of file semic.cc.

{
if( k > 0 )
{
s = new Rational[k];
w = new int[k];
#ifndef SING_NDEBUG
if( s == (Rational*)NULL || w == (int*)NULL )
{
#ifdef SEMIC_PRINT
#ifdef SEMIC_IOSTREAM
cerr << "spectrum::copy_new(" << k << ")" << endl;
cerr << " returned ZERO!!!" << endl;
cerr << " exit..." << endl;
#else
fprintf( stderr,"spectrum::copy_new( %d )\n",k );
fprintf( stderr," returned ZERO!!!\n" );
fprintf( stderr," exit...\n" );
#endif
#endif
}
#endif
}
else if( k == 0 )
{
s = (Rational*)NULL;
w = (int*)NULL;
}
else if( k < 0 )
{
#ifdef SEMIC_PRINT
#ifdef SEMIC_IOSTREAM
cerr << "spectrum::copy_new(" << k << ")";
cerr << ": k < 0 ..." << endl;
#else
fprintf( stderr,"spectrum::copy_new( %d )",k );
fprintf( stderr,": k < 0 ...\n" );
#endif
#endif
exit( 1 );
}
}

## copy_shallow()

void spectrum::copy_shallow | ( | spectrum & | spec | ) |

inline

Initialize shallow from another spectrum.

Definition at line 118 of file semic.h.

{
mu = spec.mu;
pg = spec.pg;
n = spec.n;
s = spec.s;
w = spec.w;
}

## copy_zero()

void spectrum::copy_zero | ( | void |  | ) |

inline

Initialize with zero.

Definition at line 108 of file semic.h.

{
mu = 0;
pg = 0;
n = 0;
s = (Rational*)NULL;
w = (int*)NULL;
}

## mult_spectrum()

int spectrum::mult_spectrum | ( | spectrum & | t | ) |

Definition at line 396 of file semic.cc.

{
spectrum u = *this + t;
Rational alpha1 = -2;
Rational alpha2 = -1;
int mult=MAX_INT_VAL,nthis,nt;
while( u.next_interval( &alpha1,&alpha2 ) )
{
nt = t.numbers_in_interval( alpha1,alpha2,LEFTOPEN );
nthis = this->numbers_in_interval( alpha1,alpha2,LEFTOPEN );
if( nt != 0 )
{
mult = (nthis/nt < mult ? nthis/nt: mult );
}
}
return mult;
}
spectrum::spectrum
spectrum()
Zero constructor.
Definition semic.h:77
spectrum::next_interval
int next_interval(Rational *, Rational *)
Definition semic.cc:325
spectrum::numbers_in_interval
int numbers_in_interval(Rational &, Rational &, interval_status)
Definition semic.cc:362
mult
void mult(unsigned long *result, unsigned long *a, unsigned long *b, unsigned long p, int dega, int degb)
Definition minpoly.cc:647
MAX_INT_VAL
const int MAX_INT_VAL
Definition mylimits.h:12
LEFTOPEN
@ LEFTOPEN
Definition semic.h:23

## mult_spectrumh()

int spectrum::mult_spectrumh | ( | spectrum & | t | ) |

Definition at line 425 of file semic.cc.

{
spectrum u = *this + t;
Rational alpha1 = -2;
Rational alpha2 = -1;
int mult=MAX_INT_VAL,nthis,nt;
while( u.next_interval( &alpha1,&alpha2 ) )
{
nt = t.numbers_in_interval( alpha1,alpha2,LEFTOPEN );
nthis = this->numbers_in_interval( alpha1,alpha2,LEFTOPEN );
if( nt != 0 )
{
mult = (nthis/nt < mult ? nthis/nt: mult );
}
nt = t.numbers_in_interval( alpha1,alpha2,OPEN );
nthis = this->numbers_in_interval( alpha1,alpha2,OPEN );
if( nt != 0 )
{
mult = (nthis/nt < mult ? nthis/nt: mult );
}
}
return mult;
}
OPEN
@ OPEN
Definition semic.h:22

## next_interval()

int spectrum::next_interval | ( | Rational * | alpha1,
|  | Rational * | alpha2 )

Definition at line 325 of file semic.cc.

{
Rational zero( 0,1 );
Rational a1 = *alpha1;
Rational a2 = *alpha2;
Rational d = *alpha2 - *alpha1;
int e1 = this->next_number( &a1 );
int e2 = this->next_number( &a2 );
if( e1 || e2 )
{
Rational d1 = a1 - *alpha1;
Rational d2 = a2 - *alpha2;
if( d1 < d2 || d2 == zero )
{
*alpha1 = a1;
*alpha2 = a1 + d;
}
else
{
*alpha1 = a2 - d;
*alpha2 = a2;
}
return TRUE;
}
else
{
return FALSE;
}
}
spectrum::next_number
int next_number(Rational *)
Definition semic.cc:300

## next_number()

int spectrum::next_number | ( | Rational * | alpha | ) |

Definition at line 300 of file semic.cc.

{
int i=0;
while( i < n && *alpha >= s[i] )
{
i++;
}
if( i < n )
{
*alpha = s[i];
return TRUE;
}
else
{
return FALSE;
}
}
alpha
Variable alpha
Definition facAbsBiFact.cc:52

## numbers_in_interval()

int spectrum::numbers_in_interval | ( | Rational & | alpha1,
|  | Rational & | alpha2,
|  | interval_status | status )

Definition at line 362 of file semic.cc.

{
int count = 0;
for( int i=0; i<n; i++ )
{
if( ( ( status == OPEN || status == LEFTOPEN ) &&
s[i] > alpha1 ) ||
( ( status == CLOSED || status == RIGHTOPEN ) &&
s[i] >= alpha1 ) )
{
if( ( ( status == OPEN || status == RIGHTOPEN ) &&
s[i] < alpha2 ) ||
( ( status == CLOSED || status == LEFTOPEN ) &&
s[i] <= alpha2 ) )
{
count += w[i];
}
else
{
break;
}
}
}
return count;
}
RIGHTOPEN
@ RIGHTOPEN
Definition semic.h:24
CLOSED
@ CLOSED
Definition semic.h:25
status
int * status
Definition si_signals.h:61
count
int status int void size_t count
Definition si_signals.h:69

## operator=()

spectrum spectrum::operator= | ( | const spectrum & | spec | ) |

Definition at line 122 of file semic.cc.

{
copy_delete( );
copy_deep( spec );
return *this;
}

## Friends And Related Symbol Documentation

## operator*

spectrum operator* | ( | int | k,
|  | const spectrum & | spec )

friend

Definition at line 219 of file semic.cc.

{
if( k == 0 )
{
spectrum result;
return result;
}
else
{
spectrum result( spec );
result.mu *= k;
result.pg *= k;
for( int i=0; i<result.n; i++ )
{
result.w[i] *= k;
}
return result;
}
}
result
return result
Definition facAbsBiFact.cc:76

## operator+

spectrum operator+ | ( | const spectrum & | s1,
|  | const spectrum & | s2 )

friend

Definition at line 134 of file semic.cc.

{
int i1=0, i2=0, i3=0;
spectrum result;
do
{
if( i1 >= s1.n )
{
i2++;
}
else if( i2 >= s2.n )
{
i1++;
}
else if( s1.s[i1] < s2.s[i2] )
{
i1++;
}
else if( s1.s[i1] == s2.s[i2] )
{
i1++;
i2++;
}
else
{
i2++;
}
i3++;
}
while( i1 < s1.n || i2 < s2.n );
result.copy_new( i3 );
result.n = i3;
i1 = i2 = i3 = 0;
do
{
if( i1 >= s1.n )
{
result.s[i3] = s2.s[i2];
result.w[i3] = s2.w[i2];
i2++;
}
else if( i2 >= s2.n )
{
result.s[i3] = s1.s[i1];
result.w[i3] = s1.w[i1];
i1++;
}
else if( s1.s[i1] < s2.s[i2] )
{
result.s[i3] = s1.s[i1];
result.w[i3] = s1.w[i1];
i1++;
}
else if( s1.s[i1] == s2.s[i2] )
{
result.s[i3] = s1.s[i1];
result.w[i3] = s1.w[i1] + s2.w[i2];
i1++;
i2++;
}
else
{
result.s[i3] = s2.s[i2];
result.w[i3] = s2.w[i2];
i2++;
}
i3++;
}
while( i1 < s1.n || i2 < s2.n );
result.mu = s1.mu + s2.mu;
result.pg = s1.pg + s2.pg;
return result;
}

## operator<<

ostream & operator<< | ( | ostream & | s,
|  | const spectrum & | spec )

friend

Definition at line 249 of file semic.cc.

{
for( int i=0; i<spec.n; i++ )
{
if( i>0 )
{
#ifdef SEMIC_STDOUT
s << "+";
#else
fprintf( stdout,"+" );
#endif
}
#ifdef SEMIC_STDOUT
s << spec.w[i] << "*t^";
#else
fprintf( stdout,"%d*t^",spec.w[i] );
#endif
s << spec.s[i];
}
return s;
}

## Field Documentation

## mu

int spectrum::mu

Definition at line 67 of file semic.h.

## n

int spectrum::n

Definition at line 69 of file semic.h.

## pg

int spectrum::pg

Definition at line 68 of file semic.h.

## s

Rational* spectrum::s

Definition at line 70 of file semic.h.

## w

int* spectrum::w

Definition at line 71 of file semic.h.

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

- kernel/spectrum/semic.h
- kernel/spectrum/semic.cc