I am studying a specific code of the mandelbrot set (equation with complex numbers) focusing on object-oriented programming. However, there is a specific part that I did not understand from the code, as below:
columns = 2000
rows = 2000
result = numpy.zeros([rows, columns])
for row_index, Re in enumerate(numpy.linspace(-2, 1, num=rows)):
for column_index, Im in enumerate (numpy.linspace(-1, 1, num=columns)):
result[row_index, column_index] = mset(Re, Im, 200)
Below is the complete code:
import numpy
from numba import autojit
import matplotlib.pyplot as plt
@autojit
def mset (Re, Im, max_inter):
c = complex (Re, Im)
z = 0
for i in range (max_inter):
z = z*z + c
if (z.real*z.real + z.imag*z.imag) >= 4:
return i
return max_inter
columns = 2000
rows = 2000
result = numpy.zeros([rows, columns])
for row_index, Re in enumerate(numpy.linspace(-2, 1, num=rows)):
for column_index, Im in enumerate (numpy.linspace(-1, 1, num=columns)):
result[row_index, column_index] = mset(Re, Im, 200)
plt.figure(dpi=100)
plt.imshow(result.T, cmap='hot', interpolation='bilinear', extent=[-2, 1, -1, 1])
plt.xlabel('Real')
plt.ylabel('imagin')
plt.show()