Macros | Functions
mpr_inout.h File Reference

Go to the source code of this file.

Macros

#define DEFAULT_DIGITS   30
 
#define MPR_DENSE   1
 
#define MPR_SPARSE   2
 

Functions

BOOLEAN nuUResSolve (leftv res, leftv args)
 solve a multipolynomial system using the u-resultant Input ideal must be 0-dimensional and (currRing->N) == IDELEMS(ideal). More...
 
BOOLEAN nuMPResMat (leftv res, leftv arg1, leftv arg2)
 returns module representing the multipolynomial resultant matrix Arguments 2: ideal i, int k k=0: use sparse resultant matrix of Gelfand, Kapranov and Zelevinsky k=1: use resultant matrix of Macaulay (k=0 is default) More...
 
BOOLEAN nuLagSolve (leftv res, leftv arg1, leftv arg2, leftv arg3)
 find the (complex) roots an univariate polynomial Determines the roots of an univariate polynomial using Laguerres' root-solver. More...
 
BOOLEAN nuVanderSys (leftv res, leftv arg1, leftv arg2, leftv arg3)
 COMPUTE: polynomial p with values given by v at points p1,..,pN derived from p; more precisely: consider p as point in K^n and v as N elements in K, let p1,..,pN be the points in K^n obtained by evaluating all monomials of degree 0,1,...,N at p in lexicographical order, then the procedure computes the polynomial f satisfying f(pi) = v[i] RETURN: polynomial f of degree d. More...
 
BOOLEAN loNewtonP (leftv res, leftv arg1)
 compute Newton Polytopes of input polynomials More...
 
BOOLEAN loSimplex (leftv res, leftv args)
 Implementation of the Simplex Algorithm. More...
 

Macro Definition Documentation

#define DEFAULT_DIGITS   30

Definition at line 13 of file mpr_inout.h.

#define MPR_DENSE   1

Definition at line 15 of file mpr_inout.h.

#define MPR_SPARSE   2

Definition at line 16 of file mpr_inout.h.

Function Documentation

BOOLEAN loNewtonP ( leftv  res,
leftv  arg1 
)

compute Newton Polytopes of input polynomials

Definition at line 4269 of file ipshell.cc.

4270 {
4271  res->data= (void*)loNewtonPolytope( (ideal)arg1->Data() );
4272  return FALSE;
4273 }
#define FALSE
Definition: auxiliary.h:140
const ideal
Definition: gb_hack.h:42
ideal loNewtonPolytope(const ideal id)
Definition: mpr_base.cc:3192
void * data
Definition: subexpr.h:89
void * Data()
Definition: subexpr.cc:1091
BOOLEAN loSimplex ( leftv  res,
leftv  args 
)

Implementation of the Simplex Algorithm.

For args, see class simplex.

Definition at line 4275 of file ipshell.cc.

4276 {
4277  if ( !(rField_is_long_R(currRing)) )
4278  {
4279  WerrorS("Ground field not implemented!");
4280  return TRUE;
4281  }
4282 
4283  simplex * LP;
4284  matrix m;
4285 
4286  leftv v= args;
4287  if ( v->Typ() != MATRIX_CMD ) // 1: matrix
4288  return TRUE;
4289  else
4290  m= (matrix)(v->CopyD());
4291 
4292  LP = new simplex(MATROWS(m),MATCOLS(m));
4293  LP->mapFromMatrix(m);
4294 
4295  v= v->next;
4296  if ( v->Typ() != INT_CMD ) // 2: m = number of constraints
4297  return TRUE;
4298  else
4299  LP->m= (int)(long)(v->Data());
4300 
4301  v= v->next;
4302  if ( v->Typ() != INT_CMD ) // 3: n = number of variables
4303  return TRUE;
4304  else
4305  LP->n= (int)(long)(v->Data());
4306 
4307  v= v->next;
4308  if ( v->Typ() != INT_CMD ) // 4: m1 = number of <= constraints
4309  return TRUE;
4310  else
4311  LP->m1= (int)(long)(v->Data());
4312 
4313  v= v->next;
4314  if ( v->Typ() != INT_CMD ) // 5: m2 = number of >= constraints
4315  return TRUE;
4316  else
4317  LP->m2= (int)(long)(v->Data());
4318 
4319  v= v->next;
4320  if ( v->Typ() != INT_CMD ) // 6: m3 = number of == constraints
4321  return TRUE;
4322  else
4323  LP->m3= (int)(long)(v->Data());
4324 
4325 #ifdef mprDEBUG_PROT
4326  Print("m (constraints) %d\n",LP->m);
4327  Print("n (columns) %d\n",LP->n);
4328  Print("m1 (<=) %d\n",LP->m1);
4329  Print("m2 (>=) %d\n",LP->m2);
4330  Print("m3 (==) %d\n",LP->m3);
4331 #endif
4332 
4333  LP->compute();
4334 
4335  lists lres= (lists)omAlloc( sizeof(slists) );
4336  lres->Init( 6 );
4337 
4338  lres->m[0].rtyp= MATRIX_CMD; // output matrix
4339  lres->m[0].data=(void*)LP->mapToMatrix(m);
4340 
4341  lres->m[1].rtyp= INT_CMD; // found a solution?
4342  lres->m[1].data=(void*)(long)LP->icase;
4343 
4344  lres->m[2].rtyp= INTVEC_CMD;
4345  lres->m[2].data=(void*)LP->posvToIV();
4346 
4347  lres->m[3].rtyp= INTVEC_CMD;
4348  lres->m[3].data=(void*)LP->zrovToIV();
4349 
4350  lres->m[4].rtyp= INT_CMD;
4351  lres->m[4].data=(void*)(long)LP->m;
4352 
4353  lres->m[5].rtyp= INT_CMD;
4354  lres->m[5].data=(void*)(long)LP->n;
4355 
4356  res->data= (void*)lres;
4357 
4358  return FALSE;
4359 }
const const intvec const intvec const ring _currRing const const intvec const intvec const ring _currRing int
Definition: gb_hack.h:53
sleftv * m
Definition: lists.h:45
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
matrix mapToMatrix(matrix m)
void compute()
#define Print
Definition: emacs.cc:83
Definition: tok.h:85
Definition: lists.h:22
#define FALSE
Definition: auxiliary.h:140
Linear Programming / Linear Optimization using Simplex - Algorithm.
Definition: mpr_numeric.h:194
#define TRUE
Definition: auxiliary.h:144
intvec * zrovToIV()
void WerrorS(const char *s)
Definition: feFopen.cc:23
int Typ()
Definition: subexpr.cc:949
#define omAlloc(size)
Definition: omAllocDecl.h:210
void * data
Definition: subexpr.h:89
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
intvec * posvToIV()
BOOLEAN mapFromMatrix(matrix m)
ip_smatrix * matrix
int m
Definition: cfEzgcd.cc:119
Definition: tok.h:88
leftv next
Definition: subexpr.h:87
INLINE_THIS void Init(int l=0)
Definition: lists.h:66
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define MATCOLS(i)
Definition: matpol.h:28
slists * lists
Definition: mpr_numeric.h:146
static BOOLEAN rField_is_long_R(const ring r)
Definition: ring.h:482
int rtyp
Definition: subexpr.h:92
void * Data()
Definition: subexpr.cc:1091
#define MATROWS(i)
Definition: matpol.h:27
int icase
Definition: mpr_numeric.h:201
void * CopyD(int t)
Definition: subexpr.cc:656
BOOLEAN nuLagSolve ( leftv  res,
leftv  arg1,
leftv  arg2,
leftv  arg3 
)

find the (complex) roots an univariate polynomial Determines the roots of an univariate polynomial using Laguerres' root-solver.

Good for polynomials with low and middle degree (<40). Arguments 3: poly arg1 , int arg2 , int arg3 arg2>0: defines precision of fractional part if ground field is Q arg3: number of iterations for approximation of roots (default=2) Returns a list of all (complex) roots of the polynomial arg1

Definition at line 4384 of file ipshell.cc.

4385 {
4386 
4387  poly gls;
4388  gls= (poly)(arg1->Data());
4389  int howclean= (int)(long)arg3->Data();
4390 
4391  if ( !(rField_is_R(currRing) ||
4392  rField_is_Q(currRing) ||
4395  {
4396  WerrorS("Ground field not implemented!");
4397  return TRUE;
4398  }
4399 
4402  {
4403  unsigned long int ii = (unsigned long int)arg2->Data();
4404  setGMPFloatDigits( ii, ii );
4405  }
4406 
4407  if ( gls == NULL || pIsConstant( gls ) )
4408  {
4409  WerrorS("Input polynomial is constant!");
4410  return TRUE;
4411  }
4412 
4413  int ldummy;
4414  int deg= currRing->pLDeg( gls, &ldummy, currRing );
4415  // int deg= pDeg( gls );
4416  // int len= pLength( gls );
4417  int i,vpos=0;
4418  poly piter;
4419  lists elist;
4420  lists rlist;
4421 
4422  elist= (lists)omAlloc( sizeof(slists) );
4423  elist->Init( 0 );
4424 
4425  if ( rVar(currRing) > 1 )
4426  {
4427  piter= gls;
4428  for ( i= 1; i <= rVar(currRing); i++ )
4429  if ( pGetExp( piter, i ) )
4430  {
4431  vpos= i;
4432  break;
4433  }
4434  while ( piter )
4435  {
4436  for ( i= 1; i <= rVar(currRing); i++ )
4437  if ( (vpos != i) && (pGetExp( piter, i ) != 0) )
4438  {
4439  WerrorS("The input polynomial must be univariate!");
4440  return TRUE;
4441  }
4442  pIter( piter );
4443  }
4444  }
4445 
4446  rootContainer * roots= new rootContainer();
4447  number * pcoeffs= (number *)omAlloc( (deg+1) * sizeof( number ) );
4448  piter= gls;
4449  for ( i= deg; i >= 0; i-- )
4450  {
4451  //if ( piter ) Print("deg %d, pDeg(piter) %d\n",i,pTotaldegree(piter));
4452  if ( piter && pTotaldegree(piter) == i )
4453  {
4454  pcoeffs[i]= nCopy( pGetCoeff( piter ) );
4455  //nPrint( pcoeffs[i] );PrintS(" ");
4456  pIter( piter );
4457  }
4458  else
4459  {
4460  pcoeffs[i]= nInit(0);
4461  }
4462  }
4463 
4464 #ifdef mprDEBUG_PROT
4465  for (i=deg; i >= 0; i--)
4466  {
4467  nPrint( pcoeffs[i] );PrintS(" ");
4468  }
4469  PrintLn();
4470 #endif
4471 
4472  roots->fillContainer( pcoeffs, NULL, 1, deg, rootContainer::onepoly, 1 );
4473  roots->solver( howclean );
4474 
4475  int elem= roots->getAnzRoots();
4476  char *dummy;
4477  int j;
4478 
4479  rlist= (lists)omAlloc( sizeof(slists) );
4480  rlist->Init( elem );
4481 
4483  {
4484  for ( j= 0; j < elem; j++ )
4485  {
4486  rlist->m[j].rtyp=NUMBER_CMD;
4487  rlist->m[j].data=(void *)nCopy((number)(roots->getRoot(j)));
4488  //rlist->m[j].data=(void *)(number)(roots->getRoot(j));
4489  }
4490  }
4491  else
4492  {
4493  for ( j= 0; j < elem; j++ )
4494  {
4495  dummy = complexToStr( (*roots)[j], gmp_output_digits, currRing->cf );
4496  rlist->m[j].rtyp=STRING_CMD;
4497  rlist->m[j].data=(void *)dummy;
4498  }
4499  }
4500 
4501  elist->Clean();
4502  //omFreeSize( (ADDRESS) elist, sizeof(slists) );
4503 
4504  // this is (via fillContainer) the same data as in root
4505  //for ( i= deg; i >= 0; i-- ) nDelete( &pcoeffs[i] );
4506  //omFreeSize( (ADDRESS) pcoeffs, (deg+1) * sizeof( number ) );
4507 
4508  delete roots;
4509 
4510  res->rtyp= LIST_CMD;
4511  res->data= (void*)rlist;
4512 
4513  return FALSE;
4514 }
const const intvec const intvec const ring _currRing const const intvec const intvec const ring _currRing int
Definition: gb_hack.h:53
complex root finder for univariate polynomials based on laguers algorithm
Definition: mpr_numeric.h:65
sleftv * m
Definition: lists.h:45
void PrintLn()
Definition: reporter.cc:322
Definition: lists.h:22
#define FALSE
Definition: auxiliary.h:140
static BOOLEAN rField_is_R(const ring r)
Definition: ring.h:458
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:531
#define TRUE
Definition: auxiliary.h:144
bool solver(const int polishmode=PM_NONE)
Definition: mpr_numeric.cc:450
void WerrorS(const char *s)
Definition: feFopen.cc:23
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
#define omAlloc(size)
Definition: omAllocDecl.h:210
#define nPrint(a)
only for debug, over any initalized currRing
Definition: numbers.h:46
void * data
Definition: subexpr.h:89
#define pIter(p)
Definition: monomials.h:44
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
int j
Definition: myNF.cc:70
static long pTotaldegree(poly p)
Definition: polys.h:253
polyrec * poly
Definition: hilb.h:10
#define pIsConstant(p)
like above, except that Comp might be != 0
Definition: polys.h:209
void fillContainer(number *_coeffs, number *_ievpoint, const int _var, const int _tdg, const rootType _rt, const int _anz)
Definition: mpr_numeric.cc:313
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:294
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:452
gmp_complex * getRoot(const int i)
Definition: mpr_numeric.h:88
static BOOLEAN rField_is_long_C(const ring r)
Definition: ring.h:485
INLINE_THIS void Init(int l=0)
Definition: lists.h:66
#define NULL
Definition: omList.c:10
slists * lists
Definition: mpr_numeric.h:146
int getAnzRoots()
Definition: mpr_numeric.h:97
static BOOLEAN rField_is_long_R(const ring r)
Definition: ring.h:482
int rtyp
Definition: subexpr.h:92
#define nCopy(n)
Definition: numbers.h:15
void Clean(ring r=currRing)
Definition: lists.h:25
void * Data()
Definition: subexpr.cc:1091
Definition: tok.h:96
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
Definition: mpr_complex.cc:717
size_t gmp_output_digits
Definition: mpr_complex.cc:44
void setGMPFloatDigits(size_t digits, size_t rest)
Set size of mantissa digits - the number of output digits (basis 10) the size of mantissa consists of...
Definition: mpr_complex.cc:62
#define nInit(i)
Definition: numbers.h:24
BOOLEAN nuMPResMat ( leftv  res,
leftv  arg1,
leftv  arg2 
)

returns module representing the multipolynomial resultant matrix Arguments 2: ideal i, int k k=0: use sparse resultant matrix of Gelfand, Kapranov and Zelevinsky k=1: use resultant matrix of Macaulay (k=0 is default)

Definition at line 4361 of file ipshell.cc.

4362 {
4363  ideal gls = (ideal)(arg1->Data());
4364  int imtype= (int)(long)arg2->Data();
4365 
4366  uResultant::resMatType mtype= determineMType( imtype );
4367 
4368  // check input ideal ( = polynomial system )
4369  if ( mprIdealCheck( gls, arg1->Name(), mtype, true ) != mprOk )
4370  {
4371  return TRUE;
4372  }
4373 
4374  uResultant *resMat= new uResultant( gls, mtype, false );
4375  if (resMat!=NULL)
4376  {
4377  res->rtyp = MODUL_CMD;
4378  res->data= (void*)resMat->accessResMat()->getMatrix();
4379  if (!errorreported) delete resMat;
4380  }
4381  return errorreported;
4382 }
const const intvec const intvec const ring _currRing const const intvec const intvec const ring _currRing int
Definition: gb_hack.h:53
Base class for solving 0-dim poly systems using u-resultant.
Definition: mpr_base.h:62
resMatrixBase * accessResMat()
Definition: mpr_base.h:78
const ideal
Definition: gb_hack.h:42
#define TRUE
Definition: auxiliary.h:144
uResultant::resMatType determineMType(int imtype)
Definition: mpr_inout.cc:135
const char * Name()
Definition: subexpr.h:121
Definition: mpr_base.h:98
void * data
Definition: subexpr.h:89
virtual ideal getMatrix()
Definition: mpr_base.h:31
mprState mprIdealCheck(const ideal theIdeal, const char *name, uResultant::resMatType mtype, BOOLEAN rmatrix=false)
Definition: mpr_inout.cc:94
short errorreported
Definition: feFopen.cc:22
#define NULL
Definition: omList.c:10
int rtyp
Definition: subexpr.h:92
void * Data()
Definition: subexpr.cc:1091
BOOLEAN nuUResSolve ( leftv  res,
leftv  args 
)

solve a multipolynomial system using the u-resultant Input ideal must be 0-dimensional and (currRing->N) == IDELEMS(ideal).

Resultant method can be MPR_DENSE, which uses Macaulay Resultant (good for dense homogeneous polynoms) or MPR_SPARSE, which uses Sparse Resultant (Gelfand, Kapranov, Zelevinsky). Arguments 4: ideal i, int k, int l, int m k=0: use sparse resultant matrix of Gelfand, Kapranov and Zelevinsky k=1: use resultant matrix of Macaulay (k=0 is default) l>0: defines precision of fractional part if ground field is Q m=0,1,2: number of iterations for approximation of roots (default=2) Returns a list containing the roots of the system.

Definition at line 4617 of file ipshell.cc.

4618 {
4619  leftv v= args;
4620 
4621  ideal gls;
4622  int imtype;
4623  int howclean;
4624 
4625  // get ideal
4626  if ( v->Typ() != IDEAL_CMD )
4627  return TRUE;
4628  else gls= (ideal)(v->Data());
4629  v= v->next;
4630 
4631  // get resultant matrix type to use (0,1)
4632  if ( v->Typ() != INT_CMD )
4633  return TRUE;
4634  else imtype= (int)(long)v->Data();
4635  v= v->next;
4636 
4637  if (imtype==0)
4638  {
4639  ideal test_id=idInit(1,1);
4640  int j;
4641  for(j=IDELEMS(gls)-1;j>=0;j--)
4642  {
4643  if (gls->m[j]!=NULL)
4644  {
4645  test_id->m[0]=gls->m[j];
4646  intvec *dummy_w=id_QHomWeight(test_id, currRing);
4647  if (dummy_w!=NULL)
4648  {
4649  WerrorS("Newton polytope not of expected dimension");
4650  delete dummy_w;
4651  return TRUE;
4652  }
4653  }
4654  }
4655  }
4656 
4657  // get and set precision in digits ( > 0 )
4658  if ( v->Typ() != INT_CMD )
4659  return TRUE;
4660  else if ( !(rField_is_R(currRing) || rField_is_long_R(currRing) || \
4662  {
4663  unsigned long int ii=(unsigned long int)v->Data();
4664  setGMPFloatDigits( ii, ii );
4665  }
4666  v= v->next;
4667 
4668  // get interpolation steps (0,1,2)
4669  if ( v->Typ() != INT_CMD )
4670  return TRUE;
4671  else howclean= (int)(long)v->Data();
4672 
4673  uResultant::resMatType mtype= determineMType( imtype );
4674  int i,count;
4675  lists listofroots= NULL;
4676  number smv= NULL;
4677  BOOLEAN interpolate_det= (mtype==uResultant::denseResMat)?TRUE:FALSE;
4678 
4679  //emptylist= (lists)omAlloc( sizeof(slists) );
4680  //emptylist->Init( 0 );
4681 
4682  //res->rtyp = LIST_CMD;
4683  //res->data= (void *)emptylist;
4684 
4685  // check input ideal ( = polynomial system )
4686  if ( mprIdealCheck( gls, args->Name(), mtype ) != mprOk )
4687  {
4688  return TRUE;
4689  }
4690 
4691  uResultant * ures;
4692  rootContainer ** iproots;
4693  rootContainer ** muiproots;
4694  rootArranger * arranger;
4695 
4696  // main task 1: setup of resultant matrix
4697  ures= new uResultant( gls, mtype );
4698  if ( ures->accessResMat()->initState() != resMatrixBase::ready )
4699  {
4700  WerrorS("Error occurred during matrix setup!");
4701  return TRUE;
4702  }
4703 
4704  // if dense resultant, check if minor nonsingular
4705  if ( mtype == uResultant::denseResMat )
4706  {
4707  smv= ures->accessResMat()->getSubDet();
4708 #ifdef mprDEBUG_PROT
4709  PrintS("// Determinant of submatrix: ");nPrint(smv);PrintLn();
4710 #endif
4711  if ( nIsZero(smv) )
4712  {
4713  WerrorS("Unsuitable input ideal: Minor of resultant matrix is singular!");
4714  return TRUE;
4715  }
4716  }
4717 
4718  // main task 2: Interpolate specialized resultant polynomials
4719  if ( interpolate_det )
4720  iproots= ures->interpolateDenseSP( false, smv );
4721  else
4722  iproots= ures->specializeInU( false, smv );
4723 
4724  // main task 3: Interpolate specialized resultant polynomials
4725  if ( interpolate_det )
4726  muiproots= ures->interpolateDenseSP( true, smv );
4727  else
4728  muiproots= ures->specializeInU( true, smv );
4729 
4730 #ifdef mprDEBUG_PROT
4731  int c= iproots[0]->getAnzElems();
4732  for (i=0; i < c; i++) pWrite(iproots[i]->getPoly());
4733  c= muiproots[0]->getAnzElems();
4734  for (i=0; i < c; i++) pWrite(muiproots[i]->getPoly());
4735 #endif
4736 
4737  // main task 4: Compute roots of specialized polys and match them up
4738  arranger= new rootArranger( iproots, muiproots, howclean );
4739  arranger->solve_all();
4740 
4741  // get list of roots
4742  if ( arranger->success() )
4743  {
4744  arranger->arrange();
4745  listofroots= listOfRoots(arranger, gmp_output_digits );
4746  }
4747  else
4748  {
4749  WerrorS("Solver was unable to find any roots!");
4750  return TRUE;
4751  }
4752 
4753  // free everything
4754  count= iproots[0]->getAnzElems();
4755  for (i=0; i < count; i++) delete iproots[i];
4756  omFreeSize( (ADDRESS) iproots, count * sizeof(rootContainer*) );
4757  count= muiproots[0]->getAnzElems();
4758  for (i=0; i < count; i++) delete muiproots[i];
4759  omFreeSize( (ADDRESS) muiproots, count * sizeof(rootContainer*) );
4760 
4761  delete ures;
4762  delete arranger;
4763  nDelete( &smv );
4764 
4765  res->data= (void *)listofroots;
4766 
4767  //emptylist->Clean();
4768  // omFreeSize( (ADDRESS) emptylist, sizeof(slists) );
4769 
4770  return FALSE;
4771 }
int status int void size_t count
Definition: si_signals.h:58
const const intvec const intvec const ring _currRing const const intvec const intvec const ring _currRing int
Definition: gb_hack.h:53
complex root finder for univariate polynomials based on laguers algorithm
Definition: mpr_numeric.h:65
Class used for (list of) interpreter objects.
Definition: subexpr.h:83
void PrintLn()
Definition: reporter.cc:322
Base class for solving 0-dim poly systems using u-resultant.
Definition: mpr_base.h:62
Definition: tok.h:85
Definition: lists.h:22
virtual IStateType initState() const
Definition: mpr_base.h:41
#define FALSE
Definition: auxiliary.h:140
static BOOLEAN rField_is_R(const ring r)
Definition: ring.h:458
resMatrixBase * accessResMat()
Definition: mpr_base.h:78
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
const ideal
Definition: gb_hack.h:42
intvec * id_QHomWeight(ideal id, const ring r)
#define TRUE
Definition: auxiliary.h:144
uResultant::resMatType determineMType(int imtype)
Definition: mpr_inout.cc:135
void * ADDRESS
Definition: auxiliary.h:161
void pWrite(poly p)
Definition: polys.h:279
void WerrorS(const char *s)
Definition: feFopen.cc:23
int getAnzElems()
Definition: mpr_numeric.h:95
rootContainer ** specializeInU(BOOLEAN matchUp=false, const number subDetVal=NULL)
Definition: mpr_base.cc:3060
int Typ()
Definition: subexpr.cc:949
const char * Name()
Definition: subexpr.h:121
Definition: mpr_base.h:98
#define nPrint(a)
only for debug, over any initalized currRing
Definition: numbers.h:46
void * data
Definition: subexpr.h:89
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
Definition: intvec.h:16
int j
Definition: myNF.cc:70
bool success()
Definition: mpr_numeric.h:162
void arrange()
Definition: mpr_numeric.cc:896
int i
Definition: cfEzgcd.cc:123
void PrintS(const char *s)
Definition: reporter.cc:294
void solve_all()
Definition: mpr_numeric.cc:871
#define IDELEMS(i)
Definition: simpleideals.h:19
mprState mprIdealCheck(const ideal theIdeal, const char *name, uResultant::resMatType mtype, BOOLEAN rmatrix=false)
Definition: mpr_inout.cc:94
rootContainer ** interpolateDenseSP(BOOLEAN matchUp=false, const number subDetVal=NULL)
Definition: mpr_base.cc:2922
#define nDelete(n)
Definition: numbers.h:16
leftv next
Definition: subexpr.h:87
static BOOLEAN rField_is_long_C(const ring r)
Definition: ring.h:485
ideal idInit(int idsize, int rank)
Definition: simpleideals.cc:40
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
#define nIsZero(n)
Definition: numbers.h:19
#define NULL
Definition: omList.c:10
static BOOLEAN rField_is_long_R(const ring r)
Definition: ring.h:482
void * Data()
Definition: subexpr.cc:1091
size_t gmp_output_digits
Definition: mpr_complex.cc:44
void setGMPFloatDigits(size_t digits, size_t rest)
Set size of mantissa digits - the number of output digits (basis 10) the size of mantissa consists of...
Definition: mpr_complex.cc:62
int BOOLEAN
Definition: auxiliary.h:131
lists listOfRoots(rootArranger *self, const unsigned int oprec)
Definition: ipshell.cc:4774
virtual number getSubDet()
Definition: mpr_base.h:37
BOOLEAN nuVanderSys ( leftv  res,
leftv  arg1,
leftv  arg2,
leftv  arg3 
)

COMPUTE: polynomial p with values given by v at points p1,..,pN derived from p; more precisely: consider p as point in K^n and v as N elements in K, let p1,..,pN be the points in K^n obtained by evaluating all monomials of degree 0,1,...,N at p in lexicographical order, then the procedure computes the polynomial f satisfying f(pi) = v[i] RETURN: polynomial f of degree d.

Definition at line 4516 of file ipshell.cc.

4517 {
4518  int i;
4519  ideal p,w;
4520  p= (ideal)arg1->Data();
4521  w= (ideal)arg2->Data();
4522 
4523  // w[0] = f(p^0)
4524  // w[1] = f(p^1)
4525  // ...
4526  // p can be a vector of numbers (multivariate polynom)
4527  // or one number (univariate polynom)
4528  // tdg = deg(f)
4529 
4530  int n= IDELEMS( p );
4531  int m= IDELEMS( w );
4532  int tdg= (int)(long)arg3->Data();
4533 
4534  res->data= (void*)NULL;
4535 
4536  // check the input
4537  if ( tdg < 1 )
4538  {
4539  WerrorS("Last input parameter must be > 0!");
4540  return TRUE;
4541  }
4542  if ( n != rVar(currRing) )
4543  {
4544  Werror("Size of first input ideal must be equal to %d!",rVar(currRing));
4545  return TRUE;
4546  }
4547  if ( m != (int)pow((double)tdg+1,(double)n) )
4548  {
4549  Werror("Size of second input ideal must be equal to %d!",
4550  (int)pow((double)tdg+1,(double)n));
4551  return TRUE;
4552  }
4553  if ( !(rField_is_Q(currRing) /* ||
4554  rField_is_R() || rField_is_long_R() ||
4555  rField_is_long_C()*/ ) )
4556  {
4557  WerrorS("Ground field not implemented!");
4558  return TRUE;
4559  }
4560 
4561  number tmp;
4562  number *pevpoint= (number *)omAlloc( n * sizeof( number ) );
4563  for ( i= 0; i < n; i++ )
4564  {
4565  pevpoint[i]=nInit(0);
4566  if ( (p->m)[i] )
4567  {
4568  tmp = pGetCoeff( (p->m)[i] );
4569  if ( nIsZero(tmp) || nIsOne(tmp) || nIsMOne(tmp) )
4570  {
4571  omFreeSize( (ADDRESS)pevpoint, n * sizeof( number ) );
4572  WerrorS("Elements of first input ideal must not be equal to -1, 0, 1!");
4573  return TRUE;
4574  }
4575  } else tmp= NULL;
4576  if ( !nIsZero(tmp) )
4577  {
4578  if ( !pIsConstant((p->m)[i]))
4579  {
4580  omFreeSize( (ADDRESS)pevpoint, n * sizeof( number ) );
4581  WerrorS("Elements of first input ideal must be numbers!");
4582  return TRUE;
4583  }
4584  pevpoint[i]= nCopy( tmp );
4585  }
4586  }
4587 
4588  number *wresults= (number *)omAlloc( m * sizeof( number ) );
4589  for ( i= 0; i < m; i++ )
4590  {
4591  wresults[i]= nInit(0);
4592  if ( (w->m)[i] && !nIsZero(pGetCoeff((w->m)[i])) )
4593  {
4594  if ( !pIsConstant((w->m)[i]))
4595  {
4596  omFreeSize( (ADDRESS)pevpoint, n * sizeof( number ) );
4597  omFreeSize( (ADDRESS)wresults, m * sizeof( number ) );
4598  WerrorS("Elements of second input ideal must be numbers!");
4599  return TRUE;
4600  }
4601  wresults[i]= nCopy(pGetCoeff((w->m)[i]));
4602  }
4603  }
4604 
4605  vandermonde vm( m, n, tdg, pevpoint, FALSE );
4606  number *ncpoly= vm.interpolateDense( wresults );
4607  // do not free ncpoly[]!!
4608  poly rpoly= vm.numvec2poly( ncpoly );
4609 
4610  omFreeSize( (ADDRESS)pevpoint, n * sizeof( number ) );
4611  omFreeSize( (ADDRESS)wresults, m * sizeof( number ) );
4612 
4613  res->data= (void*)rpoly;
4614  return FALSE;
4615 }
const const intvec const intvec const ring _currRing const const intvec const intvec const ring _currRing int
Definition: gb_hack.h:53
vandermonde system solver for interpolating polynomials from their values
Definition: mpr_numeric.h:28
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
const ideal
Definition: gb_hack.h:42
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:531
#define TRUE
Definition: auxiliary.h:144
#define nIsOne(n)
Definition: numbers.h:25
void * ADDRESS
Definition: auxiliary.h:161
void WerrorS(const char *s)
Definition: feFopen.cc:23
#define nIsMOne(n)
Definition: numbers.h:26
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
#define omAlloc(size)
Definition: omAllocDecl.h:210
void * data
Definition: subexpr.h:89
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
polyrec * poly
Definition: hilb.h:10
int m
Definition: cfEzgcd.cc:119
#define pIsConstant(p)
like above, except that Comp might be != 0
Definition: polys.h:209
int i
Definition: cfEzgcd.cc:123
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:452
#define IDELEMS(i)
Definition: simpleideals.h:19
#define nIsZero(n)
Definition: numbers.h:19
#define NULL
Definition: omList.c:10
const CanonicalForm & w
Definition: facAbsFact.cc:55
#define nCopy(n)
Definition: numbers.h:15
void * Data()
Definition: subexpr.cc:1091
#define nInit(i)
Definition: numbers.h:24
Rational pow(const Rational &a, int e)
Definition: GMPrat.cc:418
void Werror(const char *fmt,...)
Definition: reporter.cc:199