source: git/Singular/misc_ip.cc @ 0bae3e

spielwiese
Last change on this file since 0bae3e was 0bae3e, checked in by Hans Schoenemann <hannes@…>, 12 years ago
fix: close in m2_end (cherry picked from commit 3189a3707ba12fa2348a78276959d7cfd9155040) Signed-off-by: Andreas Steenpass <steenpass@mathematik.uni-kl.de> Conflicts: Singular/misc_ip.cc (trivial)
  • Property mode set to 100644
File size: 30.1 KB
RevLine 
[150e5d]1/*****************************************************************************\
[a3c063]2 * Computer Algebra System SINGULAR
[150e5d]3\*****************************************************************************/
[73fa1c]4/** @file misc_ip.cc
[150e5d]5 *
6 * This file provides miscellaneous functionality.
7 *
[a8ee9f]8 * For more general information, see the documentation in misc_ip.h.
[150e5d]9 *
10 **/
11/*****************************************************************************/
12
13// include header files
[16f511]14#ifdef HAVE_CONFIG_H
[ba5e9e]15#include "singularconfig.h"
[16f511]16#endif /* HAVE_CONFIG_H */
[ce9bfe]17
18#include <misc/auxiliary.h>
[047597]19#include <kernel/mod2.h>
[bdda8c2]20#include <Singular/si_signals.h>
[a8ee9f]21
[3e305b]22#ifdef HAVE_FACTORY
23#define SI_DONT_HAVE_GLOBAL_VARS
24#include <factory/factory.h>
25#endif
26
27#include <coeffs/si_gmp.h>
[a8ee9f]28#include <coeffs/coeffs.h>
29
[047597]30#include <polys/ext_fields/algext.h>
31#include <polys/ext_fields/transext.h>
32
33#include "misc_ip.h"
34#include "ipid.h"
[a8ee9f]35#include "feOpt.h"
[44ca2f]36#include "links/silink.h"
[20e3062]37#include "mod_lib.h"
[150e5d]38
[95eb6d]39// the following 2 inline functions are just convenience shortcuts for Frank's code:
40static inline void number2mpz(number n, mpz_t m){ n_MPZ(m, n, coeffs_BIGINT); }
[02fe5f]41static inline number mpz2number(mpz_t m){ return n_InitMPZ(m, coeffs_BIGINT); }
[555b03]42
[a8ee9f]43
[555b03]44void setListEntry(lists L, int index, mpz_t n)
45{ /* assumes n > 0 */
[41ab421]46  /* try to fit nn into an int: */
47  if (mpz_size1(n)<=1)
48  {
49    int ui=(int)mpz_get_si(n);
50    if ((((ui<<3)>>3)==ui)
51    && (mpz_cmp_si(n,(long)ui)==0))
52    {
[13a03b]53      L->m[index].rtyp = INT_CMD; L->m[index].data = (void*)(long)ui;
[41ab421]54      return;
55    }
56  }
[555b03]57  number nn = mpz2number(n);
58  L->m[index].rtyp = BIGINT_CMD; L->m[index].data = (void*)nn;
[41ab421]59}
60
[d322f7]61void setListEntry_ui(lists L, int index, unsigned long ui)
[41ab421]62{ /* assumes n > 0 */
[150e5d]63  /* try to fit nn into an int: */
[d322f7]64  int i=(int)ui;
65  if ((((unsigned long)i)==ui) && (((i<<3)>>3)==i))
[41ab421]66  {
[13a03b]67    L->m[index].rtyp = INT_CMD; L->m[index].data = (void*)(long)i;
[41ab421]68  }
69  else
[a3c063]70  {
[a8ee9f]71    number nn = n_Init(ui, coeffs_BIGINT);
[41ab421]72    L->m[index].rtyp = BIGINT_CMD; L->m[index].data = (void*)nn;
[a3c063]73  }
[150e5d]74}
[cdf5c3c]75
[4c4340]76/* Factoring with Pollard's rho method. stolen from GMP/demos */
77static unsigned add[] = {4, 2, 4, 2, 4, 6, 2, 6};
78
[b7e5d0]79static int factor_using_division (mpz_t t, unsigned int limit,lists primes, int *multiplicities,int &index, unsigned long bound)
[cdf5c3c]80{
[4c4340]81  mpz_t q, r;
82  unsigned long int f;
83  int ai;
84  unsigned *addv = add;
85  unsigned int failures;
[65b813]86  int bound_not_reached=1;
[4c4340]87
88  mpz_init (q);
89  mpz_init (r);
90
91  f = mpz_scan1 (t, 0);
92  mpz_div_2exp (t, t, f);
93  if (f>0)
[cdf5c3c]94  {
[4c4340]95    setListEntry_ui(primes, index, 2);
96    multiplicities[index++] = f;
[cdf5c3c]97  }
[4c4340]98
99  f=0;
100  loop
[555b03]101  {
[4c4340]102    mpz_tdiv_qr_ui (q, r, t, 3);
103    if (mpz_cmp_ui (r, 0) != 0)
104        break;
105    mpz_set (t, q);
106    f++;
107  }
108  if (f>0)
109  {
110    setListEntry_ui(primes, index, 3);
111    multiplicities[index++] = f;
112  }
113  f=0;
114  loop
115  {
116    mpz_tdiv_qr_ui (q, r, t, 5);
117    if (mpz_cmp_ui (r, 0) != 0)
118        break;
119    mpz_set (t, q);
120    f++;
121  }
122  if (f>0)
123  {
124    setListEntry_ui(primes, index, 5);
125    multiplicities[index++] = f;
[555b03]126  }
127
[4c4340]128  failures = 0;
129  f = 7;
130  ai = 0;
[65b813]131  unsigned long last_f=0;
[4c4340]132  while (mpz_cmp_ui (t, 1) != 0)
[555b03]133  {
[4c4340]134    mpz_tdiv_qr_ui (q, r, t, f);
135    if (mpz_cmp_ui (r, 0) != 0)
[4df33b]136    {
[4c4340]137      f += addv[ai];
[65b813]138      if (mpz_cmp_ui (t, f) < 0)
[4c4340]139        break;
140      ai = (ai + 1) & 7;
141      failures++;
142      if (failures > limit)
143        break;
[65b813]144      if ((bound!=0) && (f>bound))
145      {
146        bound_not_reached=0;
147        break;
148      }
[4df33b]149    }
[4c4340]150    else
[4df33b]151    {
[4c4340]152      mpz_swap (t, q);
153      if (f!=last_f)
154      {
155        setListEntry_ui(primes, index, f);
156        multiplicities[index]++;
157        index++;
158      }
159      else
160      {
161        multiplicities[index-1]++;
162      }
163      last_f=f;
164      failures = 0;
[4df33b]165    }
[4c4340]166  }
[41ab421]167
[e2207eb]168  mpz_clear (q);
169  mpz_clear (r);
[65b813]170  //printf("bound=%d,f=%d,failures=%d, reached=%d\n",bound,f,failures,bound_not_reached);
171  return bound_not_reached;
[4c4340]172}
173
[b7e5d0]174static void factor_using_pollard_rho (mpz_t n, unsigned long a, lists primes, int * multiplicities,int &index)
[4c4340]175{
176  mpz_t x, x1, y, P;
177  mpz_t t1, t2;
178  mpz_t last_f;
179  unsigned long long k, l, i;
180
181  mpz_init (t1);
182  mpz_init (t2);
183  mpz_init_set_si (last_f, 0);
184  mpz_init_set_si (y, 2);
185  mpz_init_set_si (x, 2);
186  mpz_init_set_si (x1, 2);
187  mpz_init_set_ui (P, 1);
188  k = 1;
189  l = 1;
190
191  while (mpz_cmp_ui (n, 1) != 0)
192  {
193    loop
[cdf5c3c]194    {
[4c4340]195      do
196      {
[65b813]197        mpz_mul (t1, x, x);
198        mpz_mod (x, t1, n);
199        mpz_add_ui (x, x, a);
[4c4340]200        mpz_sub (t1, x1, x);
201        mpz_mul (t2, P, t1);
202        mpz_mod (P, t2, n);
203
204        if (k % 32 == 1)
205        {
206          mpz_gcd (t1, P, n);
207          if (mpz_cmp_ui (t1, 1) != 0)
208            goto factor_found;
209          mpz_set (y, x);
210        }
211      }
212      while (--k != 0);
213
214      mpz_gcd (t1, P, n);
215      if (mpz_cmp_ui (t1, 1) != 0)
216        goto factor_found;
217
218      mpz_set (x1, x);
219      k = l;
220      l = 2 * l;
221      for (i = 0; i < k; i++)
222      {
[65b813]223        mpz_mul (t1, x, x);
224        mpz_mod (x, t1, n);
225        mpz_add_ui (x, x, a);
[4c4340]226      }
227      mpz_set (y, x);
[4df33b]228    }
229
[4c4340]230  factor_found:
231    do
[03ac3b]232    {
[65b813]233      mpz_mul (t1, y, y);
234      mpz_mod (y, t1, n);
235      mpz_add_ui (y, y, a);
[4c4340]236      mpz_sub (t1, x1, y);
237      mpz_gcd (t1, t1, n);
[03ac3b]238    }
[4c4340]239    while (mpz_cmp_ui (t1, 1) == 0);
240
241    mpz_divexact (n, n, t1);        /* divide by t1, before t1 is overwritten */
242
243    if (!mpz_probab_prime_p (t1, 10))
[3dabc0]244    {
[4c4340]245      do
246      {
247        mp_limb_t a_limb;
248        mpn_random (&a_limb, (mp_size_t) 1);
249        a = a_limb;
250      }
251      while (a == 0);
252
[65b813]253      factor_using_pollard_rho (t1, a, primes,multiplicities,index);
[3dabc0]254    }
255    else
[03ac3b]256    {
[4c4340]257      if (mpz_cmp(t1,last_f)==0)
[41ab421]258      {
[4c4340]259        multiplicities[index-1]++;
260      }
261      else
262      {
263        mpz_set(last_f,t1);
264        setListEntry(primes, index, t1);
265        multiplicities[index++] = 1;
[4df33b]266      }
267    }
[4c4340]268    mpz_mod (x, x, n);
269    mpz_mod (x1, x1, n);
270    mpz_mod (y, y, n);
271    if (mpz_probab_prime_p (n, 10))
[4df33b]272    {
[4c4340]273      if (mpz_cmp(n,last_f)==0)
274      {
275        multiplicities[index-1]++;
276      }
277      else
[4df33b]278      {
[4c4340]279        mpz_set(last_f,n);
280        setListEntry(primes, index, n);
281        multiplicities[index++] = 1;
[41ab421]282      }
[65b813]283      mpz_set_ui(n,1);
[4c4340]284      break;
[cdf5c3c]285    }
[4c4340]286  }
287
[e2207eb]288  mpz_clear (P);
289  mpz_clear (t2);
290  mpz_clear (t1);
291  mpz_clear (x1);
292  mpz_clear (x);
293  mpz_clear (y);
294  mpz_clear (last_f);
[4c4340]295}
296
[b7e5d0]297static void factor_gmp (mpz_t t,lists primes,int *multiplicities,int &index,unsigned long bound)
[4c4340]298{
299  unsigned int division_limit;
300
301  if (mpz_sgn (t) == 0)
302    return;
303
304  /* Set the trial division limit according the size of t.  */
305  division_limit = mpz_sizeinbase (t, 2);
306  if (division_limit > 1000)
307    division_limit = 1000 * 1000;
308  else
309    division_limit = division_limit * division_limit;
310
[65b813]311  if (factor_using_division (t, division_limit,primes,multiplicities,index,bound))
[4c4340]312  {
[65b813]313    if (mpz_cmp_ui (t, 1) != 0)
[cdf5c3c]314    {
[65b813]315      if (mpz_probab_prime_p (t, 10))
316      {
317        setListEntry(primes, index, t);
318        multiplicities[index++] = 1;
[b7e5d0]319        mpz_set_ui(t,1);
[65b813]320      }
321      else
322        factor_using_pollard_rho (t, 1L, primes,multiplicities,index);
[cdf5c3c]323    }
[4c4340]324  }
325}
326/* n and pBound are assumed to be bigint numbers */
[65b813]327lists primeFactorisation(const number n, const int pBound)
[4c4340]328{
329  int i;
330  int index=0;
331  mpz_t nn; number2mpz(n, nn);
332  lists primes = (lists)omAllocBin(slists_bin); primes->Init(1000);
333  int* multiplicities = (int*)omAlloc0(1000*sizeof(int));
[65b813]334  int positive=1;
[4c4340]335
336  if (!n_IsZero(n, coeffs_BIGINT))
337  {
338    if (!n_GreaterZero(n, coeffs_BIGINT))
339    {
340      positive=-1;
341      mpz_neg(nn,nn);
342    }
[b7e5d0]343    factor_gmp(nn,primes,multiplicities,index,pBound);
[cdf5c3c]344  }
345
[555b03]346  lists primesL = (lists)omAllocBin(slists_bin);
347  primesL->Init(index);
[4c4340]348  for (i = 0; i < index; i++)
[cdf5c3c]349  {
[555b03]350    primesL->m[i].rtyp = primes->m[i].rtyp;
351    primesL->m[i].data = primes->m[i].data;
[e2207eb]352    primes->m[i].rtyp=0;
353    primes->m[i].data=NULL;
[cdf5c3c]354  }
[e2207eb]355  primes->Clean(NULL);
[cdf5c3c]356
[555b03]357  lists multiplicitiesL = (lists)omAllocBin(slists_bin);
358  multiplicitiesL->Init(index);
[4c4340]359  for (i = 0; i < index; i++)
[cdf5c3c]360  {
[555b03]361    multiplicitiesL->m[i].rtyp = INT_CMD;
362    multiplicitiesL->m[i].data = (void*)multiplicities[i];
[cdf5c3c]363  }
[b7e5d0]364  omFree(multiplicities);
[555b03]365
366  lists L=(lists)omAllocBin(slists_bin);
[65b813]367  L->Init(3);
[4df33b]368  if (positive==-1) mpz_neg(nn,nn);
[8acd267]369  L->m[0].rtyp = LIST_CMD; L->m[0].data = (void*)primesL;
370  L->m[1].rtyp = LIST_CMD; L->m[1].data = (void*)multiplicitiesL;
371  setListEntry(L, 2, nn);
[65b813]372
[4c4340]373  mpz_clear(nn);
[cdf5c3c]374
375  return L;
376}
[8d38c87]377
[b1dfaf]378#include <omalloc/omalloc.h>
[e7d5ef]379#include <misc/mylimits.h>
[a8ee9f]380
[0fb34ba]381#include <misc/options.h>
[a8ee9f]382#include <misc/intvec.h>
383
384#include <polys/monomials/ring.h>
385#include <polys/templates/p_Procs.h>
386
[599326]387#include <kernel/febase.h>
388#include <kernel/kstd1.h>
389#include <kernel/timer.h>
[8d38c87]390
[a8ee9f]391
392#include "subexpr.h"
393#include "cntrlc.h"
394#include "ipid.h"
395#include "ipshell.h"
396
[cc7302]397#include "fehelp.h"
398
[8d38c87]399#ifdef HAVE_STATIC
400#undef HAVE_DYN_RL
401#endif
402
403#define SI_DONT_HAVE_GLOBAL_VARS
404
405//#ifdef HAVE_LIBPARSER
406//#  include "libparse.h"
407//#endif /* HAVE_LIBPARSER */
408
409
410/*2
411* the renice routine for very large jobs
412* works only on unix machines,
413* testet on : linux, HP 9.0
414*
415*#include <sys/times.h>
416*#include <sys/resource.h>
417*extern "C" int setpriority(int,int,int);
418*void very_nice()
419*{
420*#ifndef NO_SETPRIORITY
421*  setpriority(PRIO_PROCESS,0,19);
422*#endif
423*  sleep(10);
424*}
425*/
426
[a8ee9f]427#include <string.h>
428#include <unistd.h>
429#include <stdio.h>
430#include <stddef.h>
431#include <stdlib.h>
432#include <time.h>
433
434
[8d38c87]435void singular_example(char *str)
436{
437  assume(str!=NULL);
438  char *s=str;
439  while (*s==' ') s++;
440  char *ss=s;
441  while (*ss!='\0') ss++;
442  while (*ss<=' ')
443  {
444    *ss='\0';
445    ss--;
446  }
447  idhdl h=IDROOT->get(s,myynest);
448  if ((h!=NULL) && (IDTYP(h)==PROC_CMD))
449  {
450    char *lib=iiGetLibName(IDPROC(h));
451    if((lib!=NULL)&&(*lib!='\0'))
452    {
453      Print("// proc %s from lib %s\n",s,lib);
454      s=iiGetLibProcBuffer(IDPROC(h), 2);
455      if (s!=NULL)
456      {
457        if (strlen(s)>5)
458        {
459          iiEStart(s,IDPROC(h));
[a71a00]460          omFree((ADDRESS)s);
[8d38c87]461          return;
462        }
463        else omFree((ADDRESS)s);
464      }
465    }
466  }
467  else
468  {
469    char sing_file[MAXPATHLEN];
470    FILE *fd=NULL;
471    char *res_m=feResource('m', 0);
472    if (res_m!=NULL)
473    {
474      sprintf(sing_file, "%s/%s.sing", res_m, s);
475      fd = feFopen(sing_file, "r");
476    }
477    if (fd != NULL)
478    {
479
480      int old_echo = si_echo;
481      int length, got;
482      char* s;
483
484      fseek(fd, 0, SEEK_END);
485      length = ftell(fd);
486      fseek(fd, 0, SEEK_SET);
487      s = (char*) omAlloc((length+20)*sizeof(char));
488      got = fread(s, sizeof(char), length, fd);
489      fclose(fd);
490      if (got != length)
491      {
492        Werror("Error while reading file %s", sing_file);
493      }
494      else
495      {
496        s[length] = '\0';
497        strcat(s, "\n;return();\n\n");
498        si_echo = 2;
499        iiEStart(s, NULL);
500        si_echo = old_echo;
501      }
[a71a00]502      omFree(s);
[8d38c87]503    }
504    else
505    {
506      Werror("no example for %s", str);
507    }
508  }
509}
510
511
512struct soptionStruct
513{
514  const char * name;
515  unsigned   setval;
516  unsigned   resetval;
517};
518
519struct soptionStruct optionStruct[]=
520{
521  {"prot",         Sy_bit(OPT_PROT),           ~Sy_bit(OPT_PROT)   },
522  {"redSB",        Sy_bit(OPT_REDSB),          ~Sy_bit(OPT_REDSB)   },
523  {"notBuckets",   Sy_bit(OPT_NOT_BUCKETS),    ~Sy_bit(OPT_NOT_BUCKETS)   },
524  {"notSugar",     Sy_bit(OPT_NOT_SUGAR),      ~Sy_bit(OPT_NOT_SUGAR)   },
525  {"interrupt",    Sy_bit(OPT_INTERRUPT),      ~Sy_bit(OPT_INTERRUPT)   },
526  {"sugarCrit",    Sy_bit(OPT_SUGARCRIT),      ~Sy_bit(OPT_SUGARCRIT)   },
[750e70]527  {"teach",        Sy_bit(OPT_DEBUG),          ~Sy_bit(OPT_DEBUG)  },
528  {"notSyzMinim",  Sy_bit(OPT_NO_SYZ_MINIM),   ~Sy_bit(OPT_NO_SYZ_MINIM)  },
[8d38c87]529  /* 9 return SB in syz, quotient, intersect */
530  {"returnSB",     Sy_bit(OPT_RETURN_SB),      ~Sy_bit(OPT_RETURN_SB)  },
531  {"fastHC",       Sy_bit(OPT_FASTHC),         ~Sy_bit(OPT_FASTHC)  },
532  /* 11-19 sort in L/T */
533  {"staircaseBound",Sy_bit(OPT_STAIRCASEBOUND),~Sy_bit(OPT_STAIRCASEBOUND)  },
534  {"multBound",    Sy_bit(OPT_MULTBOUND),      ~Sy_bit(OPT_MULTBOUND)  },
535  {"degBound",     Sy_bit(OPT_DEGBOUND),       ~Sy_bit(OPT_DEGBOUND)  },
536  /* 25 no redTail(p)/redTail(s) */
537  {"redTail",      Sy_bit(OPT_REDTAIL),        ~Sy_bit(OPT_REDTAIL)  },
538  {"redThrough",   Sy_bit(OPT_REDTHROUGH),     ~Sy_bit(OPT_REDTHROUGH)  },
539  {"lazy",         Sy_bit(OPT_OLDSTD),         ~Sy_bit(OPT_OLDSTD)  },
540  {"intStrategy",  Sy_bit(OPT_INTSTRATEGY),    ~Sy_bit(OPT_INTSTRATEGY)  },
541  {"infRedTail",   Sy_bit(OPT_INFREDTAIL),     ~Sy_bit(OPT_INFREDTAIL)  },
542  /* 30: use not regularity for syz */
543  {"notRegularity",Sy_bit(OPT_NOTREGULARITY),  ~Sy_bit(OPT_NOTREGULARITY)  },
544  {"weightM",      Sy_bit(OPT_WEIGHTM),        ~Sy_bit(OPT_WEIGHTM)  },
545/*special for "none" and also end marker for showOption:*/
546  {"ne",           0,                          0 }
547};
548
549struct soptionStruct verboseStruct[]=
550{
551  {"mem",      Sy_bit(V_SHOW_MEM),  ~Sy_bit(V_SHOW_MEM)   },
552  {"yacc",     Sy_bit(V_YACC),      ~Sy_bit(V_YACC)       },
553  {"redefine", Sy_bit(V_REDEFINE),  ~Sy_bit(V_REDEFINE)   },
554  {"reading",  Sy_bit(V_READING),   ~Sy_bit(V_READING)    },
555  {"loadLib",  Sy_bit(V_LOAD_LIB),  ~Sy_bit(V_LOAD_LIB)   },
556  {"debugLib", Sy_bit(V_DEBUG_LIB), ~Sy_bit(V_DEBUG_LIB)  },
557  {"loadProc", Sy_bit(V_LOAD_PROC), ~Sy_bit(V_LOAD_PROC)  },
558  {"defRes",   Sy_bit(V_DEF_RES),   ~Sy_bit(V_DEF_RES)    },
559  {"usage",    Sy_bit(V_SHOW_USE),  ~Sy_bit(V_SHOW_USE)   },
560  {"Imap",     Sy_bit(V_IMAP),      ~Sy_bit(V_IMAP)       },
561  {"prompt",   Sy_bit(V_PROMPT),    ~Sy_bit(V_PROMPT)     },
562  {"length",   Sy_bit(V_LENGTH),    ~Sy_bit(V_LENGTH)     },
563  {"notWarnSB",Sy_bit(V_NSB),       ~Sy_bit(V_NSB)        },
564  {"contentSB",Sy_bit(V_CONTENTSB), ~Sy_bit(V_CONTENTSB)  },
565  {"cancelunit",Sy_bit(V_CANCELUNIT),~Sy_bit(V_CANCELUNIT)},
566  {"modpsolve",Sy_bit(V_MODPSOLVSB),~Sy_bit(V_MODPSOLVSB)},
567  {"geometricSB",Sy_bit(V_UPTORADICAL),~Sy_bit(V_UPTORADICAL)},
568  {"findMonomials",Sy_bit(V_FINDMONOM),~Sy_bit(V_FINDMONOM)},
569  {"coefStrat",Sy_bit(V_COEFSTRAT), ~Sy_bit(V_COEFSTRAT)},
570  {"qringNF",  Sy_bit(V_QRING),     ~Sy_bit(V_QRING)},
[d693da2]571  {"warn",     Sy_bit(V_ALLWARN),   ~Sy_bit(V_ALLWARN)},
[f6bfc4]572  {"interedSyz",Sy_bit(V_INTERSECT_SYZ), ~Sy_bit(V_INTERSECT_SYZ)},
573  {"interedElim",Sy_bit(V_INTERSECT_ELIM), ~Sy_bit(V_INTERSECT_ELIM)},
[8d38c87]574/*special for "none" and also end marker for showOption:*/
575  {"ne",         0,          0 }
576};
577
578BOOLEAN setOption(leftv res, leftv v)
579{
580  const char *n;
581  do
582  {
583    if (v->Typ()==STRING_CMD)
584    {
585      n=(const char *)v->CopyD(STRING_CMD);
586    }
587    else
588    {
589      if (v->name==NULL)
590        return TRUE;
591      if (v->rtyp==0)
592      {
593        n=v->name;
594        v->name=NULL;
595      }
596      else
597      {
598        n=omStrDup(v->name);
599      }
600    }
601
602    int i;
603
604    if(strcmp(n,"get")==0)
605    {
606      intvec *w=new intvec(2);
[d30a399]607      (*w)[0]=si_opt_1;
608      (*w)[1]=si_opt_2;
[8d38c87]609      res->rtyp=INTVEC_CMD;
610      res->data=(void *)w;
611      goto okay;
612    }
613    if(strcmp(n,"set")==0)
614    {
615      if((v->next!=NULL)
616      &&(v->next->Typ()==INTVEC_CMD))
617      {
618        v=v->next;
619        intvec *w=(intvec*)v->Data();
[d30a399]620        si_opt_1=(*w)[0];
621        si_opt_2=(*w)[1];
[8d38c87]622#if 0
623        if (TEST_OPT_INTSTRATEGY && (currRing!=NULL)
624        && rField_has_simple_inverse()
625#ifdef HAVE_RINGS
626        && !rField_is_Ring(currRing)
627#endif
628        ) {
[d30a399]629          si_opt_1 &=~Sy_bit(OPT_INTSTRATEGY);
[8d38c87]630        }
631#endif
632        goto okay;
633      }
634    }
635    if(strcmp(n,"none")==0)
636    {
[d30a399]637      si_opt_1=0;
638      si_opt_2=0;
[8d38c87]639      goto okay;
640    }
641    for (i=0; (i==0) || (optionStruct[i-1].setval!=0); i++)
642    {
643      if (strcmp(n,optionStruct[i].name)==0)
644      {
645        if (optionStruct[i].setval & validOpts)
646        {
[d30a399]647          si_opt_1 |= optionStruct[i].setval;
[8d38c87]648          // optOldStd disables redthrough
649          if (optionStruct[i].setval == Sy_bit(OPT_OLDSTD))
[d30a399]650            si_opt_1 &= ~Sy_bit(OPT_REDTHROUGH);
[8d38c87]651        }
652        else
653          Warn("cannot set option");
654#if 0
655        if (TEST_OPT_INTSTRATEGY && (currRing!=NULL)
656        && rField_has_simple_inverse()
657#ifdef HAVE_RINGS
658        && !rField_is_Ring(currRing)
659#endif
660        ) {
661          test &=~Sy_bit(OPT_INTSTRATEGY);
662        }
663#endif
664        goto okay;
665      }
666      else if ((strncmp(n,"no",2)==0)
667      && (strcmp(n+2,optionStruct[i].name)==0))
668      {
669        if (optionStruct[i].setval & validOpts)
670        {
[d30a399]671          si_opt_1 &= optionStruct[i].resetval;
[8d38c87]672        }
673        else
674          Warn("cannot clear option");
675        goto okay;
676      }
677    }
678    for (i=0; (i==0) || (verboseStruct[i-1].setval!=0); i++)
679    {
680      if (strcmp(n,verboseStruct[i].name)==0)
681      {
[d30a399]682        si_opt_2 |= verboseStruct[i].setval;
[8d38c87]683        #ifdef YYDEBUG
684        #if YYDEBUG
685        /*debugging the bison grammar --> grammar.cc*/
686        extern int    yydebug;
687        if (BVERBOSE(V_YACC)) yydebug=1;
688        else                  yydebug=0;
689        #endif
690        #endif
691        goto okay;
692      }
693      else if ((strncmp(n,"no",2)==0)
694      && (strcmp(n+2,verboseStruct[i].name)==0))
695      {
[d30a399]696        si_opt_2 &= verboseStruct[i].resetval;
[8d38c87]697        #ifdef YYDEBUG
698        #if YYDEBUG
699        /*debugging the bison grammar --> grammar.cc*/
700        extern int    yydebug;
701        if (BVERBOSE(V_YACC)) yydebug=1;
702        else                  yydebug=0;
703        #endif
704        #endif
705        goto okay;
706      }
707    }
708    Werror("unknown option `%s`",n);
709  okay:
710    if (currRing != NULL)
[d30a399]711      currRing->options = si_opt_1 & TEST_RINGDEP_OPTS;
[8d38c87]712    omFree((ADDRESS)n);
713    v=v->next;
714  } while (v!=NULL);
[3706b2]715
[eeae6e3]716#ifdef OM_SINGULAR_CONFIG_H
717   // set global variable to show memory usage
[22303d]718  extern int om_sing_opt_show_mem;
[da8702]719  if (BVERBOSE(V_SHOW_MEM)) om_sing_opt_show_mem = 1;
720  else om_sing_opt_show_mem = 0;
[eeae6e3]721#endif
[3706b2]722
[8d38c87]723  return FALSE;
724}
725
726char * showOption()
727{
728  int i;
729  BITSET tmp;
730
731  StringSetS("//options:");
[d30a399]732  if ((si_opt_1!=0)||(si_opt_2!=0))
[8d38c87]733  {
[d30a399]734    tmp=si_opt_1;
[8d38c87]735    if(tmp)
736    {
737      for (i=0; optionStruct[i].setval!=0; i++)
738      {
[d30a399]739        if (optionStruct[i].setval & tmp)
[8d38c87]740        {
741          StringAppend(" %s",optionStruct[i].name);
742          tmp &=optionStruct[i].resetval;
743        }
744      }
745      for (i=0; i<32; i++)
746      {
747        if (tmp & Sy_bit(i)) StringAppend(" %d",i);
748      }
749    }
[d30a399]750    tmp=si_opt_2;
[8d38c87]751    if (tmp)
752    {
753      for (i=0; verboseStruct[i].setval!=0; i++)
754      {
755        if (verboseStruct[i].setval & tmp)
756        {
757          StringAppend(" %s",verboseStruct[i].name);
758          tmp &=verboseStruct[i].resetval;
759        }
760      }
761      for (i=1; i<32; i++)
762      {
763        if (tmp & Sy_bit(i)) StringAppend(" %d",i+32);
764      }
765    }
[538512]766    return StringEndS();
[8d38c87]767  }
[538512]768  StringAppendS(" none");
769  return StringEndS();
[8d38c87]770}
771
[bdb9f5]772/* version strings */
773#ifdef HAVE_FLINT
774extern "C"
775{
776#ifndef __GMP_BITS_PER_MP_LIMB
777#define __GMP_BITS_PER_MP_LIMB GMP_LIMB_BITS
778#endif
779#include <flint/flint.h>
780}
781#endif
782
[574cee]783char * versionString(/*const bool bShowDetails = false*/ )
[8d38c87]784{
[538512]785  StringSetS("");
[574cee]786  StringAppend("Singular for %s version %s (%s, %d bit) %s #%s",
[e6f9145]787               S_UNAME, S_VERSION1, // SINGULAR_VERSION,
[574cee]788               PACKAGE_VERSION, SIZEOF_LONG*8, singular_date, GIT_VERSION);
[b6ad598]789  StringAppendS("\nwith\n\t");
[8d38c87]790#ifdef HAVE_FACTORY
[ce9bfe]791  StringAppend("factory(%s){'%s','%s'}", factoryVersion, FACTORY_CFLAGS, FACTORY_LIBS);
[5348866]792#ifdef HAVE_LIBFAC
793  // libfac:
[81845eb]794//  extern const char * libfac_version;
795//  extern const char * libfac_date;
796  StringAppend("+libfac");
[5348866]797#endif // #ifdef HAVE_LIBFAC
[81845eb]798  StringAppend(",");
[8d38c87]799#endif
[5348866]800
[8d38c87]801#if defined (__GNU_MP_VERSION) && defined (__GNU_MP_VERSION_MINOR)
[ce9bfe]802              StringAppend("GMP(%d.%d){'%s','%s'},",__GNU_MP_VERSION,__GNU_MP_VERSION_MINOR, GMP_CFLAGS, GMP_LIBS);
[8d38c87]803#else
804              StringAppendS("GMP(1.3),");
805#endif
806#ifdef HAVE_NTL
[599326]807#include <NTL/version.h>
[ce9bfe]808              StringAppend("NTL(%s){'%s','%s'},",NTL_VERSION, NTL_CFLAGS, NTL_LIBS);
[8d38c87]809#endif
[ce9bfe]810
[bdb9f5]811#ifdef HAVE_FACTORY
[ce9bfe]812#ifdef HAVE_FLINT
[bdb9f5]813              StringAppend("FLINT(%s){'%s','%s'},",version, FLINT_CFLAGS, FLINT_LIBS);
814#endif
[ce9bfe]815#endif
816
[8d38c87]817#if SIZEOF_VOIDP == 8
818              StringAppendS("64bit,");
819#else
820              StringAppendS("32bit,");
821#endif
822#if defined(HAVE_DYN_RL)
823              if (fe_fgets_stdin==fe_fgets_dummy)
824                StringAppendS("no input,");
825              else if (fe_fgets_stdin==fe_fgets)
826                StringAppendS("fgets,");
827              if (fe_fgets_stdin==fe_fgets_stdin_drl)
828                StringAppendS("dynamic readline,");
829              #ifdef HAVE_FEREAD
830              else if (fe_fgets_stdin==fe_fgets_stdin_emu)
831                StringAppendS("emulated readline,");
832              #endif
833              else
834                StringAppendS("unknown fgets method,");
835#else
836  #if defined(HAVE_READLINE) && !defined(FEREAD)
837              StringAppendS("static readline,");
838  #else
839    #ifdef HAVE_FEREAD
840              StringAppendS("emulated readline,");
841    #else
842              StringAppendS("fgets,");
843    #endif
844  #endif
845#endif
846#ifdef HAVE_PLURAL
847              StringAppendS("Plural,");
848#endif
849#ifdef HAVE_DBM
850              StringAppendS("DBM,\n\t");
851#else
852              StringAppendS("\n\t");
853#endif
854#ifdef HAVE_DYNAMIC_LOADING
855              StringAppendS("dynamic modules,");
856#endif
857              if (p_procs_dynamic) StringAppendS("dynamic p_Procs,");
858#ifdef TEST
859              StringAppendS("TESTs,");
860#endif
861#if YYDEBUG
862              StringAppendS("YYDEBUG=1,");
863#endif
864#ifdef HAVE_ASSUME
865             StringAppendS("ASSUME,");
866#endif
867#ifdef MDEBUG
868              StringAppend("MDEBUG=%d,",MDEBUG);
869#endif
870#ifdef OM_CHECK
871              StringAppend("OM_CHECK=%d,",OM_CHECK);
872#endif
873#ifdef OM_TRACK
874              StringAppend("OM_TRACK=%d,",OM_TRACK);
875#endif
876#ifdef OM_NDEBUG
877              StringAppendS("OM_NDEBUG,");
878#endif
879#ifdef PDEBUG
880              StringAppendS("PDEBUG,");
881#endif
882#ifdef KDEBUG
883              StringAppendS("KDEBUG,");
884#endif
885#ifndef __OPTIMIZE__
886              StringAppendS("-g,");
887#endif
888#ifdef HAVE_EIGENVAL
889              StringAppendS("eigenvalues,");
890#endif
891#ifdef HAVE_GMS
892              StringAppendS("Gauss-Manin system,");
893#endif
894#ifdef HAVE_RATGRING
895              StringAppendS("ratGB,");
896#endif
897              StringAppend("random=%d\n",siRandomStart);
[fbdfd4]898
[20e3062]899#define SI_SHOW_BUILTIN_MODULE(name) StringAppend(" %s", #name);
900              StringAppendS("built-in modules: {");
901              SI_FOREACH_BUILTIN(SI_SHOW_BUILTIN_MODULE)
902              StringAppendS("}\n");
903#undef SI_SHOW_BUILTIN_MODULE
[fbdfd4]904
[b0fc73]905              StringAppend("AC_CONFIGURE_ARGS = %s,\n"
906                           "CC = %s,FLAGS : %s,\n"
907                           "CXX = %s,FLAGS : %s,\n"
908                           "DEFS : %s,CPPFLAGS : %s,\n"
909                           "LDFLAGS : %s,LIBS : %s "
[8d38c87]910#ifdef __GNUC__
[ce9bfe]911              "(ver: " __VERSION__ ")"
[8d38c87]912#endif
[ce9bfe]913              "\n",AC_CONFIGURE_ARGS, CC,CFLAGS, CXX,CXXFLAGS,  DEFS,CPPFLAGS,  LDFLAGS,LIBS);
[8d38c87]914              feStringAppendResources(0);
915              feStringAppendBrowsers(0);
916              StringAppendS("\n");
[538512]917              return StringEndS();
[8d38c87]918}
919
920#ifdef PDEBUG
921#if (OM_TRACK > 2) && defined(OM_TRACK_CUSTOM)
922void p_SetRingOfLeftv(leftv l, ring r)
923{
924  switch(l->rtyp)
925  {
926    case INT_CMD:
927    case BIGINT_CMD:
928    case IDHDL:
929    case DEF_CMD:
930      break;
931    case POLY_CMD:
932    case VECTOR_CMD:
933    {
934      poly p=(poly)l->data;
935      while(p!=NULL) { p_SetRingOfLm(p,r); pIter(p); }
936      break;
937    }
938    case IDEAL_CMD:
939    case MODUL_CMD:
940    case MATRIX_CMD:
941    {
942      ideal I=(ideal)l->data;
943      int i;
944      for(i=IDELEMS(I)-1;i>=0;i--)
945      {
946        poly p=I->m[i];
947        while(p!=NULL) { p_SetRingOfLm(p,r); pIter(p); }
948      }
949      break;
950    }
951    case COMMAND:
952    {
953      command d=(command)l->data;
954      p_SetRingOfLeftv(&d->arg1, r);
955      if (d->argc>1) p_SetRingOfLeftv(&d->arg2, r);
956      if (d->argc>2) p_SetRingOfLeftv(&d->arg3, r);
957      break;
958    }
959    default:
960     printf("type %d not yet implementd in p_SetRingOfLeftv\n",l->rtyp);
961     break;
962  }
963}
964#endif
965#endif
966
[aefd2f]967#if 0 /* debug only */
[8d38c87]968void listall(int showproc)
969{
970      idhdl hh=basePack->idroot;
971      PrintS("====== Top ==============\n");
972      while (hh!=NULL)
973      {
974        if (showproc || (IDTYP(hh)!=PROC_CMD))
975        {
976          if (IDDATA(hh)==(void *)currRing) PrintS("(R)");
977          else if (IDDATA(hh)==(void *)currPack) PrintS("(P)");
978          else PrintS("   ");
979          Print("::%s, typ %s level %d data %lx",
980                 IDID(hh),Tok2Cmdname(IDTYP(hh)),IDLEV(hh),(long)IDDATA(hh));
981          if ((IDTYP(hh)==RING_CMD)
982          || (IDTYP(hh)==QRING_CMD))
983            Print(" ref: %d\n",IDRING(hh)->ref);
984          else
985            PrintLn();
986        }
987        hh=IDNEXT(hh);
988      }
989      hh=basePack->idroot;
990      while (hh!=NULL)
991      {
992        if (IDDATA(hh)==(void *)basePack)
993          Print("(T)::%s, typ %s level %d data %lx\n",
994          IDID(hh),Tok2Cmdname(IDTYP(hh)),IDLEV(hh),(long)IDDATA(hh));
995        else
996        if ((IDTYP(hh)==RING_CMD)
997        || (IDTYP(hh)==QRING_CMD)
998        || (IDTYP(hh)==PACKAGE_CMD))
999        {
1000          Print("====== %s ==============\n",IDID(hh));
1001          idhdl h2=IDRING(hh)->idroot;
1002          while (h2!=NULL)
1003          {
1004            if (showproc || (IDTYP(h2)!=PROC_CMD))
1005            {
1006              if ((IDDATA(h2)==(void *)currRing)
1007              && ((IDTYP(h2)==RING_CMD)||(IDTYP(h2)==QRING_CMD)))
1008                PrintS("(R)");
1009              else if (IDDATA(h2)==(void *)currPack) PrintS("(P)");
1010              else PrintS("   ");
1011              Print("%s::%s, typ %s level %d data %lx\n",
1012              IDID(hh),IDID(h2),Tok2Cmdname(IDTYP(h2)),IDLEV(h2),(long)IDDATA(h2));
1013            }
1014            h2=IDNEXT(h2);
1015          }
1016        }
1017        hh=IDNEXT(hh);
1018      }
1019      Print("currRing:%lx, currPack:%lx,basePack:%lx\n",(long)currRing,(long)currPack,(long)basePack);
1020      iiCheckPack(currPack);
1021}
[8b2ef5]1022#endif
[aefd2f]1023
[8b2ef5]1024#ifndef NDEBUG
[8d38c87]1025void checkall()
1026{
1027      idhdl hh=basePack->idroot;
1028      while (hh!=NULL)
1029      {
1030        omCheckAddr(hh);
1031        omCheckAddr((ADDRESS)IDID(hh));
1032        if (RingDependend(IDTYP(hh))) Print("%s typ %d in Top\n",IDID(hh),IDTYP(hh));
1033        hh=IDNEXT(hh);
1034      }
1035      hh=basePack->idroot;
1036      while (hh!=NULL)
1037      {
1038        if (IDTYP(hh)==PACKAGE_CMD)
1039        {
1040          idhdl h2=IDPACKAGE(hh)->idroot;
1041          while (h2!=NULL)
1042          {
1043            omCheckAddr(h2);
1044            omCheckAddr((ADDRESS)IDID(h2));
1045            if (RingDependend(IDTYP(h2))) Print("%s typ %d in %s\n",IDID(h2),IDTYP(h2),IDID(hh));
1046            h2=IDNEXT(h2);
1047          }
1048        }
1049        hh=IDNEXT(hh);
1050      }
1051}
1052#endif
1053
1054#include <sys/types.h>
1055#include <sys/stat.h>
1056#include <unistd.h>
1057
1058extern "C"
1059int singular_fstat(int fd, struct stat *buf)
1060{
[bdda8c2]1061  return si_fstat(fd,buf);
[8d38c87]1062}
1063
[8de3388]1064/*2
1065* the global exit routine of Singular
1066*/
1067extern "C" {
1068
1069void m2_end(int i)
1070{
1071  fe_reset_input_mode();
1072  #ifdef PAGE_TEST
1073  mmEndStat();
1074  #endif
1075  fe_reset_input_mode();
[0bae3e]1076  idhdl h = currPack->idroot;
[8de3388]1077  while(h != NULL)
1078  {
1079    if(IDTYP(h) == LINK_CMD)
1080    {
1081      idhdl hh=h->next;
[0bae3e]1082      //Print("kill %s\n",IDID(h));
[8de3388]1083      killhdl(h, currPack);
1084      h = hh;
1085    }
1086    else
1087    {
1088      h = h->next;
1089    }
1090  }
[0bae3e]1091  extern link_list ssiToBeClosed;
1092  link_list hh=ssiToBeClosed;
1093  while(hh!=NULL)
1094  {
1095    //Print("close %s\n",hh->l->name);
1096    slClose(hh->l);
1097    hh=ssiToBeClosed;
1098  }
1099  if (!singular_in_batchmode)
[8de3388]1100  {
[3706b2]1101    if (i<=0)
1102    {
[8de3388]1103      if (TEST_V_QUIET)
1104      {
1105        if (i==0)
1106          printf("Auf Wiedersehen.\n");
1107        else
1108          printf("\n$Bye.\n");
1109      }
[3706b2]1110      //#ifdef sun
1111      //  #ifndef __svr4__
1112      //    _cleanup();
1113      //    _exit(0);
1114      //  #endif
1115      //#endif
1116      i=0;
1117    }
1118    else
1119    {
[1edbcdd]1120        printf("\nhalt %d\n",i);
[3706b2]1121    }
[8de3388]1122  }
1123  exit(i);
1124}
1125}
[9f82971]1126
1127const char *singular_date=__DATE__ " " __TIME__;
1128
1129extern "C"
1130{
1131  void omSingOutOfMemoryFunc()
1132  {
1133    fprintf(stderr, "\nSingular error: no more memory\n");
1134    omPrintStats(stderr);
1135    m2_end(14);
1136    /* should never get here */
1137    exit(1);
1138  }
1139}
1140
[d3b70ae]1141/*2
1142* initialize components of Singular
1143*/
1144void siInit(char *name)
[9f82971]1145{
[3645fc]1146#ifdef HAVE_FACTORY
[5374da]1147// factory default settings: -----------------------------------------------
[3645fc]1148  On(SW_USE_NTL);
1149  On(SW_USE_NTL_GCD_0); // On -> seg11 in Old/algnorm, Old/factor...
1150  On(SW_USE_NTL_GCD_P); // On -> cyle in Short/brnoeth_s: fixed
1151  On(SW_USE_EZGCD);
1152  On(SW_USE_CHINREM_GCD);
1153  //On(SW_USE_FF_MOD_GCD);
1154  On(SW_USE_EZGCD_P);
1155  On(SW_USE_QGCD);
1156  Off(SW_USE_NTL_SORT); // may be changed by an command line option
[5374da]1157  factoryError=WerrorS;
[3645fc]1158#endif
1159
[5374da]1160// memory initialization: -----------------------------------------------
1161    om_Opts.OutOfMemoryFunc = omSingOutOfMemoryFunc;
1162#ifndef OM_NDEBUG
1163#ifndef __OPTIMIZE__
1164    om_Opts.ErrorHook = dErrorBreak;
[9bc6a43]1165#else
1166    om_Opts.Keep = 0; /* !OM_NDEBUG, __OPTIMIZE__*/
[5374da]1167#endif
[9bc6a43]1168#else
1169    om_Opts.Keep = 0; /* OM_NDEBUG */
[5374da]1170#endif
1171    omInitInfo();
1172
1173// interpreter tables etc.: -----------------------------------------------
[3645fc]1174#ifdef INIT_BUG
1175  jjInitTab1();
1176#endif
[5374da]1177  memset(&sLastPrinted,0,sizeof(sleftv));
1178  sLastPrinted.rtyp=NONE;
[3706b2]1179
[047597]1180  extern int iiInitArithmetic(); iiInitArithmetic(); // iparith.cc
1181
[5374da]1182  basePack=(package)omAlloc0(sizeof(*basePack));
1183  currPack=basePack;
1184  idhdl h;
1185  h=enterid("Top", 0, PACKAGE_CMD, &IDROOT, TRUE);
1186  IDPACKAGE(h)->language = LANG_TOP;
1187  IDPACKAGE(h)=basePack;
1188  currPackHdl=h;
1189  basePackHdl=h;
[047597]1190
1191  coeffs_BIGINT = nInitChar(n_Q,NULL);
[3706b2]1192
1193#if 1
[047597]1194   // def HAVE_POLYEXTENSIONS
1195  if(TRUE)
1196  {
1197    n_coeffType type = nRegister(n_algExt, naInitChar);
1198    assume(type == n_algExt);
[3706b2]1199
[047597]1200    type = nRegister(n_transExt, ntInitChar);
1201    assume(type == n_transExt);
[7520ee]1202
[14ad9b]1203    (void)type;
[047597]1204  }
1205#endif
[5374da]1206
1207// random generator: -----------------------------------------------
[d3b70ae]1208  int t=initTimer();
1209  if (t==0) t=1;
1210  initRTimer();
1211  siSeed=t;
1212#ifdef HAVE_FACTORY
1213  factoryseed(t);
1214#endif
1215  siRandomStart=t;
[3645fc]1216  feOptSpec[FE_OPT_RANDOM].value = (void*) ((long)siRandomStart);
[e3c0c1d]1217
[5374da]1218// ressource table: ----------------------------------------------------
[3645fc]1219  // Don't worry: ifdef OM_NDEBUG, then all these calls are undef'ed
[9f82971]1220  // hack such that all shared' libs in the bindir are loaded correctly
1221  feInitResources(name);
1222
[5374da]1223// singular links: --------------------------------------------------
[9f82971]1224  slStandardInit();
1225  myynest=0;
[7d63e1]1226// semapohore 0 -----------------------------------------------------
1227  int cpus=2;
1228  int cpu_n;
1229  #ifdef _SC_NPROCESSORS_ONLN
1230  if ((cpu_n=sysconf(_SC_NPROCESSORS_ONLN))>cpus) cpus=cpu_n;
1231  #elif defined(_SC_NPROCESSORS_CONF)
1232  if ((cpu_n=sysconf(_SC_NPROCESSORS_CONF))>cpus) cpus=cpu_n;
1233  #endif
1234  feSetOptValue(FE_OPT_CPUS, cpus);
[3645fc]1235
[5374da]1236// loading standard.lib -----------------------------------------------
[9f82971]1237  if (! feOptValue(FE_OPT_NO_STDLIB))
1238  {
[d30a399]1239    BITSET save1,save2;
1240    SI_SAVE_OPT(save1,save2);
1241    si_opt_2 &= ~Sy_bit(V_LOAD_LIB);
[9f82971]1242    iiLibCmd(omStrDup("standard.lib"), TRUE,TRUE,TRUE);
[d30a399]1243    SI_RESTORE_OPT(save1,save2);
[9f82971]1244  }
1245  errorreported = 0;
1246}
1247
[13a8de]1248/*
[c8c436]1249#ifdef LIBSINGULAR
1250#ifdef HAVE_FACTORY
1251// the init routines of factory need mmInit
1252int mmInit( void )
1253{
1254  return 1;
1255}
1256#endif
1257#endif
[13a8de]1258*/
Note: See TracBrowser for help on using the repository browser.