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::rootArranger ( rootContainer **  _roots,
rootContainer **  _mu,
const int  _howclean = PM_CORRUPT 
)

Definition at line 861 of file mpr_numeric.cc.

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

Definition at line 157 of file mpr_numeric.h.

157 {}
rootArranger::rootArranger ( const rootArranger )
private

Member Function Documentation

void rootArranger::arrange ( )

Definition at line 896 of file mpr_numeric.cc.

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

Definition at line 871 of file mpr_numeric.cc.

872 {
873  int i;
874  found_roots= true;
875 
876  // find roots of polys given by coeffs in roots
877  rc= roots[0]->getAnzElems();
878  for ( i= 0; i < rc; i++ )
879  if ( !roots[i]->solver( howclean ) )
880  {
881  found_roots= false;
882  return;
883  }
884  // find roots of polys given by coeffs in mu
885  mc= mu[0]->getAnzElems();
886  for ( i= 0; i < mc; i++ )
887  if ( ! mu[i]->solver( howclean ) )
888  {
889  found_roots= false;
890  return;
891  }
892 }
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
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

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

Definition at line 4983 of file ipshell.cc.

4984 {
4985  int i,j;
4986  int count= self->roots[0]->getAnzRoots(); // number of roots
4987  int elem= self->roots[0]->getAnzElems(); // number of koordinates per root
4988 
4989  lists listofroots= (lists)omAlloc( sizeof(slists) ); // must be done this way!
4990 
4991  if ( self->found_roots )
4992  {
4993  listofroots->Init( count );
4994 
4995  for (i=0; i < count; i++)
4996  {
4997  lists onepoint= (lists)omAlloc(sizeof(slists)); // must be done this way!
4998  onepoint->Init(elem);
4999  for ( j= 0; j < elem; j++ )
5000  {
5001  if ( !rField_is_long_C(currRing) )
5002  {
5003  onepoint->m[j].rtyp=STRING_CMD;
5004  onepoint->m[j].data=(void *)complexToStr((*self->roots[j])[i],oprec, currRing->cf);
5005  }
5006  else
5007  {
5008  onepoint->m[j].rtyp=NUMBER_CMD;
5009  onepoint->m[j].data=(void *)n_Copy((number)(self->roots[j]->getRoot(i)), currRing->cf);
5010  }
5011  onepoint->m[j].next= NULL;
5012  onepoint->m[j].name= NULL;
5013  }
5014  listofroots->m[i].rtyp=LIST_CMD;
5015  listofroots->m[i].data=(void *)onepoint;
5016  listofroots->m[j].next= NULL;
5017  listofroots->m[j].name= NULL;
5018  }
5019 
5020  }
5021  else
5022  {
5023  listofroots->Init( 0 );
5024  }
5025 
5026  return listofroots;
5027 }
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:12
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:491
INLINE_THIS void Init(int l=0)
Definition: lists.h:66
#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:452
int rtyp
Definition: subexpr.h:92
Definition: tok.h:120
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
Definition: mpr_complex.cc:717
rootContainer ** roots
Definition: mpr_numeric.h:167

Field Documentation

bool rootArranger::found_roots
private

Definition at line 172 of file mpr_numeric.h.

int rootArranger::howclean
private

Definition at line 170 of file mpr_numeric.h.

int rootArranger::mc
private

Definition at line 171 of file mpr_numeric.h.

rootContainer** rootArranger::mu
private

Definition at line 168 of file mpr_numeric.h.

int rootArranger::rc
private

Definition at line 171 of file mpr_numeric.h.

rootContainer** rootArranger::roots
private

Definition at line 167 of file mpr_numeric.h.


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