MCPcopy Create free account
hub / github.com/Singular/Singular / arrange

Method arrange

kernel/numeric/mpr_numeric.cc:883–953  ·  view source on GitHub ↗

-> void rootArranger::arrange()

Source from the content-addressed store, hash-verified

881
882//-> void rootArranger::arrange()
883void rootArranger::arrange()
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

Callers 1

nuUResSolveFunction · 0.80

Calls 10

gmp_complexClass · 0.85
WarnSFunction · 0.85
WarnFunction · 0.85
complexToStrFunction · 0.85
getAnzElemsMethod · 0.80
getAnzRootsMethod · 0.80
realMethod · 0.80
imagMethod · 0.80
swapRootsMethod · 0.80
powFunction · 0.50

Tested by

no test coverage detected