Changeset da408f in git
- Timestamp:
- Jul 8, 1999, 12:18:13 PM (24 years ago)
- Branches:
- (u'spielwiese', '828514cf6e480e4bafc26df99217bf2a1ed1ef45')
- Children:
- b719a30005f8bcbcca9d638b7908dda038ffee56
- Parents:
- 4deddb979be065737d63e926fc05f264a6b1078a
- Location:
- Singular
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/solve.lib
r4deddb rda408f 1 1 /////////////////////////////////////////////////////////////////////////////// 2 2 3 version="$Id: solve.lib,v 1.1 1 1999-07-07 16:38:28 obachmanExp $";3 version="$Id: solve.lib,v 1.12 1999-07-08 10:18:13 wenk Exp $"; 4 4 info=" 5 5 LIBRARY: solve.lib PROCEDURES TO SOLVE POLYNOMIAL SYSTEMS … … 67 67 } 68 68 69 int digits= system("setFloatDigits",prec); 70 71 return(uressolve(gls,typ,polish)); 69 return(uressolve(gls,typ,prec,polish)); 72 70 73 71 } … … 81 79 // result is a list (x,y)-coordinates as strings 82 80 83 // now with complex coefficient field, precision is 10 digits84 ring rsc= (real, 10,I),(x,y),lp;81 // now with complex coefficient field, precision is 20 digits 82 ring rsc= (real,20,I),(x,y),lp; 85 83 ideal i = (2+3*I)*x2 + (0.35+I*45.0e-2)*y2 - 8, x2 + xy + (42.7)*y2; 86 ures_solve(i);84 list l= ures_solve(i); 87 85 // result is a list of (x,y)-coordinates of complex numbers 86 l; 87 // check the result 88 subst(subst(i[1],x,l[1][1]),y,l[1][2]); 88 89 } 89 90 /////////////////////////////////////////////////////////////////////////////// … … 126 127 } 127 128 128 int digits= system("setFloatDigits",prec); 129 130 return(laguerre(f,polish)); 129 return(laguerre(f,prec,polish)); 131 130 132 131 } … … 147 146 list l = laguerre_solve(f); 148 147 l; 148 // check result, value of substituted poly should be near to zero 149 subst(f,x,l[1]); 150 subst(f,x,l[2]); 149 151 } 150 152 /////////////////////////////////////////////////////////////////////////////// … … 244 246 ideal p = 2,3; 245 247 ideal v= 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16; 246 interpolate( p,v,3 ); 247 } 248 /////////////////////////////////////////////////////////////////////////////// 248 poly ip= interpolate( p,v,3 ); 249 ip; 250 // compute poly at point 2,3, result must be 2 251 subst(subst(ip,x,2),y,3); 252 // compute poly at point 2^15,3^15, result must be 16 253 subst(subst(ip,x,2^15),y,3^15); 254 } 255 /////////////////////////////////////////////////////////////////////////////// -
Singular/extra.cc
r4deddb rda408f 2 2 * Computer Algebra System SINGULAR * 3 3 *****************************************/ 4 /* $Id: extra.cc,v 1.9 4 1999-06-28 12:48:07 wenk Exp $ */4 /* $Id: extra.cc,v 1.95 1999-07-08 10:18:07 wenk Exp $ */ 5 5 /* 6 6 * ABSTRACT: general interface to internals of Singular ("system" command) … … 409 409 char *sys_cmd=(char *)(h->Data()); 410 410 h=h->next; 411 /*==================== setFloatDigits ================================*/412 if(strcmp(sys_cmd,"setFloatDigits")==0)413 {414 if ((h!=NULL) && (h->Typ()==INT_CMD))415 {416 if ( !(rField_is_R()||rField_is_long_R()||rField_is_long_C()) )417 {418 setGMPFloatDigits( (unsigned long int)h->Data() );419 res->rtyp=INT_CMD;420 res->data=(void*)getGMPFloatDigits();421 }422 else423 {424 res->rtyp=INT_CMD;425 res->data=(void*)0;426 }427 return FALSE;428 }429 else430 {431 WerrorS("int expected as second parameter");432 }433 }434 else435 411 /*==================== pcv ==================================*/ 436 412 #ifndef HAVE_DYNAMIC_LOADING -
Singular/gnumpc.h
r4deddb rda408f 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: gnumpc.h,v 1. 2 1999-06-24 07:46:49wenk Exp $ */6 /* $Id: gnumpc.h,v 1.3 1999-07-08 10:18:08 wenk Exp $ */ 7 7 /* 8 8 * ABSTRACT: computations with GMP floating-point numbers … … 10 10 #include "structs.h" 11 11 12 BOOLEAN ngcGreaterZero(number za); 12 BOOLEAN ngcGreaterZero(number za); // !!! MAY NOT WORK AS EXPECTED !!! 13 13 BOOLEAN ngcGreater(number a, number b); 14 14 BOOLEAN ngcEqual(number a, number b); -
Singular/iparith.cc
r4deddb rda408f 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: iparith.cc,v 1.15 5 1999-06-30 14:41:04 pohlExp $ */4 /* $Id: iparith.cc,v 1.156 1999-07-08 10:18:09 wenk Exp $ */ 5 5 6 6 /* … … 196 196 { "killattrib", 0, KILLATTR_CMD , CMD_12}, 197 197 { "koszul", 0, KOSZUL_CMD , CMD_23}, 198 { "laguerre", 0, LAGSOLVE_CMD, CMD_ 2},198 { "laguerre", 0, LAGSOLVE_CMD, CMD_3}, 199 199 { "lead", 0, LEAD_CMD , CMD_1}, 200 200 { "leadcoef", 0, LEADCOEF_CMD , CMD_1}, … … 295 295 { "unload", 0, UNLOAD_CMD , CMD_M}, 296 296 #endif 297 { "uressolve", 0, URSOLVE_CMD, CMD_ 3},297 { "uressolve", 0, URSOLVE_CMD, CMD_M}, 298 298 { "vandermonde", 0, VANDER_CMD, CMD_3}, 299 299 { "var", 0, VAR_CMD , CMD_1}, … … 2278 2278 ,{jjWEDGE, WEDGE_CMD, MATRIX_CMD, MATRIX_CMD, INT_CMD PROFILER} 2279 2279 ,{jjLOAD_E, LOAD_CMD, NONE, STRING_CMD, STRING_CMD PROFILER} 2280 ,{nuLagSolve, LAGSOLVE_CMD, LIST_CMD, POLY_CMD, INT_CMD PROFILER}2281 2280 ,{nuMPResMat, MPRES_CMD, MODUL_CMD, IDEAL_CMD, INT_CMD PROFILER} 2282 2281 ,{NULL, 0, 0, 0, 0 PROFILER} … … 4298 4297 ,{jjSUBST_Id, SUBST_CMD, MODUL_CMD, MODUL_CMD, POLY_CMD, POLY_CMD } 4299 4298 ,{jjSUBST_Id, SUBST_CMD, MATRIX_CMD, MATRIX_CMD, POLY_CMD, POLY_CMD } 4300 ,{jjCALL3MANY, SYSTEM_CMD, NONE, STRING_CMD, DEF_CMD, DEF_CMD }4301 ,{nu UResSolve, URSOLVE_CMD,LIST_CMD, IDEAL_CMD, INT_CMD, INT_CMD}4302 ,{nuVanderSys, VANDER_CMD, POLY_CMD, IDEAL_CMD, IDEAL_CMD, INT_CMD }4299 ,{jjCALL3MANY, SYSTEM_CMD, NONE, STRING_CMD, DEF_CMD, DEF_CMD } 4300 ,{nuLagSolve, LAGSOLVE_CMD,LIST_CMD, POLY_CMD, INT_CMD, INT_CMD } 4301 ,{nuVanderSys, VANDER_CMD, POLY_CMD, IDEAL_CMD, IDEAL_CMD, INT_CMD } 4303 4302 ,{NULL, 0, 0, 0, 0, 0 } 4304 4303 }; … … 4814 4813 ,{jjUNLOAD, UNLOAD_CMD, NONE, -2 } 4815 4814 #endif /* HAVE_NAMESPACES */ 4816 ,{NULL, 0, 0, 0 } 4815 ,{nuUResSolve, URSOLVE_CMD, LIST_CMD, 4 } 4816 ,{NULL, 0, 0, 0 } 4817 4817 }; 4818 4818 #ifdef MDEBUG -
Singular/mpr_base.cc
r4deddb rda408f 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: mpr_base.cc,v 1. 6 1999-06-30 11:54:31 SingularExp $ */4 /* $Id: mpr_base.cc,v 1.7 1999-07-08 10:18:10 wenk Exp $ */ 5 5 6 6 /* … … 50 50 #define MAXINITELEMS 256 51 51 #define LIFT_COOR 100000000 52 #define SCALEDOWN 10000 .052 #define SCALEDOWN 100000.0 53 53 #define MAXSEED 1024 //512 54 54 #define MINVDIST 0.0 … … 2615 2615 //----------------------------------------------------------------------------- 2616 2616 2617 #define MAXEVPOINT 1 000000.02617 #define MAXEVPOINT 1.0e+6 2618 2618 2619 2619 //-> unsigned long over(unsigned long n,unsigned long d) -
Singular/mpr_complex.cc
r4deddb rda408f 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: mpr_complex.cc,v 1.1 2 1999-07-02 16:43:19wenk Exp $ */4 /* $Id: mpr_complex.cc,v 1.13 1999-07-08 10:18:11 wenk Exp $ */ 5 5 6 6 /* … … 69 69 size_t bits= 1 + (size_t) (digits / (log(2)/log(10))); 70 70 bits= bits>64?bits:64; 71 // 72 gmp_float::setPrecision( bits+(bits/ 2) );71 //gmp_float::setPrecision( bits+EXTRABYTES*8 ); 72 gmp_float::setPrecision( bits+(bits/5) ); 73 73 gmp_float::setEqualBits( bits ); 74 74 gmp_output_digits= digits; … … 338 338 out= (char*)AllocL(*size); 339 339 memset(out,0,*size); 340 sprintf(out,"%s0.%se% d",csign,in+sign,(unsignedint)exponent);340 sprintf(out,"%s0.%se%s%d",csign,in+sign,exponent>=0?"+":"",(int)exponent); 341 341 // } 342 342 // else -
Singular/mpr_inout.cc
r4deddb rda408f 3 3 ****************************************/ 4 4 5 /* $Id: mpr_inout.cc,v 1. 3 1999-06-29 09:03:45wenk Exp $ */5 /* $Id: mpr_inout.cc,v 1.4 1999-07-08 10:18:12 wenk Exp $ */ 6 6 7 7 /* … … 166 166 //<- 167 167 168 //-> BOOLEAN nuUResSolve( leftv res, leftv arg1, leftv arg2, leftv arg3 ) 169 BOOLEAN nuUResSolve( leftv res, leftv arg1, leftv arg2, leftv arg3 ) 170 { 168 //-> BOOLEAN nuUResSolve( leftv res, leftv args ) 169 BOOLEAN nuUResSolve( leftv res, leftv args ) 170 { 171 leftv v= args; 172 171 173 ideal gls; 172 gls= (ideal)(arg1->Data()); 173 int imtype= (int)arg2->Data(); 174 int howclean= (int)arg3->Data(); 174 int imtype; 175 int howclean; 176 177 // get ideal 178 if ( v->Typ() != IDEAL_CMD ) 179 return TRUE; 180 else gls= (ideal)(args->Data()); 181 v= v->next; 182 183 // get resultant matrix type to use (0,1) 184 if ( v->Typ() != INT_CMD ) 185 return TRUE; 186 else imtype= (int)v->Data(); 187 v= v->next; 188 189 // get and set precision in digits ( > 0 ) 190 if ( v->Typ() != INT_CMD ) 191 return TRUE; 192 else if ( !(rField_is_R()||rField_is_long_R()||rField_is_long_C()) ) 193 { 194 setGMPFloatDigits( (unsigned long int)v->Data() ); 195 } 196 v= v->next; 197 198 // get interpolation steps (0,1,2) 199 if ( v->Typ() != INT_CMD ) 200 return TRUE; 201 else howclean= (int)v->Data(); 175 202 176 203 uResultant::resMatType mtype= determineMType( imtype ); … … 181 208 BOOLEAN interpolate_det= (mtype==uResultant::denseResMat)?TRUE:FALSE; 182 209 183 emptylist= (lists)Alloc( sizeof(slists) );184 emptylist->Init( 0 );185 186 res->rtyp = LIST_CMD;187 res->data= (void *)emptylist;210 //emptylist= (lists)Alloc( sizeof(slists) ); 211 //emptylist->Init( 0 ); 212 213 //res->rtyp = LIST_CMD; 214 //res->data= (void *)emptylist; 188 215 189 216 TIMING_START(mpr_overall); 190 217 191 218 // check input ideal ( = polynomial system ) 192 if ( mprIdealCheck( gls, arg 1->Name(), mtype ) != mprOk )219 if ( mprIdealCheck( gls, args->Name(), mtype ) != mprOk ) 193 220 { 194 221 return TRUE; … … 265 292 else 266 293 { 267 WerrorS("Solver was unable to find any root !");294 WerrorS("Solver was unable to find any roots!"); 268 295 return TRUE; 269 296 } … … 283 310 res->data= (void *)listofroots; 284 311 285 emptylist->Clean();286 // Free( (ADDRESS) emptylist, sizeof(slists) );312 //emptylist->Clean(); 313 // Free( (ADDRESS) emptylist, sizeof(slists) ); 287 314 288 315 TIMING_EPR(mpr_overall,"overall time\t\t") … … 318 345 //<- 319 346 320 //-> BOOLEAN nuLagSolve( leftv res, leftv arg1, leftv arg2 )321 BOOLEAN nuLagSolve( leftv res, leftv arg1, leftv arg2 )347 //-> BOOLEAN nuLagSolve( leftv res, leftv arg1, leftv arg2, leftv arg3 ) 348 BOOLEAN nuLagSolve( leftv res, leftv arg1, leftv arg2, leftv arg3 ) 322 349 { 323 350 324 351 poly gls; 325 352 gls= (poly)(arg1->Data()); 326 int howclean= (int)arg2->Data(); 353 int howclean= (int)arg3->Data(); 354 355 if ( !(rField_is_R()||rField_is_long_R()||rField_is_long_C()) ) 356 { 357 setGMPFloatDigits( (unsigned long int)arg2->Data() ); 358 } 327 359 328 360 int deg= pTotaldegree( gls ); -
Singular/mpr_inout.h
r4deddb rda408f 5 5 ****************************************/ 6 6 7 /* $Id: mpr_inout.h,v 1. 3 1999-06-29 09:03:45wenk Exp $ */7 /* $Id: mpr_inout.h,v 1.4 1999-07-08 10:18:13 wenk Exp $ */ 8 8 9 9 /* … … 22 22 * dense homogeneous polynoms) or MPR_SPARSE, which uses Sparse Resultant 23 23 * (Gelfand, Kapranov, Zelevinsky). 24 * If interpolate == true then the determinant of the u-resultant will be 25 * numerically interpolatet using a Vandermonde System. 26 * Otherwise, the Sparse Bareiss will be used (faster!). 24 * Arguments 4: ideal i, int k, int l, int m 25 * k=0: use sparse resultant matrix of Gelfand, Kapranov and Zelevinsky 26 * k=1: use resultant matrix of Macaulay (k=0 is default) 27 * l>0: defines precision of fractional part if ground field is Q 28 * m=0,1,2: number of iterations for approximation of roots (default=2) 27 29 * Returns a list containing the roots of the system. 28 30 */ 29 BOOLEAN nuUResSolve( leftv res, leftv arg 1, leftv arg2, leftv arg3);31 BOOLEAN nuUResSolve( leftv res, leftv args ); 30 32 31 /** build resultant matrix from ideal 32 * Make sure that IDELEMS(ideal) == pVariables+1. 33 /** returns module representing the multipolynomial resultant matrix 34 * Arguments 2: ideal i, int k 35 * k=0: use sparse resultant matrix of Gelfand, Kapranov and Zelevinsky 36 * k=1: use resultant matrix of Macaulay (k=0 is default) 33 37 */ 34 38 BOOLEAN nuMPResMat( leftv res, leftv arg1, leftv arg2 ); … … 37 41 * Determines the roots of an univariate polynomial using Laguerres' 38 42 * root-solver. Good for polynomials with low and middle degree (<40). 39 * Returns a list containing the roots of the polynomial. 43 * Arguments 3: poly arg1 , int arg2 , int arg3 44 * arg2>0: defines precision of fractional part if ground field is Q 45 * arg3: number of iterations for approximation of roots (default=2) 46 * Returns a list of all (complex) roots of the polynomial arg1 40 47 */ 41 BOOLEAN nuLagSolve( leftv res, leftv arg1, leftv arg2 );48 BOOLEAN nuLagSolve( leftv res, leftv arg1, leftv arg2, leftv arg3 ); 42 49 43 50 /** 51 * COMPUTE: polynomial p with values given by v at points p1,..,pN derived 52 * from p; more precisely: consider p as point in K^n and v as N elements in K, 53 * let p1,..,pN be the points in K^n obtained by evaluating all monomials 54 * of degree 0,1,...,N at p in lexicographical order, then the procedure 55 * computes the polynomial f satisfying f(pi) = v[i] 56 * RETURN: polynomial f of degree d 44 57 */ 45 58 BOOLEAN nuVanderSys( leftv res, leftv arg1, leftv arg2, leftv arg3 );
Note: See TracChangeset
for help on using the changeset viewer.