source: git/factory/cf_primes.cc @ 2dd068

spielwiese
Last change on this file since 2dd068 was 2dd068, checked in by Rüdiger Stobbe <stobbe@…>, 28 years ago
Initial revision git-svn-id: file:///usr/local/Singular/svn/trunk@6 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 3.3 KB
Line 
1// emacs edit mode for this file is -*- C++ -*-
2// $Id: cf_primes.cc,v 1.0 1996-05-17 10:59:44 stobbe Exp $
3
4/*
5$Log: not supported by cvs2svn $
6*/
7
8#include "assert.h"
9#include "cf_defs.h"
10#include "cf_globals.h"
11#include "cf_primes.h"
12
13#define NUMSMALLPRIMES 160
14#define NUMBIGPRIMES 189
15
16static const int small_primes [] = {
17    3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59,
18    61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127,
19    131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193,
20    197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269,
21    271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349,
22    353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431,
23    433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503,
24    509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599,
25    601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673,
26    677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761,
27    769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857,
28    859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 0 };
29
30static const int big_primes [] = {
31    29989, 30011, 30013, 30029, 30047, 30059, 30071, 30089, 30091,
32    30097, 30103, 30109, 30113, 30119, 30133, 30137, 30139, 30161,
33    30169, 30181, 30187, 30197, 30203, 30211, 30223, 30241, 30253,
34    30259, 30269, 30271, 30293, 30307, 30313, 30319, 30323, 30341,
35    30347, 30367, 30389, 30391, 30403, 30427, 30431, 30449, 30467,
36    30469, 30491, 30493, 30497, 30509, 30517, 30529, 30539, 30553,
37    30557, 30559, 30577, 30593, 30631, 30637, 30643, 30649, 30661,
38    30671, 30677, 30689, 30697, 30703, 30707, 30713, 30727, 30757,
39    30763, 30773, 30781, 30803, 30809, 30817, 30829, 30839, 30841,
40    30851, 30853, 30859, 30869, 30871, 30881, 30893, 30911, 30931,
41    30937, 30941, 30949, 30971, 30977, 30983, 31013, 31019, 31033,
42    31039, 31051, 31063, 31069, 31079, 31081, 31091, 31121, 31123,
43    31139, 31147, 31151, 31153, 31159, 31177, 31181, 31183, 31189,
44    31193, 31219, 31223, 31231, 31237, 31247, 31249, 31253, 31259,
45    31267, 31271, 31277, 31307, 31319, 31321, 31327, 31333, 31337,
46    31357, 31379, 31387, 31391, 31393, 31397, 31469, 31477, 31481,
47    31489, 31511, 31513, 31517, 31531, 31541, 31543, 31547, 31567,
48    31573, 31583, 31601, 31607, 31627, 31643, 31649, 31657, 31663,
49    31667, 31687, 31699, 31721, 31723, 31727, 31729, 31741, 31751,
50    31769, 31771, 31793, 31799, 31817, 31847, 31849, 31859, 31873,
51    31883, 31891, 31907, 31957, 31963, 31973, 31981, 31991, 32003, 0 };
52
53
54int cf_getPrime( int i )
55{
56    if ( cf_glob_switches.isOn( SW_FAC_USE_BIG_PRIMES ) ) {
57        ASSERT( i >= 0 && i < NUMBIGPRIMES, "index to primes too high" );
58        return big_primes[i];
59    }
60    else {
61        ASSERT( i >= 0 && i < NUMSMALLPRIMES, "index to primes too high" );
62        return small_primes[i];
63    }
64}
65
66int cf_getNumPrimes()
67{
68    if ( cf_glob_switches.isOn( SW_FAC_USE_BIG_PRIMES ) )
69        return NUMBIGPRIMES;
70    else
71        return NUMSMALLPRIMES;
72}
73
74int cf_getSmallPrime( int i )
75{
76    ASSERT( i >= 0 && i < NUMSMALLPRIMES, "index to primes too high" );
77    return small_primes[i];
78}
79
80int cf_getNumSmallPrimes()
81{
82    return NUMSMALLPRIMES;
83}
84
85int cf_getBigPrime( int i )
86{
87    ASSERT( i >= 0 && i < NUMBIGPRIMES, "index to primes too high" );
88    return big_primes[i];
89}
90
91int cf_getNumBigPrimes()
92{
93    return NUMBIGPRIMES;
94}
Note: See TracBrowser for help on using the repository browser.