Public Member Functions | Private Member Functions | Private Attributes | Friends
rootArranger Class Reference

#include <mpr_numeric.h>

Public Member Functions

 rootArranger (rootContainer **_roots, rootContainer **_mu, const int _howclean=PM_CORRUPT)
 
 ~rootArranger ()
 
void solve_all ()
 
void arrange ()
 
bool success ()
 

Private Member Functions

 rootArranger (const rootArranger &)
 

Private Attributes

rootContainer ** roots
 
rootContainer ** mu
 
int howclean
 
int rc
 
int mc
 
bool found_roots
 

Friends

lists listOfRoots (rootArranger *, const unsigned int oprec)
 

Detailed Description

Definition at line 149 of file mpr_numeric.h.

Constructor & Destructor Documentation

§ rootArranger() [1/2]

rootArranger::rootArranger ( rootContainer **  _roots,
rootContainer **  _mu,
const int  _howclean = PM_CORRUPT 
)

Definition at line 860 of file mpr_numeric.cc.

863  : roots(_roots), mu(_mu), howclean(_howclean)
864 {
865  found_roots=false;
866 }
rootContainer ** mu
Definition: mpr_numeric.h:168
bool found_roots
Definition: mpr_numeric.h:172
rootContainer ** roots
Definition: mpr_numeric.h:167

§ ~rootArranger()

rootArranger::~rootArranger ( )
inline

Definition at line 157 of file mpr_numeric.h.

157 {}

§ rootArranger() [2/2]

rootArranger::rootArranger ( const rootArranger )
private

Member Function Documentation

§ arrange()

void rootArranger::arrange ( )

Definition at line 895 of file mpr_numeric.cc.

896 {
897  gmp_complex tmp,zwerg;
898  int anzm= mu[0]->getAnzElems();
899  int anzr= roots[0]->getAnzRoots();
900  int xkoord, r, rtest, xk, mtest;
901  bool found;
902  //gmp_complex mprec(1.0/pow(10,gmp_output_digits-5),1.0/pow(10,gmp_output_digits-5));
903 
904  for ( xkoord= 0; xkoord < anzm; xkoord++ ) { // für x1,x2, x1,x2,x3, x1,x2,...,xn
905  gmp_float mprec(1.0/pow(10.0,(int)(gmp_output_digits/3)));
906  for ( r= 0; r < anzr; r++ ) { // für jede Nullstelle
907  // (x1-koordinate) * evp[1] + (x2-koordinate) * evp[2] +
908  // ... + (xkoord-koordinate) * evp[xkoord]
909  tmp= gmp_complex();
910  for ( xk =0; xk <= xkoord; xk++ )
911  {
912  tmp -= (*roots[xk])[r] * mu[xkoord]->evPointCoord(xk+1); //xk+1
913  }
914  found= false;
915  do { // while not found
916  for ( rtest= r; rtest < anzr; rtest++ ) { // für jede Nullstelle
917  zwerg = tmp - (*roots[xk])[rtest] * mu[xkoord]->evPointCoord(xk+1); // xk+1, xkoord+2
918  for ( mtest= 0; mtest < anzr; mtest++ )
919  {
920  // if ( tmp == (*mu[xkoord])[mtest] )
921  // {
922  if ( ((zwerg.real() <= (*mu[xkoord])[mtest].real() + mprec) &&
923  (zwerg.real() >= (*mu[xkoord])[mtest].real() - mprec)) &&
924  ((zwerg.imag() <= (*mu[xkoord])[mtest].imag() + mprec) &&
925  (zwerg.imag() >= (*mu[xkoord])[mtest].imag() - mprec)) )
926  {
927  roots[xk]->swapRoots( r, rtest );
928  found= true;
929  break;
930  }
931  }
932  } // rtest
933  if (!found)
934  {
935  WarnS("rootArranger::arrange: precision lost");
936  mprec*=10;
937  }
938  } while(!found);
939 #if 0
940  if ( !found )
941  {
942  Warn("rootArranger::arrange: No match? coord %d, root %d.",xkoord,r);
943 //#ifdef mprDEBUG_PROT
944  WarnS("One of these ...");
945  for ( rtest= r; rtest < anzr; rtest++ )
946  {
947  tmp= gmp_complex();
948  for ( xk =0; xk <= xkoord; xk++ )
949  {
950  tmp-= (*roots[xk])[r] * mu[xkoord]->evPointCoord(xk+1);
951  }
952  tmp-= (*roots[xk])[rtest] * mu[xkoord]->evPointCoord(xk+1); // xkoord+2
953  Warn(" %s",complexToStr(tmp,gmp_output_digits+1),rtest);
954  }
955  WarnS(" ... must match to one of these:");
956  for ( mtest= 0; mtest < anzr; mtest++ )
957  {
958  Warn(" %s",complexToStr((*mu[xkoord])[mtest],gmp_output_digits+1));
959  }
960 //#endif
961  }
962 #endif
963  } // r
964  } // xkoord
965 }
rootContainer ** mu
Definition: mpr_numeric.h:168
bool swapRoots(const int from, const int to)
Definition: mpr_numeric.cc:429
gmp_float real() const
Definition: mpr_complex.h:234
gmp_complex numbers based on
Definition: mpr_complex.h:178
int getAnzElems()
Definition: mpr_numeric.h:95
#define WarnS
Definition: emacs.cc:81
bool found
Definition: facFactorize.cc:56
const ring r
Definition: syzextra.cc:208
int getAnzRoots()
Definition: mpr_numeric.h:97
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
Definition: mpr_complex.cc:706
size_t gmp_output_digits
Definition: mpr_complex.cc:44
rootContainer ** roots
Definition: mpr_numeric.h:167
Rational pow(const Rational &a, int e)
Definition: GMPrat.cc:418
gmp_float imag() const
Definition: mpr_complex.h:235
#define Warn
Definition: emacs.cc:80

§ solve_all()

void rootArranger::solve_all ( )

Definition at line 870 of file mpr_numeric.cc.

871 {
872  int i;
873  found_roots= true;
874 
875  // find roots of polys given by coeffs in roots
876  rc= roots[0]->getAnzElems();
877  for ( i= 0; i < rc; i++ )
878  if ( !roots[i]->solver( howclean ) )
879  {
880  found_roots= false;
881  return;
882  }
883  // find roots of polys given by coeffs in mu
884  mc= mu[0]->getAnzElems();
885  for ( i= 0; i < mc; i++ )
886  if ( ! mu[i]->solver( howclean ) )
887  {
888  found_roots= false;
889  return;
890  }
891 }
rootContainer ** mu
Definition: mpr_numeric.h:168
int getAnzElems()
Definition: mpr_numeric.h:95
int i
Definition: cfEzgcd.cc:123
bool found_roots
Definition: mpr_numeric.h:172
rootContainer ** roots
Definition: mpr_numeric.h:167

§ success()

bool rootArranger::success ( )
inline

Definition at line 162 of file mpr_numeric.h.

162 { return found_roots; }
bool found_roots
Definition: mpr_numeric.h:172

Friends And Related Function Documentation

§ listOfRoots

lists listOfRoots ( rootArranger self,
const unsigned int  oprec 
)
friend

Definition at line 4974 of file ipshell.cc.

4975 {
4976  int i,j;
4977  int count= self->roots[0]->getAnzRoots(); // number of roots
4978  int elem= self->roots[0]->getAnzElems(); // number of koordinates per root
4979 
4980  lists listofroots= (lists)omAlloc( sizeof(slists) ); // must be done this way!
4981 
4982  if ( self->found_roots )
4983  {
4984  listofroots->Init( count );
4985 
4986  for (i=0; i < count; i++)
4987  {
4988  lists onepoint= (lists)omAlloc(sizeof(slists)); // must be done this way!
4989  onepoint->Init(elem);
4990  for ( j= 0; j < elem; j++ )
4991  {
4992  if ( !rField_is_long_C(currRing) )
4993  {
4994  onepoint->m[j].rtyp=STRING_CMD;
4995  onepoint->m[j].data=(void *)complexToStr((*self->roots[j])[i],oprec, currRing->cf);
4996  }
4997  else
4998  {
4999  onepoint->m[j].rtyp=NUMBER_CMD;
5000  onepoint->m[j].data=(void *)n_Copy((number)(self->roots[j]->getRoot(i)), currRing->cf);
5001  }
5002  onepoint->m[j].next= NULL;
5003  onepoint->m[j].name= NULL;
5004  }
5005  listofroots->m[i].rtyp=LIST_CMD;
5006  listofroots->m[i].data=(void *)onepoint;
5007  listofroots->m[j].next= NULL;
5008  listofroots->m[j].name= NULL;
5009  }
5010 
5011  }
5012  else
5013  {
5014  listofroots->Init( 0 );
5015  }
5016 
5017  return listofroots;
5018 }
int status int void size_t count
Definition: si_signals.h:59
sleftv * m
Definition: lists.h:45
Definition: lists.h:22
#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:10
int j
Definition: myNF.cc:70
const char * name
Definition: subexpr.h:88
int i
Definition: cfEzgcd.cc:123
bool found_roots
Definition: mpr_numeric.h:172
leftv next
Definition: subexpr.h:87
static BOOLEAN rField_is_long_C(const ring r)
Definition: ring.h:534
INLINE_THIS void Init(int l=0)
#define NULL
Definition: omList.c:10
slists * lists
Definition: mpr_numeric.h:146
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:455
int rtyp
Definition: subexpr.h:92
Definition: tok.h:117
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
Definition: mpr_complex.cc:706
rootContainer ** roots
Definition: mpr_numeric.h:167

Field Documentation

§ found_roots

bool rootArranger::found_roots
private

Definition at line 172 of file mpr_numeric.h.

§ howclean

int rootArranger::howclean
private

Definition at line 170 of file mpr_numeric.h.

§ mc

int rootArranger::mc
private

Definition at line 171 of file mpr_numeric.h.

§ mu

rootContainer** rootArranger::mu
private

Definition at line 168 of file mpr_numeric.h.

§ rc

int rootArranger::rc
private

Definition at line 171 of file mpr_numeric.h.

§ roots

rootContainer** rootArranger::roots
private

Definition at line 167 of file mpr_numeric.h.


The documentation for this class was generated from the following files: