Loading...
Searching...
No Matches
DegreePattern.cc
Go to the documentation of this file.
/*****************************************************************************\
* Computer Algebra System SINGULAR
\*****************************************************************************/
/** @file DegreePattern.cc
*
* This file provides functions for manipulating DegreePatterns
*
* @author Martin Lee
*
**/
/*****************************************************************************/
#include "config.h"
#include "DegreePattern.h"
#include "cf_iter.h"
#include "templates/ftmpl_functions.h"
#include "gfops.h"
#include "cf_factory.h"
DegreePattern::DegreePattern (const CFList& l)
{
m_data = NULL;
if (l.length() == 0)
m_data = new Pattern();
else
{
Variable x= Variable (1);
int p= getCharacteristic();
int d= 0;
char cGFName= 'Z';
if (CFFactory::gettype() == GaloisFieldDomain)
{
d= getGFDegree();
cGFName= gf_name;
}
setCharacteristic(0);
CanonicalForm buf= 1;
CFListIterator k= l;
for (int i= 0; i < l.length(); i++, k++)
buf *= (power (x, degree (k.getItem(), x)) + 1);
int j= 0;
for (CFIterator i= buf; i.hasTerms(); i++, j++)
;
ASSERT ( j > 1, "j > 1 expected" );
m_data = new Pattern( j - 1 );
int i= 0;
for (CFIterator m = buf; i < getLength(); i++, m++)
(*this) [i]= m.exp();
if (d > 1)
setCharacteristic (p, d, cGFName);
else
setCharacteristic (p);
}
}
void DegreePattern::intersect (const DegreePattern& degPat)
{
if (degPat.getLength() < getLength())
{
DegreePattern bufDeg= *this;
*this= degPat;
return (*this).intersect (bufDeg);
}
int count= 0;
int length= tmin (getLength(), degPat.getLength());
int* buf= new int [length];
for (int i= 0; i < length; i++)
{
if (degPat.find ((*this)[i]))
{
buf[i]= (*this)[i];
count++;
}
else
buf[i]= -1;
}
ASSERT ( count > 0, "count > 0 expected" );
init (count);
count= 0;
for (int i= 0; i < length; i++)
{
if (buf[i] != -1)
{
(*this) [count]= buf[i];
count++;
}
}
delete[] buf;
}
void DegreePattern::refine ()
{
if (getLength() <= 1)
return;
int count= 0;
int* buf= new int [getLength()];
int d= (*this) [0];
int pos;
for (int i= 0; i < getLength(); i++)
buf[i]= -1;
for (int i= 1; i < getLength(); i++)
{
pos= (*this).find (d - (*this)[i]);
if (pos)
{
buf[i]= (*this)[i];
count++;
}
}
buf[0]= d;
count++;
if (count == getLength())
{
delete [] buf;
return;
}
int length= getLength();
ASSERT ( count > 0, "count > 0 expected" );
init (count);
count= 0;
for (int i= 0; i < length; i++)
{
if (buf[i] != -1)
{
(*this)[count]= buf[i];
count++;
}
}
delete[] buf;
return;
}
DegreePattern.h
This file provides a class to handle degree patterns.
power
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
Definition canonicalform.cc:1896
degree
int degree(const CanonicalForm &f)
Definition canonicalform.h:316
getGFDegree
int getGFDegree()
Definition cf_char.cc:75
setCharacteristic
void FACTORY_PUBLIC setCharacteristic(int c)
Definition cf_char.cc:28
CFListIterator
ListIterator< CanonicalForm > CFListIterator
Definition canonicalform.h:396
CFList
List< CanonicalForm > CFList
Definition canonicalform.h:395
getCharacteristic
int FACTORY_PUBLIC getCharacteristic()
Definition cf_char.cc:70
l
int l
Definition cfEzgcd.cc:100
m
int m
Definition cfEzgcd.cc:128
i
int i
Definition cfEzgcd.cc:132
k
int k
Definition cfEzgcd.cc:99
x
Variable x
Definition cfModGcd.cc:4090
p
int p
Definition cfModGcd.cc:4086
ASSERT
#define ASSERT(expression, message)
Definition cf_assert.h:99
GaloisFieldDomain
#define GaloisFieldDomain
Definition cf_defs.h:18
cf_factory.h
Interface to generate InternalCF's over various domains from intrinsic types or mpz_t's.
cf_iter.h
Iterators for CanonicalForm's.
CFFactory::gettype
static int gettype()
Definition cf_factory.h:28
CFIterator
class to iterate through CanonicalForm's
Definition cf_iter.h:44
CanonicalForm
factory's main class
Definition canonicalform.h:86
DegreePattern::m_data
struct DegreePattern::Pattern * m_data
DegreePattern::find
int find(const int x) const
find an element x
Definition DegreePattern.h:159
DegreePattern::intersect
void intersect(const DegreePattern &degPat)
intersect two degree patterns
Definition DegreePattern.cc:68
DegreePattern::getLength
int getLength() const
getter
Definition DegreePattern.h:86
DegreePattern::refine
void refine()
Refine a degree pattern. Assumes that (*this)[0]:= d is the degree of the poly to be factored....
Definition DegreePattern.cc:105
DegreePattern::init
void init(int n)
initialise a DegreePattern
Definition DegreePattern.h:60
DegreePattern::DegreePattern
DegreePattern()
default constructor
Definition DegreePattern.h:117
Variable
factory's class for variables
Definition factory.h:127
j
int j
Definition facHensel.cc:110
ftmpl_functions.h
some useful template functions.
tmin
template CanonicalForm tmin(const CanonicalForm &, const CanonicalForm &)
gf_name
VAR char gf_name
Definition gfops.cc:52
gfops.h
Operations in GF, where GF is a finite field of size less than 2^16 represented by a root of Conway p...
length
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
NULL
#define NULL
Definition omList.c:12
count
int status int void size_t count
Definition si_signals.h:69
buf
int status int void * buf
Definition si_signals.h:69
DegreePattern::Pattern
Definition DegreePattern.h:35