All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Macros | Functions
mpr_inout.cc File Reference
#include <kernel/mod2.h>
#include <omalloc/omalloc.h>
#include <misc/mylimits.h>
#include <misc/options.h>
#include <misc/intvec.h>
#include <coeffs/numbers.h>
#include <coeffs/mpr_global.h>
#include <polys/matpol.h>
#include <kernel/structs.h>
#include <kernel/polys.h>
#include <kernel/ideals.h>
#include <math.h>
#include "mpr_base.h"
#include "mpr_numeric.h"
#include "mpr_inout.h"
#include <factory/timing.h>

Go to the source code of this file.

Macros

#define TIMING_EPR(t, msg)   TIMING_END_AND_PRINT(t,msg);TIMING_RESET(t);
 

Functions

 TIMING_DEFINE_PRINT (mpr_overall) TIMING_DEFINE_PRINT(mpr_check) TIMING_DEFINE_PRINT(mpr_constr) TIMING_DEFINE_PRINT(mpr_ures) TIMING_DEFINE_PRINT(mpr_mures) TIMING_DEFINE_PRINT(mpr_arrange) TIMING_DEFINE_PRINT(mpr_solver) void mprPrintError(mprState state
 
const char *name switch (state)
 
mprState mprIdealCheck (const ideal theIdeal, const char *, uResultant::resMatType mtype, BOOLEAN rmatrix)
 
uResultant::resMatType determineMType (int imtype)
 
poly u_resultant_det (ideal gls, int imtype)
 

Macro Definition Documentation

#define TIMING_EPR (   t,
  msg 
)    TIMING_END_AND_PRINT(t,msg);TIMING_RESET(t);

Function Documentation

uResultant::resMatType determineMType ( int  imtype)

Definition at line 134 of file mpr_inout.cc.

135 {
136  switch ( imtype )
137  {
138  case MPR_DENSE:
140  case 0:
141  case MPR_SPARSE:
143  default:
144  return uResultant::none;
145  }
146 }
#define MPR_DENSE
Definition: mpr_inout.h:15
#define MPR_SPARSE
Definition: mpr_inout.h:16
mprState mprIdealCheck ( const ideal  theIdeal,
const char *  ,
uResultant::resMatType  mtype,
BOOLEAN  rmatrix 
)

Definition at line 93 of file mpr_inout.cc.

97 {
98  mprState state = mprOk;
99  // int power;
100  int k;
101 
102  int numOfVars= mtype == uResultant::denseResMat?(currRing->N)-1:(currRing->N);
103  if ( rmatrix ) numOfVars++;
104 
105  if ( mtype == uResultant::none )
106  state= mprWrongRType;
107 
108  if ( IDELEMS(theIdeal) != numOfVars )
109  state= mprInfNumOfVars;
110 
111  for ( k= IDELEMS(theIdeal) - 1; (state == mprOk) && (k >= 0); k-- )
112  {
113  poly p = (theIdeal->m)[k];
114  if ( pIsConstant(p) ) state= mprHasOne;
115  else
116  if ( (mtype == uResultant::denseResMat) && !p_IsHomogeneous(p, currRing) )
117  state=mprNotHomog;
118  }
119 
120  if ( !(rField_is_R(currRing)||
124  (rmatrix && rField_is_Q_a(currRing))) )
125  state= mprUnSupField;
126 
127  if ( state != mprOk ) mprPrintError( state, "" /* name */ );
128 
129  return state;
130 }
return P p
Definition: myNF.cc:203
BOOLEAN p_IsHomogeneous(poly p, const ring r)
Definition: p_polys.cc:3203
static BOOLEAN rField_is_R(const ring r)
Definition: ring.h:507
static BOOLEAN rField_is_Q_a(const ring r)
Definition: ring.h:528
int k
Definition: cfEzgcd.cc:93
Definition: mpr_base.h:98
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
#define pIsConstant(p)
like above, except that Comp might be != 0
Definition: polys.h:221
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:501
#define IDELEMS(i)
Definition: simpleideals.h:24
static BOOLEAN rField_is_long_C(const ring r)
Definition: ring.h:534
static BOOLEAN rField_is_long_R(const ring r)
Definition: ring.h:531
mprState
Definition: mpr_base.h:96
polyrec * poly
Definition: hilb.h:10
const char* name switch ( state  )

Definition at line 61 of file mpr_inout.cc.

62  {
63  case mprWrongRType:
64  WerrorS("Unknown chosen resultant matrix type!");
65  break;
66  case mprHasOne:
67  Werror("One element of the ideal %s is constant!",name);
68  break;
69  case mprInfNumOfVars:
70  Werror("Wrong number of elements in given ideal %s, should be %d resp. %d!",
71  name,(currRing->N)+1,(currRing->N));
72  break;
73  case mprNotZeroDim:
74  Werror("The given ideal %s must be 0-dimensional!",name);
75  break;
76  case mprNotHomog:
77  Werror("The given ideal %s has to be homogeneous in the first ring variable!",
78  name);
79  break;
80  case mprNotReduced:
81  Werror("The given ideal %s has to reduced!",name);
82  break;
83  case mprUnSupField:
84  WerrorS("Ground field not implemented!");
85  break;
86  default:
87  break;
88  }
void WerrorS(const char *s)
Definition: feFopen.cc:24
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:10
char name(const Variable &v)
Definition: factory.h:178
void Werror(const char *fmt,...)
Definition: reporter.cc:189
TIMING_DEFINE_PRINT ( mpr_overall  )
poly u_resultant_det ( ideal  gls,
int  imtype 
)

Definition at line 150 of file mpr_inout.cc.

151 {
152  uResultant::resMatType mtype= determineMType( imtype );
153  poly resdet;
154  poly emptypoly= pInit();
155  number smv= NULL;
156 
157  TIMING_START(mpr_overall);
158 
159  // check input ideal ( = polynomial system )
160  if ( mprIdealCheck( gls, "", mtype ) != mprOk )
161  {
162  return emptypoly;
163  }
164 
165  uResultant *ures;
166 
167  // main task 1: setup of resultant matrix
168  TIMING_START(mpr_constr);
169  ures= new uResultant( gls, mtype );
170  TIMING_EPR(mpr_constr,"construction");
171 
172  // if dense resultant, check if minor nonsingular
173  if ( mtype == uResultant::denseResMat )
174  {
175  smv= ures->accessResMat()->getSubDet();
176 #ifdef mprDEBUG_PROT
177  PrintS("// Determinant of submatrix: ");nPrint(smv); PrintLn();
178 #endif
179  if ( nIsZero(smv) )
180  {
181  WerrorS("Unsuitable input ideal: Minor of resultant matrix is singular!");
182  return emptypoly;
183  }
184  }
185 
186  // main task 2: Interpolate resultant polynomial
187  TIMING_START(mpr_ures);
188  resdet= ures->interpolateDense( smv );
189  TIMING_EPR(mpr_ures,"ures");
190 
191  // free mem
192  delete ures;
193  nDelete( &smv );
194  pDelete( &emptypoly );
195 
196  TIMING_EPR(mpr_overall,"overall");
197 
198  return ( resdet );
199 }
void PrintLn()
Definition: reporter.cc:310
Base class for solving 0-dim poly systems using u-resultant.
Definition: mpr_base.h:62
mprState mprIdealCheck(const ideal theIdeal, const char *, uResultant::resMatType mtype, BOOLEAN rmatrix)
Definition: mpr_inout.cc:93
resMatrixBase * accessResMat()
Definition: mpr_base.h:78
void WerrorS(const char *s)
Definition: feFopen.cc:24
Definition: mpr_base.h:98
#define nPrint(a)
only for debug, over any initalized currRing
Definition: numbers.h:46
#define TIMING_EPR(t, msg)
void PrintS(const char *s)
Definition: reporter.cc:284
#define nDelete(n)
Definition: numbers.h:16
uResultant::resMatType determineMType(int imtype)
Definition: mpr_inout.cc:134
#define nIsZero(n)
Definition: numbers.h:19
#define NULL
Definition: omList.c:10
#define TIMING_START(t)
Definition: timing.h:87
#define pInit()
allocates a new monomial and initializes everything to 0
Definition: polys.h:61
poly interpolateDense(const number subDetVal=NULL)
Definition: mpr_base.cc:2769
#define pDelete(p_ptr)
Definition: polys.h:169
polyrec * poly
Definition: hilb.h:10
virtual number getSubDet()
Definition: mpr_base.h:37