/[dtapublic]/projs/dtats/trunk/projs/2018/20180707_cgi_web_tools_aux_exe/dtats_cgi_aux_arith_large/sieve_gen.c
ViewVC logotype

Diff of /projs/dtats/trunk/projs/2018/20180707_cgi_web_tools_aux_exe/dtats_cgi_aux_arith_large/sieve_gen.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 206 by dashley, Sat Jul 14 00:10:29 2018 UTC revision 207 by dashley, Sun Jul 15 21:50:56 2018 UTC
# Line 41  Line 41 
41    
42  unsigned int pfacts[] = {2, 3, 5, 7, 11};  unsigned int pfacts[] = {2, 3, 5, 7, 11};
43  unsigned int sieve_table_a[SIEVE_SIZE];  unsigned int sieve_table_a[SIEVE_SIZE];
44  char *output_header[] =  char *output_header[] =
45     {     {
46     "//This file is an automatically-generated sieve table, generated by the",     "//This file is an automatically-generated sieve table, generated by the",
47     "//program \"sieve_gen.c\".",     "//program \"sieve_gen.c\".",
48     "//",     "//",
49     NULL     NULL
50     };     };
51  char *output_footer[] =  char *output_footer[] =
52     {     {
53     "//",     "//",
54     "//End of automatically-generated file.",     "//End of automatically-generated file.",
# Line 62  int main(int argc, char *argv[]) Line 62  int main(int argc, char *argv[])
62     unsigned p, q;     unsigned p, q;
63     unsigned current_factor;     unsigned current_factor;
64     char **cptr;     char **cptr;
65        
66     //Initialize the sieve table. */     //Initialize the sieve table. */
67     for (i=0; i < SIEVE_SIZE; i++)     for (i=0; i < SIEVE_SIZE; i++)
68        {        {
# Line 77  int main(int argc, char *argv[]) Line 77  int main(int argc, char *argv[])
77        p = 0;        p = 0;
78        while (p < SIEVE_SIZE)        while (p < SIEVE_SIZE)
79           {           {
80           sieve_table_a[p] = 0;      sieve_table_a[p] = 0;
81           p += current_factor;           p += current_factor;
82           }      }
83        }        }
84    
85     //Output the header.     //Output the header.
# Line 96  int main(int argc, char *argv[]) Line 96  int main(int argc, char *argv[])
96        {        {
97        if (sieve_table_a[i])        if (sieve_table_a[i])
98           {           {
99           p = (i+1) % SIEVE_SIZE;      p = (i+1) % SIEVE_SIZE;
100           while (sieve_table_a[p] == 0)           while (sieve_table_a[p] == 0)
101              {         {
102              sieve_table_a[i]++;         sieve_table_a[i]++;
103              p = (p+1) % SIEVE_SIZE;              p = (p+1) % SIEVE_SIZE;
104              }         }
105           }      }
106        }        }
107    
108     //Print out the table of differentials for reference.  Each entry will     //Print out the table of differentials for reference.  Each entry will
# Line 116  int main(int argc, char *argv[]) Line 116  int main(int argc, char *argv[])
116        printf("//   sieve_table[%5d]: %3d    (", i, sieve_table_a[i]);        printf("//   sieve_table[%5d]: %3d    (", i, sieve_table_a[i]);
117        q = 0;        q = 0;
118        for (j=0; j<sizeof(pfacts)/sizeof(pfacts[0]); j++)        for (j=0; j<sizeof(pfacts)/sizeof(pfacts[0]); j++)
119           {      {
120           if ((i % pfacts[j]) == 0)      if ((i % pfacts[j]) == 0)
121              {         {
122              printf("[%d]", pfacts[j]);         printf("[%d]", pfacts[j]);
123              q = 1;         q = 1;
124              }         }
125           }      }
126        if (!q)        if (!q)
127           printf("NONE");      printf("NONE");
128        printf(")\n");        printf(")\n");
129        }        }
130     printf("//\n");     printf("//\n");
# Line 136  int main(int argc, char *argv[]) Line 136  int main(int argc, char *argv[])
136        {        {
137        printf("%d", pfacts[i]);        printf("%d", pfacts[i]);
138        if (i != (sizeof(pfacts)/sizeof(pfacts[0]) - 1))        if (i != (sizeof(pfacts)/sizeof(pfacts[0]) - 1))
139           printf(",");      printf(",");
140        }        }
141    
142     printf("}\n");     printf("}\n");
143     printf("//\n");     printf("//\n");
144     q = 0;     q = 0;
# Line 152  int main(int argc, char *argv[]) Line 152  int main(int argc, char *argv[])
152        {        {
153        if (sieve_table_a[i])        if (sieve_table_a[i])
154           {           {
155           printf("   %3d", sieve_table_a[i]);      printf("   %3d", sieve_table_a[i]);
156           if (j==q)      if (j==q)
157              printf(" ");         printf(" ");
158           else      else
159              printf(",");         printf(",");
160           printf(" /* [%5d] (was [%d]) */\n", j, i);           printf(" /* [%5d] (was [%d]) */\n", j, i);
161           j++;           j++;
162           }      }
163        }        }
164     printf("     };\n");     printf("     };\n");
165    

Legend:
Removed from v.206  
changed lines
  Added in v.207

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25