My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
Singular
dyn_modules
gfanlib
callgfanlib_conversion.cc
Go to the documentation of this file.
1
#include "gfanlib/gfanlib.h"
2
3
#include "
coeffs/bigintmat.h
"
4
#include "
coeffs/longrat.h
"
5
#include "
coeffs/numbers.h
"
6
7
#include "
Singular/ipid.h
"
// for coeffs_BIGINT
8
9
number
integerToNumber
(
const
gfan::Integer &I)
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
}
20
21
bigintmat
*
zVectorToBigintmat
(
const
gfan::ZVector &zv)
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);
29
n_Delete
(&temp,
coeffs_BIGINT
);
30
}
31
return
bim;
32
}
33
34
bigintmat
*
zMatrixToBigintmat
(
const
gfan::ZMatrix &zm)
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);
44
n_Delete
(&temp,
coeffs_BIGINT
);
45
}
46
return
bim;
47
}
48
49
gfan::Integer*
numberToInteger
(
const
number &n)
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
}
56
57
gfan::ZMatrix*
bigintmatToZMatrix
(
const
bigintmat
&bim)
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
}
72
73
gfan::ZVector*
bigintmatToZVector
(
const
bigintmat
&bim)
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
}
85
86
gfan::ZVector
intStar2ZVector
(
const
int
d,
const
int
*
i
)
87
{
88
gfan::ZVector zv(d);
89
for
(
int
j
=0;
j
<d;
j
++)
90
zv[
j
]=
i
[
j
+1];
91
return
zv;
92
}
93
94
gfan::ZVector
expvToZVector
(
const
int
n,
const
int
* expv)
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
}
101
102
gfan::ZVector
wvhdlEntryToZVector
(
const
int
n,
const
int
* wvhdl0)
103
{
104
gfan::ZVector zv(n);
105
for
(
int
j
=0;
j
<n;
j
++)
106
zv[
j
]=wvhdl0[
j
];
107
return
zv;
108
}
109
110
int
*
ZVectorToIntStar
(
const
gfan::ZVector &
v
,
bool
&overflow)
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
}
126
127
char
*
toString
(gfan::ZMatrix
const
&zm)
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
}
136
137
gfan::ZFan*
toFanStar
(std::set<gfan::ZCone> setOfCones)
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
}
150
151
std::set<gfan::ZVector>
rays
(std::set<gfan::ZCone> setOfCones)
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
}
bigintmat.h
BIMATELEM
#define BIMATELEM(M, I, J)
Definition
bigintmat.h:133
integerToNumber
number integerToNumber(const gfan::Integer &I)
Definition
callgfanlib_conversion.cc:9
zMatrixToBigintmat
bigintmat * zMatrixToBigintmat(const gfan::ZMatrix &zm)
Definition
callgfanlib_conversion.cc:34
bigintmatToZMatrix
gfan::ZMatrix * bigintmatToZMatrix(const bigintmat &bim)
Definition
callgfanlib_conversion.cc:57
ZVectorToIntStar
int * ZVectorToIntStar(const gfan::ZVector &v, bool &overflow)
Definition
callgfanlib_conversion.cc:110
toString
char * toString(gfan::ZMatrix const &zm)
Definition
callgfanlib_conversion.cc:127
rays
std::set< gfan::ZVector > rays(std::set< gfan::ZCone > setOfCones)
Definition
callgfanlib_conversion.cc:151
numberToInteger
gfan::Integer * numberToInteger(const number &n)
Definition
callgfanlib_conversion.cc:49
intStar2ZVector
gfan::ZVector intStar2ZVector(const int d, const int *i)
Definition
callgfanlib_conversion.cc:86
wvhdlEntryToZVector
gfan::ZVector wvhdlEntryToZVector(const int n, const int *wvhdl0)
Definition
callgfanlib_conversion.cc:102
expvToZVector
gfan::ZVector expvToZVector(const int n, const int *expv)
Definition
callgfanlib_conversion.cc:94
zVectorToBigintmat
bigintmat * zVectorToBigintmat(const gfan::ZVector &zv)
Definition
callgfanlib_conversion.cc:21
toFanStar
gfan::ZFan * toFanStar(std::set< gfan::ZCone > setOfCones)
Definition
callgfanlib_conversion.cc:137
bigintmatToZVector
gfan::ZVector * bigintmatToZVector(const bigintmat &bim)
Definition
callgfanlib_conversion.cc:73
i
int i
Definition
cfEzgcd.cc:132
bigintmat
Matrices of numbers.
Definition
bigintmat.h:51
bigintmat::StringAsPrinted
char * StringAsPrinted()
Returns a string as it would have been printed in the interpreter.
Definition
bigintmat.cc:445
bigintmat::cols
int cols() const
Definition
bigintmat.h:144
bigintmat::rows
int rows() const
Definition
bigintmat.h:145
bigintmat::set
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:93
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition
coeffs.h:461
n_InitMPZ
static FORCE_INLINE number n_InitMPZ(mpz_t n, const coeffs r)
conversion of a GMP integer to number
Definition
coeffs.h:545
s
const CanonicalForm int s
Definition
facAbsFact.cc:51
w
const CanonicalForm & w
Definition
facAbsFact.cc:51
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition
facBivar.h:39
j
int j
Definition
facHensel.cc:110
WerrorS
void WerrorS(const char *s)
Definition
feFopen.cc:24
ipid.h
longrat.h
SR_INT
#define SR_INT
Definition
longrat.h:67
SR_TO_INT
#define SR_TO_INT(SR)
Definition
longrat.h:69
numbers.h
omAlloc
#define omAlloc(size)
Definition
omAllocDecl.h:210
omFree
#define omFree(addr)
Definition
omAllocDecl.h:261
omAlloc0
#define omAlloc0(size)
Definition
omAllocDecl.h:211
NULL
#define NULL
Definition
omList.c:12
coeffs_BIGINT
VAR coeffs coeffs_BIGINT
Definition
polys.cc:14
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition
polys.cc:13
SR_HDL
#define SR_HDL(A)
Definition
tgb.cc:35
Generated on
for My Project by
doxygen 1.17.0
for
Singular