Exemplo n.º 1
0
        // Render the fractal on multiple threads using the ComplexVecDouble data type
        // For a well commented version, go see VectorFloatRenderer.RenderSingleThreadedWithADT in VectorFloat.cs
        public void RenderMultiThreadedWithADT(float xminf, float xmaxf, float yminf, float ymaxf, float stepf)
        {
            double xmin = (double)xminf;
            double xmax = (double)xmaxf;
            double ymin = (double)yminf;
            double ymax = (double)ymaxf;
            double step = (double)stepf;

            Vector <long>   vmax_iters = new Vector <long>(max_iters);
            Vector <double> vlimit     = new Vector <double>(limit);
            Vector <double> vinc       = new Vector <double>((double)Vector <double> .Count * step);
            Vector <double> vxmax      = new Vector <double>(xmax);
            Vector <double> vstep      = new Vector <double>(step);
            Vector <double> vxmin      = VectorHelper.Create(i => xmin + step * i);

            Parallel.For(0, (int)(((ymax - ymin) / step) + .5), (yp) =>
            {
                if (Abort)
                {
                    return;
                }

                Vector <double> vy = new Vector <double>(ymin + step * yp);
                int xp             = 0;
                for (Vector <double> vx = vxmin; Vector.LessThanOrEqualAny(vx, vxmax); vx += vinc, xp += Vector <long> .Count)
                {
                    ComplexVecDouble num   = new ComplexVecDouble(vx, vy);
                    ComplexVecDouble accum = num;

                    Vector <long> viters    = Vector <long> .Zero;
                    Vector <long> increment = Vector <long> .One;

                    do
                    {
                        accum   = accum.square() + num;
                        viters += increment;
                        Vector <long> vCond = Vector.LessThanOrEqual(accum.sqabs(), vlimit) &
                                              Vector.LessThanOrEqual(viters, vmax_iters);
                        increment = increment & vCond;
                    } while (increment != Vector <long> .Zero);

                    viters.ForEach((iter, elemNum) => DrawPixel(xp + elemNum, yp, (int)iter));
                }
            });
        }
Exemplo n.º 2
0
        // Render the fractal on multiple threads using the ComplexVecDouble data type
        // For a well commented version, go see VectorFloatRenderer.RenderSingleThreadedWithADT in VectorFloat.cs
        public void RenderMultiThreadedWithADT(float xminf, float xmaxf, float yminf, float ymaxf, float stepf)
        {
            double xmin = (double)xminf;
            double xmax = (double)xmaxf;
            double ymin = (double)yminf;
            double ymax = (double)ymaxf;
            double step = (double)stepf;

            Vector<double> vmax_iters = new Vector<double>((double)max_iters);
            Vector<double> vlimit = new Vector<double>(limit);
            Vector<double> vstep = new Vector<double>(step);
            Vector<double> vinc = new Vector<double>((double)Vector<double>.Count * step);
            Vector<double> vxmax = new Vector<double>(xmax);
            Vector<double> vxmin = VectorHelper.Create(i => xmin + step * i);

            Parallel.For(0, (int)(((ymax - ymin) / step) + .5), (yp) =>
            {
                if (Abort)
                    return;

                Vector<double> vy = new Vector<double>(ymin + step * yp);
                int xp = 0;
                for (Vector<double> vx = vxmin; Vector.LessThanOrEqualAny(vx, vxmax); vx += vinc, xp += Vector<double>.Count)
                {
                    ComplexVecDouble num = new ComplexVecDouble(vx, vy);
                    ComplexVecDouble accum = num;

                    Vector<double> viters = Vector<double>.Zero;
                    Vector<double> increment = Vector<double>.One;
                    do
                    {
                        accum = accum.square() + num;
                        viters += increment;
                        Vector<double> vCond = Vector.LessThanOrEqual<double>(accum.sqabs(), vlimit) &
                            Vector.LessThanOrEqual<double>(viters, vmax_iters);
                        increment = increment & vCond;
                    } while (increment != Vector<double>.Zero);

                    viters.ForEach((iter, elemNum) => DrawPixel(xp + elemNum, yp, (int)iter));
                }
            });
        }
Exemplo n.º 3
0
        // Render the fractal on a single thread using the ComplexVecDouble data type
        // For a well commented version, go see VectorFloatRenderer.RenderSingleThreadedWithADT in VectorFloat.cs
        public void RenderSingleThreadedWithADT(float xminf, float xmaxf, float yminf, float ymaxf, float stepf)
        {
            double xmin = (double)xminf;
            double xmax = (double)xmaxf;
            double ymin = (double)yminf;
            double ymax = (double)ymaxf;
            double step = (double)stepf;

            Vector <double> vlimit     = new Vector <double>(limit);
            Vector <double> vinc       = new Vector <double>((double)Vector <double> .Length * step);
            Vector <double> vstep      = new Vector <double>(step);
            Vector <long>   vmax_iters = new Vector <long>(max_iters);
            Vector <double> vxmax      = new Vector <double>(xmax);
            Vector <double> vxmin      = VectorHelper.Create(i => xmin + step * i);

            double y  = ymin;
            int    yp = 0;

            for (Vector <double> vy = new Vector <double>(ymin); y <= ymax && !Abort; vy += vstep, y += step, yp++)
            {
                int xp = 0;
                for (Vector <double> vx = vxmin; Vector.LessThanOrEqualAny(vx, vxmax); vx += vinc, xp += Vector <long> .Length)
                {
                    ComplexVecDouble num   = new ComplexVecDouble(vx, vy);
                    ComplexVecDouble accum = num;

                    Vector <long> viters    = Vector <long> .Zero;
                    Vector <long> increment = Vector <long> .One;

                    do
                    {
                        accum   = accum.square() + num;
                        viters += increment;
                        Vector <long> vCond = Vector.LessThanOrEqual(accum.sqabs(), vlimit) &
                                              Vector.LessThanOrEqual(viters, vmax_iters);
                        increment = increment & vCond;
                    } while (increment != Vector <long> .Zero);

                    viters.ForEach((iter, elemNum) => DrawPixel(xp + elemNum, yp, (int)iter));
                }
            }
        }
Exemplo n.º 4
0
        // Render the fractal on a single thread using the ComplexVecDouble data type
        // For a well commented version, go see VectorFloatRenderer.RenderSingleThreadedWithADT in VectorFloat.cs
        public void RenderSingleThreadedWithADT(float xminf, float xmaxf, float yminf, float ymaxf, float stepf)
        {
            double xmin = (double)xminf;
            double xmax = (double)xmaxf;
            double ymin = (double)yminf;
            double ymax = (double)ymaxf;
            double step = (double)stepf;

            Vector<double> vlimit = new Vector<double>(limit);
            Vector<double> vinc = new Vector<double>((double)Vector<double>.Count * step);
            Vector<double> vstep = new Vector<double>(step);
            Vector<long> vmax_iters = new Vector<long>(max_iters);
            Vector<double> vxmax = new Vector<double>(xmax);
            Vector<double> vxmin = VectorHelper.Create(i => xmin + step * i);

            double y = ymin;
            int yp = 0;
            for (Vector<double> vy = new Vector<double>(ymin); y <= ymax && !Abort; vy += vstep, y += step, yp++)
            {
                int xp = 0;
                for (Vector<double> vx = vxmin; Vector.LessThanOrEqualAny(vx, vxmax); vx += vinc, xp += Vector<long>.Count)
                {
                    ComplexVecDouble num = new ComplexVecDouble(vx, vy);
                    ComplexVecDouble accum = num;

                    Vector<long> viters = Vector<long>.Zero;
                    Vector<long> increment = Vector<long>.One;

                    do
                    {
                        accum = accum.square() + num;
                        viters += increment;
                        Vector<long> vCond = Vector.LessThanOrEqual(accum.sqabs(), vlimit) &
                            Vector.LessThanOrEqual(viters, vmax_iters);
                        increment = increment & vCond;
                    } while (increment != Vector<long>.Zero);

                    viters.ForEach((iter, elemNum) => DrawPixel(xp + elemNum, yp, (int)iter));
                }
            }
        }