My Project
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 847 of file mpr_numeric.cc.

850 : roots(_roots), mu(_mu), howclean(_howclean)
851{
852 found_roots=false;
853}
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 882 of file mpr_numeric.cc.

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

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

5164{
5165 int i,j;
5166 int count= self->roots[0]->getAnzRoots(); // number of roots
5167 int elem= self->roots[0]->getAnzElems(); // number of koordinates per root
5168
5169 lists listofroots= (lists)omAlloc( sizeof(slists) ); // must be done this way!
5170
5171 if ( self->found_roots )
5172 {
5173 listofroots->Init( count );
5174
5175 for (i=0; i < count; i++)
5176 {
5177 lists onepoint= (lists)omAlloc(sizeof(slists)); // must be done this way!
5178 onepoint->Init(elem);
5179 for ( j= 0; j < elem; j++ )
5180 {
5181 if ( !rField_is_long_C(currRing) )
5182 {
5183 onepoint->m[j].rtyp=STRING_CMD;
5184 onepoint->m[j].data=(void *)complexToStr((*self->roots[j])[i],oprec, currRing->cf);
5185 }
5186 else
5187 {
5188 onepoint->m[j].rtyp=NUMBER_CMD;
5189 onepoint->m[j].data=(void *)n_Copy((number)(self->roots[j]->getRoot(i)), currRing->cf);
5190 }
5191 onepoint->m[j].next= NULL;
5192 onepoint->m[j].name= NULL;
5193 }
5194 listofroots->m[i].rtyp=LIST_CMD;
5195 listofroots->m[i].data=(void *)onepoint;
5196 listofroots->m[j].next= NULL;
5197 listofroots->m[j].name= NULL;
5198 }
5199
5200 }
5201 else
5202 {
5203 listofroots->Init( 0 );
5204 }
5205
5206 return listofroots;
5207}
#define NULL
Definition: auxiliary.h:104
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:452
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
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:547
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: