Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

minor tweaks

  • Loading branch information...
commit 73ba6db92ad05a17666762842a18e2c9897d0021 1 parent a2922a2
@robertwb robertwb authored
Showing with 5 additions and 6 deletions.
  1. +5 −6 mandelbrot_cython.pyx
View
11 mandelbrot_cython.pyx
@@ -9,8 +9,7 @@ import sys
def main(int size, outfile=sys.stdout):
cdef int iter = 50
cdef double step = 2.0 / size
- cdef double Cx, Cy, Zx, Zy, abs2
- cdef double Zx2, Zy2
+ cdef double Cx, Cy, Zx, Zy
cdef int i, xi, yi
cdef double square_abs
@@ -27,14 +26,14 @@ def main(int size, outfile=sys.stdout):
for xi in range(size):
Zx = Cx = step*xi - 1.5
Zy = Cy = step*yi - 1.0
- i = 0
+ i = iter
while True:
- # Z = Z^2 + C
# Soon (hopefully) Cython will have native c complex types
+ # Z = Z^2 + C
Zx, Zy = Zx*Zx - Zy*Zy + Cx , 2*Zx*Zy + Cy
square_abs = Zx*Zx + Zy*Zy
- i += 1
- if (i > iter) | (square_abs > 4.0):
+ i -= 1
+ if (i == 0) | (square_abs > 4.0):
break
byte_acc = (byte_acc << 1) | (square_abs < 4.0)
Please sign in to comment.
Something went wrong with that request. Please try again.