From f1104a3b0faac4a6daf54b6a7474ab693a40e8d1 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 21 Jul 2010 17:13:02 +0200 Subject: fix mandelbrot compilation, and make it use Array instead of Matrix --- demos/mandelbrot/mandelbrot.cpp | 15 ++++++++------- demos/mandelbrot/mandelbrot.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'demos/mandelbrot') diff --git a/demos/mandelbrot/mandelbrot.cpp b/demos/mandelbrot/mandelbrot.cpp index 14341b7e4..f89526cf6 100644 --- a/demos/mandelbrot/mandelbrot.cpp +++ b/demos/mandelbrot/mandelbrot.cpp @@ -23,6 +23,7 @@ // Eigen. If not, see . #include "mandelbrot.h" +#include #include #include #include @@ -45,7 +46,7 @@ template<> struct iters_before_test { enum { ret = 16 }; }; template void MandelbrotThread::render(int img_width, int img_height) { enum { packetSize = Eigen::ei_packet_traits::size }; // number of reals in a Packet - typedef Eigen::Matrix Packet; // wrap a Packet as a vector + typedef Eigen::Array Packet; // wrap a Packet as a vector enum { iters_before_test = iters_before_test::ret }; max_iter = (max_iter / iters_before_test) * iters_before_test; @@ -54,7 +55,7 @@ template void MandelbrotThread::render(int img_width, int img_hei const double xradius = widget->xradius; const double yradius = xradius * img_height / img_width; const int threadcount = widget->threadcount; - typedef Eigen::Matrix Vector2; + typedef Eigen::Array Vector2; Vector2 start(widget->center.x() - widget->xradius, widget->center.y() - yradius); Vector2 step(2*widget->xradius/img_width, 2*yradius/img_height); total_iter = 0; @@ -87,16 +88,16 @@ template void MandelbrotThread::render(int img_width, int img_hei { # define ITERATE \ pzr_buf = pzr; \ - pzr = pzr.cwise().square(); \ - pzr -= pzi.cwise().square(); \ + pzr = pzr.square(); \ + pzr -= pzi.square(); \ pzr += pcr; \ - pzi = (2*pzr_buf).cwise()*pzi; \ + pzi = (2*pzr_buf)*pzi; \ pzi += pci; ITERATE ITERATE ITERATE ITERATE } - pix_dont_diverge = ((pzr.cwise().square() + pzi.cwise().square()) + pix_dont_diverge = ((pzr.square() + pzi.square()) .eval() // temporary fix as what follows is not yet vectorized by Eigen - .cwise() <= Packet::Constant(4)) + <= Packet::Constant(4)) // the 4 here is not a magic value, it's a math fact that if // the square modulus is >4 then divergence is inevitable. .template cast(); diff --git a/demos/mandelbrot/mandelbrot.h b/demos/mandelbrot/mandelbrot.h index d0e3b6c96..950be82e2 100644 --- a/demos/mandelbrot/mandelbrot.h +++ b/demos/mandelbrot/mandelbrot.h @@ -25,7 +25,7 @@ #ifndef MANDELBROT_H #define MANDELBROT_H -#include +#include #include #include #include -- cgit v1.2.3