Functions
callgfanlib_conversion.h File Reference
#include <gfanlib/gfanlib.h>
#include <coeffs/bigintmat.h>
#include <coeffs/longrat.h>
#include <coeffs/numbers.h>

Go to the source code of this file.

Functions

gfan::Integer * numberToInteger (const number &n)
 
number integerToNumber (const gfan::Integer &I)
 
bigintmatzVectorToBigintmat (const gfan::ZVector &zv)
 
bigintmatzMatrixToBigintmat (const gfan::ZMatrix &zm)
 
gfan::ZMatrix * bigintmatToZMatrix (const bigintmat &bim)
 
gfan::ZVector * bigintmatToZVector (const bigintmat &bim)
 
gfan::ZVector intStar2ZVector (const int d, const int *i)
 
gfan::ZVector wvhdlEntryToZVector (const int n, const int *wvhdl0)
 
int * ZVectorToIntStar (const gfan::ZVector &v, bool &overflow)
 
char * toString (gfan::ZMatrix const &m)
 
gfan::ZVector expvToZVector (const int n, const int *expv)
 
gfan::ZFan * toFanStar (std::set< gfan::ZCone > setOfCones)
 
std::set< gfan::ZVector > rays (std::set< gfan::ZCone > setOfCones)
 

Function Documentation

§ bigintmatToZMatrix()

gfan::ZMatrix* bigintmatToZMatrix ( const bigintmat bim)

Definition at line 60 of file callgfanlib_conversion.cc.

61 {
62  int d=bim.rows();
63  int n=bim.cols();
64  gfan::ZMatrix* zm = new gfan::ZMatrix(d,n);
65  for(int i=0;i<d;i++)
66  for(int j=0;j<n;j++)
67  {
68  number temp = BIMATELEM(bim, i+1, j+1);
69  gfan::Integer* gi = numberToInteger(temp);
70  (*zm)[i][j] = *gi;
71  delete gi;
72  }
73  return zm;
74 }
int rows() const
Definition: bigintmat.h:146
gfan::Integer * numberToInteger(const number &n)
int j
Definition: myNF.cc:70
int cols() const
Definition: bigintmat.h:145
int i
Definition: cfEzgcd.cc:123
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:134

§ bigintmatToZVector()

gfan::ZVector* bigintmatToZVector ( const bigintmat bim)

Definition at line 76 of file callgfanlib_conversion.cc.

77 {
78  gfan::ZVector* zv=new gfan::ZVector(bim.cols());
79  for(int j=0; j<bim.cols(); j++)
80  {
81  number temp = BIMATELEM(bim, 1, j+1);
82  gfan::Integer* gi = numberToInteger(temp);
83  (*zv)[j] = *gi;
84  n_Delete(&temp,coeffs_BIGINT);
85  delete gi;
86  }
87  return zv;
88 }
coeffs coeffs_BIGINT
Definition: ipid.cc:54
gfan::Integer * numberToInteger(const number &n)
int j
Definition: myNF.cc:70
int cols() const
Definition: bigintmat.h:145
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:134
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459

§ expvToZVector()

gfan::ZVector expvToZVector ( const int  n,
const int *  expv 
)

Definition at line 98 of file callgfanlib_conversion.cc.

99 {
100  gfan::ZVector zv(n);
101  for(int i=0; i<n; i++)
102  zv[i]=gfan::Integer(expv[i+1]);
103  return zv;
104 }
int i
Definition: cfEzgcd.cc:123

§ integerToNumber()

number integerToNumber ( const gfan::Integer &  I)

Definition at line 9 of file callgfanlib_conversion.cc.

10 {
11  mpz_t i;
12  mpz_init(i);
13  I.setGmp(i);
14  long m = 268435456;
15  if(mpz_cmp_si(i,m))
16  {
17  int temp = (int) mpz_get_si(i);
18  return n_Init(temp,coeffs_BIGINT);
19  }
20  else
21  return n_InitMPZ(i,coeffs_BIGINT);
22 }
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:542
coeffs coeffs_BIGINT
Definition: ipid.cc:54
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
Definition: coeffs.h:546
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123

§ intStar2ZVector()

gfan::ZVector intStar2ZVector ( const int  d,
const int *  i 
)

Definition at line 90 of file callgfanlib_conversion.cc.

91 {
92  gfan::ZVector zv(d);
93  for(int j=0; j<d; j++)
94  zv[j]=i[j+1];
95  return zv;
96 }
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123

§ numberToInteger()

gfan::Integer* numberToInteger ( const number &  n)

Definition at line 52 of file callgfanlib_conversion.cc.

53 {
54  if (SR_HDL(n) & SR_INT)
55  return new gfan::Integer(SR_TO_INT(n));
56  else
57  return new gfan::Integer(n->z);
58 }
#define SR_TO_INT(SR)
Definition: longrat.h:70
#define SR_INT
Definition: longrat.h:68
#define SR_HDL(A)
Definition: tgb.cc:35

§ rays()

std::set<gfan::ZVector> rays ( std::set< gfan::ZCone >  setOfCones)

Definition at line 155 of file callgfanlib_conversion.cc.

156 {
157  std::set<gfan::ZVector> setOfRays;
158  for (std::set<gfan::ZCone>::iterator cone = setOfCones.begin(); cone!=setOfCones.end(); cone++)
159  {
160  gfan::ZMatrix raysOfCone = cone->extremeRays();
161  for (int i=0; i<raysOfCone.getHeight(); i++)
162  setOfRays.insert(raysOfCone[i]);
163  }
164  return setOfRays;
165 }
int i
Definition: cfEzgcd.cc:123

§ toFanStar()

gfan::ZFan* toFanStar ( std::set< gfan::ZCone >  setOfCones)

Definition at line 141 of file callgfanlib_conversion.cc.

142 {
143  if (setOfCones.size() > 0)
144  {
145  std::set<gfan::ZCone>::iterator cone = setOfCones.begin();
146  gfan::ZFan* zf = new gfan::ZFan(cone->ambientDimension());
147  for (std::set<gfan::ZCone>::iterator cone = setOfCones.begin(); cone!=setOfCones.end(); cone++)
148  zf->insert(*cone);
149  return zf;
150  }
151  else
152  return new gfan::ZFan(gfan::ZFan::fullFan(currRing->N));
153 }
BOOLEAN fullFan(leftv res, leftv args)
Definition: bbfan.cc:229
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10

§ toString()

char* toString ( gfan::ZMatrix const m)

Definition at line 131 of file callgfanlib_conversion.cc.

132 {
133  bigintmat* bim = zMatrixToBigintmat(zm);
134  char* s = bim->StringAsPrinted();
135  if (s==NULL)
136  s = (char*) omAlloc0(sizeof(char));
137  delete bim;
138  return s;
139 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
Matrices of numbers.
Definition: bigintmat.h:51
bigintmat * zMatrixToBigintmat(const gfan::ZMatrix &zm)
char * StringAsPrinted()
Returns a string as it would have been printed in the interpreter.
Definition: bigintmat.cc:454
#define NULL
Definition: omList.c:10
#define omAlloc0(size)
Definition: omAllocDecl.h:211

§ wvhdlEntryToZVector()

gfan::ZVector wvhdlEntryToZVector ( const int  n,
const int *  wvhdl0 
)

Definition at line 106 of file callgfanlib_conversion.cc.

107 {
108  gfan::ZVector zv(n);
109  for(int j=0; j<n; j++)
110  zv[j]=wvhdl0[j];
111  return zv;
112 }
int j
Definition: myNF.cc:70

§ zMatrixToBigintmat()

bigintmat* zMatrixToBigintmat ( const gfan::ZMatrix &  zm)

Definition at line 37 of file callgfanlib_conversion.cc.

38 {
39  int d=zm.getHeight();
40  int n=zm.getWidth();
41  bigintmat* bim = new bigintmat(d,n,coeffs_BIGINT);
42  for(int i=1;i<=d;i++)
43  for(int j=1; j<=n; j++)
44  {
45  number temp = integerToNumber(zm[i-1][j-1]);
46  bim->set(i,j,temp);
47  n_Delete(&temp,coeffs_BIGINT);
48  }
49  return bim;
50 }
Matrices of numbers.
Definition: bigintmat.h:51
coeffs coeffs_BIGINT
Definition: ipid.cc:54
void set(int i, int j, number n, const coeffs C=NULL)
replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
Definition: bigintmat.cc:96
int j
Definition: myNF.cc:70
number integerToNumber(const gfan::Integer &I)
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459

§ zVectorToBigintmat()

bigintmat* zVectorToBigintmat ( const gfan::ZVector &  zv)

Definition at line 24 of file callgfanlib_conversion.cc.

25 {
26  int d=zv.size();
27  bigintmat* bim = new bigintmat(1,d,coeffs_BIGINT);
28  for(int i=1;i<=d;i++)
29  {
30  number temp = integerToNumber(zv[i-1]);
31  bim->set(1,i,temp);
32  n_Delete(&temp,coeffs_BIGINT);
33  }
34  return bim;
35 }
Matrices of numbers.
Definition: bigintmat.h:51
coeffs coeffs_BIGINT
Definition: ipid.cc:54
void set(int i, int j, number n, const coeffs C=NULL)
replace an entry with a copy (delete old + copy new!). NOTE: starts at [1,1]
Definition: bigintmat.cc:96
number integerToNumber(const gfan::Integer &I)
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:459

§ ZVectorToIntStar()

int* ZVectorToIntStar ( const gfan::ZVector &  v,
bool &  overflow 
)

Definition at line 114 of file callgfanlib_conversion.cc.

115 {
116  int* w = (int*) omAlloc(v.size()*sizeof(int));
117  for (unsigned i=0; i<v.size(); i++)
118  {
119  if (!v[i].fitsInInt())
120  {
121  omFree(w);
122  WerrorS("intoverflow converting gfan:ZVector to int*");
123  overflow = true;
124  return NULL;
125  }
126  w[i]=v[i].toInt();
127  }
128  return w;
129 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define omFree(addr)
Definition: omAllocDecl.h:261
int i
Definition: cfEzgcd.cc:123
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define NULL
Definition: omList.c:10
const CanonicalForm & w
Definition: facAbsFact.cc:55