SHARE
TWEET

Untitled

a guest Oct 13th, 2017 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. poly FWHT(poly P, bool inverse) {
  2.     for (len = 1; 2 * len <= degree(P); len <<= 1) {
  3.         for (i = 0; i < degree(P); i += 2 * len) {
  4.             for (j = 0; j < len; j++) {
  5.                 u = P[i + j];
  6.                 v = P[i + len + j];
  7.                 P[i + j] = u + v;
  8.                 P[i + len + j] = u - v;
  9.             }
  10.         }
  11.     }
  12.    
  13.     if (inverse) {
  14.         for (i = 0; i < degree(P); i++)
  15.             P[i] = P[i] / degree(P);
  16.     }
  17.  
  18.     return P;
  19. }
RAW Paste Data
Top