My Project
Loading...
Searching...
No Matches
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 *self, 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 848 of file mpr_numeric.cc.

851 : roots(_roots), mu(_mu), howclean(_howclean)
852{
853 found_roots=false;
854}
rootContainer ** roots
rootContainer ** mu

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

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

◆ solve_all()

void rootArranger::solve_all ( )

Definition at line 858 of file mpr_numeric.cc.

859{
860 int i;
861 found_roots= true;
862
863 // find roots of polys given by coeffs in roots
864 rc= roots[0]->getAnzElems();
865 for ( i= 0; i < rc; i++ )
866 if ( !roots[i]->solver( howclean ) )
867 {
868 found_roots= false;
869 return;
870 }
871 // find roots of polys given by coeffs in mu
872 mc= mu[0]->getAnzElems();
873 for ( i= 0; i < mc; i++ )
874 if ( ! mu[i]->solver( howclean ) )
875 {
876 found_roots= false;
877 return;
878 }
879}
int i
Definition cfEzgcd.cc:132

◆ success()

bool rootArranger::success ( )
inline

Definition at line 162 of file mpr_numeric.h.

162{ return found_roots; }

Friends And Related Symbol Documentation

◆ listOfRoots

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

Definition at line 5075 of file ipshell.cc.

5076{
5077 int i,j;
5078 int count= self->roots[0]->getAnzRoots(); // number of roots
5079 int elem= self->roots[0]->getAnzElems(); // number of koordinates per root
5080
5081 lists listofroots= (lists)omAlloc( sizeof(slists) ); // must be done this way!
5082
5083 if ( self->found_roots )
5084 {
5085 listofroots->Init( count );
5086
5087 for (i=0; i < count; i++)
5088 {
5089 lists onepoint= (lists)omAlloc(sizeof(slists)); // must be done this way!
5090 onepoint->Init(elem);
5091 for ( j= 0; j < elem; j++ )
5092 {
5093 if ( !rField_is_long_C(currRing) )
5094 {
5095 onepoint->m[j].rtyp=STRING_CMD;
5096 onepoint->m[j].data=(void *)complexToStr((*self->roots[j])[i],oprec, currRing->cf);
5097 }
5098 else
5099 {
5100 onepoint->m[j].rtyp=NUMBER_CMD;
5101 onepoint->m[j].data=(void *)n_Copy((number)(self->roots[j]->getRoot(i)), currRing->cf);
5102 }
5103 onepoint->m[j].next= NULL;
5104 onepoint->m[j].name= NULL;
5105 }
5106 listofroots->m[i].rtyp=LIST_CMD;
5107 listofroots->m[i].data=(void *)onepoint;
5108 listofroots->m[j].next= NULL;
5109 listofroots->m[j].name= NULL;
5110 }
5111
5112 }
5113 else
5114 {
5115 listofroots->Init( 0 );
5116 }
5117
5118 return listofroots;
5119}
gmp_complex * getRoot(const int i)
Definition mpr_numeric.h:88
int getAnzRoots()
Definition mpr_numeric.h:97
int getAnzElems()
Definition mpr_numeric.h:95
const char * name
Definition subexpr.h:87
int rtyp
Definition subexpr.h:91
leftv next
Definition subexpr.h:86
void * data
Definition subexpr.h:88
sleftv * m
Definition lists.h:46
INLINE_THIS void Init(int l=0)
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition coeffs.h:455
int j
Definition facHensel.cc:110
@ NUMBER_CMD
Definition grammar.cc:289
slists * lists
#define omAlloc(size)
#define NULL
Definition omList.c:12
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
static BOOLEAN rField_is_long_C(const ring r)
Definition ring.h:551
int status int void size_t count
Definition si_signals.h:69
@ LIST_CMD
Definition tok.h:118
@ STRING_CMD
Definition tok.h:187

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: