MCPcopy Create free account
hub / github.com/Singular/Singular / gf_get_table

Function gf_get_table

factory/gfops.cc:76–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76static void gf_get_table ( int p, int n )
77{
78 char buffer[gf_maxbuffer];
79 int q = ipower( p, n );
80
81 // do not read the table a second time
82 if ( gf_q == q )
83 {
84 return;
85 }
86
87 if ( gf_table == 0 )
88 gf_table = new unsigned short[gf_maxtable];
89
90 // try to open file
91 char *gffilename;
92 FILE * inputfile;
93 if (gftable_dir)
94 {
95 snprintf( buffer, gf_maxbuffer, "gftables/%d", q);
96 gffilename = (char *)malloc(strlen(gftable_dir) + strlen(buffer) + 1);
97 STICKYASSERT(gffilename,"out of memory");
98 strcpy(gffilename,gftable_dir);
99 strcat(gffilename,buffer);
100 inputfile = fopen( gffilename, "r" );
101 }
102 else
103 {
104 snprintf( buffer, gf_maxbuffer, "gftables/%d", q );
105 gffilename = buffer;
106#ifndef SINGULAR
107 inputfile = fopen( buffer, "r" );
108#else
109 inputfile = feFopen( buffer, "r" );
110#endif
111 }
112 if (!inputfile)
113 {
114 fprintf(stderr,"can not open GF(q) addition table: %s\n",gffilename);
115 STICKYASSERT(inputfile, "can not open GF(q) table");
116 }
117
118 // read ID
119 char * bufptr;
120 char * success;
121 success = fgets( buffer, gf_maxbuffer, inputfile );
122 STICKYASSERT( success, "illegal table (reading ID)" );
123 STICKYASSERT( strcmp( buffer, "@@ factory GF(q) table @@\n" ) == 0, "illegal table" );
124 // read p and n from file
125 int pFile, nFile;
126 success = fgets( buffer, gf_maxbuffer, inputfile );
127 STICKYASSERT( success, "illegal table (reading p and n)" );
128 sscanf( buffer, "%d %d", &pFile, &nFile );
129 STICKYASSERT( p == pFile && n == nFile, "illegal table" );
130 // skip (sic!) factory-representation of mipo
131 // and terminating "; "
132 bufptr = (char *)strchr( buffer, ';' ) + 2;
133 // read simple representation of mipo

Callers 1

gf_setcharacteristicFunction · 0.85

Calls 6

ipowerFunction · 0.85
mallocFunction · 0.85
feFopenFunction · 0.85
intVec2CFFunction · 0.85
gf_tab_numdigits62Function · 0.85
convertback62Function · 0.85

Tested by

no test coverage detected