My Project
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends
Variable Class Reference

factory's class for variables More...

#include <variable.h>

Public Member Functions

 Variable ()
 
 Variable (int l)
 
 Variable (char name)
 
 Variable (int l, char name)
 
 Variable (const Variable &v)
 
 ~Variable ()
 
Variableoperator= (const Variable &v)
 
int level () const
 
char name () const
 
Variable next () const
 

Static Public Member Functions

static Variable highest ()
 

Private Member Functions

 Variable (int l, bool flag)
 

Private Attributes

int _level
 

Friends

bool operator== (const Variable &lhs, const Variable &rhs)
 
bool operator!= (const Variable &lhs, const Variable &rhs)
 
bool operator> (const Variable &lhs, const Variable &rhs)
 
bool operator< (const Variable &lhs, const Variable &rhs)
 
bool operator>= (const Variable &lhs, const Variable &rhs)
 
bool operator<= (const Variable &lhs, const Variable &rhs)
 
OSTREAMoperator<< (OSTREAM &os, const Variable &v)
 
void swap_levels ()
 
Variable rootOf (const CanonicalForm &, char name)
 returns a symbolic root of polynomial with name name. More...
 

Detailed Description

factory's class for variables

Definition at line 32 of file variable.h.

Constructor & Destructor Documentation

◆ Variable() [1/6]

Variable::Variable ( int  l,
bool  flag 
)
private

Definition at line 47 of file variable.cc.

47 : _level(l)
48{
49 ASSERT( flag, "illegal level" );
50}
int l
Definition: cfEzgcd.cc:100
#define ASSERT(expression, message)
Definition: cf_assert.h:99
int _level
Definition: variable.h:35

◆ Variable() [2/6]

Variable::Variable ( )
inline

Definition at line 38 of file variable.h.

38: _level(LEVELBASE) {}
#define LEVELBASE
Definition: cf_defs.h:25

◆ Variable() [3/6]

Variable::Variable ( int  l)

Definition at line 52 of file variable.cc.

52 : _level(l)
53{
54 //ASSERT( l > 0 && l != LEVELQUOT, "illegal level" );
55}

◆ Variable() [4/6]

Variable::Variable ( char  name)

Definition at line 57 of file variable.cc.

58{
59 bool isext = false;
60 int n, i;
61 if ( var_names_ext != 0 ) {
62 n = strlen( var_names_ext );
63 i = 1;
64 while ( i < n && var_names_ext[i] != name ) i++;
65 if ( i < n ) {
66 _level = -i;
67 isext = true;
68 }
69 }
70 if ( ! isext ) {
71 if ( var_names == 0 ) {
72 var_names = new char [3];
73 var_names[0] = '@';
74 var_names[1] = name;
75 var_names[2] = '\0';
76 _level = 1;
77 }
78 else {
79 n = strlen( var_names );
80 i = 1;
81 while ( i < n && var_names[i] != name ) i++;
82 if ( i < n )
83 _level = i;
84 else {
85 ASSERT( name != '@', "illegal variable name" );
86 char * newvarnames = new char [n+2];
87 for ( i = 0; i < n; i++ )
88 newvarnames[i] = var_names[i];
89 newvarnames[n] = name;
90 newvarnames[n+1] = 0;
91 delete [] var_names;
92 var_names = newvarnames;
93 _level = n;
94 }
95 }
96 }
97}
int i
Definition: cfEzgcd.cc:132
char name() const
Definition: variable.cc:122
int name
New type name for int.
Definition: templateForC.h:21
STATIC_VAR char * var_names_ext
Definition: variable.cc:43
STATIC_VAR char * var_names
Definition: variable.cc:42

◆ Variable() [5/6]

Variable::Variable ( int  l,
char  name 
)

Definition at line 99 of file variable.cc.

99 : _level(l)
100{
101 ASSERT( l > 0 && l != LEVELQUOT, "illegal level" );
102 int n;
103 if ( (n = (var_names == 0 ? 0 : strlen( var_names ))) <= l ) {
104 char * newvarnames = new char [l+2];
105 int i;
106 for ( i = 0; i < n; i++ )
107 newvarnames[i] = var_names[i];
108 for ( i = n; i < l; i++ )
109 newvarnames[i] = '@';
110 newvarnames[l] = name;
111 newvarnames[l+1] = 0;
112 delete [] var_names;
113 var_names = newvarnames;
114 }
115 else {
116 ASSERT( var_names[l] == '@', "illegal name" );
117 var_names[l] = name;
118 }
119}
#define LEVELQUOT
Definition: cf_defs.h:27

◆ Variable() [6/6]

Variable::Variable ( const Variable v)
inline

Definition at line 42 of file variable.h.

42: _level(v._level) {}
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39

◆ ~Variable()

Variable::~Variable ( )
inline

Definition at line 43 of file variable.h.

43{};

Member Function Documentation

◆ highest()

static Variable Variable::highest ( )
inlinestatic

Definition at line 51 of file variable.h.

51{ return Variable( LEVELQUOT-1 ); }
Variable()
Definition: variable.h:38

◆ level()

int Variable::level ( ) const
inline

Definition at line 49 of file variable.h.

49{ return _level; }

◆ name()

char Variable::name ( ) const

Definition at line 122 of file variable.cc.

123{
124 if ( _level > 0 && _level < (int)strlen( var_names ) )
125 return( var_names[_level] );
126 else if ( _level < 0 && -_level < (int)strlen( var_names_ext ) )
127 return( var_names_ext[-_level] );
128 else
129 return '@';
130}

◆ next()

Variable Variable::next ( ) const
inline

Definition at line 52 of file variable.h.

52{ return Variable( _level+1 ); }

◆ operator=()

Variable & Variable::operator= ( const Variable v)
inline

Definition at line 44 of file variable.h.

45 {
46 _level = v._level;
47 return *this;
48 }

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const Variable lhs,
const Variable rhs 
)
friend

Definition at line 57 of file variable.h.

58 {
59 return lhs._level != rhs._level;
60 }

◆ operator<

bool operator< ( const Variable lhs,
const Variable rhs 
)
friend

Definition at line 65 of file variable.h.

66 {
67 return lhs._level < rhs._level;
68 }

◆ operator<<

OSTREAM & operator<< ( OSTREAM os,
const Variable v 
)
friend

◆ operator<=

bool operator<= ( const Variable lhs,
const Variable rhs 
)
friend

Definition at line 73 of file variable.h.

74 {
75 return lhs._level <= rhs._level;
76 }

◆ operator==

bool operator== ( const Variable lhs,
const Variable rhs 
)
friend

Definition at line 53 of file variable.h.

54 {
55 return lhs._level == rhs._level;
56 }

◆ operator>

bool operator> ( const Variable lhs,
const Variable rhs 
)
friend

Definition at line 61 of file variable.h.

62 {
63 return lhs._level > rhs._level;
64 }

◆ operator>=

bool operator>= ( const Variable lhs,
const Variable rhs 
)
friend

Definition at line 69 of file variable.h.

70 {
71 return lhs._level >= rhs._level;
72 }

◆ rootOf

Variable rootOf ( const CanonicalForm ,
char  name 
)
friend

returns a symbolic root of polynomial with name name.

Use it to define algebraic variables

Note
: algebraic variables have a level < 0
: algebraic variables have a level < 0

Definition at line 162 of file variable.cc.

163{
164 ASSERT (mipo.isUnivariate(), "not a legal extension");
165
166 int l;
167 if ( var_names_ext == 0 ) {
168 var_names_ext = new char [3];
169 var_names_ext[0] = '@';
170 var_names_ext[1] = name;
171 var_names_ext[2] = '\0';
172 l = 1;
173 Variable result( -l, true );
174 algextensions = new ext_entry [2];
175 algextensions[1] = ext_entry( 0, false );
176 algextensions[1] = ext_entry( (InternalPoly*)(conv2mipo( mipo, result ).getval()), true );
177 return result;
178 }
179 else {
180 int i, n = strlen( var_names_ext );
181 char * newvarnames = new char [n+2];
182 for ( i = 0; i < n; i++ )
183 newvarnames[i] = var_names_ext[i];
184 newvarnames[n] = name;
185 newvarnames[n+1] = 0;
186 delete [] var_names_ext;
187 var_names_ext = newvarnames;
188 l = n;
189 Variable result( -l, true );
190 ext_entry * newalgext = new ext_entry [n+1];
191 for ( i = 0; i < n; i++ )
192 newalgext[i] = algextensions[i];
193 newalgext[n] = ext_entry( 0, false );
194 delete [] algextensions;
195 algextensions = newalgext;
196 algextensions[n] = ext_entry( (InternalPoly*)(conv2mipo( mipo, result ).getval()), true );
197 return result;
198 }
199}
bool isUnivariate() const
factory's class for polynomials
Definition: int_poly.h:71
factory's class for variables
Definition: variable.h:33
Definition: variable.cc:19
return result
Definition: facAbsBiFact.cc:75
CanonicalForm mipo
Definition: facAlgExt.cc:57
static CanonicalForm conv2mipo(const CanonicalForm &mipo, const Variable &alpha)
Definition: variable.cc:154
STATIC_VAR ext_entry * algextensions
Definition: variable.cc:41

◆ swap_levels

void swap_levels ( )
friend

Field Documentation

◆ _level

int Variable::_level
private

Definition at line 35 of file variable.h.


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