Data Structures | Macros | Typedefs | Functions
cf_map.h File Reference

map polynomials More...

#include <iostream>
#include "variable.h"
#include "canonicalform.h"
#include <factory/templates/ftmpl_list.h>

Go to the source code of this file.

Data Structures

class  MapPair
 class MapPair More...
 
class  CFMap
 class CFMap More...
 

Macros

#define OSTREAM   std::ostream
 

Typedefs

typedef List< MapPairMPList
 
typedef ListIterator< MapPairMPListIterator
 

Functions

CanonicalForm compress (const CanonicalForm &f, CFMap &m)
 CanonicalForm compress ( const CanonicalForm & f, CFMap & m ) More...
 
void compress (const CFArray &a, CFMap &M, CFMap &N)
 void compress ( const CFArray & a, CFMap & M, CFMap & N ) More...
 
void compress (const CanonicalForm &f, const CanonicalForm &g, CFMap &M, CFMap &N)
 void compress ( const CanonicalForm & f, const CanonicalForm & g, CFMap & M, CFMap & N ) More...
 

Detailed Description

map polynomials

Definition in file cf_map.h.

Macro Definition Documentation

#define OSTREAM   std::ostream

Definition at line 18 of file cf_map.h.

Typedef Documentation

typedef List<MapPair> MPList

Definition at line 68 of file cf_map.h.

Definition at line 69 of file cf_map.h.

Function Documentation

CanonicalForm compress ( const CanonicalForm f,
CFMap m 
)

CanonicalForm compress ( const CanonicalForm & f, CFMap & m )

compress() - compress the canonical form f.

Compress the polynomial f such that the levels of its polynomial variables are ordered without any gaps starting from level 1. Return the compressed polynomial and a map m to undo the compression. That is, if f' = compress(f, m), than f = m(f').

Definition at line 210 of file cf_map.cc.

211 {
213  int i, n;
214  int * degs = degrees( f );
215 
216  m = CFMap();
217  n = i = 1;
218  while ( i <= level( f ) ) {
219  while( degs[i] == 0 ) i++;
220  if ( i != n ) {
221  // swap variables and remember the swap in the map
222  m.newpair( Variable( n ), Variable( i ) );
223  result = swapvar( result, Variable( i ), Variable( n ) );
224  }
225  n++; i++;
226  }
227  delete [] degs;
228  return result;
229 }
int level(const CanonicalForm &f)
factory&#39;s class for variables
Definition: factory.h:115
int * degrees(const CanonicalForm &f, int *degs=0)
int * degrees ( const CanonicalForm & f, int * degs )
Definition: cf_ops.cc:493
factory&#39;s main class
Definition: canonicalform.h:75
CanonicalForm swapvar(const CanonicalForm &, const Variable &, const Variable &)
swapvar() - swap variables x1 and x2 in f.
Definition: cf_ops.cc:168
FILE * f
Definition: checklibs.c:7
int i
Definition: cfEzgcd.cc:123
class CFMap
Definition: cf_map.h:84
void newpair(const Variable &v, const CanonicalForm &s)
void CFMap::newpair ( const Variable & v, const CanonicalForm & s )
Definition: cf_map.cc:120
return result
Definition: facAbsBiFact.cc:76
void compress ( const CFArray a,
CFMap M,
CFMap N 
)

void compress ( const CFArray & a, CFMap & M, CFMap & N )

compress() - compress the variables occuring in an a.

Compress the polynomial variables occuring in a so that their levels are ordered without any gaps starting from level 1. Return the CFMap M to realize the compression and its inverse, the CFMap N. Note that if you compress a member of a using M the result of the compression is not necessarily compressed, since the map is constructed using all variables occuring in a.

Definition at line 245 of file cf_map.cc.

246 {
247  M = N = CFMap();
248  if ( a.size() == 0 )
249  return;
250  int maxlevel = level( a[a.min()] );
251  int i, j;
252 
253  // get the maximum of levels in a
254  for ( i = a.min() + 1; i <= a.max(); i++ )
255  if ( level( a[i] ) > maxlevel )
256  maxlevel = level( a[i] );
257  if ( maxlevel <= 0 )
258  return;
259 
260  int * degs = new int[maxlevel+1];
261  int * tmp = new int[maxlevel+1];
262  for ( i = 1; i <= maxlevel; i++ )
263  degs[i] = 0;
264 
265  // calculate the union of all levels occuring in a
266  for ( i = a.min(); i <= a.max(); i++ ) {
267  tmp = degrees( a[i], tmp );
268  for ( j = 1; j <= level( a[i] ); j++ )
269  if ( tmp[j] != 0 )
270  degs[j] = 1;
271  }
272 
273  // create the maps
274  i = 1; j = 1;
275  while ( i <= maxlevel ) {
276  if ( degs[i] != 0 ) {
277  M.newpair( Variable(i), Variable(j) );
278  N.newpair( Variable(j), Variable(i) );
279  j++;
280  }
281  i++;
282  }
283  delete [] tmp;
284  delete [] degs;
285 }
int level(const CanonicalForm &f)
factory&#39;s class for variables
Definition: factory.h:115
int size() const
Definition: ftmpl_array.cc:92
int * degrees(const CanonicalForm &f, int *degs=0)
int * degrees ( const CanonicalForm & f, int * degs )
Definition: cf_ops.cc:493
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
class CFMap
Definition: cf_map.h:84
int min() const
Definition: ftmpl_array.cc:98
void newpair(const Variable &v, const CanonicalForm &s)
void CFMap::newpair ( const Variable & v, const CanonicalForm & s )
Definition: cf_map.cc:120
int max() const
Definition: ftmpl_array.cc:104
void compress ( const CanonicalForm f,
const CanonicalForm g,
CFMap M,
CFMap N 
)

void compress ( const CanonicalForm & f, const CanonicalForm & g, CFMap & M, CFMap & N )

compress() - compress the variables occurring in f and g with respect to optimal variables

Compress the polynomial variables occurring in f and g so that the levels of variables common to f and g are ordered without any gaps starting from level 1, whereas the variables occuring in only one of f or g are moved to levels higher than the levels of the common variables. Return the CFMap M to realize the compression and its inverse, the CFMap N. N needs only variables common to f and g.

Definition at line 346 of file cf_map.cc.

347 {
348  int n = tmax( f.level(), g.level() );
349  int i, k, p1, pe;
350  int * degsf = new int[n+1];
351  int * degsg = new int[n+1];
352 
353  for ( i = 0; i <= n; i++ )
354  {
355  degsf[i] = degsg[i] = 0;
356  }
357 
358  degsf = degrees( f, degsf );
359  degsg = degrees( g, degsg );
360  optvalues( degsf, degsg, n, p1, pe );
361 
362  i = 1; k = 1;
363  if ( pe > 1 )
364  {
365  M.newpair( Variable(pe), Variable(k) );
366  N.newpair( Variable(k), Variable(pe) );
367  k++;
368  }
369  while ( i <= n )
370  {
371  if ( degsf[i] > 0 && degsg[i] > 0 )
372  {
373  if ( ( i != k ) && ( i != pe ) && ( i != p1 ) )
374  {
375  M.newpair( Variable(i), Variable(k) );
376  N.newpair( Variable(k), Variable(i) );
377  }
378  k++;
379  }
380  i++;
381  }
382  if ( p1 != pe )
383  {
384  M.newpair( Variable(p1), Variable(k) );
385  N.newpair( Variable(k), Variable(p1) );
386  k++;
387  }
388  i = 1;
389  while ( i <= n )
390  {
391  if ( degsf[i] > 0 && degsg[i] == 0 ) {
392  if ( i != k )
393  {
394  M.newpair( Variable(i), Variable(k) );
395  k++;
396  }
397  }
398  else if ( degsf[i] == 0 && degsg[i] > 0 )
399  {
400  if ( i != k )
401  {
402  M.newpair( Variable(i), Variable(k) );
403  k++;
404  }
405  }
406  i++;
407  }
408 
409  delete [] degsf;
410  delete [] degsg;
411 }
template CanonicalForm tmax(const CanonicalForm &, const CanonicalForm &)
factory&#39;s class for variables
Definition: factory.h:115
int * degrees(const CanonicalForm &f, int *degs=0)
int * degrees ( const CanonicalForm & f, int * degs )
Definition: cf_ops.cc:493
int * degsg
Definition: cfEzgcd.cc:54
int k
Definition: cfEzgcd.cc:93
int level() const
level() returns the level of CO.
int i
Definition: cfEzgcd.cc:123
static void optvalues(const int *df, const int *dg, const int n, int &p1, int &pe)
Definition: cf_map.cc:293
void newpair(const Variable &v, const CanonicalForm &s)
void CFMap::newpair ( const Variable & v, const CanonicalForm & s )
Definition: cf_map.cc:120
int * degsf
Definition: cfEzgcd.cc:53