My Project
Static Public Member Functions | Static Private Attributes
CFFactory Class Reference

#include <cf_factory.h>

Static Public Member Functions

static int gettype ()
 
static void settype (int type)
 
static InternalCF * basic (int value)
 
static InternalCF * basic (long value)
 
static InternalCF * basic (int type, long value)
 
static InternalCF * basic (const char *str)
 
static InternalCF * basic (const char *str, int base)
 
static InternalCF * basic (int type, const char *const str)
 
static InternalCF * basic (int type, long value, bool nonimm)
 
static InternalCF * basic (const mpz_ptr num)
 
static InternalCF * rational (long num, long den)
 
static InternalCF * rational (const mpz_ptr num, const mpz_ptr den, bool normalize)
 
static InternalCF * poly (const Variable &v, int exp, const CanonicalForm &c)
 
static InternalCF * poly (const Variable &v, int exp=1)
 

Static Private Attributes

static int currenttype = IntegerDomain
 

Detailed Description

Definition at line 23 of file cf_factory.h.

Member Function Documentation

◆ basic() [1/8]

InternalCF * CFFactory::basic ( const char *  str)
static

Definition at line 122 of file cf_factory.cc.

123 {
124  if ( currenttype == IntegerDomain ) {
125  InternalInteger * dummy = new InternalInteger( str );
126  if ( dummy->is_imm() ) {
127  InternalCF * res = int2imm( dummy->intval() );
128  delete dummy;
129  return res;
130  }
131  else
132  return dummy;
133  }
134 // else if ( currenttype == RationalDomain ) {
135 // InternalRational * dummy = new InternalRational( str );
136 // if ( dummy->is_imm() ) {
137 // InternalCF * res = int2imm( dummy->intval() );
138 // delete dummy;
139 // return res;
140 // }
141 // else
142 // return dummy;
143 // }
144  else if ( currenttype == FiniteFieldDomain ) {
145  InternalInteger * dummy = new InternalInteger( str );
146  InternalCF * res = int2imm_p( dummy->intmod( ff_prime ) );
147  delete dummy;
148  return res;
149  }
150  else if ( currenttype == GaloisFieldDomain ) {
151  InternalInteger * dummy = new InternalInteger( str );
152  InternalCF * res = int2imm_gf( gf_int2gf( dummy->intmod( ff_prime ) ) );
153  delete dummy;
154  return res;
155  }
156  else {
157  ASSERT( 0, "illegal basic domain!" );
158  return 0;
159  }
160 }
#define ASSERT(expression, message)
Definition: cf_assert.h:99
#define FiniteFieldDomain
Definition: cf_defs.h:19
#define IntegerDomain
Definition: cf_defs.h:21
#define GaloisFieldDomain
Definition: cf_defs.h:18
static int currenttype
Definition: cf_factory.h:26
virtual class for internal CanonicalForm's
Definition: int_cf.h:47
factory's class for integers
Definition: int_int.h:41
long intval() const
Definition: int_int.cc:506
bool is_imm() const
Definition: int_int.cc:41
int intmod(int p) const
Definition: int_int.cc:511
CanonicalForm res
Definition: facAbsFact.cc:60
VAR int ff_prime
Definition: ffops.cc:14
int gf_int2gf(int i)
Definition: gfops.h:65
InternalCF * int2imm_p(long i)
Definition: imm.h:101
static InternalCF * int2imm(long i)
Definition: imm.h:75
InternalCF * int2imm_gf(long i)
Definition: imm.h:106
char * str(leftv arg)
Definition: shared.cc:704

◆ basic() [2/8]

InternalCF * CFFactory::basic ( const char *  str,
int  base 
)
static

Definition at line 163 of file cf_factory.cc.

164 {
165  if ( currenttype == IntegerDomain ) {
166  InternalInteger * dummy = new InternalInteger( str, base );
167  if ( dummy->is_imm() ) {
168  InternalCF * res = int2imm( dummy->intval() );
169  delete dummy;
170  return res;
171  }
172  else
173  return dummy;
174  }
175 // else if ( currenttype == RationalDomain ) {
176 // InternalRational * dummy = new InternalRational( str );
177 // if ( dummy->is_imm() ) {
178 // InternalCF * res = int2imm( dummy->intval() );
179 // delete dummy;
180 // return res;
181 // }
182 // else
183 // return dummy;
184 // }
185  else if ( currenttype == FiniteFieldDomain ) {
186  InternalInteger * dummy = new InternalInteger( str, base );
187  InternalCF * res = int2imm_p( dummy->intmod( ff_prime ) );
188  delete dummy;
189  return res;
190  }
191  else if ( currenttype == GaloisFieldDomain ) {
192  InternalInteger * dummy = new InternalInteger( str, base );
193  InternalCF * res = int2imm_gf( gf_int2gf( dummy->intmod( ff_prime ) ) );
194  delete dummy;
195  return res;
196  }
197  else {
198  ASSERT( 0, "illegal basic domain!" );
199  return 0;
200  }
201 }
char N base
Definition: ValueTraits.h:144

◆ basic() [3/8]

InternalCF * CFFactory::basic ( const mpz_ptr  num)
static

Definition at line 261 of file cf_factory.cc.

262 {
263  ASSERT (currenttype == IntegerDomain, "Integer domain expected");
264  return new InternalInteger( num );
265 }
CanonicalForm num(const CanonicalForm &f)

◆ basic() [4/8]

InternalCF * CFFactory::basic ( int  type,
const char *const  str 
)
static

Definition at line 204 of file cf_factory.cc.

205 {
206  if ( type == IntegerDomain ) {
207  InternalInteger * dummy = new InternalInteger( str );
208  if ( dummy->is_imm() ) {
209  InternalCF * res = int2imm( dummy->intval() );
210  delete dummy;
211  return res;
212  }
213  else
214  return dummy;
215  }
216 // else if ( type == RationalDomain ) {
217 // InternalRational * dummy = new InternalRational( str );
218 // if ( dummy->is_imm() ) {
219 // InternalCF * res = int2imm( dummy->intval() );
220 // delete dummy;
221 // return res;
222 // }
223 // else
224 // return dummy;
225 // }
226  else if ( type == FiniteFieldDomain ) {
227  InternalInteger * dummy = new InternalInteger( str );
228  InternalCF * res = int2imm( dummy->intmod( ff_prime ) );
229  delete dummy;
230  return res;
231  }
232  else if ( type == GaloisFieldDomain ) {
233  InternalInteger * dummy = new InternalInteger( str );
234  InternalCF * res = int2imm_gf( gf_int2gf( dummy->intmod( ff_prime ) ) );
235  delete dummy;
236  return res;
237  }
238  else {
239  ASSERT( 0, "illegal basic domain!" );
240  return 0;
241  }
242 }

◆ basic() [5/8]

InternalCF * CFFactory::basic ( int  type,
long  value 
)
static

Definition at line 99 of file cf_factory.cc.

100 {
101  if ( type == IntegerDomain )
102  if (LIKELY( value >= MINIMMEDIATE && value <= MAXIMMEDIATE ))
103  return int2imm( value );
104  else
105  return new InternalInteger( value );
106 // else if ( type == RationalDomain )
107 // if ( value >= MINIMMEDIATE && value <= MAXIMMEDIATE )
108 // return int2imm( value );
109 // else
110 // return new InternalRational( value );
111  else if ( type == FiniteFieldDomain )
112  return int2imm_p( ff_norm( value ) );
113  else if ( type == GaloisFieldDomain )
114  return int2imm_gf( gf_int2gf( value ) );
115  else {
116  ASSERT1( 0, "illegal basic domain (type = %d)!", type );
117  return 0;
118  }
119 }
#define ASSERT1(expression, message, parameter1)
Definition: cf_assert.h:101
#define LIKELY(expression)
For optimizing if-branches.
Definition: cf_factory.cc:24
int ff_norm(const int a)
Definition: ffops.h:39
const long MAXIMMEDIATE
Definition: imm.h:55
const long MINIMMEDIATE
Definition: imm.h:54

◆ basic() [6/8]

InternalCF * CFFactory::basic ( int  type,
long  value,
bool  nonimm 
)
static

Definition at line 245 of file cf_factory.cc.

246 {
247  if ( nonimm )
248  if ( type == IntegerDomain )
249  return new InternalInteger( value );
250  else if ( type == RationalDomain )
251  return new InternalRational( value );
252  else {
253  ASSERT( 0, "illegal basic domain!" );
254  return 0;
255  }
256  else
257  return CFFactory::basic( type, value );
258 }
#define RationalDomain
Definition: cf_defs.h:20
static InternalCF * basic(int value)
Definition: cf_factory.cc:61
factory's class for rationals
Definition: int_rat.h:39

◆ basic() [7/8]

InternalCF * CFFactory::basic ( int  value)
static

Definition at line 61 of file cf_factory.cc.

62 {
63  switch(currenttype)
64  {
65  case IntegerDomain:
66 #if SIZEOF_LONG == 8
67  return int2imm( value );
68 #else
69  if (LIKELY( value >= MINIMMEDIATE && value <= MAXIMMEDIATE ))
70  return int2imm( value );
71  else
72  return new InternalInteger( value );
73 #endif
74  case RationalDomain:
75 #if SIZEOF_LONG == 8
76  return int2imm( value );
77 #else
78  if (LIKELY( value >= MINIMMEDIATE && value <= MAXIMMEDIATE ))
79  return int2imm( value );
80  else
81  return new InternalRational( value );
82 #endif
83  case FiniteFieldDomain:
84  return int2imm_p( ff_norm( value ) );
85  case GaloisFieldDomain:
86  return int2imm_gf( gf_int2gf( value ) );
87  #ifndef HAVE_NTL
88  case PrimePowerDomain:
89  return new InternalPrimePower( value );
90  #endif
91  default: {
92  ASSERT( 0, "illegal basic domain!" );
93  return 0;
94  }
95  }
96 }
#define PrimePowerDomain
Definition: cf_defs.h:17

◆ basic() [8/8]

InternalCF * CFFactory::basic ( long  value)
static

Definition at line 31 of file cf_factory.cc.

32 {
33  switch(currenttype)
34  {
35  case IntegerDomain:
36  if (LIKELY( value >= MINIMMEDIATE && value <= MAXIMMEDIATE ))
37  return int2imm( value );
38  else
39  return new InternalInteger( value );
40 // else if ( currenttype == RationalDomain )
41 // if ( value >= MINIMMEDIATE && value <= MAXIMMEDIATE )
42 // return int2imm( value );
43 // else
44 // return new InternalRational( value );
45  case FiniteFieldDomain:
46  return int2imm_p( ff_norm( value ) );
47  case GaloisFieldDomain:
48  return int2imm_gf( gf_int2gf( value ) );
49  #ifndef HAVE_NTL
50  case PrimePowerDomain:
51  return new InternalPrimePower( value );
52  #endif
53  default: {
54  ASSERT( 0, "illegal basic domain!" );
55  return 0;
56  }
57  }
58 }

◆ gettype()

static int CFFactory::gettype ( )
inlinestatic

Definition at line 28 of file cf_factory.h.

28 { return currenttype; }

◆ poly() [1/2]

InternalCF * CFFactory::poly ( const Variable &  v,
int  exp,
const CanonicalForm &  c 
)
static

Definition at line 286 of file cf_factory.cc.

287 {
288  if ( v.level() == LEVELBASE )
289  return c.getval();
290  else
291  return new InternalPoly( v, exp, c );
292 }
#define LEVELBASE
Definition: cf_defs.h:25
InternalCF * getval() const
factory's class for polynomials
Definition: int_poly.h:71
int level() const
Definition: factory.h:143
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357

◆ poly() [2/2]

InternalCF * CFFactory::poly ( const Variable &  v,
int  exp = 1 
)
static

Definition at line 295 of file cf_factory.cc.

296 {
297  if ( v.level() == LEVELBASE )
298  return CFFactory::basic( 1L );
299  else
300  return new InternalPoly( v, exp, 1 );
301 }

◆ rational() [1/2]

InternalCF * CFFactory::rational ( const mpz_ptr  num,
const mpz_ptr  den,
bool  normalize 
)
static

Definition at line 275 of file cf_factory.cc.

276 {
277  if ( normalize ) {
279  return result->normalize_myself();
280  }
281  else
282  return new InternalRational( num, den );
283 }
CanonicalForm den(const CanonicalForm &f)
return result
Definition: facAbsBiFact.cc:75
static poly normalize(poly next_p, ideal add_generators, syStrategy syzstr, int *g_l, int *p_l, int crit_comp)
Definition: syz3.cc:1026

◆ rational() [2/2]

InternalCF * CFFactory::rational ( long  num,
long  den 
)
static

Definition at line 268 of file cf_factory.cc.

269 {
271  return res->normalize_myself();
272 }

◆ settype()

static void CFFactory::settype ( int  type)
inlinestatic

Definition at line 29 of file cf_factory.h.

30  {
31  ASSERT( type==FiniteFieldDomain || type==GaloisFieldDomain || type==IntegerDomain || type==RationalDomain || type==PrimePowerDomain, "illegal basic domain!" );
32  currenttype = type;
33  };

Field Documentation

◆ currenttype

int CFFactory::currenttype = IntegerDomain
staticprivate

Definition at line 26 of file cf_factory.h.


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