My Project  UNKNOWN_GIT_VERSION
singext.cc
Go to the documentation of this file.
1 /* emacs edit mode for this file is -*- C++ -*- */
2 
3 
4 #include "config.h"
5 
6 
7 #include "cf_assert.h"
8 
9 #include "cf_defs.h"
10 #include "singext.h"
11 #include "int_cf.h"
12 #include "int_int.h"
13 #include "int_rat.h"
14 #include "imm.h"
15 #include "cf_factory.h"
16 
17 #include "factory/cf_gmp.h"
18 
19 
20 void gmp_numerator ( const CanonicalForm & f, mpz_ptr result )
21 {
22  InternalCF * ff = f.getval();
23  ASSERT( ! is_imm( ff ), "illegal type" );
24  if ( ff->levelcoeff() == IntegerDomain )
25  {
26  mpz_init_set( result, (InternalInteger::MPI( ff )) );
27  ff->deleteObject();
28  }
29  else if ( ff->levelcoeff() == RationalDomain )
30  {
31  mpz_init_set( result, (InternalRational::MPQNUM( ff )) );
32  ff->deleteObject();
33  }
34  else
35  {
36  ASSERT( 0, "illegal type" );
37  }
38 }
39 
40 void gmp_denominator ( const CanonicalForm & f, mpz_ptr result )
41 {
42  InternalCF * ff = f.getval();
43  ASSERT( ! is_imm( ff ), "illegal type" );
44  if ( ff->levelcoeff() == IntegerDomain )
45  {
46  mpz_init_set_si( result, 1 );
47  ff->deleteObject();
48  }
49  else if ( ff->levelcoeff() == RationalDomain )
50  {
51  mpz_init_set( result, (InternalRational::MPQDEN( ff )) );
52  ff->deleteObject();
53  }
54  else
55  {
56  ASSERT( 0, "illegal type" );
57  }
58 }
59 
60 int gf_value (const CanonicalForm & f )
61 {
62  InternalCF * ff = f.getval();
63  return ((intptr_t)ff) >>2;
64 }
65 
66 CanonicalForm make_cf ( const mpz_ptr n )
67 {
68  return CanonicalForm( CFFactory::basic( n ) );
69 }
70 
71 CanonicalForm make_cf ( const mpz_ptr n, const mpz_ptr d, bool normalize )
72 {
73  return CanonicalForm( CFFactory::rational( n, d, normalize ) );
74 }
75 
77 {
78  return CanonicalForm(int2imm_gf(z));
79 }
void gmp_numerator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:20
Factory's internal rationals.
int deleteObject()
Definition: int_cf.h:61
static poly normalize(poly next_p, ideal add_generators, syStrategy syzstr, int *g_l, int *p_l, int crit_comp)
Definition: syz3.cc:1027
factory's main class
Definition: canonicalform.h:77
assertions for Factory
static mpz_ptr MPQDEN(const InternalCF *const c)
Definition: int_rat.h:124
virtual class for internal CanonicalForm's
Definition: int_cf.h:41
#define IntegerDomain
Definition: cf_defs.h:25
virtual int levelcoeff() const
Definition: int_cf.h:68
CanonicalForm make_cf(const mpz_ptr n)
Definition: singext.cc:66
int gf_value(const CanonicalForm &f)
Definition: singext.cc:60
helper functions for conversion to and from Singular
static InternalCF * rational(long num, long den)
Definition: cf_factory.cc:225
Interface to generate InternalCF's over various domains from intrinsic types or mpz_t's.
InternalCF * int2imm_gf(long i)
Definition: imm.h:106
FILE * f
Definition: checklibs.c:9
static InternalCF * basic(long value)
Definition: cf_factory.cc:30
factory switches.
#define RationalDomain
Definition: cf_defs.h:24
static mpz_ptr MPI(const InternalCF *const c)
MPI() - return underlying mpz_t of ā€˜c’.
Definition: int_int.h:232
CanonicalForm make_cf_from_gf(const int z)
Definition: singext.cc:76
void gmp_denominator(const CanonicalForm &f, mpz_ptr result)
Definition: singext.cc:40
int is_imm(const InternalCF *const ptr)
Definition: canonicalform.h:62
operations on immediates, that is elements of F_p, GF, Z, Q that fit into intrinsic int,...
Factory's internal CanonicalForm's.
#define ASSERT(expression, message)
Definition: cf_assert.h:99
return result
Definition: facAbsBiFact.cc:76
static mpz_ptr MPQNUM(const InternalCF *const c)
Definition: int_rat.h:119
Factory's internal integers.