\\ ---------------------------- GP code --------------------------------------- \\ Description: Routines for computing exact moments of Rudin-Shapiro polynomials \\ \\ \\ Original author: Christophe Doche \\ Université Bordeaux I \\ Laboratoire A2X \\ christophe.doche@mq.edu.au \\ \\ Created: Monday Aug 12th 2002 \\ \\=============================================================================== \\\r data; \\\r data32; \\findMoment computes the exact value of the Generalised Rudin-Shapiro polynomials \\l is an integer between 2 and 8 \\q is the (even) order of the moment \\n is the index of the Rudin-Polynomial \\J is the l^th root of unity \\l == 2 corresponds to classical Rudin-Shapiro polynomials \\findMoment returns a value for l == 2 and q == 2, 4, ..., 32 \\ l == 3 and q == 2, 4, 6, 8, 10 \\ l == 4 and q == 2, 4, 6 \\ l == 5 and q == 2, 4 \\ l == 6 and q == 2, 4 \\ l == 7 and q == 2, 4 \\ l == 8 and q == 2, 4 {findMoment(l, q, n)= local(lg, r, p, deg, mc, j, nv, lgmod); if( (l == 2 && q%2 == 0 && q >=2 && q <= 32) || (l == 3 && q%2 == 0 && q >=2 && q <= 10) || (l == 4 && q%2 == 0 && q >=2 && q <= 6) || ((l == 5 || l == 6 || l == 7 || l == 8) && q%2 == 0 && q >=2 && q <= 4), deg = eval(Str("deg"""l"_"q)); p = eval(Str("p"""l"_"q)); m = eval(Str("m"""l"_"q)); mc = eval(Str("M"""l))[q]; r = eval(Str("r"""l"_"q)); lg = mc[1]; if(n < deg, return(m[n+1]), if(lg >= n && lg - n < deg, return(mc = eval(Str("M"""l))[q][2][deg-lg+n]); ); if(lg > n, mc = [deg - 1, vector(deg, i, m[i])]; ); lg = mc[1]; j = n - lg; while(j > 0, nv = lift(scalar(mc[2],r)); mc[2] = nextValue(mc[2],nv); mc[1]++; j--; ); eval(Str("M"""l"[""q""]="mc)); return(nv); ), print("Invalid input"); ); } {scalar(v1, v2)= return(sum(i=1,length(v1),v1[i]*v2[i])); } {nextValue(w, val)= return(concat(vector(length(w) - 1, i, w[i+1]), val)); }