summaryrefslogtreecommitdiffstats
path: root/scilab/modules/core/tests/benchmarks/mandelbrot_vect.tst
diff options
context:
space:
mode:
Diffstat (limited to 'scilab/modules/core/tests/benchmarks/mandelbrot_vect.tst')
-rw-r--r--scilab/modules/core/tests/benchmarks/mandelbrot_vect.tst49
1 files changed, 49 insertions, 0 deletions
diff --git a/scilab/modules/core/tests/benchmarks/mandelbrot_vect.tst b/scilab/modules/core/tests/benchmarks/mandelbrot_vect.tst
new file mode 100644
index 0000000..f0789fd
--- /dev/null
+++ b/scilab/modules/core/tests/benchmarks/mandelbrot_vect.tst
@@ -0,0 +1,49 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2016 - Scilab Enterprises - Clement DAVID
4// Copyright (C) 2011 - DIGITEO - Mickael BAUDIN
5//
6// This file is distributed under the same license as the Scilab package.
7// =============================================================================
8
9//==============================================================================
10// Naive mandelbrot benchmark
11//==============================================================================
12
13// <-- BENCH NB RUN : 30 -->
14
15function R = computeMandelbrot(xsize,ysize,nmax,xmin,xmax,ymin,ymax)
16 xvect = linspace( xmin, xmax, xsize );
17 yvect = linspace( ymin, ymax, ysize );
18 [X,Y]=meshgrid(xvect,yvect);
19
20 Z = zeros(xsize,ysize);
21 R = -ones(xsize,ysize);
22 W = zeros(xsize,ysize);
23 C=X+%i*Y;
24 J = 1:xsize*ysize;
25 for k=0:nmax
26 L = J(J>0);
27 Z(L) = Z(L).^2+C(L);
28 W(L) = abs(Z(L));
29 M = find(W(L)>2);
30 R(L(M)) = k;
31 J(L(M)) = 0;
32 end
33 R = R';
34endfunction
35
36xsize = 50;
37ysize = 50;
38nmax = 1000;
39xmin = 0.2675;
40xmax = 0.2685;
41ymin = 0.591;
42ymax = 0.592;
43
44// <-- BENCH START -->
45
46R = computeMandelbrot(xsize,ysize,nmax,xmin,xmax,ymin,ymax);
47
48// <-- BENCH END -->
49