Loading...
Searching...
No Matches
mpr_inout.cc
Go to the documentation of this file.
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
/*
* ABSTRACT - multipolynomial resultant
*/
#include "kernel/mod2.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 "mpr_base.h"
#include "mpr_numeric.h"
#include "mpr_inout.h"
// to get detailed timigs, define MPR_TIMING
#ifdef MPR_TIMING
#define TIMING
#endif
#include "factory/timing.h"
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)
#define TIMING_EPR(t,msg) TIMING_END_AND_PRINT(t,msg);TIMING_RESET(t);
//<-
//------------------------------------------------------------------------------
//-> void mprPrintError( mprState state )
void mprPrintError( mprState state, const char * name )
{
switch (state)
{
case mprWrongRType:
WerrorS("Unknown chosen resultant matrix type!");
break;
case mprHasOne:
Werror("One element of the ideal %s is constant!",name);
break;
case mprInfNumOfVars:
Werror("Wrong number of elements in given ideal %s, should be %d resp. %d!",
name,(currRing->N)+1,(currRing->N));
break;
case mprNotZeroDim:
Werror("The given ideal %s must be 0-dimensional!",name);
break;
case mprNotHomog:
Werror("The given ideal %s has to be homogeneous in the first ring variable!",
name);
break;
case mprNotReduced:
Werror("The given ideal %s has to reduced!",name);
break;
case mprUnSupField:
WerrorS("Ground field not implemented!");
break;
default:
break;
}
}
//<-
//-> mprState mprIdealCheck()
mprState mprIdealCheck( const ideal theIdeal,
const char * /*name*/,
uResultant::resMatType mtype,
BOOLEAN rmatrix )
{
mprState state = mprOk;
// int power;
int k;
int numOfVars= mtype == uResultant::denseResMat?(currRing->N)-1:(currRing->N);
if ( rmatrix ) numOfVars++;
if ( mtype == uResultant::none )
state= mprWrongRType;
if ( IDELEMS(theIdeal) != numOfVars )
state= mprInfNumOfVars;
for ( k= IDELEMS(theIdeal) - 1; (state == mprOk) && (k >= 0); k-- )
{
poly p = (theIdeal->m)[k];
if ( pIsConstant(p) ) state= mprHasOne;
else
if ( (mtype == uResultant::denseResMat) && !p_IsHomogeneous(p, currRing) )
state=mprNotHomog;
}
if ( !(rField_is_R(currRing)||
rField_is_Q(currRing)||
rField_is_long_R(currRing)||
rField_is_long_C(currRing)||
(rmatrix && rField_is_Q_a(currRing))) )
state= mprUnSupField;
if ( state != mprOk ) mprPrintError( state, "" /* name */ );
return state;
}
//<-
//-> uResultant::resMatType determineMType( int imtype )
uResultant::resMatType determineMType( int imtype )
{
switch ( imtype )
{
case MPR_DENSE:
return uResultant::denseResMat;
case 0:
case MPR_SPARSE:
return uResultant::sparseResMat;
default:
return uResultant::none;
}
}
//<-
//-> function u_resultant_det
poly u_resultant_det( ideal gls, int imtype )
{
uResultant::resMatType mtype= determineMType( imtype );
poly resdet;
poly emptypoly= pInit();
number smv= NULL;
TIMING_START(mpr_overall);
// check input ideal ( = polynomial system )
if ( mprIdealCheck( gls, "", mtype ) != mprOk )
{
return emptypoly;
}
uResultant *ures;
// main task 1: setup of resultant matrix
TIMING_START(mpr_constr);
ures= new uResultant( gls, mtype );
TIMING_EPR(mpr_constr,"construction");
// if dense resultant, check if minor nonsingular
if ( mtype == uResultant::denseResMat )
{
smv= ures->accessResMat()->getSubDet();
#ifdef mprDEBUG_PROT
PrintS("// Determinant of submatrix: ");nPrint(smv); PrintLn();
#endif
if ( nIsZero(smv) )
{
WerrorS("Unsuitable input ideal: Minor of resultant matrix is singular!");
return emptypoly;
}
}
// main task 2: Interpolate resultant polynomial
TIMING_START(mpr_ures);
resdet= ures->interpolateDense( smv );
TIMING_EPR(mpr_ures,"ures");
// free mem
delete ures;
nDelete( &smv );
pDelete( &emptypoly );
TIMING_EPR(mpr_overall,"overall");
return ( resdet );
}
//<-
//-----------------------------------------------------------------------------
// local Variables: ***
// folded-file: t ***
// compile-command-1: "make installg" ***
// compile-command-2: "make install" ***
// End: ***
// in folding: C-c x
// leave fold: C-c y
// 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
name
char name(const Variable &v)
Definition factory.h:189
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:524
rField_is_long_C
static BOOLEAN rField_is_long_C(const ring r)
Definition ring.h:551
rField_is_Q_a
static BOOLEAN rField_is_Q_a(const ring r)
Definition ring.h:545
rField_is_Q
static BOOLEAN rField_is_Q(const ring r)
Definition ring.h:512
rField_is_long_R
static BOOLEAN rField_is_long_R(const ring r)
Definition ring.h:548
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23
structs.h
timing.h
TIMING_DEFINE_PRINT
#define TIMING_DEFINE_PRINT(t)
Definition timing.h:95
TIMING_START
#define TIMING_START(t)
Definition timing.h:92