Changeset f323dd1 in git


Ignore:
Timestamp:
Feb 29, 2012, 5:18:58 PM (12 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
8d8cd944663cf80b3fd163a42279526ce163a5fd
Parents:
d8b0f69f9828897dca663d5bb516369b1b0ac64a
Message:
chg: move feResource to findexec lib
Files:
15 edited
2 moved

Legend:

Unmodified
Added
Removed
  • Singular/emacs.cc

    rd8b0f69 rf323dd1  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id$ */
    54/*
    65* ABSTRACT: Esingular main file
     
    2827#include <omalloc/omalloc.h>
    2928#include <Singular/version.h>
    30 #include <resources/feResource.h>
     29#include <findexec/feResource.h>
    3130#include <Singular/feOpt.h>
    3231
     
    130129      case 'h':
    131130          extern void feOptHelp(const char* name);
    132        
     131
    133132          feOptHelp(feArgv0);
    134133          exit(0);
     
    306305  // xemacs-20.4 sometimes crashed on startup when using -q. DonŽt know why.
    307306  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,
    309308          singular, cwd);
    310309
  • Singular/test.cc

    rd8b0f69 rf323dd1  
    1515
    1616#include <resources/feFopen.h>
    17 #include <resources/feResource.h>
     17#include <findexec/feResource.h>
    1818
    1919#include <coeffs/coeffs.h>
     
    128128#include <kernel/GMPrat.h>
    129129
    130 // #include "htmlhelp.h" // For Windows // 
     130// #include "htmlhelp.h" // For Windows //
    131131#include <kernel/hutil.h>
    132132// #include <kernel/Ideal.h> // Too old?
     
    244244void siInit(char *);
    245245
    246 int main( int, char *argv[] ) 
     246int main( int, char *argv[] )
    247247{
    248248  // init path names etc.
     
    251251
    252252  // Libpolys tests:
    253    
     253
    254254  // construct the ring Z/32003[x,y,z]
    255255  // the variable names
     
    259259  n[2]=omStrDup("z2");
    260260
    261    
     261
    262262/*
    263263  StringSetS("ressources in use (as reported by feStringAppendResources(0):\n");
     
    265265  PrintS(StringAppendS("\n"));
    266266
    267    
    268    
     267
     268
    269269  ring R=rDefault(32003,3,n);
    270270  // make R the default ring:
     
    285285  // compute p1+p2
    286286  p1=p_Add_q(p1,p2,R); p2=NULL;
    287   pWrite(p1); 
     287  pWrite(p1);
    288288
    289289  // clean up:
    290290  pDelete(&p1);
    291    
     291
    292292  rDelete(R);
    293293  rChangeCurrRing(NULL);
    294    
     294
    295295*/
    296    
    297    
    298    
     296
     297
     298
    299299  currentVoice=feInitStdin(NULL);
    300    
     300
    301301  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
    303303  printf("interpreter returns %d\n",err);
    304   if (err) 
     304  if (err)
    305305     errorreported = 0; // reset error handling
    306    
     306
    307307  assume( err == 0 );
    308    
    309    
    310    
     308
     309
     310
    311311  // hook for error handling:
    312312  // WerrorS_callback=......; of type p(const char *)
    313313  err=iiEStart(omStrDup("int ver=system(\"version\");export ver;return();\n"),NULL);
    314  
     314
    315315  printf("interpreter returns %d\n",err);
    316   if (err) 
     316  if (err)
    317317     errorreported = 0; // reset error handling
    318    
     318
    319319  assume( err == 0 );
    320320
    321321  idhdl h=ggetid("ver");
    322    
     322
    323323  if (h != NULL)
    324324    printf("singular variable ver of type %d contains %d\n",h->typ,(int)(long)IDDATA(h));
    325325  else
    326326    printf("variable ver does not exist\n");
    327    
     327
    328328  assume( h != NULL );
    329329
    330    
     330
    331331  err = iiEStart(
    332                 omStrDup("system(\"--version\");return();\n"),
    333                 NULL);
    334    
     332                omStrDup("system(\"--version\");return();\n"),
     333                NULL);
     334
    335335  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
    339339  assume( err == 0 );
    340    
     340
    341341  // calling a singular-library function
    342342  idhdl datetime=ggetid("datetime");
     
    358358                           &IDROOT,
    359359                           FALSE);
    360  
     360
    361361  IDRING(newRingHdl)=R;
    362362  // make R the default ring (include rChangeCurrRing):
     
    370370  arg.data=omStrDup("huhu");
    371371  err=iiExprArith1(&r1,&arg,TYPEOF_CMD);
    372  
     372
    373373  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
    377377     printf("typeof returned type %d, >>%s<<\n",r1.Typ(),r1.Data());
    378    
     378
    379379  // clean up r1:
    380380  r1.CleanUp();
    381    
     381
    382382  return 0;
    383383}
  • findexec/Makefile.am

    rd8b0f69 rf323dd1  
    1616INCLUDES = -I${top_srcdir} -I${top_builddir}
    1717
    18 SOURCES  = omFindExec.c
     18SOURCES  = omFindExec.c feResource.cc
    1919libfindexec_la_SOURCES   = $(SOURCES)
    2020libfindexec_g_la_SOURCES = $(SOURCES)
     
    2222libfindexec_includedir  =$(includedir)/singular/findexec/
    2323
    24 libfindexec_include_HEADERS = omFindExec.h
     24libfindexec_include_HEADERS = omFindExec.h feResource.h
    2525
    2626
  • findexec/feResource.cc

    rd8b0f69 rf323dd1  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id$ */
    54/*
    65* ABSTRACT: management of resources
     
    109#include <unistd.h>
    1110#include <string.h>
    12 #include <unistd.h>
     11#include <stdio.h>
    1312#include <sys/param.h>
    1413
     
    3433
    3534
    36 #include <reporter/reporter.h>
     35//#include <reporter/reporter.h>
    3736//char* feResource(const char id, int warn = -1);
    3837//char* feResource(const char* key, int warn = -1);
     
    4140// #define RESOURCE_DEBUG
    4241
    43 #define SINGULAR_DEFAULT_DIR "/usr/local/Singular/"S_VERSION1
     42#define SINGULAR_DEFAULT_DIR "/usr/local/Singular/"PACKAGE_VERSION
    4443
    4544/*****************************************************************
     
    4847 *
    4948 *****************************************************************/
    50 typedef enum {feResUndef = 0, feResBinary, feResDir, feResFile, feResUrl, feResPath} feResourceType;
    51 
    52 typedef struct feResourceConfig_s
    53 {
    54   const char*           key;   // key to identify resource
    55   const char            id;    // char id to identify resource
    56   feResourceType  type;  // type of Resource
    57   const char*           env;   // env variable to look for
    58   const char*           fmt;   // format string -- see below for epxlaination
    59   char*                 value; // what it was set to: may be changed
    60 } feResourceConfig_s;
    61 typedef feResourceConfig_s * feResourceConfig;
    62 
    6349// feSprintf transforms format strings as follows:
    6450// 1.) substrings of the form %c (c being a letter) are replaced by respective resource value
     
    6854// 1.) '/' characters are replaced by respective directory - separators
    6955// 2.) ';' characters are replaced by respective path separators
    70 static feResourceConfig_s feResourceConfigs[] =
     56feResourceConfig_s feResourceConfigs[] =
    7157{
    7258  {"SearchPath",    's', feResPath,  NULL,
     
    9682  {"HtmlHelpFile",'C',  feResFile,  "SINGULAR_CHM_FILE",    "%r/doc/Manual.chm",    (char *)""},
    9783#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 *)""},
    9985  {"ExDir",     'm',    feResDir,   "SINGULAR_EXAMPLES_DIR","%r/examples",          (char *)""},
    10086  {"Path",      'p',    feResPath,  NULL,                   "%b;$PATH",             (char *)""},
     
    130116static char* feInitResource(feResourceConfig config, int warn);
    131117static char* feGetExpandedExecutable();
    132 static BOOLEAN feVerifyResourceValue(feResourceType type, char* value);
     118static int feVerifyResourceValue(feResourceType type, char* value);
    133119static char* feCleanResourceValue(feResourceType type, char* value);
    134120static char* feCleanUpFile(char* fname);
     
    278264static char* feInitResource(feResourceConfig config, int warn)
    279265{
    280   assume(config != NULL);
     266  /*assume(config != NULL);*/
    281267#ifdef RESOURCE_DEBUG
    282268  printf("feInitResource: entering for %s\n", config->key);
     
    351337  else if (config->fmt == NULL)
    352338  {
    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__);
    355340    return NULL;
    356341  }
     
    388373  if (warn > 0 || (warn < 0 && config->value != NULL))
    389374  {
    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,",
    392377         config->env, config->key);
    393378    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);
    395380  }
    396381#ifdef RESOURCE_DEBUG
     
    405390  if (feArgv0 == NULL || *feArgv0 == '\0')
    406391  {
    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__);
    409396    return NULL;
    410397  }
     
    430417  if (value == NULL)
    431418  {
    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__);
    435420    return NULL;
    436421  }
     
    439424
    440425
    441 static BOOLEAN feVerifyResourceValue(feResourceType type, char* value)
     426static int feVerifyResourceValue(feResourceType type, char* value)
    442427{
    443428#ifdef RESOURCE_DEBUG
     
    449434      case feResUrl:
    450435      case feResPath:
    451         return TRUE;
     436        return 1;
    452437
    453438      case feResFile:
     
    459444
    460445      default:
    461         return FALSE;
     446        return 0;
    462447  }
    463448}
     
    663648static void mystrcpy(char* d, char* s)
    664649{
    665   assume(d != NULL && s != NULL);
     650  /*assume(d != NULL && s != NULL);*/
    666651  while (*s != '\0')
    667652  {
     
    727712}
    728713
    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  
    1717 *
    1818 *****************************************************************/
     19typedef enum {feResUndef = 0, feResBinary, feResDir, feResFile, feResUrl, feResPath} feResourceType;
     20
     21typedef 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;
     30typedef feResourceConfig_s * feResourceConfig;
     31
     32extern feResourceConfig_s feResourceConfigs[];
     33
    1934// returns value of Resource as read-only string, or NULL
    2035// if Resource not found
     
    3651// Re-inits resources, should be called after changing env. variables
    3752void feReInitResources();
    38 // Prints resources into string with StringAppend, etc
    39 void feStringAppendResources(int warn = -1);
    4053#endif /* end ifdef __cplusplus */
    4154
  • kernel/febase.h

    rd8b0f69 rf323dd1  
    44 * *  Computer Algebra System SINGULAR     *
    55 * ****************************************/
    6 /* $Id: febase.h 14137 2011-04-11 16:39:34Z hannes $ */
    76/*
    87 * * ABSTRACT: basic i/o
     
    1211
    1312#include <resources/feFopen.h>
    14 #include <resources/feResource.h>
     13#include <findexec/feResource.h>
    1514
    1615#include <kernel/structs.h>
     
    194193#endif
    195194#endif
    196  
     195
  • kernel/test.cc

    rd8b0f69 rf323dd1  
    1616
    1717#include <resources/feFopen.h>
    18 #include <resources/feResource.h>
     18#include <findexec/feResource.h>
    1919
    2020#include <coeffs/coeffs.h>
     
    5353#ifdef HAVE_FACTORY
    5454// The following are needed due to FACTORY (e.g. initCanonicalForm)
    55 int initializeGMP(){ return 1; } 
     55int initializeGMP(){ return 1; }
    5656int mmInit(void) {return 1; }
    5757#endif
     
    134134#include "GMPrat.h"
    135135
    136 // #include "htmlhelp.h" // For Windows // 
     136// #include "htmlhelp.h" // For Windows //
    137137#include "hutil.h"
    138138// #include "Ideal.h" // Too old?
     
    203203void TestGBEngine()
    204204{
    205    
     205
    206206  //  R = MPolynomialRing_polydict(QQ,5,'w,x,y,z,C', order='degrevlex')
    207207  //  J = (w*w - x*z, w*x - y*z, x*x - w*y, x*y - z*z, y*y - w*z)
    208          
     208
    209209  const short w = 1;
    210210  const short x = 2;
     
    216216  char **n=(char**)omalloc(N*sizeof(char*));
    217217
    218  
     218
    219219  n[w-1]=omStrDup("w");
    220220  n[x-1]=omStrDup("x");
     
    236236  block1[1] = N;
    237237
    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);
    241241
    242242  rWrite(R); PrintLn();
     
    253253    // -xz
    254254    poly p = p_ISet(-1,R);
    255    
     255
    256256    p_SetExp(p, x, 1, R);
    257257    p_SetExp(p, z, 1, R);
     
    302302    MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // wx - yz
    303303  }
    304  
     304
    305305
    306306  {
     
    329329    MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // x2 - wy
    330330  }
    331  
     331
    332332
    333333  {
     
    356356    MATELEM(I, 1, ++gen) = p_Add_q(lp, p, R); // xy - z2
    357357  }
    358  
     358
    359359
    360360  {
     
    408408    intvec *weights = NULL;
    409409    ideal SYZ = idSyzygies(I, testHomog, &weights);
    410    
     410
    411411#ifdef PDEBUG
    412412    PrintS("SYZ: ");
     
    437437    b = syBettiOfComputation(r, TRUE);
    438438    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
    445445    syKillComputation(r, R);
    446446  }
     
    465465    b = syBettiOfComputation(r, TRUE);
    466466    PrintS("min. betti: \n");    b->show();    PrintLn();
    467     delete b;   
     467    delete b;
    468468
    469469    Print("length: %d\n", sySize(r));
     
    474474  }
    475475
    476    
     476
    477477
    478478  {
     
    495495    b = syBettiOfComputation(r, TRUE);
    496496    PrintS("min. betti: \n");    b->show();    PrintLn();
    497     delete b;   
     497    delete b;
    498498
    499499    Print("length: %d\n", sySize(r));
     
    503503    syKillComputation(r, R);
    504504  }
    505  
     505
    506506
    507507  {
     
    524524    b = syBettiOfComputation(r, TRUE);
    525525    PrintS("min. betti: \n");    b->show();    PrintLn();
    526     delete b;   
     526    delete b;
    527527
    528528    Print("length: %d\n", sySize(r));
     
    532532    syKillComputation(r, R);
    533533  }
    534  
    535 
    536 
    537  
    538   idDelete( &I, R); 
     534
     535
     536
     537
     538  idDelete( &I, R);
    539539  rDelete(R); // should cleanup every belonging polynomial, right!?
    540    
     540
    541541}
    542542
     
    596596
    597597  // print p1 + p2
    598   Print("p1: "); pWrite0(p1); 
    599   Print(" + p2: "); pWrite0(p2); 
     598  Print("p1: "); pWrite0(p1);
     599  Print(" + p2: "); pWrite0(p2);
    600600  Print("  ---- >>>> ");
    601601
    602602  // compute p1+p2
    603603  p1=p_Add_q(p1,p2,R); p2=NULL;
    604   pWrite(p1); 
     604  pWrite(p1);
    605605
    606606  // clean up:
     
    611611
    612612
    613 int main( int, char *argv[] ) 
     613int main( int, char *argv[] )
    614614{
    615615  feInitResources(argv[0]);
     
    621621  TestGBEngine();
    622622  TestSimpleRingArithmetcs();
    623    
     623
    624624  return 0;
    625625}
  • libpolys/coeffs/test.cc

    rd8b0f69 rf323dd1  
    99
    1010#include <reporter/reporter.h>
    11 #include <resources/feResource.h>
     11#include <findexec/feResource.h>
    1212
    1313#include <coeffs/coeffs.h>
  • libpolys/polys/mod_raw.cc

    rd8b0f69 rf323dd1  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id$ */
    54/*
    65 * ABSTRACT: machine depend code for dynamic modules
     
    2524#include <reporter/reporter.h>
    2625
    27 #include <resources/feResource.h>
     26#include <findexec/feResource.h>
    2827#include <resources/feFopen.h>
    2928
     
    9291  }
    9392
    94    
     93
    9594  if( (strncmp(buf, "\02\020\01\016\05\022@", 7)==0))
    9695  {
  • libpolys/polys/monomials/p_polys.h

    rd8b0f69 rf323dd1  
    88 *  Author:  obachman (Olaf Bachmann)
    99 *  Created: 9/00
    10  *  Version: $Id$
    1110 *******************************************************************/
    1211/***************************************************************
     
    1413 *  Author:  obachman (Olaf Bachmann)
    1514 *  Created: 8/00
    16  *  Version: $Id$
    1715 *******************************************************************/
    1816#ifndef P_POLYS_H
     
    6563
    6664
    67 // 
     65//
    6866// deletes old coeff before setting the new one???
    6967#define pSetCoeff0(p,n)     (p)->coef=(n)
     
    228226
    229227void      p_Content(poly p, const ring r);
    230 #if 1 
     228#if 1
    231229// currently only used by Singular/janet
    232230void      p_SimpleContent(poly p, int s, const ring r);
     
    707705static inline void p_LmFree(poly *p, ring r)
    708706#else
    709 static inline void p_LmFree(poly *p, ring) 
     707static inline void p_LmFree(poly *p, ring)
    710708#endif
    711709{
     
    10581056{
    10591057  assume( (p != q) || (p == NULL && q == NULL) );
    1060  
     1058
    10611059  if (p == NULL)
    10621060  {
  • libpolys/reporter/reporter.cc

    rd8b0f69 rf323dd1  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id$ */
    54/*
    65* ABSTRACT: output system
     
    2221
    2322#include <reporter/reporter.h>
     23#include <findexec/feResource.h>
    2424#include <omalloc/omalloc.h>
    2525//#include "options.h"
     
    411411  return s;
    412412}
     413
     414void 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  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id$ */
    76/*
    87* ABSTRACT: basic output
     
    6564const char *  eati(const char *s, int *i);
    6665
     66// Prints resources into string with StringAppend, etc
     67void feStringAppendResources(int warn = -1);
    6768#endif /* c++ only */
    6869
  • libpolys/resources/Makefile.am

    rd8b0f69 rf323dd1  
    1616INCLUDES = -I${top_srcdir} -I${top_srcdir}/.. -I${top_builddir} -I${top_builddir}/..
    1717
    18 SOURCES = feFopen.cc feResource.cc
     18SOURCES = feFopen.cc
    1919libresources_la_SOURCES   = $(SOURCES)
    2020libresources_g_la_SOURCES = $(SOURCES)
     
    2222libresources_includedir  =$(includedir)/singular/resources
    2323
    24 libresources_include_HEADERS   = feFopen.h feResource.h
     24libresources_include_HEADERS   = feFopen.h
    2525
    2626
  • libpolys/resources/feFopen.cc

    rd8b0f69 rf323dd1  
    1212
    1313#include "feFopen.h"
    14 #include "feResource.h"
     14#include <findexec/feResource.h>
    1515
    1616
  • libpolys/tests/coeffs_test.h

    rd8b0f69 rf323dd1  
    55
    66#include <reporter/reporter.h>
    7 #include <resources/feResource.h>
     7#include <findexec/feResource.h>
    88
    99#include <coeffs/coeffs.h>
     
    3535
    3636  const unsigned long ssss = (N * (N+1)) / 2;
    37  
     37
    3838  number sum1 = n_Init(ssss, r);
    3939  clog<< "N*(N+1)/2 (int: " << ssss << "): "; PrintSized(sum1, r);
     
    4545  ndInpMult(s, i, r);
    4646  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
    5050  i = n_Init(2, r);
    51   clog<< "2: "; PrintSized(i, r); 
     51  clog<< "2: "; PrintSized(i, r);
    5252
    5353  if( !n_IsZero( i, r) )
     
    5656    TS_ASSERT( n_DivBy(s, i, r) );
    5757#endif
    58      
     58
    5959    res = n_Div(s, i, r);
    60  
     60
    6161    clog<< "N*(N+1)/2: "; PrintSized(res, r);
    6262
     
    6565    TS_ASSERT( n_IsZeroDivisor(d, r) );
    6666    n_Delete(&d, r);
    67    
     67
    6868    if( n_GetChar(r) == 0 )
    6969    {
     
    7373  } else
    7474    TS_ASSERT_EQUALS( n_GetChar(r), 2);
    75  
     75
    7676
    7777  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
    8181
    8282  s = n_Init(0  , r);
     
    8989    i = n_Neg(i, r);
    9090    ndInpAdd(ss, i, r); // ss -= i
    91    
    92     n_Delete(&i, r);   
     91
     92    n_Delete(&i, r);
    9393  }
    94   clog<< "ss: "; PrintSized(ss, r); 
     94  clog<< "ss: "; PrintSized(ss, r);
    9595
    9696  ss = n_Neg(ss, r); // ss = -ss
    97  
     97
    9898  clog<< "real sum    : "; PrintSized(s, r);
    99   clog<< "real sum(--): "; PrintSized(ss, r); 
     99  clog<< "real sum(--): "; PrintSized(ss, r);
    100100
    101101  TS_ASSERT( n_Equal(s, ss, r) );
    102102  TS_ASSERT( n_Equal(ss, s, r) );
    103103
    104   n_Delete(&s, r);   
    105   n_Delete(&ss, r);   
     104  n_Delete(&s, r);
     105  n_Delete(&ss, r);
    106106
    107107  clog << ( " >>> TEST DONE!" );
     
    118118  number two = n_Init(2, r);
    119119
    120   number t = n_Init(1, r); 
    121   ndInpAdd(t, t, r); 
     120  number t = n_Init(1, r);
     121  ndInpAdd(t, t, r);
    122122  TS_ASSERT( n_Equal(two, t, r) );
    123123  n_Delete(&t, r);
    124  
     124
    125125  if( getCoeffType(r) == n_Q )
    126126  {
    127     number t = n_Init(1, r); 
     127    number t = n_Init(1, r);
    128128    nlInpAdd(t, t, r);
    129129    TS_ASSERT( n_Equal(two, t, r) );
     
    133133
    134134
    135  
     135
    136136  const int N = 66666;
    137137
    138138  number a = n_Init(N, r);
    139    
     139
    140140  clog<< "a: "; PrintSized(a, r);
    141141
    142  
     142
    143143  clog<< "two: "; PrintSized(two, r);
    144144
     
    148148
    149149  clog<< "aa = a + a: "; PrintSized(aa, r);
    150  
     150
    151151  number aa2 = n_Mult(a, two, r);
    152152
     
    154154
    155155  number aa1 = n_Mult(two, a, r);
    156  
     156
    157157  clog<< "aa1 = 2 * a: "; PrintSized(aa1, r);
    158158
     
    162162
    163163  a = n_Sub( aa, aa1, r );
    164  
     164
    165165  clog<< "a = aa - aa1: "; PrintSized(a, r);
    166166
     
    187187
    188188
    189  
     189
    190190  TS_ASSERT( n_Equal(aa, aa1, r) );
    191191  TS_ASSERT( n_Equal(aa, aa2, r) );
    192192  TS_ASSERT( n_Equal(aa1, aa2, r) );
    193  
     193
    194194  TS_ASSERT( n_Equal(aa0, aa, r) );
    195195  TS_ASSERT( n_Equal(aa0, aa1, r) );
     
    209209
    210210
    211  
     211
    212212
    213213BOOLEAN Test(const n_coeffType type, void* p = NULLp)
    214214{
    215  
     215
    216216  clog << endl;
    217217  clog << ( "----------------------- Testing coeffs: [" + _2S(type) +  ", " + _2S(p) + "]: -----------------------");
     
    230230  if( r->cfCoeffWrite != NULL )
    231231  {
    232     clog << "Coeff-domain: "  << endl; 
     232    clog << "Coeff-domain: "  << endl;
    233233    n_CoeffWrite(r); PrintLn();
    234234  }
     
    239239    number z = nfPar (0, r); // also any integer instead of 0//?
    240240    clog << "Generator: "; PrintSized(z, r);
    241     n_Delete(&z, r);   
     241    n_Delete(&z, r);
    242242  }
    243243
    244   clog << "Char: " << n_GetChar(r) << endl; 
    245 
    246  
     244  clog << "Char: " << n_GetChar(r) << endl;
     245
     246
    247247  TS_ASSERT_DIFFERS( r, NULLp );
    248248  nSetChar( r );
     
    262262      TS_ASSERT_EQUALS( r->cfAdd, nlAdd );
    263263      TS_ASSERT_EQUALS( r->cfDelete, nlDelete );
    264      
     264
    265265      TS_ASSERT(  nCoeff_is_Q( r ));
    266266      TS_ASSERT(  nCoeff_is_Domain( r ));
     
    283283      TS_ASSERT( !nCoeff_is_CF( r ));
    284284      TS_ASSERT( !nCoeff_is_Extension( r ));
    285      
     285
    286286      break;
    287287    }
     
    299299      TS_ASSERT_EQUALS( r->cfWrite, ngcWrite );
    300300      TS_ASSERT_EQUALS( r->cfAdd, ngcAdd );
    301       TS_ASSERT_EQUALS( r->cfDelete, ngcDelete );   
     301      TS_ASSERT_EQUALS( r->cfDelete, ngcDelete );
    302302      break;
    303303    }
     
    362362
    363363
    364 class CoeffsTestSuite : public CxxTest::TestSuite 
     364class CoeffsTestSuite : public CxxTest::TestSuite
    365365{
    366366 public:
     
    388388#endif
    389389   }
    390    
     390
    391391   void simple(const n_coeffType _type)
    392392   {
     
    395395     TS_ASSERT( Test(type) );
    396396   }
    397    
     397
    398398   void test_Q()
    399399   {
    400400     simple(n_Q);
    401401   }
    402    
     402
    403403   void test_R()
    404404   {
     
    414414   }
    415415
    416    
     416
    417417   void test_GF_toobig()
    418418   {
     
    427427     TS_ASSERT( !Test(type, (void*) &param) );
    428428
    429       // it should not be used by numbers... right? 
     429      // it should not be used by numbers... right?
    430430      // TODO: what is our policy wrt param-pointer-ownership?
    431431   }
     
    445445     TS_ASSERT( Test(type, (void*) &param) );
    446446
    447       // it should not be used by numbers... right? 
     447      // it should not be used by numbers... right?
    448448      // TODO: what is our policy wrt param-pointer-ownership?
    449449   }
    450    
     450
    451451
    452452   void test_Zn3()
     
    472472     simple(n_long_R);
    473473   }
    474    
     474
    475475   void test_LC()
    476476   {
    477477     simple(n_long_C);
    478478   }
    479    
     479
    480480   void test_Q_special()
    481481   {
     
    489489     if (cf->cfCoeffWrite != NULL )
    490490     {
    491        clog << "Coeff-domain: "  << endl; 
     491       clog << "Coeff-domain: "  << endl;
    492492       n_CoeffWrite(cf); PrintLn();
    493493     }
    494      
     494
    495495     number q1 = n_Init(21, cf);
    496496     number q2 = n_Init(2, cf);
  • libpolys/tests/common.h

    rd8b0f69 rf323dd1  
    1818
    1919#include <reporter/reporter.h>
    20 #include <resources/feResource.h>
     20#include <findexec/feResource.h>
    2121
    2222#ifndef PLURAL_INTERNAL_DECLARATIONS
    23 #define PLURAL_INTERNAL_DECLARATIONS 
     23#define PLURAL_INTERNAL_DECLARATIONS
    2424#endif
    2525
     
    5757      CASE(n_Z2m);
    5858      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    }
    6161#undef CASE
    6262    return o;
     
    7676  {
    7777    n_Test(a,r);
    78     StringSetS(""); 
     78    StringSetS("");
    7979    n_Write(a, r);
    8080
     
    8383    std::stringstream ss;  ss << s;
    8484
    85     StringSetS(""); 
     85    StringSetS("");
    8686    return ss.str();
    8787
     
    9292    std::clog << _2S(a, r) << ", of size: " << n_Size(a, r);
    9393
    94     if( eoln ) 
    95       std::clog << std::endl; 
     94    if( eoln )
     95      std::clog << std::endl;
    9696  }
    9797
     
    106106  public:
    107107    GlobalPrintingFixture(bool redirect = false): _redirect(redirect){}
    108    
     108
    109109    ~GlobalPrintingFixture()
    110110    {
     
    112112        _ofs.close();
    113113    }
    114    
     114
    115115    void Redirect()
    116116    {
     
    120120      s = strncpy(s, argv0, ll);
    121121      strncpy(s + ll, ".log", 4);
    122       _ofs.open(s); // , ios_base::out) 
     122      _ofs.open(s); // , ios_base::out)
    123123      omFreeSize((ADDRESS)s, l);
    124124
     
    126126    }
    127127
    128     virtual bool setUpWorld() 
     128    virtual bool setUpWorld()
    129129    {
    130130      if( _redirect )
     
    137137      feStringAppendResources(0);
    138138      PrintS(StringAppendS("\n"));
    139      
     139
    140140      return true;
    141141    }
    142142
    143     virtual bool tearDownWorld() 
     143    virtual bool tearDownWorld()
    144144    {
    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;
    147147    }
    148148    virtual bool setUp() { std::clog << std::endl << std::endl <<( "<test>" ) << std::endl  << std::endl; return true; }
  • standalone.test/test.cc

    rd8b0f69 rf323dd1  
    66
    77#include <reporter/reporter.h>
    8 #include <resources/feResource.h>
     8#include <findexec/feResource.h>
    99
    1010#ifdef HAVE_FACTORY
     
    3636  }
    3737
    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
    4141  number two = n_Init(2, r);
    4242  assume(n_Equal(two, t, r));
     
    4444  n_Delete(&t, r);
    4545  n_Delete(&two, r);
    46  
     46
    4747
    4848  const int N = 2; // number of vars
    4949  char* n[N] = {"x", "y"}; // teir names
    50  
     50
    5151  ring R = rDefault( r, N, n);  // now r belongs to R!
    5252
     
    6666
    6767  const int exp[N] = {5, 8};
    68  
     68
    6969  poly p = p_ISet(1, R);
    7070  assume( p != NULL );
     
    7979  assume( p_GetExp(p, 2, R) == exp[1] );
    8080
    81   p = p_Add_q(p_Copy(p, R), p, R); 
     81  p = p_Add_q(p_Copy(p, R), p, R);
    8282
    8383  ret = ret && p_EqualPolys(p, p, R);
    8484
    85  
     85
    8686  poly p2 = p_ISet(2, R);
    8787  assume( p2 != NULL );
    8888  assume(pNext(p2) == NULL);
    8989  ret = ret && (pNext(p2) == NULL);
    90  
     90
    9191  p_SetExp(p2,1,exp[0],R);
    9292  p_SetExp(p2,2,exp[1],R);
     
    9999  two = n_Init(2, r);
    100100  assume(n_Equal(two, s, r));
    101   ret = ret && n_Equal(s, two, r); 
     101  ret = ret && n_Equal(s, two, r);
    102102  n_Delete(&two, r);
    103103
     
    106106
    107107  p_Delete(&p, R);
    108  
     108
    109109  p_Delete(&p2, R);
    110110
     
    125125
    126126
    127 int main( int, char *argv[] ) 
     127int main( int, char *argv[] )
    128128{
    129129  feInitResources(argv[0]);
     
    135135  if( simple(n_Q) )
    136136    PrintS("Q: Test Passed!");
    137   else 
     137  else
    138138    PrintS("Q: Test: Failed!");
    139139  PrintLn();
     
    142142  if( simple(n_Zp, (void*)7) )
    143143    PrintS("Zp: Test Passed!");
    144   else 
     144  else
    145145    PrintS("Zp: Test: Failed!");
    146146  PrintLn();
    147  
     147
    148148  // due to coeffs/ffields.h
    149   struct 
     149  struct
    150150  {
    151151    int GFChar;
     
    160160  if( simple(n_GF, (void*)&param) )
    161161    PrintS("GF: Test Passed!");
    162   else 
     162  else
    163163    PrintS("GF: Test: Failed!");
    164164  PrintLn();
    165  
     165
    166166  return 0;
    167167}
Note: See TracChangeset for help on using the changeset viewer.