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

851 : roots(_roots), mu(_mu), howclean(_howclean)
852{
853 found_roots=false;
854}
rootContainer ** roots
Definition: mpr_numeric.h:167
rootContainer ** mu
Definition: mpr_numeric.h:168
bool found_roots
Definition: mpr_numeric.h:172

◆ ~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_complex numbers based on
Definition: mpr_complex.h:179
gmp_float imag() const
Definition: mpr_complex.h:235
gmp_float real() const
Definition: mpr_complex.h:234
bool swapRoots(const int from, const int to)
Definition: mpr_numeric.cc:417
int getAnzRoots()
Definition: mpr_numeric.h:97
int getAnzElems()
Definition: mpr_numeric.h:95
#define Warn
Definition: emacs.cc:77
#define WarnS
Definition: emacs.cc:78
bool found
Definition: facFactorize.cc:55
EXTERN_VAR size_t gmp_output_digits
Definition: mpr_base.h:115
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
Definition: mpr_complex.cc:704

◆ 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 Function Documentation

◆ listOfRoots

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

Definition at line 5079 of file ipshell.cc.

5080{
5081 int i,j;
5082 int count= self->roots[0]->getAnzRoots(); // number of roots
5083 int elem= self->roots[0]->getAnzElems(); // number of koordinates per root
5084
5085 lists listofroots= (lists)omAlloc( sizeof(slists) ); // must be done this way!
5086
5087 if ( self->found_roots )
5088 {
5089 listofroots->Init( count );
5090
5091 for (i=0; i < count; i++)
5092 {
5093 lists onepoint= (lists)omAlloc(sizeof(slists)); // must be done this way!
5094 onepoint->Init(elem);
5095 for ( j= 0; j < elem; j++ )
5096 {
5097 if ( !rField_is_long_C(currRing) )
5098 {
5099 onepoint->m[j].rtyp=STRING_CMD;
5100 onepoint->m[j].data=(void *)complexToStr((*self->roots[j])[i],oprec, currRing->cf);
5101 }
5102 else
5103 {
5104 onepoint->m[j].rtyp=NUMBER_CMD;
5105 onepoint->m[j].data=(void *)n_Copy((number)(self->roots[j]->getRoot(i)), currRing->cf);
5106 }
5107 onepoint->m[j].next= NULL;
5108 onepoint->m[j].name= NULL;
5109 }
5110 listofroots->m[i].rtyp=LIST_CMD;
5111 listofroots->m[i].data=(void *)onepoint;
5112 listofroots->m[j].next= NULL;
5113 listofroots->m[j].name= NULL;
5114 }
5115
5116 }
5117 else
5118 {
5119 listofroots->Init( 0 );
5120 }
5121
5122 return listofroots;
5123}
gmp_complex * getRoot(const int i)
Definition: mpr_numeric.h:88
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
Definition: lists.h:24
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:448
int j
Definition: facHensel.cc:110
@ NUMBER_CMD
Definition: grammar.cc:288
slists * lists
Definition: mpr_numeric.h:146
#define omAlloc(size)
Definition: omAllocDecl.h:210
#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:545
int status int void size_t count
Definition: si_signals.h:59
@ LIST_CMD
Definition: tok.h:118
@ STRING_CMD
Definition: tok.h:185

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: