My Project
Loading...
Searching...
No Matches
Data Structures | Functions | Variables
variable.cc File Reference
#include "config.h"
#include <string.h>
#include "cf_assert.h"
#include "cf_defs.h"
#include "variable.h"
#include "canonicalform.h"
#include "cf_factory.h"
#include "int_poly.h"
#include "cf_iter.h"

Go to the source code of this file.

Data Structures

class  ext_entry
 

Functions

static CanonicalForm conv2mipo (const CanonicalForm &mipo, const Variable &alpha)
 
Variable rootOf (const CanonicalForm &mipo, char name)
 returns a symbolic root of polynomial with name name Use it to define algebraic variables More...
 
InternalPolygetInternalMipo (const Variable &alpha)
 
CanonicalForm getMipo (const Variable &alpha, const Variable &x)
 
CanonicalForm getMipo (const Variable &alpha)
 
void setMipo (const Variable &alpha, const CanonicalForm &mipo)
 
bool hasMipo (const Variable &alpha)
 
bool getReduce (const Variable &alpha)
 
void setReduce (const Variable &alpha, bool reduce)
 
char getDefaultVarName ()
 
char getDefaultExtName ()
 
int ExtensionLevel ()
 
void prune (Variable &alpha)
 
void prune1 (const Variable &alpha)
 
void Reduce (bool on)
 

Variables

STATIC_VAR ext_entryalgextensions = 0
 
STATIC_VAR char * var_names = 0
 
STATIC_VAR char * var_names_ext = 0
 
STATIC_VAR char default_name = 'v'
 
STATIC_VAR char default_name_ext = 'a'
 

Function Documentation

◆ conv2mipo()

static CanonicalForm conv2mipo ( const CanonicalForm mipo,
const Variable alpha 
)
static

Definition at line 154 of file variable.cc.

155{
157 for ( CFIterator i = mipo; i.hasTerms(); i++ )
158 result += i.coeff() * power( alpha, i.exp() );
159 return result;
160}
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
int i
Definition: cfEzgcd.cc:132
class to iterate through CanonicalForm's
Definition: cf_iter.h:44
factory's main class
Definition: canonicalform.h:86
Variable alpha
Definition: facAbsBiFact.cc:51
return result
Definition: facAbsBiFact.cc:75
CanonicalForm mipo
Definition: facAlgExt.cc:57

◆ ExtensionLevel()

int ExtensionLevel ( )

Definition at line 254 of file variable.cc.

255{
256 if( var_names_ext == 0)
257 return 0;
258 return strlen( var_names_ext )-1;
259}
STATIC_VAR char * var_names_ext
Definition: variable.cc:43

◆ getDefaultExtName()

char getDefaultExtName ( )

Definition at line 249 of file variable.cc.

250{
251 return default_name_ext;
252}
STATIC_VAR char default_name_ext
Definition: variable.cc:45

◆ getDefaultVarName()

char getDefaultVarName ( )

Definition at line 244 of file variable.cc.

245{
246 return default_name;
247}
STATIC_VAR char default_name
Definition: variable.cc:44

◆ getInternalMipo()

InternalPoly * getInternalMipo ( const Variable alpha)

Definition at line 201 of file variable.cc.

202{
203 ASSERT( alpha.level() < 0 && alpha.level() != LEVELBASE, "illegal extension" );
204 return algextensions[-alpha.level()].mipo();
205}
#define ASSERT(expression, message)
Definition: cf_assert.h:99
#define LEVELBASE
Definition: cf_defs.h:25
int level() const
Definition: variable.h:49
InternalPoly * mipo()
Definition: variable.cc:36
STATIC_VAR ext_entry * algextensions
Definition: variable.cc:41

◆ getMipo() [1/2]

CanonicalForm getMipo ( const Variable alpha)

Definition at line 213 of file variable.cc.

214{
215 ASSERT( alpha.level() < 0 && alpha.level() != LEVELBASE, "illegal extension" );
217}
InternalCF * copyObject()
Definition: int_cf.h:62

◆ getMipo() [2/2]

CanonicalForm getMipo ( const Variable alpha,
const Variable x 
)

Definition at line 207 of file variable.cc.

208{
209 ASSERT( alpha.level() < 0 && alpha.level() != LEVELBASE, "illegal extension" );
211}
Variable x
Definition: cfModGcd.cc:4082

◆ getReduce()

bool getReduce ( const Variable alpha)

Definition at line 232 of file variable.cc.

233{
234 ASSERT( alpha.level() < 0 && alpha.level() != LEVELBASE, "illegal extension" );
235 return algextensions[-alpha.level()].reduce();
236}
bool & reduce()
Definition: variable.cc:38

◆ hasMipo()

bool hasMipo ( const Variable alpha)

Definition at line 226 of file variable.cc.

227{
228 ASSERT( alpha.level() < 0, "illegal extension" );
229 return (alpha.level() != LEVELBASE && (algextensions!=NULL) && getReduce(alpha) );
230}
#define NULL
Definition: omList.c:12
bool getReduce(const Variable &alpha)
Definition: variable.cc:232

◆ prune()

void prune ( Variable alpha)

Definition at line 261 of file variable.cc.

262{
263 if (alpha.level()==LEVELBASE) return;
264 int last_var=-alpha.level();
265 if ((last_var <= 0)||(var_names_ext==NULL)) return;
266 int i, n = strlen( var_names_ext );
267 ASSERT (n+1 >= last_var, "wrong variable");
268 if (last_var == 1)
269 {
270 delete [] var_names_ext;
271 delete [] algextensions;
272 var_names_ext= 0;
273 algextensions= 0;
274 alpha= Variable();
275 return;
276 }
277 char * newvarnames = new char [last_var+1];
278 for ( i = 0; i < last_var; i++ )
279 newvarnames[i] = var_names_ext[i];
280 newvarnames[last_var] = 0;
281 delete [] var_names_ext;
282 var_names_ext = newvarnames;
283 ext_entry * newalgext = new ext_entry [last_var];
284 for ( i = 0; i < last_var; i++ )
285 newalgext[i] = algextensions[i];
286 delete [] algextensions;
287 algextensions = newalgext;
288 alpha= Variable();
289}
factory's class for variables
Definition: variable.h:33
Definition: variable.cc:19

◆ prune1()

void prune1 ( const Variable alpha)

Definition at line 291 of file variable.cc.

292{
293 int i, n = strlen( var_names_ext );
294 ASSERT (n+1 >= -alpha.level(), "wrong variable");
295
296 char * newvarnames = new char [-alpha.level() + 2];
297 for ( i = 0; i <= -alpha.level(); i++ )
298 newvarnames[i] = var_names_ext[i];
299 newvarnames[-alpha.level()+1] = 0;
300 delete [] var_names_ext;
301 var_names_ext = newvarnames;
302 ext_entry * newalgext = new ext_entry [-alpha.level()+1];
303 for ( i = 0; i <= -alpha.level(); i++ )
304 newalgext[i] = algextensions[i];
305 delete [] algextensions;
306 algextensions = newalgext;
307}

◆ Reduce()

void Reduce ( bool  on)

Definition at line 309 of file variable.cc.

310{
311 int i;
312 for (i=ExtensionLevel(); i>0;i--)
313 {
314 Variable l(-i);
315 setReduce(l,on);
316 }
317}
int l
Definition: cfEzgcd.cc:100
void setReduce(const Variable &alpha, bool reduce)
Definition: variable.cc:238
int ExtensionLevel()
Definition: variable.cc:254

◆ rootOf()

Variable rootOf ( const CanonicalForm mipo,
char  name 
)

returns a symbolic root of polynomial with name name Use it to define algebraic variables

Use it to define algebraic variables

Note
: 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
int name
New type name for int.
Definition: templateForC.h:21
static CanonicalForm conv2mipo(const CanonicalForm &mipo, const Variable &alpha)
Definition: variable.cc:154

◆ setMipo()

void setMipo ( const Variable alpha,
const CanonicalForm mipo 
)

Definition at line 219 of file variable.cc.

220{
221 ASSERT( alpha.level() < 0 && alpha.level() != LEVELBASE, "illegal extension" );
222 algextensions[-alpha.level()]= ext_entry( 0, false );
223 algextensions[-alpha.level()]= ext_entry((InternalPoly*)(conv2mipo( mipo, alpha ).getval()), true );
224}

◆ setReduce()

void setReduce ( const Variable alpha,
bool  reduce 
)

Definition at line 238 of file variable.cc.

239{
240 ASSERT( alpha.level() < 0 && alpha.level() != LEVELBASE, "illegal extension" );
242}
CanonicalForm reduce(const CanonicalForm &f, const CanonicalForm &M)
polynomials in M.mvar() are considered coefficients M univariate monic polynomial the coefficients of...
Definition: cf_ops.cc:660

Variable Documentation

◆ algextensions

STATIC_VAR ext_entry* algextensions = 0

Definition at line 41 of file variable.cc.

◆ default_name

STATIC_VAR char default_name = 'v'

Definition at line 44 of file variable.cc.

◆ default_name_ext

STATIC_VAR char default_name_ext = 'a'

Definition at line 45 of file variable.cc.

◆ var_names

STATIC_VAR char* var_names = 0

Definition at line 42 of file variable.cc.

◆ var_names_ext

STATIC_VAR char* var_names_ext = 0

Definition at line 43 of file variable.cc.