My Project
Toggle main menu visibility
Loading...
Searching...
No Matches
kernel
numeric
mpr_inout.cc
Go to the documentation of this file.
1
/****************************************
2
* Computer Algebra System SINGULAR *
3
****************************************/
4
5
6
/*
7
* ABSTRACT - multipolynomial resultant
8
*/
9
10
11
#include "
kernel/mod2.h
"
12
13
#include "
misc/mylimits.h
"
14
#include "
misc/options.h
"
15
#include "
misc/intvec.h
"
16
17
#include "
coeffs/numbers.h
"
18
#include "
coeffs/mpr_global.h
"
19
20
#include "
polys/matpol.h
"
21
22
23
#include "
kernel/structs.h
"
24
#include "
kernel/polys.h
"
25
#include "
kernel/ideals.h
"
26
27
#include "
mpr_base.h
"
28
#include "
mpr_numeric.h
"
29
#include "
mpr_inout.h
"
30
31
// to get detailed timigs, define MPR_TIMING
32
#ifdef MPR_TIMING
33
#define TIMING
34
#endif
35
#include "
factory/timing.h
"
36
TIMING_DEFINE_PRINT
(mpr_overall)
37
TIMING_DEFINE_PRINT
(mpr_check)
38
TIMING_DEFINE_PRINT
(mpr_constr)
39
TIMING_DEFINE_PRINT
(mpr_ures)
40
TIMING_DEFINE_PRINT
(mpr_mures)
41
TIMING_DEFINE_PRINT
(mpr_arrange)
42
TIMING_DEFINE_PRINT
(mpr_solver)
43
44
#define TIMING_EPR(t,msg) TIMING_END_AND_PRINT(t,msg);TIMING_RESET(t);
45
46
//<-
47
48
//------------------------------------------------------------------------------
49
50
//-> void mprPrintError( mprState state )
51
void
mprPrintError(
mprState
state,
const
char
*
name
)
52
{
53
switch
(state)
54
{
55
case
mprWrongRType
:
56
WerrorS
(
"Unknown chosen resultant matrix type!"
);
57
break
;
58
case
mprHasOne
:
59
Werror
(
"One element of the ideal %s is constant!"
,
name
);
60
break
;
61
case
mprInfNumOfVars
:
62
Werror
(
"Wrong number of elements in given ideal %s, should be %d resp. %d!"
,
63
name
,(
currRing
->N)+1,(
currRing
->N));
64
break
;
65
case
mprNotZeroDim
:
66
Werror
(
"The given ideal %s must be 0-dimensional!"
,
name
);
67
break
;
68
case
mprNotHomog
:
69
Werror
(
"The given ideal %s has to be homogeneous in the first ring variable!"
,
70
name
);
71
break
;
72
case
mprNotReduced
:
73
Werror
(
"The given ideal %s has to reduced!"
,
name
);
74
break
;
75
case
mprUnSupField
:
76
WerrorS
(
"Ground field not implemented!"
);
77
break
;
78
default
:
79
break
;
80
}
81
}
82
//<-
83
84
//-> mprState mprIdealCheck()
85
mprState
mprIdealCheck
(
const
ideal theIdeal,
86
const
char
*
/*name*/
,
87
uResultant::resMatType
mtype,
88
BOOLEAN
rmatrix )
89
{
90
mprState
state =
mprOk
;
91
// int power;
92
int
k
;
93
94
int
numOfVars= mtype ==
uResultant::denseResMat
?(
currRing
->N)-1:(
currRing
->
N
);
95
if
( rmatrix ) numOfVars++;
96
97
if
( mtype ==
uResultant::none
)
98
state=
mprWrongRType
;
99
100
if
(
IDELEMS
(theIdeal) != numOfVars )
101
state=
mprInfNumOfVars
;
102
103
for
(
k
=
IDELEMS
(theIdeal) - 1; (state ==
mprOk
) && (
k
>= 0);
k
-- )
104
{
105
poly
p
= (theIdeal->m)[
k
];
106
if
(
pIsConstant
(
p
) ) state=
mprHasOne
;
107
else
108
if
( (mtype ==
uResultant::denseResMat
) && !
p_IsHomogeneous
(
p
,
currRing
) )
109
state=
mprNotHomog
;
110
}
111
112
if
( !(
rField_is_R
(
currRing
)||
113
rField_is_Q
(
currRing
)||
114
rField_is_long_R
(
currRing
)||
115
rField_is_long_C
(
currRing
)||
116
(rmatrix &&
rField_is_Q_a
(
currRing
))) )
117
state=
mprUnSupField
;
118
119
if
( state !=
mprOk
) mprPrintError( state,
""
/* name */
);
120
121
return
state;
122
}
123
//<-
124
125
//-> uResultant::resMatType determineMType( int imtype )
126
uResultant::resMatType
determineMType
(
int
imtype )
127
{
128
switch
( imtype )
129
{
130
case
MPR_DENSE
:
131
return
uResultant::denseResMat
;
132
case
0:
133
case
MPR_SPARSE
:
134
return
uResultant::sparseResMat
;
135
default
:
136
return
uResultant::none
;
137
}
138
}
139
//<-
140
141
//-> function u_resultant_det
142
poly u_resultant_det( ideal gls,
int
imtype )
143
{
144
uResultant::resMatType
mtype=
determineMType
( imtype );
145
poly resdet;
146
poly emptypoly=
pInit
();
147
number smv=
NULL
;
148
149
TIMING_START
(mpr_overall);
150
151
// check input ideal ( = polynomial system )
152
if
(
mprIdealCheck
( gls,
""
, mtype ) !=
mprOk
)
153
{
154
return
emptypoly;
155
}
156
157
uResultant
*ures;
158
159
// main task 1: setup of resultant matrix
160
TIMING_START
(mpr_constr);
161
ures=
new
uResultant
( gls, mtype );
162
TIMING_EPR
(mpr_constr,
"construction"
);
163
164
// if dense resultant, check if minor nonsingular
165
if
( mtype ==
uResultant::denseResMat
)
166
{
167
smv= ures->
accessResMat
()->
getSubDet
();
168
#ifdef mprDEBUG_PROT
169
PrintS
(
"// Determinant of submatrix: "
);
nPrint
(smv);
PrintLn
();
170
#endif
171
if
(
nIsZero
(smv) )
172
{
173
WerrorS
(
"Unsuitable input ideal: Minor of resultant matrix is singular!"
);
174
return
emptypoly;
175
}
176
}
177
178
// main task 2: Interpolate resultant polynomial
179
TIMING_START
(mpr_ures);
180
resdet= ures->
interpolateDense
( smv );
181
TIMING_EPR
(mpr_ures,
"ures"
);
182
183
// free mem
184
delete
ures;
185
nDelete
( &smv );
186
pDelete
( &emptypoly );
187
188
TIMING_EPR
(mpr_overall,
"overall"
);
189
190
return
( resdet );
191
}
192
//<-
193
194
//-----------------------------------------------------------------------------
195
196
// local Variables: ***
197
// folded-file: t ***
198
// compile-command-1: "make installg" ***
199
// compile-command-2: "make install" ***
200
// End: ***
201
202
// in folding: C-c x
203
// leave fold: C-c y
204
// foldmode: F10
BOOLEAN
int BOOLEAN
Definition
auxiliary.h:88
N
const CanonicalForm CFMap CFMap & N
Definition
cfEzgcd.cc:56
k
int k
Definition
cfEzgcd.cc:99
p
int p
Definition
cfModGcd.cc:4086
resMatrixBase::getSubDet
virtual number getSubDet()
Definition
mpr_base.h:37
uResultant
Base class for solving 0-dim poly systems using u-resultant.
Definition
mpr_base.h:63
uResultant::resMatType
resMatType
Definition
mpr_base.h:65
uResultant::denseResMat
@ denseResMat
Definition
mpr_base.h:65
uResultant::none
@ none
Definition
mpr_base.h:65
uResultant::sparseResMat
@ sparseResMat
Definition
mpr_base.h:65
uResultant::accessResMat
resMatrixBase * accessResMat()
Definition
mpr_base.h:78
uResultant::interpolateDense
poly interpolateDense(const number subDetVal=NULL)
Definition
mpr_base.cc:2770
WerrorS
void WerrorS(const char *s)
Definition
feFopen.cc:24
ideals.h
intvec.h
matpol.h
mod2.h
mpr_base.h
mprState
mprState
Definition
mpr_base.h:97
mprNotHomog
@ mprNotHomog
Definition
mpr_base.h:104
mprInfNumOfVars
@ mprInfNumOfVars
Definition
mpr_base.h:101
mprHasOne
@ mprHasOne
Definition
mpr_base.h:100
mprNotReduced
@ mprNotReduced
Definition
mpr_base.h:102
mprWrongRType
@ mprWrongRType
Definition
mpr_base.h:99
mprNotZeroDim
@ mprNotZeroDim
Definition
mpr_base.h:103
mprOk
@ mprOk
Definition
mpr_base.h:98
mprUnSupField
@ mprUnSupField
Definition
mpr_base.h:105
determineMType
uResultant::resMatType determineMType(int imtype)
mprIdealCheck
mprState mprIdealCheck(const ideal theIdeal, const char *name, uResultant::resMatType mtype, BOOLEAN rmatrix=false)
mpr_global.h
TIMING_EPR
#define TIMING_EPR(t, msg)
mpr_inout.h
MPR_SPARSE
#define MPR_SPARSE
Definition
mpr_inout.h:16
MPR_DENSE
#define MPR_DENSE
Definition
mpr_inout.h:15
mpr_numeric.h
mylimits.h
numbers.h
nDelete
#define nDelete(n)
Definition
numbers.h:16
nIsZero
#define nIsZero(n)
Definition
numbers.h:19
nPrint
#define nPrint(a)
only for debug, over any initialized currRing
Definition
numbers.h:46
NULL
#define NULL
Definition
omList.c:12
options.h
p_IsHomogeneous
BOOLEAN p_IsHomogeneous(poly p, const ring r)
Definition
p_polys.cc:3408
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition
polys.cc:13
polys.h
Compatibility layer for legacy polynomial operations (over currRing).
pDelete
#define pDelete(p_ptr)
Definition
polys.h:187
pIsConstant
#define pIsConstant(p)
like above, except that Comp must be 0
Definition
polys.h:239
pInit
#define pInit()
allocates a new monomial and initializes everything to 0
Definition
polys.h:62
PrintS
void PrintS(const char *s)
Definition
reporter.cc:288
PrintLn
void PrintLn()
Definition
reporter.cc:314
Werror
void Werror(const char *fmt,...)
Definition
reporter.cc:189
rField_is_R
static BOOLEAN rField_is_R(const ring r)
Definition
ring.h:529
rField_is_long_C
static BOOLEAN rField_is_long_C(const ring r)
Definition
ring.h:556
rField_is_Q_a
static BOOLEAN rField_is_Q_a(const ring r)
Definition
ring.h:550
rField_is_Q
static BOOLEAN rField_is_Q(const ring r)
Definition
ring.h:517
rField_is_long_R
static BOOLEAN rField_is_long_R(const ring r)
Definition
ring.h:553
IDELEMS
#define IDELEMS(i)
Definition
simpleideals.h:23
structs.h
name
int name
New type name for int.
Definition
templateForC.h:21
timing.h
TIMING_DEFINE_PRINT
#define TIMING_DEFINE_PRINT(t)
Definition
timing.h:95
TIMING_START
#define TIMING_START(t)
Definition
timing.h:92
Generated on
for My Project by
doxygen 1.17.0
for
Singular