\\ Centered vector for cyclic indices. t_center (v) = {my (n=#v,d=n\2); vector(n,i,v[(i+d)%n+1])} \\ Fourier transform on a cyclic group. t_ft (v,realpart=0) = {my (n,m,Omstar); n=#v; w=exp(2*Pi*I/n); Omstar=matrix(n,n,j,k,w^(-(j-1)*(k-1))); t=(v*Omstar)/n; if (!realpart,t,apply(real,t))} t_ftstrabs (v,d=2,center=1) = {my (w); w=t_ft(v); if (center, w=t_center(w)); apply(x->Strprintf("%.*f",d,abs(x)),w)} t_ftstrarg (v,d=2,center=1) = {my (w); w=t_ft(v); if (center, w=t_center(w)); apply(x->Strprintf("%.*f",d,arg(x)),w)} \\Inverse Fourier transform on a cyclic group. t_fti (v,realpart=0) = {my (n,m,Om); n=#v; w=exp(2*Pi*I/n); Om=matrix(n,n,j,k,w^((j-1)*(k-1))); t=v*Om; if (!realpart,t,apply(real,t))} \\ Walsh transform. t_ftw (v) = {my (k,W); n=#v; k=#binary(n)-1; W=matrix(1,1,i,j,1); for (i=1,k,W=matconcat([W,W;W,-W])); (v*W)/n} \\ Inverse Walsh transform. t_ftwi (v) = {my (k,W); n=#v; k=#binary(n)-1; W=matrix(1,1,i,j,1); for (i=1,k,W=matconcat([W,W;W,-W])); v*W} t_ftwrite (F,X,name,G=F) = {my (u,v); u=apply(G,X); v=apply(F,X); t_writeplotpairs(Strprintf("%s.fun",name),u); t_writeplotpairs(Strprintf("%s.abs",name),t_ftstrabs(v)); t_writeplotpairs(Strprintf("%s.arg",name),t_ftstrarg(v));}