 |
My Project
debian-1:4.1.2-p1+ds-2
|
Go to the documentation of this file.
9 #if defined(WINNT) && ! defined(__GNUC__)
13 #include <strstream.h>
34 #define LIKELY(X) (__builtin_expect(!!(X), 1))
35 #define UNLIKELY(X) (__builtin_expect(!!(X), 0))
38 #define UNLIKELY(X) (X)
55 ASSERT( 0,
"ups, why do you initialize an empty poly" );
61 firstTerm =
new term( 0, c, e );
67 ASSERT( 0,
"ups there is something wrong in your code" );
91 cursor = cursor->
next;
167 if ( theCursor->
exp ==
i )
168 return theCursor->
coeff;
169 else if ( theCursor->
exp <
i )
172 theCursor = theCursor->
next;
182 aStream << 0 << aString;
189 ostrstream theStream;
190 if ( theCursor->
exp == 0 )
195 if ( theCursor->
exp != 1 )
196 aStream <<
'^' << theCursor->
exp << aString;
202 aStream <<
'-' <<
var;
203 if ( theCursor->
exp != 1 )
204 aStream <<
'^' << theCursor->
exp << aString;
210 theStream <<
'*' <<
var;
211 if ( theCursor->
exp != 1 )
212 theStream <<
'^' << theCursor->
exp << aString << ends;
214 theStream << aString << ends;
215 theString = theStream.str();
219 theCursor = theCursor->
next;
220 if ( theCursor && ( theCursor->
coeff.
sign() >= 0 ) )
311 if ( first && first->
exp != 0 )
351 if ( first && first->
exp != 0 )
370 termList resultFirst = 0, resultLast = 0;
376 theCursor->
coeff, theCursor->
exp, resultLast,
false );
377 theCursor = theCursor->
next;
382 if ( resultFirst == 0 )
395 else if ( resultFirst->
exp == 0 )
433 termList resultFirst = 0, resultLast = 0;
439 theCursor->
coeff, theCursor->
exp, resultLast,
false );
440 theCursor = theCursor->
next;
445 if ( resultFirst == 0 )
458 else if ( resultFirst->
exp == 0 )
504 else dummy = dummy->
mulsame(
this );
517 termList dummy, first,
last, resultfirst = 0, resultlast = 0;
533 while (first && ( first->
exp >=
exp ) )
536 newexp = first->
exp -
exp;
545 if ( resultfirst && resultfirst->
exp != 0 )
551 else if ( resultfirst )
562 ASSERT( 0,
"FATAL ERROR, PLEASE INFORM THE AUTHOR" );
570 if ( resultfirst && resultfirst->
exp != 0 )
572 else if ( resultfirst )
613 termList dummy, first,
last, resultfirst = 0, resultlast = 0;
629 while (first && ( first->
exp >=
exp ) )
637 newcoeff=
reduce (newcoeff,
M);
638 newexp = first->
exp -
exp;
648 if ( resultfirst && resultfirst->
exp != 0 )
654 else if ( resultfirst )
665 ASSERT( 0,
"FATAL ERROR, PLEASE INFORM THE AUTHOR" );
673 if ( resultfirst && resultfirst->
exp != 0 )
675 else if ( resultfirst )
717 while (first && ( first->
exp >=
exp ) )
720 newexp = first->
exp -
exp;
727 if ( first && first->
exp != 0 )
750 if ( first && first->
exp != 0 )
776 termList dummy, first,
last, resultfirst = 0, resultlast = 0;
784 while (first && ( first->
exp >=
exp ) )
787 newexp = first->
exp -
exp;
794 if ( resultfirst->
exp == 0 )
804 if ( first->
exp == 0 )
825 termList dummy, first,
last, resultfirst = 0, resultlast = 0;
828 bool divideok =
true;
837 while (first && ( first->
exp >=
exp ) && divideok )
840 if ( divideok && dummycoeff.
isZero() )
842 newexp = first->
exp -
exp;
854 if ( resultfirst->
exp == 0 )
864 if ( first->
exp == 0 )
897 termList dummy, first,
last, resultfirst = 0, resultlast = 0;
900 bool divideok =
true;
906 while (first && ( first->
exp >=
exp ) && divideok )
914 if ( divideok && dummycoeff.
isZero() )
916 newexp = first->
exp -
exp;
929 if ( resultfirst->
exp == 0 )
939 if ( first->
exp == 0 )
1000 termList cursor2 = apoly->firstTerm;
1001 for ( ; cursor1 && cursor2; cursor1 = cursor1->
next, cursor2 = cursor2->
next )
1006 if ( (cursor1->
exp != cursor2->exp) || (cursor1->
coeff != cursor2->coeff) )
1008 if ( cursor1->
exp > cursor2->exp )
1010 else if ( cursor1->
exp < cursor2->exp )
1012 else if ( cursor1->
coeff > cursor2->coeff )
1018 if ( cursor1 == cursor2 )
1020 else if ( cursor1 != 0 )
1054 cursor = cursor->
next;
1071 if (
last->exp == 0 )
1074 if (
last->coeff.isZero() )
1078 cursor = cursor->
next;
1128 cursor = cursor->
next;
1151 if (
last->exp == 0 )
1157 if (
last->coeff.isZero() )
1161 cursor = cursor->
next;
1197 else if ( c.isOne() )
1234 else dummy = dummy->
mulcoeff( cc );
1285 if ( first && first->
exp != 0 )
1328 else dummy = dummy->
mulcoeff( cc );
1380 if ( first && first->
exp != 0 )
1457 if ( first && first->
exp != 0 )
1556 if ( first && first->
exp != 0 )
1582 ASSERT( ! c.isZero(),
"divide by zero!" );
1596 ASSERT( ! c.isZero(),
"divide by zero!" );
1634 if ( first && first->
exp != 0 )
1671 ASSERT( ! c.isZero(),
"divide by zero!" );
1675 if ( quotfirst->exp == 0 )
1708 ASSERT( ! c.isZero(),
"divide by zero!" );
1712 bool divideok =
true;
1715 quotcursor = quotfirst =
new term;
1717 while ( cursor && divideok )
1720 divideok = divideok && crem.
isZero();
1725 quotcursor->next =
new term( 0, cquot, cursor->
exp );
1726 quotcursor = quotcursor->next;
1728 cursor = cursor->
next;
1731 quotcursor->
next = 0;
1734 cursor = quotfirst; quotfirst = quotfirst->
next;
delete cursor;
1736 if ( quotfirst->exp == 0 )
1776 ASSERT( ! c.isZero(),
"divide by zero!" );
1780 bool divideok =
true;
1783 quotcursor = quotfirst =
new term;
1785 while ( cursor && divideok )
1793 divideok = divideok && crem.
isZero();
1798 quotcursor->next =
new term( 0, cquot, cursor->
exp );
1799 quotcursor = quotcursor->next;
1801 cursor = cursor->
next;
1804 quotcursor->
next = 0;
1807 cursor = quotfirst; quotfirst = quotfirst->
next;
delete cursor;
1809 if ( quotfirst->exp == 0 )
1832 if ( aTermList == 0 )
1840 while ( sourceCursor )
1842 targetCursor->
next =
new term( 0, -sourceCursor->
coeff, sourceCursor->
exp );
1843 targetCursor = targetCursor->
next;
1844 sourceCursor = sourceCursor->
next;
1846 targetCursor->
next = 0;
1847 theLastTerm = targetCursor;
1848 targetCursor = dummy->
next;
1850 return targetCursor;
1858 while ( sourceCursor )
1860 targetCursor->
next =
new term( 0, sourceCursor->
coeff, sourceCursor->
exp );
1861 targetCursor = targetCursor->
next;
1862 sourceCursor = sourceCursor->
next;
1864 targetCursor->
next = 0;
1865 theLastTerm = targetCursor;
1866 targetCursor = dummy->
next;
1868 return targetCursor;
1875 if ( aTermList == 0 )
1883 while ( sourceCursor )
1886 targetCursor = targetCursor->
next;
1887 sourceCursor = sourceCursor->
next;
1889 targetCursor->
next = 0;
1890 theLastTerm = targetCursor;
1891 targetCursor = dummy->
next;
1893 return targetCursor;
1904 cursor = cursor->
next;
1917 cursor = cursor->
next;
1928 while ( theCursor && aCursor )
1930 if ( theCursor->
exp == aCursor->
exp )
1940 predCursor->
next = theCursor->
next;
1942 theCursor = predCursor->
next;
1946 theList = theList->
next;
1948 theCursor = theList;
1953 predCursor = theCursor;
1954 theCursor = theCursor->
next;
1956 aCursor = aCursor->
next;
1958 else if ( theCursor->
exp < aCursor->
exp )
1964 predCursor = predCursor->
next;
1968 theList =
new term( theCursor, -aCursor->
coeff, aCursor->
exp );
1969 predCursor = theList;
1975 predCursor = predCursor->
next;
1979 theList =
new term( theCursor, aCursor->
coeff, aCursor->
exp );
1980 predCursor = theList;
1982 aCursor = aCursor->
next;
1986 predCursor = theCursor;
1987 theCursor = theCursor->
next;
1997 else if ( ! theCursor )
2010 theCursor = theCursor->
next;
2031 theCursor = theCursor->
next;
2037 theCursor = theCursor->
next;
2060 theCursor = theCursor->
next;
2066 theCursor = theCursor->
next;
2091 theCursor = theCursor->
next;
2097 theCursor = theCursor->
next;
2120 theCursor = theCursor->
next;
2126 theCursor = theCursor->
next;
2160 while ( theCursor && aCursor )
2162 if ( theCursor->
exp == aCursor->
exp +
exp )
2169 predCursor->
next = theCursor->
next;
2171 theCursor = predCursor->
next;
2175 theList = theList->
next;
2177 theCursor = theList;
2182 predCursor = theCursor;
2183 theCursor = theCursor->
next;
2185 aCursor = aCursor->
next;
2187 else if ( theCursor->
exp < aCursor->
exp +
exp )
2192 predCursor = predCursor->
next;
2197 predCursor = theList;
2199 aCursor = aCursor->
next;
2203 predCursor = theCursor;
2204 theCursor = theCursor->
next;
2212 predCursor = predCursor->
next;
2217 predCursor = theList;
2219 while ( predCursor )
2223 predCursor = predCursor->
next;
2226 else if ( ! theCursor )
2239 while ( first && ( first->
exp >=
exp ) )
2242 newexp = first->
exp -
exp;
virtual InternalCF * mulsame(InternalCF *) PVIRT_INTCF("mulsame")
void divremcoeff(InternalCF *, InternalCF *&, InternalCF *&, bool)
bool tryDivremsamet(InternalCF *, InternalCF *&, InternalCF *&, const CanonicalForm &, bool &)
InternalPoly * getInternalMipo(const Variable &alpha)
virtual InternalCF * invert()
InternalCF * divsame(InternalCF *)
CanonicalForm tailcoeff()
CanonicalForm InternalPoly::tailcoeff (), int InternalPoly::taildegree ()
InternalCF * modulocoeff(InternalCF *, bool)
#define omGetSpecBin(size)
InternalCF * deepCopyObject() const
InternalCF * subcoeff(InternalCF *, bool)
virtual InternalCF * tryDividecoeff(InternalCF *, bool, const CanonicalForm &, bool &)
bool tryDivremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool, const CanonicalForm &, bool &)
InternalCF * mulcoeff(InternalCF *)
bool isUnivariate() const
InternalCF * tryDividecoeff(InternalCF *, bool, const CanonicalForm &, bool &)
InternalCF * neg()
InternalCF * InternalPoly::neg ()
int comparesame(InternalCF *)
comparesame(), comparecoeff() - compare with an InternalPoly.
InternalCF * tryInvert(const CanonicalForm &, bool &)
InternalCF * mulsame(InternalCF *)
CanonicalForm coeff(int i)
CanonicalForm InternalPoly::coeff ( int i )
static termList deepCopyTermList(termList, termList &)
virtual class for internal CanonicalForm's
static termList modTermList(termList, const CanonicalForm &, termList &)
CanonicalForm extgcd(const CanonicalForm &f, const CanonicalForm &g, CanonicalForm &a, CanonicalForm &b)
CanonicalForm extgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a,...
virtual bool isOne() const
bool InternalCF::isOne, isZero () const
static void appendTermList(termList &, termList &, const CanonicalForm &, const int)
static termList addTermList(termList, termList, termList &, bool negate)
InternalCF * copyObject()
virtual int level() const
CanonicalForm getMipo(const Variable &alpha, const Variable &x)
#define ASSERT(expression, message)
static termList divideTermList(termList, const CanonicalForm &, termList &)
factory's class for polynomials
static termList mulAddTermList(termList theList, termList aList, const CanonicalForm &c, const int exp, termList &lastTerm, bool negate)
static InternalCF * basic(long value)
bool divremsamet(InternalCF *, InternalCF *&, InternalCF *&)
void print(OSTREAM &, char *)
virtual CanonicalForm coeff(int i)
CanonicalForm InternalCF::coeff ( int i )
static const omBin InternalPoly_bin
int degree()
int InternalPoly::degree ()
InternalCF * dividesame(InternalCF *)
InternalCF * subsame(InternalCF *)
InternalCF * addsame(InternalCF *)
virtual InternalCF * dividecoeff(InternalCF *, bool) PVIRT_INTCF("dividecoeff")
static termList divTermList(termList, const CanonicalForm &, termList &)
gmp_float exp(const gmp_float &a)
InternalCF * tryDivcoeff(InternalCF *, bool, const CanonicalForm &, bool &)
virtual InternalCF * tryMulsame(InternalCF *, const CanonicalForm &)
static termList reduceTermList(termList first, termList redterms, termList &last)
void setReduce(const Variable &alpha, bool reduce)
bool divremcoefft(InternalCF *, InternalCF *&, InternalCF *&, bool)
InternalCF * tryMulsame(InternalCF *, const CanonicalForm &)
static long imm2int(const InternalCF *const imm)
factory's class for variables
friend class InternalInteger
void divremsame(InternalCF *, InternalCF *&, InternalCF *&)
InternalCF * modulosame(InternalCF *)
int comparecoeff(InternalCF *)
comparecoeff() always returns 1 since CO is defined to be larger than anything which is a coefficient...
InternalCF * modsame(InternalCF *)
static void freeTermList(termList)
virtual InternalCF * mulcoeff(InternalCF *) PVIRT_INTCF("mulcoeff")
InternalCF * addcoeff(InternalCF *)
const Variable & v
< [in] a sqrfree bivariate poly
static termList tryDivTermList(termList, const CanonicalForm &, termList &, const CanonicalForm &, bool &)
static void negateTermList(termList)
static void mulTermList(termList, const CanonicalForm &, const int)
InternalCF * modcoeff(InternalCF *, bool)
static const omBin term_bin
bool getReduce(const Variable &alpha)
static termList copyTermList(termList, termList &, bool negate=false)
virtual InternalCF * tryInvert(const CanonicalForm &, bool &)
InternalCF * divcoeff(InternalCF *, bool)
InternalCF * dividecoeff(InternalCF *, bool)
InternalCF * tryDivsame(InternalCF *, const CanonicalForm &, bool &)
void rem(unsigned long *a, unsigned long *q, unsigned long p, int °a, int degq)
factory's class for integers
int sign() const
int InternalPoly::sign () const