def mandelbrot(data, it, maxval):
    C = data
    Z = data
    mag = af.constant(0, *C.dims())

    for ii in range(1, 1 + it):
        # Doing the calculation
        Z = Z * Z + C

        # Get indices where abs(Z) crosses maxval
        cond = ((af.abs(Z) > maxval)).as_type(af.Dtype.f32)
        mag = af.maxof(mag, cond * ii)

        C = C * (1 - cond)
        Z = Z * (1 - cond)

        af.eval(C)
        af.eval(Z)

    return mag / maxval
dataset/ETHPy150Open arrayfire/arrayfire-python/examples/graphics/fractal.py/mandelbrot/original