[493c477] | 1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
[2dd068] | 2 | |
---|
[b52d27] | 3 | /** |
---|
| 4 | * @file variable.h |
---|
| 5 | * |
---|
| 6 | * operations on variables |
---|
| 7 | **/ |
---|
[2dd068] | 8 | #ifndef INCL_VARIABLE_H |
---|
| 9 | #define INCL_VARIABLE_H |
---|
| 10 | |
---|
[e4fe2b] | 11 | // #include "config.h" |
---|
[037633] | 12 | |
---|
[175e355] | 13 | #ifndef NOSTREAMIO |
---|
[e4fe2b] | 14 | # ifdef HAVE_IOSTREAM |
---|
| 15 | # include <iostream> |
---|
| 16 | # define OSTREAM std::ostream |
---|
| 17 | # elif defined(HAVE_IOSTREAM_H) |
---|
| 18 | # include <iostream.h> |
---|
| 19 | # define OSTREAM ostream |
---|
| 20 | # endif |
---|
[175e355] | 21 | #endif /* NOSTREAMIO */ |
---|
[2dd068] | 22 | |
---|
| 23 | #include "cf_defs.h" |
---|
| 24 | |
---|
| 25 | /*BEGINPUBLIC*/ |
---|
| 26 | |
---|
| 27 | class CanonicalForm; |
---|
| 28 | |
---|
[b52d27] | 29 | /** |
---|
| 30 | * factory's class for variables |
---|
| 31 | **/ |
---|
[3edea1] | 32 | class FACTORY_PUBLIC Variable |
---|
[2dd068] | 33 | { |
---|
| 34 | private: |
---|
| 35 | int _level; |
---|
| 36 | Variable( int l, bool flag ); |
---|
| 37 | public: |
---|
| 38 | Variable() : _level(LEVELBASE) {} |
---|
| 39 | Variable( int l ); |
---|
| 40 | Variable( char name ); |
---|
| 41 | Variable( int l, char name ); |
---|
| 42 | Variable( const Variable & v ) : _level(v._level) {} |
---|
| 43 | ~Variable() {}; |
---|
| 44 | Variable& operator= ( const Variable & v ) |
---|
| 45 | { |
---|
[2bf04b] | 46 | _level = v._level; |
---|
| 47 | return *this; |
---|
[2dd068] | 48 | } |
---|
| 49 | int level() const { return _level; } |
---|
| 50 | char name() const; |
---|
| 51 | static Variable highest() { return Variable( LEVELQUOT-1 ); } |
---|
| 52 | Variable next() const { return Variable( _level+1 ); } |
---|
| 53 | friend bool operator == ( const Variable & lhs, const Variable & rhs ) |
---|
| 54 | { |
---|
[2bf04b] | 55 | return lhs._level == rhs._level; |
---|
[2dd068] | 56 | } |
---|
| 57 | friend bool operator != ( const Variable & lhs, const Variable & rhs ) |
---|
| 58 | { |
---|
[2bf04b] | 59 | return lhs._level != rhs._level; |
---|
[2dd068] | 60 | } |
---|
| 61 | friend bool operator > ( const Variable & lhs, const Variable & rhs ) |
---|
| 62 | { |
---|
[2bf04b] | 63 | return lhs._level > rhs._level; |
---|
[2dd068] | 64 | } |
---|
| 65 | friend bool operator < ( const Variable & lhs, const Variable & rhs ) |
---|
| 66 | { |
---|
[2bf04b] | 67 | return lhs._level < rhs._level; |
---|
[2dd068] | 68 | } |
---|
| 69 | friend bool operator >= ( const Variable & lhs, const Variable & rhs ) |
---|
| 70 | { |
---|
[2bf04b] | 71 | return lhs._level >= rhs._level; |
---|
[2dd068] | 72 | } |
---|
| 73 | friend bool operator <= ( const Variable & lhs, const Variable & rhs ) |
---|
| 74 | { |
---|
[2bf04b] | 75 | return lhs._level <= rhs._level; |
---|
[2dd068] | 76 | } |
---|
[175e355] | 77 | #ifndef NOSTREAMIO |
---|
[e4fe2b] | 78 | friend OSTREAM & operator << ( OSTREAM & os, const Variable & v ); |
---|
[175e355] | 79 | #endif /* NOSTREAMIO */ |
---|
[c3aa45] | 80 | friend void swap_levels(); |
---|
[b52d27] | 81 | /** returns a symbolic root of polynomial with name @a name. |
---|
| 82 | * Use it to define algebraic variables |
---|
| 83 | * @note: algebraic variables have a level < 0 |
---|
| 84 | **/ |
---|
[6b503c] | 85 | friend Variable rootOf( const CanonicalForm &, char name ); |
---|
[2dd068] | 86 | }; |
---|
[b52d27] | 87 | |
---|
| 88 | /** returns a symbolic root of polynomial with name @a name |
---|
| 89 | * Use it to define algebraic variables |
---|
| 90 | * @note: algebraic variables have a level < 0 |
---|
| 91 | **/ |
---|
[3edea1] | 92 | Variable FACTORY_PUBLIC rootOf( const CanonicalForm &, char name = '@' ); |
---|
[2dd068] | 93 | |
---|
| 94 | inline int level( const Variable & v ) { return v.level(); } |
---|
| 95 | inline char name( const Variable & v ) { return v.name(); } |
---|
| 96 | |
---|
[183688] | 97 | void setReduce( const Variable & alpha, bool reduce ); |
---|
[5ab7d6] | 98 | void setMipo ( const Variable & alpha, const CanonicalForm & mipo); |
---|
[2dd068] | 99 | CanonicalForm getMipo( const Variable & alpha, const Variable & x ); |
---|
[6981f1] | 100 | bool hasMipo( const Variable & alpha ); |
---|
[2dd068] | 101 | |
---|
| 102 | char getDefaultVarName(); |
---|
| 103 | char getDefaultExtName(); |
---|
| 104 | |
---|
[3edea1] | 105 | void FACTORY_PUBLIC prune (Variable& alpha); |
---|
[03f640] | 106 | void prune1 (const Variable& alpha); |
---|
[c3aa45] | 107 | int ExtensionLevel(); |
---|
| 108 | |
---|
[2dd068] | 109 | /*ENDPUBLIC*/ |
---|
| 110 | |
---|
| 111 | // the following functions do not need to be public available |
---|
| 112 | CanonicalForm getMipo( const Variable & alpha ); |
---|
| 113 | class InternalPoly; |
---|
| 114 | InternalPoly * getInternalMipo ( const Variable & alpha ); |
---|
| 115 | bool getReduce( const Variable & alpha ); |
---|
| 116 | |
---|
[493c477] | 117 | #endif /* ! INCL_VARIABLE_H */ |
---|