Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Mandelbrot with Plots.jl

$
0
0

I’m trying to do a crude sketch of the Mandelbrot set to better my understanding of Plots.jl. But the code is taking way too long to execute. Thus I humbly ask for help.
My class is as follows (the begin and end I use because I’m working on Pluto):

begin
	Base.@kwdef mutable struct frac
	z::Complex=0+0im
	c::Complex
	end
	
	function iterate!(f::frac)
		f.z=f.z^2+f.c
	end
end

And then I plot the graph by iterating through a discretized plane:

begin
	ploot=plot(1,xlim = (-2,2),ylim = (-2,2),title="mandelbrot iterator")
@gif for x=-2:1e-1:2,y=-1:1e-2:2
	mandel=frac(c=x+y*im)
	map(x->iterate!(mandel),(1:7))
	if(abs(mandel.z)<2)
		push!(ploot,x,y)
	end
end
end

This code has been running for at least an hour on my machine (6th gen i5+4GB GTX960 with tons of RAM). From my reading I’ve understood that my code isn’t leveraging the GPU, but I’m unable to think of a way to make Plots use the GPU.

Thank You

8 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles