Changeset f323dd1 in git
- Timestamp:
- Feb 29, 2012, 5:18:58 PM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- 8d8cd944663cf80b3fd163a42279526ce163a5fd
- Parents:
- d8b0f69f9828897dca663d5bb516369b1b0ac64a
- Files:
-
- 15 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
Singular/emacs.cc
rd8b0f69 rf323dd1 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id$ */5 4 /* 6 5 * ABSTRACT: Esingular main file … … 28 27 #include <omalloc/omalloc.h> 29 28 #include <Singular/version.h> 30 #include < resources/feResource.h>29 #include <findexec/feResource.h> 31 30 #include <Singular/feOpt.h> 32 31 … … 130 129 case 'h': 131 130 extern void feOptHelp(const char* name); 132 131 133 132 feOptHelp(feArgv0); 134 133 exit(0); … … 306 305 // xemacs-20.4 sometimes crashed on startup when using -q. DonŽt know why. 307 306 sprintf(syscall, "%s %sno-init-file %seval '(progn (setq singular-emacs-home-directory \"%s\") (load-file \"%s\") (singular-other \"%s\" \"%s\" (list ", 308 emacs, prefix, prefix, emacs_dir, emacs_load, 307 emacs, prefix, prefix, emacs_dir, emacs_load, 309 308 singular, cwd); 310 309 -
Singular/test.cc
rd8b0f69 rf323dd1 15 15 16 16 #include <resources/feFopen.h> 17 #include < resources/feResource.h>17 #include <findexec/feResource.h> 18 18 19 19 #include <coeffs/coeffs.h> … … 128 128 #include <kernel/GMPrat.h> 129 129 130 // #include "htmlhelp.h" // For Windows // 130 // #include "htmlhelp.h" // For Windows // 131 131 #include <kernel/hutil.h> 132 132 // #include <kernel/Ideal.h> // Too old? … … 244 244 void siInit(char *); 245 245 246 int main( int, char *argv[] ) 246 int main( int, char *argv[] ) 247 247 { 248 248 // init path names etc. … … 251 251 252 252 // Libpolys tests: 253 253 254 254 // construct the ring Z/32003[x,y,z] 255 255 // the variable names … … 259 259 n[2]=omStrDup("z2"); 260 260 261 261 262 262 /* 263 263 StringSetS("ressources in use (as reported by feStringAppendResources(0):\n"); … … 265 265 PrintS(StringAppendS("\n")); 266 266 267 268 267 268 269 269 ring R=rDefault(32003,3,n); 270 270 // make R the default ring: … … 285 285 // compute p1+p2 286 286 p1=p_Add_q(p1,p2,R); p2=NULL; 287 pWrite(p1); 287 pWrite(p1); 288 288 289 289 // clean up: 290 290 pDelete(&p1); 291 291 292 292 rDelete(R); 293 293 rChangeCurrRing(NULL); 294 294 295 295 */ 296 297 298 296 297 298 299 299 currentVoice=feInitStdin(NULL); 300 300 301 301 int err=iiEStart(omStrDup("ring R = (0, a), x, dp; R; system(\"r\", R); minpoly=a*a+1; R; system(\"r\", R); kill R; return();\n"),NULL); 302 302 303 303 printf("interpreter returns %d\n",err); 304 if (err) 304 if (err) 305 305 errorreported = 0; // reset error handling 306 306 307 307 assume( err == 0 ); 308 309 310 308 309 310 311 311 // hook for error handling: 312 312 // WerrorS_callback=......; of type p(const char *) 313 313 err=iiEStart(omStrDup("int ver=system(\"version\");export ver;return();\n"),NULL); 314 314 315 315 printf("interpreter returns %d\n",err); 316 if (err) 316 if (err) 317 317 errorreported = 0; // reset error handling 318 318 319 319 assume( err == 0 ); 320 320 321 321 idhdl h=ggetid("ver"); 322 322 323 323 if (h != NULL) 324 324 printf("singular variable ver of type %d contains %d\n",h->typ,(int)(long)IDDATA(h)); 325 325 else 326 326 printf("variable ver does not exist\n"); 327 327 328 328 assume( h != NULL ); 329 329 330 330 331 331 err = iiEStart( 332 333 334 332 omStrDup("system(\"--version\");return();\n"), 333 NULL); 334 335 335 printf("interpreter returns %d\n",err); 336 if (err) 337 errorreported = 0; // reset error handling 338 336 if (err) 337 errorreported = 0; // reset error handling 338 339 339 assume( err == 0 ); 340 340 341 341 // calling a singular-library function 342 342 idhdl datetime=ggetid("datetime"); … … 358 358 &IDROOT, 359 359 FALSE); 360 360 361 361 IDRING(newRingHdl)=R; 362 362 // make R the default ring (include rChangeCurrRing): … … 370 370 arg.data=omStrDup("huhu"); 371 371 err=iiExprArith1(&r1,&arg,TYPEOF_CMD); 372 372 373 373 printf("interpreter returns %d\n",err); 374 if (err) 375 errorreported = 0; // reset error handling 376 else 374 if (err) 375 errorreported = 0; // reset error handling 376 else 377 377 printf("typeof returned type %d, >>%s<<\n",r1.Typ(),r1.Data()); 378 378 379 379 // clean up r1: 380 380 r1.CleanUp(); 381 381 382 382 return 0; 383 383 } -
findexec/Makefile.am
rd8b0f69 rf323dd1 16 16 INCLUDES = -I${top_srcdir} -I${top_builddir} 17 17 18 SOURCES = omFindExec.c 18 SOURCES = omFindExec.c feResource.cc 19 19 libfindexec_la_SOURCES = $(SOURCES) 20 20 libfindexec_g_la_SOURCES = $(SOURCES) … … 22 22 libfindexec_includedir =$(includedir)/singular/findexec/ 23 23 24 libfindexec_include_HEADERS = omFindExec.h 24 libfindexec_include_HEADERS = omFindExec.h feResource.h 25 25 26 26 -
findexec/feResource.cc
rd8b0f69 rf323dd1 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id$ */5 4 /* 6 5 * ABSTRACT: management of resources … … 10 9 #include <unistd.h> 11 10 #include <string.h> 12 #include < unistd.h>11 #include <stdio.h> 13 12 #include <sys/param.h> 14 13 … … 34 33 35 34 36 #include <reporter/reporter.h>35 //#include <reporter/reporter.h> 37 36 //char* feResource(const char id, int warn = -1); 38 37 //char* feResource(const char* key, int warn = -1); … … 41 40 // #define RESOURCE_DEBUG 42 41 43 #define SINGULAR_DEFAULT_DIR "/usr/local/Singular/" S_VERSION142 #define SINGULAR_DEFAULT_DIR "/usr/local/Singular/"PACKAGE_VERSION 44 43 45 44 /***************************************************************** … … 48 47 * 49 48 *****************************************************************/ 50 typedef enum {feResUndef = 0, feResBinary, feResDir, feResFile, feResUrl, feResPath} feResourceType;51 52 typedef struct feResourceConfig_s53 {54 const char* key; // key to identify resource55 const char id; // char id to identify resource56 feResourceType type; // type of Resource57 const char* env; // env variable to look for58 const char* fmt; // format string -- see below for epxlaination59 char* value; // what it was set to: may be changed60 } feResourceConfig_s;61 typedef feResourceConfig_s * feResourceConfig;62 63 49 // feSprintf transforms format strings as follows: 64 50 // 1.) substrings of the form %c (c being a letter) are replaced by respective resource value … … 68 54 // 1.) '/' characters are replaced by respective directory - separators 69 55 // 2.) ';' characters are replaced by respective path separators 70 staticfeResourceConfig_s feResourceConfigs[] =56 feResourceConfig_s feResourceConfigs[] = 71 57 { 72 58 {"SearchPath", 's', feResPath, NULL, … … 96 82 {"HtmlHelpFile",'C', feResFile, "SINGULAR_CHM_FILE", "%r/doc/Manual.chm", (char *)""}, 97 83 #endif 98 {"ManualUrl", 'u', feResUrl, "SINGULAR_URL", "http://www.singular.uni-kl.de/Manual/" S_VERSION1, (char *)""},84 {"ManualUrl", 'u', feResUrl, "SINGULAR_URL", "http://www.singular.uni-kl.de/Manual/"PACKAGE_VERSION, (char *)""}, 99 85 {"ExDir", 'm', feResDir, "SINGULAR_EXAMPLES_DIR","%r/examples", (char *)""}, 100 86 {"Path", 'p', feResPath, NULL, "%b;$PATH", (char *)""}, … … 130 116 static char* feInitResource(feResourceConfig config, int warn); 131 117 static char* feGetExpandedExecutable(); 132 static BOOLEANfeVerifyResourceValue(feResourceType type, char* value);118 static int feVerifyResourceValue(feResourceType type, char* value); 133 119 static char* feCleanResourceValue(feResourceType type, char* value); 134 120 static char* feCleanUpFile(char* fname); … … 278 264 static char* feInitResource(feResourceConfig config, int warn) 279 265 { 280 assume(config != NULL);266 /*assume(config != NULL);*/ 281 267 #ifdef RESOURCE_DEBUG 282 268 printf("feInitResource: entering for %s\n", config->key); … … 351 337 else if (config->fmt == NULL) 352 338 { 353 sprintf(value, "Wrong Resource Specification of %s", config->key); 354 dReportBug(value); 339 printf("Bug >>Wrong Resource Specification of %s<< at %s:%d\n",config->key,__FILE__,__LINE__); 355 340 return NULL; 356 341 } … … 388 373 if (warn > 0 || (warn < 0 && config->value != NULL)) 389 374 { 390 Warn("Could not get %s. ", config->key);391 Warn("Either set environment variable %s to %s,",375 printf("// ** Could not get %s. ", config->key); 376 printf("// ** Either set environment variable %s to %s,", 392 377 config->env, config->key); 393 378 feSprintf(value, config->fmt, warn); 394 Warn("or make sure that %s is at %s", config->key, value);379 printf("// ** or make sure that %s is at %s", config->key, value); 395 380 } 396 381 #ifdef RESOURCE_DEBUG … … 405 390 if (feArgv0 == NULL || *feArgv0 == '\0') 406 391 { 407 if (feArgv0 == NULL) dReportBug("feArgv0 == NULL"); 408 else dReportBug("feArgv0 == ''"); 392 if (feArgv0 == NULL) 393 printf("Bug >>feArgv0 == NULL<< at %s:%d\n",__FILE__,__LINE__); 394 else 395 printf("Bug >>feArgv0 == ''<< at %s:%d\n",__FILE__,__LINE__); 409 396 return NULL; 410 397 } … … 430 417 if (value == NULL) 431 418 { 432 char message[MAXRESOURCELEN]; 433 sprintf(message, "Could not get expanded executable from %s", feArgv0); 434 dReportBug(message); 419 printf("Bug >>Could not get expanded executable from %s<< at %s:%d\n",feArgv0,__FILE__,__LINE__); 435 420 return NULL; 436 421 } … … 439 424 440 425 441 static BOOLEANfeVerifyResourceValue(feResourceType type, char* value)426 static int feVerifyResourceValue(feResourceType type, char* value) 442 427 { 443 428 #ifdef RESOURCE_DEBUG … … 449 434 case feResUrl: 450 435 case feResPath: 451 return TRUE;436 return 1; 452 437 453 438 case feResFile: … … 459 444 460 445 default: 461 return FALSE;446 return 0; 462 447 } 463 448 } … … 663 648 static void mystrcpy(char* d, char* s) 664 649 { 665 assume(d != NULL && s != NULL);650 /*assume(d != NULL && s != NULL);*/ 666 651 while (*s != '\0') 667 652 { … … 727 712 } 728 713 729 void feStringAppendResources(int warn)730 {731 int i = 0;732 char* r;733 StringAppend("%-10s:\t%s\n", "argv[0]", feArgv0);734 while (feResourceConfigs[i].key != NULL)735 {736 r = feResource(feResourceConfigs[i].key, warn);737 StringAppend("%-10s:\t%s\n", feResourceConfigs[i].key,738 (r != NULL ? r : ""));739 i++;740 }741 } -
findexec/feResource.h
rd8b0f69 rf323dd1 17 17 * 18 18 *****************************************************************/ 19 typedef enum {feResUndef = 0, feResBinary, feResDir, feResFile, feResUrl, feResPath} feResourceType; 20 21 typedef struct feResourceConfig_s 22 { 23 const char* key; // key to identify resource 24 const char id; // char id to identify resource 25 feResourceType type; // type of Resource 26 const char* env; // env variable to look for 27 const char* fmt; // format string -- see below for epxlaination 28 char* value; // what it was set to: may be changed 29 } feResourceConfig_s; 30 typedef feResourceConfig_s * feResourceConfig; 31 32 extern feResourceConfig_s feResourceConfigs[]; 33 19 34 // returns value of Resource as read-only string, or NULL 20 35 // if Resource not found … … 36 51 // Re-inits resources, should be called after changing env. variables 37 52 void feReInitResources(); 38 // Prints resources into string with StringAppend, etc39 void feStringAppendResources(int warn = -1);40 53 #endif /* end ifdef __cplusplus */ 41 54 -
kernel/febase.h
rd8b0f69 rf323dd1 4 4 * * Computer Algebra System SINGULAR * 5 5 * ****************************************/ 6 /* $Id: febase.h 14137 2011-04-11 16:39:34Z hannes $ */7 6 /* 8 7 * * ABSTRACT: basic i/o … … 12 11 13 12 #include <resources/feFopen.h> 14 #include < resources/feResource.h>13 #include <findexec/feResource.h> 15 14 16 15 #include <kernel/structs.h> … … 194 193 #endif 195 194 #endif 196 195 -
kernel/test.cc
rd8b0f69 rf323dd1 16 16 17 17 #include <resources/feFopen.h> 18 #include < resources/feResource.h>18 #include <findexec/feResource.h> 19 19 20 20 #include <coeffs/coeffs.h> … … 53 53 #ifdef HAVE_FACTORY 54 54 // The following are needed due to FACTORY (e.g. initCanonicalForm) 55 int initializeGMP(){ return 1; } 55 int initializeGMP(){ return 1; } 56 56 int mmInit(void) {return 1; } 57 57 #endif … … 134 134 #include "GMPrat.h" 135 135 136 // #include "htmlhelp.h" // For Windows // 136 // #include "htmlhelp.h" // For Windows // 137 137 #include "hutil.h" 138 138 // #include "Ideal.h" // Too old? … … 203 203 void TestGBEngine() 204 204 { 205 205 206 206 // R = MPolynomialRing_polydict(QQ,5,'w,x,y,z,C', order='degrevlex') 207 207 // J = (w*w - x*z, w*x - y*z, x*x - w*y, x*y - z*z, y*y - w*z) 208 208 209 209 const short w = 1; 210 210 const short x = 2; … … 216 216 char **n=(char**)omalloc(N*sizeof(char*)); 217 217 218 218 219 219 n[w-1]=omStrDup("w"); 220 220 n[x-1]=omStrDup("x"); … … 236 236 block1[1] = N; 237 237 238 ring R = rDefault(0, N, n, D, order, block0, block1); 239 240 // ring R = rDefault(0, N, n); 238 ring R = rDefault(0, N, n, D, order, block0, block1); 239 240 // ring R = rDefault(0, N, n); 241 241 242 242 rWrite(R); PrintLn(); … … 253 253 // -xz 254 254 poly p = p_ISet(-1,R); 255 255 256 256 p_SetExp(p, x, 1, R); 257 257 p_SetExp(p, z, 1, R); … … 302 302 MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // wx - yz 303 303 } 304 304 305 305 306 306 { … … 329 329 MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // x2 - wy 330 330 } 331 331 332 332 333 333 { … … 356 356 MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // xy - z2 357 357 } 358 358 359 359 360 360 { … … 408 408 intvec *weights = NULL; 409 409 ideal SYZ = idSyzygies(I, testHomog, &weights); 410 410 411 411 #ifdef PDEBUG 412 412 PrintS("SYZ: "); … … 437 437 b = syBettiOfComputation(r, TRUE); 438 438 PrintS("min. betti: \n"); b->show(); PrintLn(); 439 delete b; 440 441 Print("length: %d\n", sySize(r)); 442 443 syPrint(r, "R"); 444 439 delete b; 440 441 Print("length: %d\n", sySize(r)); 442 443 syPrint(r, "R"); 444 445 445 syKillComputation(r, R); 446 446 } … … 465 465 b = syBettiOfComputation(r, TRUE); 466 466 PrintS("min. betti: \n"); b->show(); PrintLn(); 467 delete b; 467 delete b; 468 468 469 469 Print("length: %d\n", sySize(r)); … … 474 474 } 475 475 476 476 477 477 478 478 { … … 495 495 b = syBettiOfComputation(r, TRUE); 496 496 PrintS("min. betti: \n"); b->show(); PrintLn(); 497 delete b; 497 delete b; 498 498 499 499 Print("length: %d\n", sySize(r)); … … 503 503 syKillComputation(r, R); 504 504 } 505 505 506 506 507 507 { … … 524 524 b = syBettiOfComputation(r, TRUE); 525 525 PrintS("min. betti: \n"); b->show(); PrintLn(); 526 delete b; 526 delete b; 527 527 528 528 Print("length: %d\n", sySize(r)); … … 532 532 syKillComputation(r, R); 533 533 } 534 535 536 537 538 idDelete( &I, R); 534 535 536 537 538 idDelete( &I, R); 539 539 rDelete(R); // should cleanup every belonging polynomial, right!? 540 540 541 541 } 542 542 … … 596 596 597 597 // print p1 + p2 598 Print("p1: "); pWrite0(p1); 599 Print(" + p2: "); pWrite0(p2); 598 Print("p1: "); pWrite0(p1); 599 Print(" + p2: "); pWrite0(p2); 600 600 Print(" ---- >>>> "); 601 601 602 602 // compute p1+p2 603 603 p1=p_Add_q(p1,p2,R); p2=NULL; 604 pWrite(p1); 604 pWrite(p1); 605 605 606 606 // clean up: … … 611 611 612 612 613 int main( int, char *argv[] ) 613 int main( int, char *argv[] ) 614 614 { 615 615 feInitResources(argv[0]); … … 621 621 TestGBEngine(); 622 622 TestSimpleRingArithmetcs(); 623 623 624 624 return 0; 625 625 } -
libpolys/coeffs/test.cc
rd8b0f69 rf323dd1 9 9 10 10 #include <reporter/reporter.h> 11 #include < resources/feResource.h>11 #include <findexec/feResource.h> 12 12 13 13 #include <coeffs/coeffs.h> -
libpolys/polys/mod_raw.cc
rd8b0f69 rf323dd1 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id$ */5 4 /* 6 5 * ABSTRACT: machine depend code for dynamic modules … … 25 24 #include <reporter/reporter.h> 26 25 27 #include < resources/feResource.h>26 #include <findexec/feResource.h> 28 27 #include <resources/feFopen.h> 29 28 … … 92 91 } 93 92 94 93 95 94 if( (strncmp(buf, "\02\020\01\016\05\022@", 7)==0)) 96 95 { -
libpolys/polys/monomials/p_polys.h
rd8b0f69 rf323dd1 8 8 * Author: obachman (Olaf Bachmann) 9 9 * Created: 9/00 10 * Version: $Id$11 10 *******************************************************************/ 12 11 /*************************************************************** … … 14 13 * Author: obachman (Olaf Bachmann) 15 14 * Created: 8/00 16 * Version: $Id$17 15 *******************************************************************/ 18 16 #ifndef P_POLYS_H … … 65 63 66 64 67 // 65 // 68 66 // deletes old coeff before setting the new one??? 69 67 #define pSetCoeff0(p,n) (p)->coef=(n) … … 228 226 229 227 void p_Content(poly p, const ring r); 230 #if 1 228 #if 1 231 229 // currently only used by Singular/janet 232 230 void p_SimpleContent(poly p, int s, const ring r); … … 707 705 static inline void p_LmFree(poly *p, ring r) 708 706 #else 709 static inline void p_LmFree(poly *p, ring) 707 static inline void p_LmFree(poly *p, ring) 710 708 #endif 711 709 { … … 1058 1056 { 1059 1057 assume( (p != q) || (p == NULL && q == NULL) ); 1060 1058 1061 1059 if (p == NULL) 1062 1060 { -
libpolys/reporter/reporter.cc
rd8b0f69 rf323dd1 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id$ */5 4 /* 6 5 * ABSTRACT: output system … … 22 21 23 22 #include <reporter/reporter.h> 23 #include <findexec/feResource.h> 24 24 #include <omalloc/omalloc.h> 25 25 //#include "options.h" … … 411 411 return s; 412 412 } 413 414 void feStringAppendResources(int warn) 415 { 416 int i = 0; 417 char* r; 418 StringAppend("%-10s:\t%s\n", "argv[0]", feArgv0); 419 while (feResourceConfigs[i].key != NULL) 420 { 421 r = feResource(feResourceConfigs[i].key, warn); 422 StringAppend("%-10s:\t%s\n", feResourceConfigs[i].key, 423 (r != NULL ? r : "")); 424 i++; 425 } 426 } -
libpolys/reporter/reporter.h
rd8b0f69 rf323dd1 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id$ */7 6 /* 8 7 * ABSTRACT: basic output … … 65 64 const char * eati(const char *s, int *i); 66 65 66 // Prints resources into string with StringAppend, etc 67 void feStringAppendResources(int warn = -1); 67 68 #endif /* c++ only */ 68 69 -
libpolys/resources/Makefile.am
rd8b0f69 rf323dd1 16 16 INCLUDES = -I${top_srcdir} -I${top_srcdir}/.. -I${top_builddir} -I${top_builddir}/.. 17 17 18 SOURCES = feFopen.cc feResource.cc18 SOURCES = feFopen.cc 19 19 libresources_la_SOURCES = $(SOURCES) 20 20 libresources_g_la_SOURCES = $(SOURCES) … … 22 22 libresources_includedir =$(includedir)/singular/resources 23 23 24 libresources_include_HEADERS = feFopen.h feResource.h24 libresources_include_HEADERS = feFopen.h 25 25 26 26 -
libpolys/resources/feFopen.cc
rd8b0f69 rf323dd1 12 12 13 13 #include "feFopen.h" 14 #include "feResource.h"14 #include <findexec/feResource.h> 15 15 16 16 -
libpolys/tests/coeffs_test.h
rd8b0f69 rf323dd1 5 5 6 6 #include <reporter/reporter.h> 7 #include < resources/feResource.h>7 #include <findexec/feResource.h> 8 8 9 9 #include <coeffs/coeffs.h> … … 35 35 36 36 const unsigned long ssss = (N * (N+1)) / 2; 37 37 38 38 number sum1 = n_Init(ssss, r); 39 39 clog<< "N*(N+1)/2 (int: " << ssss << "): "; PrintSized(sum1, r); … … 45 45 ndInpMult(s, i, r); 46 46 n_Delete(&i, r); 47 48 clog<< "N*(N+1): ("<< N*(N+1) << ")"; PrintSized(s, r); 49 47 48 clog<< "N*(N+1): ("<< N*(N+1) << ")"; PrintSized(s, r); 49 50 50 i = n_Init(2, r); 51 clog<< "2: "; PrintSized(i, r); 51 clog<< "2: "; PrintSized(i, r); 52 52 53 53 if( !n_IsZero( i, r) ) … … 56 56 TS_ASSERT( n_DivBy(s, i, r) ); 57 57 #endif 58 58 59 59 res = n_Div(s, i, r); 60 60 61 61 clog<< "N*(N+1)/2: "; PrintSized(res, r); 62 62 … … 65 65 TS_ASSERT( n_IsZeroDivisor(d, r) ); 66 66 n_Delete(&d, r); 67 67 68 68 if( n_GetChar(r) == 0 ) 69 69 { … … 73 73 } else 74 74 TS_ASSERT_EQUALS( n_GetChar(r), 2); 75 75 76 76 77 77 n_Delete(&s, r); n_Delete(&i, r); 78 79 n_Delete(&sum1, r); n_Delete(&res, r); 80 78 79 n_Delete(&sum1, r); n_Delete(&res, r); 80 81 81 82 82 s = n_Init(0 , r); … … 89 89 i = n_Neg(i, r); 90 90 ndInpAdd(ss, i, r); // ss -= i 91 92 n_Delete(&i, r); 91 92 n_Delete(&i, r); 93 93 } 94 clog<< "ss: "; PrintSized(ss, r); 94 clog<< "ss: "; PrintSized(ss, r); 95 95 96 96 ss = n_Neg(ss, r); // ss = -ss 97 97 98 98 clog<< "real sum : "; PrintSized(s, r); 99 clog<< "real sum(--): "; PrintSized(ss, r); 99 clog<< "real sum(--): "; PrintSized(ss, r); 100 100 101 101 TS_ASSERT( n_Equal(s, ss, r) ); 102 102 TS_ASSERT( n_Equal(ss, s, r) ); 103 103 104 n_Delete(&s, r); 105 n_Delete(&ss, r); 104 n_Delete(&s, r); 105 n_Delete(&ss, r); 106 106 107 107 clog << ( " >>> TEST DONE!" ); … … 118 118 number two = n_Init(2, r); 119 119 120 number t = n_Init(1, r); 121 ndInpAdd(t, t, r); 120 number t = n_Init(1, r); 121 ndInpAdd(t, t, r); 122 122 TS_ASSERT( n_Equal(two, t, r) ); 123 123 n_Delete(&t, r); 124 124 125 125 if( getCoeffType(r) == n_Q ) 126 126 { 127 number t = n_Init(1, r); 127 number t = n_Init(1, r); 128 128 nlInpAdd(t, t, r); 129 129 TS_ASSERT( n_Equal(two, t, r) ); … … 133 133 134 134 135 135 136 136 const int N = 66666; 137 137 138 138 number a = n_Init(N, r); 139 139 140 140 clog<< "a: "; PrintSized(a, r); 141 141 142 142 143 143 clog<< "two: "; PrintSized(two, r); 144 144 … … 148 148 149 149 clog<< "aa = a + a: "; PrintSized(aa, r); 150 150 151 151 number aa2 = n_Mult(a, two, r); 152 152 … … 154 154 155 155 number aa1 = n_Mult(two, a, r); 156 156 157 157 clog<< "aa1 = 2 * a: "; PrintSized(aa1, r); 158 158 … … 162 162 163 163 a = n_Sub( aa, aa1, r ); 164 164 165 165 clog<< "a = aa - aa1: "; PrintSized(a, r); 166 166 … … 187 187 188 188 189 189 190 190 TS_ASSERT( n_Equal(aa, aa1, r) ); 191 191 TS_ASSERT( n_Equal(aa, aa2, r) ); 192 192 TS_ASSERT( n_Equal(aa1, aa2, r) ); 193 193 194 194 TS_ASSERT( n_Equal(aa0, aa, r) ); 195 195 TS_ASSERT( n_Equal(aa0, aa1, r) ); … … 209 209 210 210 211 211 212 212 213 213 BOOLEAN Test(const n_coeffType type, void* p = NULLp) 214 214 { 215 215 216 216 clog << endl; 217 217 clog << ( "----------------------- Testing coeffs: [" + _2S(type) + ", " + _2S(p) + "]: -----------------------"); … … 230 230 if( r->cfCoeffWrite != NULL ) 231 231 { 232 clog << "Coeff-domain: " << endl; 232 clog << "Coeff-domain: " << endl; 233 233 n_CoeffWrite(r); PrintLn(); 234 234 } … … 239 239 number z = nfPar (0, r); // also any integer instead of 0//? 240 240 clog << "Generator: "; PrintSized(z, r); 241 n_Delete(&z, r); 241 n_Delete(&z, r); 242 242 } 243 243 244 clog << "Char: " << n_GetChar(r) << endl; 245 246 244 clog << "Char: " << n_GetChar(r) << endl; 245 246 247 247 TS_ASSERT_DIFFERS( r, NULLp ); 248 248 nSetChar( r ); … … 262 262 TS_ASSERT_EQUALS( r->cfAdd, nlAdd ); 263 263 TS_ASSERT_EQUALS( r->cfDelete, nlDelete ); 264 264 265 265 TS_ASSERT( nCoeff_is_Q( r )); 266 266 TS_ASSERT( nCoeff_is_Domain( r )); … … 283 283 TS_ASSERT( !nCoeff_is_CF( r )); 284 284 TS_ASSERT( !nCoeff_is_Extension( r )); 285 285 286 286 break; 287 287 } … … 299 299 TS_ASSERT_EQUALS( r->cfWrite, ngcWrite ); 300 300 TS_ASSERT_EQUALS( r->cfAdd, ngcAdd ); 301 TS_ASSERT_EQUALS( r->cfDelete, ngcDelete ); 301 TS_ASSERT_EQUALS( r->cfDelete, ngcDelete ); 302 302 break; 303 303 } … … 362 362 363 363 364 class CoeffsTestSuite : public CxxTest::TestSuite 364 class CoeffsTestSuite : public CxxTest::TestSuite 365 365 { 366 366 public: … … 388 388 #endif 389 389 } 390 390 391 391 void simple(const n_coeffType _type) 392 392 { … … 395 395 TS_ASSERT( Test(type) ); 396 396 } 397 397 398 398 void test_Q() 399 399 { 400 400 simple(n_Q); 401 401 } 402 402 403 403 void test_R() 404 404 { … … 414 414 } 415 415 416 416 417 417 void test_GF_toobig() 418 418 { … … 427 427 TS_ASSERT( !Test(type, (void*) ¶m) ); 428 428 429 // it should not be used by numbers... right? 429 // it should not be used by numbers... right? 430 430 // TODO: what is our policy wrt param-pointer-ownership? 431 431 } … … 445 445 TS_ASSERT( Test(type, (void*) ¶m) ); 446 446 447 // it should not be used by numbers... right? 447 // it should not be used by numbers... right? 448 448 // TODO: what is our policy wrt param-pointer-ownership? 449 449 } 450 450 451 451 452 452 void test_Zn3() … … 472 472 simple(n_long_R); 473 473 } 474 474 475 475 void test_LC() 476 476 { 477 477 simple(n_long_C); 478 478 } 479 479 480 480 void test_Q_special() 481 481 { … … 489 489 if (cf->cfCoeffWrite != NULL ) 490 490 { 491 clog << "Coeff-domain: " << endl; 491 clog << "Coeff-domain: " << endl; 492 492 n_CoeffWrite(cf); PrintLn(); 493 493 } 494 494 495 495 number q1 = n_Init(21, cf); 496 496 number q2 = n_Init(2, cf); -
libpolys/tests/common.h
rd8b0f69 rf323dd1 18 18 19 19 #include <reporter/reporter.h> 20 #include < resources/feResource.h>20 #include <findexec/feResource.h> 21 21 22 22 #ifndef PLURAL_INTERNAL_DECLARATIONS 23 #define PLURAL_INTERNAL_DECLARATIONS 23 #define PLURAL_INTERNAL_DECLARATIONS 24 24 #endif 25 25 … … 57 57 CASE(n_Z2m); 58 58 CASE(n_CF); 59 default: return o << "Unknown type: [" << (const unsigned long) type << "]"; 60 } 59 default: return o << "Unknown type: [" << (const unsigned long) type << "]"; 60 } 61 61 #undef CASE 62 62 return o; … … 76 76 { 77 77 n_Test(a,r); 78 StringSetS(""); 78 StringSetS(""); 79 79 n_Write(a, r); 80 80 … … 83 83 std::stringstream ss; ss << s; 84 84 85 StringSetS(""); 85 StringSetS(""); 86 86 return ss.str(); 87 87 … … 92 92 std::clog << _2S(a, r) << ", of size: " << n_Size(a, r); 93 93 94 if( eoln ) 95 std::clog << std::endl; 94 if( eoln ) 95 std::clog << std::endl; 96 96 } 97 97 … … 106 106 public: 107 107 GlobalPrintingFixture(bool redirect = false): _redirect(redirect){} 108 108 109 109 ~GlobalPrintingFixture() 110 110 { … … 112 112 _ofs.close(); 113 113 } 114 114 115 115 void Redirect() 116 116 { … … 120 120 s = strncpy(s, argv0, ll); 121 121 strncpy(s + ll, ".log", 4); 122 _ofs.open(s); // , ios_base::out) 122 _ofs.open(s); // , ios_base::out) 123 123 omFreeSize((ADDRESS)s, l); 124 124 … … 126 126 } 127 127 128 virtual bool setUpWorld() 128 virtual bool setUpWorld() 129 129 { 130 130 if( _redirect ) … … 137 137 feStringAppendResources(0); 138 138 PrintS(StringAppendS("\n")); 139 139 140 140 return true; 141 141 } 142 142 143 virtual bool tearDownWorld() 143 virtual bool tearDownWorld() 144 144 { 145 std::clog << std::endl << std::endl <<( "</world>" ) << std::endl << std::endl ; 146 return true; 145 std::clog << std::endl << std::endl <<( "</world>" ) << std::endl << std::endl ; 146 return true; 147 147 } 148 148 virtual bool setUp() { std::clog << std::endl << std::endl <<( "<test>" ) << std::endl << std::endl; return true; } -
standalone.test/test.cc
rd8b0f69 rf323dd1 6 6 7 7 #include <reporter/reporter.h> 8 #include < resources/feResource.h>8 #include <findexec/feResource.h> 9 9 10 10 #ifdef HAVE_FACTORY … … 36 36 } 37 37 38 number t = n_Init(1, r); 39 ndInpAdd(t, t, r); 40 38 number t = n_Init(1, r); 39 ndInpAdd(t, t, r); 40 41 41 number two = n_Init(2, r); 42 42 assume(n_Equal(two, t, r)); … … 44 44 n_Delete(&t, r); 45 45 n_Delete(&two, r); 46 46 47 47 48 48 const int N = 2; // number of vars 49 49 char* n[N] = {"x", "y"}; // teir names 50 50 51 51 ring R = rDefault( r, N, n); // now r belongs to R! 52 52 … … 66 66 67 67 const int exp[N] = {5, 8}; 68 68 69 69 poly p = p_ISet(1, R); 70 70 assume( p != NULL ); … … 79 79 assume( p_GetExp(p, 2, R) == exp[1] ); 80 80 81 p = p_Add_q(p_Copy(p, R), p, R); 81 p = p_Add_q(p_Copy(p, R), p, R); 82 82 83 83 ret = ret && p_EqualPolys(p, p, R); 84 84 85 85 86 86 poly p2 = p_ISet(2, R); 87 87 assume( p2 != NULL ); 88 88 assume(pNext(p2) == NULL); 89 89 ret = ret && (pNext(p2) == NULL); 90 90 91 91 p_SetExp(p2,1,exp[0],R); 92 92 p_SetExp(p2,2,exp[1],R); … … 99 99 two = n_Init(2, r); 100 100 assume(n_Equal(two, s, r)); 101 ret = ret && n_Equal(s, two, r); 101 ret = ret && n_Equal(s, two, r); 102 102 n_Delete(&two, r); 103 103 … … 106 106 107 107 p_Delete(&p, R); 108 108 109 109 p_Delete(&p2, R); 110 110 … … 125 125 126 126 127 int main( int, char *argv[] ) 127 int main( int, char *argv[] ) 128 128 { 129 129 feInitResources(argv[0]); … … 135 135 if( simple(n_Q) ) 136 136 PrintS("Q: Test Passed!"); 137 else 137 else 138 138 PrintS("Q: Test: Failed!"); 139 139 PrintLn(); … … 142 142 if( simple(n_Zp, (void*)7) ) 143 143 PrintS("Zp: Test Passed!"); 144 else 144 else 145 145 PrintS("Zp: Test: Failed!"); 146 146 PrintLn(); 147 147 148 148 // due to coeffs/ffields.h 149 struct 149 struct 150 150 { 151 151 int GFChar; … … 160 160 if( simple(n_GF, (void*)¶m) ) 161 161 PrintS("GF: Test Passed!"); 162 else 162 else 163 163 PrintS("GF: Test: Failed!"); 164 164 PrintLn(); 165 165 166 166 return 0; 167 167 }
Note: See TracChangeset
for help on using the changeset viewer.