code: function(N) {
    cosMap = cosMap || {};
    cosMap[N] = new Array(N*N);
  
    var PI_N = Math.PI / N;
  
    for (var k = 0; k < N; k++) {
      for (var n = 0; n < N; n++) {
        cosMap[N][n + (k * N)] = Math.cos(PI_N * (n + 0.5) * k);
      }
    }
  }
docs: Builds a cosine map for the given input size. This allows multiple input sizes to be memoized automagically if you want to run the DCT over and over.