Code covered by the BSD License  

Highlights from
Mandelbrot set vectorized

4.33333

4.3 | 6 ratings Rate this file 31 Downloads (last 30 days) File Size: 2.78 KB File ID: #1329
image thumbnail

Mandelbrot set vectorized

by Lucio Cetto

 

13 Feb 2002 (Updated 02 Jun 2004)

Produces the Mandelbrot set using vectorized code.

| Watch this File

File Information
Description

Produces the Mandelbrot set, as other user contributed "m" files, but this submission is VECTORIZED, achieving a speedup of approx 2.5 against a traditional implementation (which is optimized by the JIT). In the past (6.0), a vectorized implementation would achieve speedups up to 100 times faster, this is no longer true.
This is a very instructive example of how to vectorize nested loops.

When being used in interactive mode you can zoom into a region of interest and launch again the computation with a GUI push-button.

Acknowledgements
This submission has inspired the following:
mandelbrot set
MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
14 Nov 2003 chris seeling  
02 Jun 2004 Brian Mearns

Good use of vectorization, but I'm not a big fan of the output when nargout == 0. But that's easily enough remidied on my end by assigning an output argumnent. I was also hoping to be able to specify different values for real and imaginary steps.
Also, as I informed the author in an email, in MATLAB R14, the code is slightly broken, but it's easily fixed. In R14, an identifier cannot be used as a function and a variable in the same code, which i is in this file, it's used as the sqrt(-1) (function) and as a counter in a loop (variable). But it's a minor detail and was perfectly legal in earlier versions.

15 Mar 2005 rash jadhav  
30 Nov 2005 Jas Ellis

I haven't tried the program, but I like the vectorisation! :) I added the code to my own a Mandelbrot program, in which I had previously (and, er, idiotically) used NaNs to mask out absolute values greater than 2 (32 seconds, approx). A loop took 24s. Using this linear indexing I got down to 17.5s and Logical indexing shaved another 2s! (Excerpt below).

h = logical(ones(size(X)));
for m=1:50
    X(h) = X(h).^2 + X0(h);
    h = (abs(X)<2);
    A(h) = A(h) + 1;
end;

14 Jan 2006 Sheldon Danielson  
19 Apr 2006 sacrosancttayyar sacrosancttayyar

i like this type of fractals..
with some changes of type it will be more great :)

Please login to add a comment or rating.
Updates
02 Jun 2004

Updating for R14

Tag Activity for this File
Tag Applied By Date/Time
fractals Lucio Cetto 22 Oct 2008 06:41:38
mandelbrot Lucio Cetto 22 Oct 2008 06:41:38
fractal Lucio Cetto 22 Oct 2008 06:41:38
vetorize Lucio Cetto 22 Oct 2008 06:41:38
vectorizing Lucio Cetto 22 Oct 2008 06:41:38

Contact us at files@mathworks.com