My Project
Loading...
Searching...
No Matches
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 57 of file callgfanlib_conversion.cc.

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

◆ bigintmatToZVector()

gfan::ZVector * bigintmatToZVector ( const bigintmat bim)

Definition at line 73 of file callgfanlib_conversion.cc.

74{
75 gfan::ZVector* zv=new gfan::ZVector(bim.cols());
76 for(int j=0; j<bim.cols(); j++)
77 {
78 number temp = BIMATELEM(bim, 1, j+1);
79 gfan::Integer* gi = numberToInteger(temp);
80 (*zv)[j] = *gi;
81 delete gi;
82 }
83 return zv;
84}

◆ expvToZVector()

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

Definition at line 94 of file callgfanlib_conversion.cc.

95{
96 gfan::ZVector zv(n);
97 for(int i=0; i<n; i++)
98 zv[i]=gfan::Integer(expv[i+1]);
99 return zv;
100}

◆ 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
15 number j = n_InitMPZ(i,coeffs_BIGINT);
16
17 mpz_clear(i);
18 return j;
19}
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
Definition: coeffs.h:539
VAR coeffs coeffs_BIGINT
Definition: ipid.cc:50

◆ intStar2ZVector()

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

Definition at line 86 of file callgfanlib_conversion.cc.

87{
88 gfan::ZVector zv(d);
89 for(int j=0; j<d; j++)
90 zv[j]=i[j+1];
91 return zv;
92}

◆ numberToInteger()

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

Definition at line 49 of file callgfanlib_conversion.cc.

50{
51 if (SR_HDL(n) & SR_INT)
52 return new gfan::Integer(SR_TO_INT(n));
53 else
54 return new gfan::Integer(n->z);
55}
#define SR_INT
Definition: longrat.h:67
#define SR_TO_INT(SR)
Definition: longrat.h:69
#define SR_HDL(A)
Definition: tgb.cc:35

◆ rays()

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

Definition at line 151 of file callgfanlib_conversion.cc.

152{
153 std::set<gfan::ZVector> setOfRays;
154 for (std::set<gfan::ZCone>::iterator cone = setOfCones.begin(); cone!=setOfCones.end(); cone++)
155 {
156 gfan::ZMatrix raysOfCone = cone->extremeRays();
157 for (int i=0; i<raysOfCone.getHeight(); i++)
158 setOfRays.insert(raysOfCone[i]);
159 }
160 return setOfRays;
161}

◆ toFanStar()

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

Definition at line 137 of file callgfanlib_conversion.cc.

138{
139 if (setOfCones.size() > 0)
140 {
141 std::set<gfan::ZCone>::iterator cone = setOfCones.begin();
142 gfan::ZFan* zf = new gfan::ZFan(cone->ambientDimension());
143 for (std::set<gfan::ZCone>::iterator cone = setOfCones.begin(); cone!=setOfCones.end(); cone++)
144 zf->insert(*cone);
145 return zf;
146 }
147 else
148 return new gfan::ZFan(gfan::ZFan::fullFan(currRing->N));
149}
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13

◆ toString()

char * toString ( gfan::ZMatrix const m)

Definition at line 127 of file callgfanlib_conversion.cc.

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

◆ wvhdlEntryToZVector()

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

Definition at line 102 of file callgfanlib_conversion.cc.

103{
104 gfan::ZVector zv(n);
105 for(int j=0; j<n; j++)
106 zv[j]=wvhdl0[j];
107 return zv;
108}

◆ zMatrixToBigintmat()

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

Definition at line 34 of file callgfanlib_conversion.cc.

35{
36 int d=zm.getHeight();
37 int n=zm.getWidth();
38 bigintmat* bim = new bigintmat(d,n,coeffs_BIGINT);
39 for(int i=1;i<=d;i++)
40 for(int j=1; j<=n; j++)
41 {
42 number temp = integerToNumber(zm[i-1][j-1]);
43 bim->set(i,j,temp);
45 }
46 return bim;
47}
number integerToNumber(const gfan::Integer &I)
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:95
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:452

◆ zVectorToBigintmat()

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

Definition at line 21 of file callgfanlib_conversion.cc.

22{
23 int d=zv.size();
24 bigintmat* bim = new bigintmat(1,d,coeffs_BIGINT);
25 for(int i=1;i<=d;i++)
26 {
27 number temp = integerToNumber(zv[i-1]);
28 bim->set(1,i,temp);
30 }
31 return bim;
32}

◆ ZVectorToIntStar()

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

Definition at line 110 of file callgfanlib_conversion.cc.

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