My Project  debian-1:4.1.1-p2+ds-4build2
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 852 of file mpr_numeric.cc.

855  : roots(_roots), mu(_mu), howclean(_howclean)
856 {
857  found_roots=false;
858 }

◆ ~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 887 of file mpr_numeric.cc.

888 {
889  gmp_complex tmp,zwerg;
890  int anzm= mu[0]->getAnzElems();
891  int anzr= roots[0]->getAnzRoots();
892  int xkoord, r, rtest, xk, mtest;
893  bool found;
894  //gmp_complex mprec(1.0/pow(10,gmp_output_digits-5),1.0/pow(10,gmp_output_digits-5));
895 
896  for ( xkoord= 0; xkoord < anzm; xkoord++ ) { // für x1,x2, x1,x2,x3, x1,x2,...,xn
897  gmp_float mprec(1.0/pow(10.0,(int)(gmp_output_digits/3)));
898  for ( r= 0; r < anzr; r++ ) { // für jede Nullstelle
899  // (x1-koordinate) * evp[1] + (x2-koordinate) * evp[2] +
900  // ... + (xkoord-koordinate) * evp[xkoord]
901  tmp= gmp_complex();
902  for ( xk =0; xk <= xkoord; xk++ )
903  {
904  tmp -= (*roots[xk])[r] * mu[xkoord]->evPointCoord(xk+1); //xk+1
905  }
906  found= false;
907  do { // while not found
908  for ( rtest= r; rtest < anzr; rtest++ ) { // für jede Nullstelle
909  zwerg = tmp - (*roots[xk])[rtest] * mu[xkoord]->evPointCoord(xk+1); // xk+1, xkoord+2
910  for ( mtest= 0; mtest < anzr; mtest++ )
911  {
912  // if ( tmp == (*mu[xkoord])[mtest] )
913  // {
914  if ( ((zwerg.real() <= (*mu[xkoord])[mtest].real() + mprec) &&
915  (zwerg.real() >= (*mu[xkoord])[mtest].real() - mprec)) &&
916  ((zwerg.imag() <= (*mu[xkoord])[mtest].imag() + mprec) &&
917  (zwerg.imag() >= (*mu[xkoord])[mtest].imag() - mprec)) )
918  {
919  roots[xk]->swapRoots( r, rtest );
920  found= true;
921  break;
922  }
923  }
924  } // rtest
925  if (!found)
926  {
927  WarnS("rootArranger::arrange: precision lost");
928  mprec*=10;
929  }
930  } while(!found);
931 #if 0
932  if ( !found )
933  {
934  Warn("rootArranger::arrange: No match? coord %d, root %d.",xkoord,r);
935 //#ifdef mprDEBUG_PROT
936  WarnS("One of these ...");
937  for ( rtest= r; rtest < anzr; rtest++ )
938  {
939  tmp= gmp_complex();
940  for ( xk =0; xk <= xkoord; xk++ )
941  {
942  tmp-= (*roots[xk])[r] * mu[xkoord]->evPointCoord(xk+1);
943  }
944  tmp-= (*roots[xk])[rtest] * mu[xkoord]->evPointCoord(xk+1); // xkoord+2
945  Warn(" %s",complexToStr(tmp,gmp_output_digits+1),rtest);
946  }
947  WarnS(" ... must match to one of these:");
948  for ( mtest= 0; mtest < anzr; mtest++ )
949  {
950  Warn(" %s",complexToStr((*mu[xkoord])[mtest],gmp_output_digits+1));
951  }
952 //#endif
953  }
954 #endif
955  } // r
956  } // xkoord
957 }

◆ solve_all()

void rootArranger::solve_all ( )

Definition at line 862 of file mpr_numeric.cc.

863 {
864  int i;
865  found_roots= true;
866 
867  // find roots of polys given by coeffs in roots
868  rc= roots[0]->getAnzElems();
869  for ( i= 0; i < rc; i++ )
870  if ( !roots[i]->solver( howclean ) )
871  {
872  found_roots= false;
873  return;
874  }
875  // find roots of polys given by coeffs in mu
876  mc= mu[0]->getAnzElems();
877  for ( i= 0; i < mc; i++ )
878  if ( ! mu[i]->solver( howclean ) )
879  {
880  found_roots= false;
881  return;
882  }
883 }

◆ success()

bool rootArranger::success ( )
inline

Definition at line 162 of file mpr_numeric.h.

162 { return found_roots; }

Friends And Related Function Documentation

◆ listOfRoots

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

Definition at line 5003 of file ipshell.cc.

5004 {
5005  int i,j;
5006  int count= self->roots[0]->getAnzRoots(); // number of roots
5007  int elem= self->roots[0]->getAnzElems(); // number of koordinates per root
5008 
5009  lists listofroots= (lists)omAlloc( sizeof(slists) ); // must be done this way!
5010 
5011  if ( self->found_roots )
5012  {
5013  listofroots->Init( count );
5014 
5015  for (i=0; i < count; i++)
5016  {
5017  lists onepoint= (lists)omAlloc(sizeof(slists)); // must be done this way!
5018  onepoint->Init(elem);
5019  for ( j= 0; j < elem; j++ )
5020  {
5021  if ( !rField_is_long_C(currRing) )
5022  {
5023  onepoint->m[j].rtyp=STRING_CMD;
5024  onepoint->m[j].data=(void *)complexToStr((*self->roots[j])[i],oprec, currRing->cf);
5025  }
5026  else
5027  {
5028  onepoint->m[j].rtyp=NUMBER_CMD;
5029  onepoint->m[j].data=(void *)n_Copy((number)(self->roots[j]->getRoot(i)), currRing->cf);
5030  }
5031  onepoint->m[j].next= NULL;
5032  onepoint->m[j].name= NULL;
5033  }
5034  listofroots->m[i].rtyp=LIST_CMD;
5035  listofroots->m[i].data=(void *)onepoint;
5036  listofroots->m[j].next= NULL;
5037  listofroots->m[j].name= NULL;
5038  }
5039 
5040  }
5041  else
5042  {
5043  listofroots->Init( 0 );
5044  }
5045 
5046  return listofroots;
5047 }

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:
j
int j
Definition: facHensel.cc:105
gmp_output_digits
size_t gmp_output_digits
Definition: mpr_complex.cc:43
NUMBER_CMD
@ NUMBER_CMD
Definition: grammar.cc:287
LIST_CMD
@ LIST_CMD
Definition: tok.h:118
STRING_CMD
@ STRING_CMD
Definition: tok.h:183
rootArranger::mc
int mc
Definition: mpr_numeric.h:171
gmp_complex::imag
gmp_float imag() const
Definition: mpr_complex.h:235
rootContainer::swapRoots
bool swapRoots(const int from, const int to)
Definition: mpr_numeric.cc:421
found
bool found
Definition: facFactorize.cc:56
currRing
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
sleftv::name
const char * name
Definition: subexpr.h:87
i
int i
Definition: cfEzgcd.cc:125
rootArranger::found_roots
bool found_roots
Definition: mpr_numeric.h:172
sleftv::data
void * data
Definition: subexpr.h:88
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:210
slists::m
sleftv * m
Definition: lists.h:45
rootArranger::rc
int rc
Definition: mpr_numeric.h:171
complexToStr
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
Definition: mpr_complex.cc:705
slists
Definition: lists.h:22
gmp_complex::real
gmp_float real() const
Definition: mpr_complex.h:234
rootArranger::roots
rootContainer ** roots
Definition: mpr_numeric.h:167
rootContainer::getAnzRoots
int getAnzRoots()
Definition: mpr_numeric.h:97
n_Copy
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:452
pow
Rational pow(const Rational &a, int e)
Definition: GMPrat.cc:414
WarnS
#define WarnS
Definition: emacs.cc:78
sleftv::rtyp
int rtyp
Definition: subexpr.h:91
NULL
#define NULL
Definition: omList.c:10
lists
slists * lists
Definition: mpr_numeric.h:146
Warn
#define Warn
Definition: emacs.cc:77
slists::Init
INLINE_THIS void Init(int l=0)
rootArranger::mu
rootContainer ** mu
Definition: mpr_numeric.h:168
count
int status int void size_t count
Definition: si_signals.h:59
rootContainer::getAnzElems
int getAnzElems()
Definition: mpr_numeric.h:95
rootArranger::howclean
int howclean
Definition: mpr_numeric.h:170
rField_is_long_C
static BOOLEAN rField_is_long_C(const ring r)
Definition: ring.h:537
gmp_float
Definition: mpr_complex.h:31
sleftv::next
leftv next
Definition: subexpr.h:86
gmp_complex
gmp_complex numbers based on
Definition: mpr_complex.h:178