author | Francesco Abbate <francesco.bbt@gmail.com> | 2011年10月27日 18:41:30 +0200 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2011年10月27日 18:41:30 +0200 |
commit | 485292c127db59762d50ae333270a8ad1ea32c3f (patch) | |
tree | 7c8b2b02ae0c00bf71f74d9cddb7d03b8520f6d2 /demos/fractals.lua | |
parent | be14a81e8187a069fc23845b4a9920b6b2bc0be8 (diff) | |
download | gsl-shell-485292c127db59762d50ae333270a8ad1ea32c3f.tar.gz |
-rw-r--r-- | demos/fractals.lua | 12 |
diff --git a/demos/fractals.lua b/demos/fractals.lua index a5828316..84ceb3c1 100644 --- a/demos/fractals.lua +++ b/demos/fractals.lua @@ -1,16 +1,19 @@ - -use 'stdlib' +use 'math' +use 'graph' +use 'iter' local function c_generator(n, n_angle, len_frac, g) local exp, real, imag = complex.exp, complex.real, complex.imag local w, r, k = ilist(|| 0, n+1), #g local s = len_frac^n - local sz = cnew(n_angle, 1, |k| s * exp(2i*pi*(k-1)/n_angle)) + local sz = matrix.cnew(n_angle, 1, |k| s * exp(2i*pi*(k-1)/n_angle)) - local sh = ilist(|k| g[k%r+1] - g[(k-1)%r+1], 0, r-1) + local sh = ilist(|k| g[(k-1)%r+1] - g[(k-2)%r+1], r) local a = (g[1]*n) % n_angle + print('sh', sh) + local z = 0 return function() if w[n+1] == 0 then @@ -18,6 +21,7 @@ local function c_generator(n, n_angle, len_frac, g) z = z + sz[a+1] for j=1,n+1 do w[j] = (w[j] + 1) % r + print(j, w[j], sh[w[j]+1], a) a = (a + sh[w[j]+1]) % n_angle if w[j] ~= 0 then break |