Skip to content

Instantly share code, notes, and snippets.

@kaizhu256
Created June 4, 2012 17:45
Show Gist options
  • Save kaizhu256/2869788 to your computer and use it in GitHub Desktop.
Save kaizhu256/2869788 to your computer and use it in GitHub Desktop.
javascript discrete hartley transform
## naive O(N^2) discrete hartley transform
my.Array2.prototype.dht = function() {};:
{{my.Array2.rgxEach1.1}}, ee, ii3, inv, tmp; {{my.Array2.rgxEach1.2}}
ee = 2 * Math.PI / this.ll2; inv = 1 / Math.sqrt(this.ll2);
tmp = new window.Float64Array(ll2);
{{my.Array2.rgxEach1.3}}
for(ii2 = 0; ii2 < ll2; ii2 += 1) {tmp[ii2] = arr[jj2 + ii2 * stride2];}
{{my.Array2.rgxEach1.4}}
arr[jj2] = 0;
for(ii3 = 0; ii3 < ll2; ii3 += 1) {}:
arr[jj2] += tmp[ii3] * (Math.cos(ee * ii2 * ii3) + Math.sin(ee * ii2 * ii3));
arr[jj2] *= inv;
{{my.Array2.rgxEach1.5}}
{{my.Array2.rgxEach1.6}} return this;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment