/*O(n^2) cyclic convolution code for testing*/ void slow_cyclic_convolution_1024_40961(FFTSHORT z[1024], FFTSHORT x[1024], FFTSHORT y[1024]) { FFTSHORT i,j,t; for (i = 0; i < n; ++i) { z[i] = 0; for (j = 0; j <= i; ++j) { MUL_MOD(t, x[j], y[i-j], q); ADD_MOD(z[i], z[i], t, q); } for (j = i+1; j < n; ++j) { MUL_MOD(t, x[j], y[n+i-j], q); ADD_MOD(z[i], z[i], t, q); } } }
static int change(MYLDAP_SESSION *session, const char *userdn, const char *homedir, const char *shell) { #define NUMARGS 2 char *strvals[(NUMARGS + 1) * 2]; LDAPMod mods[(NUMARGS + 1)], *modsp[(NUMARGS + 1)]; int i = 0; /* build the list of modifications */ ADD_MOD(attmap_passwd_homeDirectory, homedir); ADD_MOD(attmap_passwd_loginShell, shell); /* terminate the list of modifications */ modsp[i] = NULL; /* execute the update */ return myldap_modify(session, userdn, modsp); }
/* We use Gentleman-Sande, decimation-in-frequency FFT, for the forward FFT. We premultiply x by the 2n'th roots of unity to affect a Discrete Weighted Fourier Transform, so when we apply pointwise multiplication we obtain the negacyclic convolution, i.e. multiplication modulo x^n+1. Note that we will not perform the usual scambling / bit-reversal procedure here because we will invert the fourier transform using decimation-in-time. */ void FFT_twisted_forward_1024_40961(FFTSHORT x[1024]) { FFTSHORT index, step; FFTSHORT i,j,m; FFTSHORT t0,t1; //Pre multiplication for twisted FFT j = 0; for (i = 0; i < n>>1; ++i) { MUL_MOD(x[j], x[j], W[i], q); j++; MUL_MOD(x[j], x[j], W_sqrt[i], q); j++; } step = 1; for (m = n>>1; m >= 1; m=m>>1) { index = 0; for (j = 0 ; j < m; ++j) { for (i = j; i < n; i += (m<<1)) { ADD_MOD(t0, x[i], x[i+m], q); ADD(t1, x[i], q - x[i+m]); MUL_MOD(x[i+m], t1, W[index], q); x[i] = t0; } SUB_MODn(index, index, step); } step = step << 1; } }
INT X(safe_mulmod)(INT x, INT y, INT p) { INT r; if (y > x) return X(safe_mulmod)(y, x, p); A(0 <= y && x < p); r = 0; while (y) { r = ADD_MOD(r, x*(y&1), p); y >>= 1; x = ADD_MOD(x, x, p); } return r; }
/* We use Gentleman-Sande, decimation-in-frequency FFT, for the forward FFT. Note that we will not perform the usual scambling / bit-reversal procedure here because we will invert the fourier transform using decimation-in-time. */ void FFT_forward_1024_40961(FFTSHORT x[1024]) { FFTSHORT index, step; FFTSHORT i,j,m; FFTSHORT t0,t1; step = 1; for (m = n>>1; m >= 1; m=m>>1) { index = 0; for (j = 0 ; j < m; ++j) { for (i = j; i < n; i += (m<<1)) { ADD_MOD(t0, x[i], x[i+m], q); ADD(t1, x[i], q - x[i+m]); MUL_MOD(x[i+m], t1, W[index], q); x[i] = t0; } SUB_MODn(index, index, step); } step = step << 1; } }