Edmond Griffin on Sun, 19 Feb 2023 16:58:45 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Segmentation Fault in Pari/GP from gp2c-run |
Hello, I am working on an old conjecture of Erdos-Turan using Pari/GP. Although the computations are simple, the number of them is very large. To speed things up, I hoped to convert my .gp code into C using gp2c. I am having difficulty doing so. I believe both gp and gp2c were built successfully on my machine - a quad core i7 MacBook Pro. When I compile and run the code using gp2c-run I get no warnings of undeclared or unused variables. I do get the following warning before gp starts: ld: warning: -undefined dynamic_lookup may not work with chained fixups Then when I call my function (extDnkc) I get ? extDnkc(15,6,0,"/Volumes/BinPolyData/Diffs/") *** user warning: *** at top-level: extDnkc(15,6,0,"/Volumes/BinPolyData/Diffs/") *** ^--------------------------------------------- *** extDnkc: bug in PARI/GP (Segmentation Fault), please report. Can you suggest a course of action? Thank you very much, Ed Griffin P.S. For refernce, here is my gp code: extDnkc(n, k, c, fPath) = { /* ======================================================================= This function looks in fPath for a file called D_n_k_TN.csv where n and k are input integers. It then applies the Extension process described in Borwein to generate a new set of basic binary polynomials. Unlike extDnk this function only records ("keeps") extended polynomials Whose norms differ from k by c. By Proposition 5, the only useful values of c are 0, 1, 2. Although the function produces no direct outputs it does create a file. Inputs: n = poly width k = poly norm c = change in norm (out norm = in norm + c) fPath = full file path to data sets Outputs: (none but does create/append files) Author: EE Griffin II Date: Feb 12, 2023 ========================================================================== */ my(fIn,fOut,fName,pwrOf2,qIdx,phiQ,degQ,strL,strS,pIdx,pV,p2V,pNorm,phiP); /*************** Try to open the input file located in fPath. If this doesn't work bail out with an error message. ***************/ fName = strjoin([fPath,strprintf("D_%d_%d_TN.csv", n, k)]); iferr(fIn=fileopen(fName,"r"), ERR, warning(strprintf("Bad input file: %s",fName)); return,errname(ERR)=="e_FILE"); /*************** As shown in Proposition 5 an element of D_n_k can only extend to an element in D_n+1_k, D_n+1_k+1, or D_n+1_k+2. So the input is checked and a file is opened if input c is in {0,1,2}. ***************/ if((c==0)||(c==1)||(c==2), fName = strjoin([fPath,strprintf("D_%d_%d_TD.csv", n+1, k+c)]); iferr(fOut=fileopen(fName,"a"), ERR, warning(strprintf("Bad output file: %s",fName)); fileclose(fIn);return, errname(ERR)=="e_FILE"); warning(fName);, warning(strprintf("Third input, c = norm change, must be in {0,1,2}"));return; ); /*************** Each extension of a binary polynomial corresponds to adding a power of 2 to the integer index of that polynomial. Calculate an array of 2^n ***************/ pwrOf2 = vector(1001, m, 2^m); /*************** Loop over the input file line-by-line. Each D_n_k is a .csv file with 3 integers per row. They are: qIdx = the integer index of the polynomial (=p(2)) phiQ = upper bound of extension loop qDeg = the degree of q (Note that two associated values are inputs: qWid = n = the polynomial width (= # of non-zero coefficients in q) qNorm = k = the largest coeff in the square of q ) We use filereadstr to read in a line and then split it into three parts. ***************/ while(strL = filereadstr(fIn), strS = strsplit(strL,","); qIdx = eval(strS[1]); phiQ = eval(strS[2]); degQ = eval(strS[3]); /*************** Loop over the possible extensions of q, using phiQ per Borwein ***************/ for(MM = degQ+1, phiQ, /*************** Calculate the index, coefficients and norm of p. By the definition of the index, adding another monomial of higher degree to q is the same as adding a power of 2 to the index of q. ***************/ pIdx = qIdx + pwrOf2[MM]; pV = binary(pIdx); p2V=Vec(Pol(pV)^2); pNorm = vecmax(p2V); /*************** Check to see if p is a basic binary polynomial. If so, write out the data for it ***************/ if(pNorm == k+c, if(#select(x->x,p2V[-MM-1..-1]) == MM+1, phiP = 2*#pV - 1 - iferr(vecmax(select(x->(x==0), p2V, 1)), ERR, 0,errname(ERR)=="e_DOMAIN"); filewrite(fOut, strprintf("%d,%d,%d",pIdx, phiP ,MM)); ); ); ); ); /*************** Close the output files ***************/ iferr(fileclose(fOut), ERR, warning(strprintf("Could not close output file")),errname(ERR)=="e_FILE" ); /*************** Close the input file ***************/ fileclose(fIn); }; |