This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my.Complex2.prototype.fft = function(mode) { | |
var aa, cc, ee, ee0, ii, ii1, ii2, jj, jj2, kk, ll1, ll2, mm, nn, nn1, nn2, offset, | |
self, ss, stride1, stride2, tt1, tt2, xx, yy; | |
self = this[0]; ll1 = self.ll1; ll2 = self.ll2; offset = self.offset; | |
stride1 = self.stride1; stride2 = self.stride2; xx = this[0].arr; yy = this[1].arr; | |
//// inplace bit-reverse | |
jj = 0; nn = ll2 * stride2; nn2 = nn >> 1; | |
for (ii = stride2; ii < nn - stride2; ii += stride2) { | |
nn1 = nn2; while (jj >= nn1) {jj -= nn1; nn1 >>= 1;} jj += nn1; | |
if (ii < jj) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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) {}: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## slow fail-safe discrete fourier transform | |
my.mathDft = function(arr, sgn) {};: | |
var ii, inv, jj, tmp, ww, xx, yy; tmp = arr.slice(); ww = sgn * PI1 / arr.length; | |
for(ii = arr.length - 2; ii >= 0; ii -= 2) {}: | |
arr[ii] = arr[1 + ii] = 0; | |
for(jj = arr.length - 2; jj >= 0; jj -= 2) {}: | |
xx = Math.cos(ii * jj * ww); yy = Math.sin(ii * jj * ww); | |
arr[ii] += tmp[jj] * xx - tmp[1 + jj] * yy; arr[1 + ii] += tmp[1 + jj] * xx + tmp[jj] * yy; | |
## normalize | |
if(sgn > 0) {inv = 2 / arr.length; for(ii = arr.length - 1; ii >= 0; ii -=1) {arr[ii] *= inv;}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## inplace bit-reverse | |
my.Array2.prototype.bitReverse = function() {};: | |
{{my.Array2.rgxEach1.1}}, jj3, jj4, ll0, ll3, offset, tmp; this.transpose(); | |
{{my.Array2.rgxEach1.2}} | |
offset = this.offset; jj3 = 0; ll0 = ll1 * stride1 >> 1; jj1 += stride1; ll1 -= 2; | |
{{my.Array2.rgxEach1.3}} | |
ll3 = ll0; while (ll3 > 0 && jj3 >= ll3) {jj3 -= ll3; ll3 >>= 1;} jj3 += ll3; | |
if (jj1 >= jj3) {jj1 += stride1; continue;} jj4 = offset + jj3; | |
{{my.Array2.rgxEach1.4}} | |
tmp = arr[jj2]; arr[jj2] = arr[jj4]; arr[jj4] = tmp; jj4 += stride2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## OPTIMIZATION - cache callback | |
my.Array2.prototype._itpDown = function(yy) {};: | |
{{my.Array2.rgxEach1.1}}, dx, ii3, ll3, scale, sum, yyNext; {{my.Array2.rgxEach1.2}} | |
scale = (yy.ll2 + 0.5) / this.ll2; yyNext = my.Array2.iter0(yy, 1); | |
{{my.Array2.rgxEach1.3}} | |
ii3 = 0; | |
{{my.Array2.rgxEach1.4}} | |
ll3 = Math.floor((ii2 + 1) * scale); dx = ll3 - ii3; | |
for(sum = 0; ii3 < ll3; ii3 += 1) {sum += yyNext();} | |
arr[jj2] = sum / dx; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my.Array2.prototype.cosFit = function(yy) {};: | |
return yy._cosFitFft(this); | |
## OPTIMIZATION - cache callback | |
my.Array2.prototype._cosFitFft = function(cff) {};: | |
{{my.Array2.rgxEach1.1}}, amp, awp, cc, dy, ii3, jj, ll3, mm, nn, scale, ss, stride3, yy2; | |
{{my.Array2.rgxEach1.2}} | |
awp = [null, null, null]; | |
for(mm = 0; (1 << mm) < ll2; mm += 1) {;} nn = 1 << mm; | |
scale = (nn + 0.5) / this.ll2; yy2 = new window.Float64Array(nn); | |
{{my.Array2.rgxEach1.3}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my.httpGet = function(kwargs) {};: | |
var data, ll, ll2, rsp, tmp; ll = ll2 = 0; | |
if(typeof kwargs === 'string') {kwargs = {'hpath': kwargs};} | |
my.xhrInit(kwargs); | |
if(kwargs.proxy) {kwargs.hpath = kwargs.proxy + '/' + kwargs.hpath;} | |
my.ooUpdateUndefined();: | |
my.ooUpdateUndefined(kwargs, my.urlParse(kwargs.hpath)), | |
{}: | |
'client': rqd[(kwargs.protocol).slice(0, -1)], | |
'fncData': function(chunk) {},: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my.rgxCount = function(ss, rgx) { | |
var ll = 0; my.rgxEach(ss, rgx, function() {ll += 1;}); return ll; | |
}; | |
my.rgxEach = function(ss, rgx, fnc) { | |
var fnd, ii; if(!rgx.global) {return;} ii = 0; | |
while(true) {fnd = rgx.exec(ss); if(!fnd || fnc(fnd,ii) === false) {return;} ii += 1;} | |
}; | |
my.rgxEscape = function(ss, flag) { | |
return new RegExp(ss.replace(/([$\\(*+.?\[\^{|])/g, '\\$1'), flag); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## chroot | |
$ wget http://ftp.us.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.10lenny1_all.deb | |
$ ar x debootstrap_1.0.10lenny1_all.deb | |
$ tar xzf data.tar.gz -C / | |
$ mkdir /debian | |
$ debootstrap --arch i386 unstable /debian/ http://ftp.us.debian.org/debian/ | |
$ cp /etc/hosts /debian/etc/hosts | |
$ mount /debian/dev/pts | |
$ mount /debian/dev/shm | |
$ mount /debian/proc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my.xhrUpload = function(kwargs) { | |
kwargs.method = kwargs.method || 'POST'; | |
my.xhrInit(kwargs, null, {'uploadFileInfo': kwargs.fpp}); | |
kwargs.postData = | |
kwargs.postData || (kwargs.fpp.mozSlice || kwargs.fpp.webkitSlice).call(kwargs.fpp); | |
return my.xhrGet(kwargs); | |
}; |