Initial commit.
authorFrancois Fleuret <francois@fleuret.org>
Wed, 23 Sep 2020 20:34:42 +0000 (22:34 +0200)
committerFrancois Fleuret <francois@fleuret.org>
Wed, 23 Sep 2020 20:34:42 +0000 (22:34 +0200)
mandelbrot.py [new file with mode: 0755]

diff --git a/mandelbrot.py b/mandelbrot.py
new file mode 100755 (executable)
index 0000000..fa522eb
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+
+import torch, torchvision
+
+n = 1280
+
+cr = torch.linspace(-2, 1, n).view(1, -1)
+ci = torch.linspace(-1.5, 1.5, n).view(-1, 1)
+
+zr = torch.zeros(n, n)
+zi = torch.zeros(n, n)
+
+for k in range(100):
+    zr, zi = zr**2 - zi**2 + cr, 2 * zr * zi + ci
+
+torchvision.utils.save_image(1-(1-zr**2 + zi**2).sign(), 'mandelbrot.png')