标签: mandelbrot

ruby中的快速/快速整数乘法?

我试图在Ruby中快速/高效地实现Mandelbrot.很久很久以前,加速它的一种方法是使用定点整数而不是浮点数.

所以我做了以下基准测试,使用乘法或平方**操作数将浮点数和整数提升比较为平方.

require 'benchmark'

Benchmark.bmbm(10) do |x|  
  x.report("float-multip") do
    for z in 0..100000 
      zf = z.to_f
      y = zf*zf
    end
  end  

  x.report("float-square") do
    for z in 0..100000 
      zf = z.to_f
      y = zf**2
    end
  end  

  x.report("int-multip") do
    zo = 0
    for zi in 0..100000 
      y2 = zo*zo
      zo += 1
    end
  end   

  x.report("int-multip") do
    for zi in 0..100000 
      y2 = zi**2
    end
  end  
end
Run Code Online (Sandbox Code Playgroud)

这会生成以下输出:

Rehearsal ------------------------------------------------
float-multip   0.125000   0.000000   0.125000 (  0.125000)
float-square   0.125000   0.000000   0.125000 (  0.125000)
int-multip …
Run Code Online (Sandbox Code Playgroud)

ruby multiplication mandelbrot

5
推荐指数
2
解决办法
2360
查看次数

一些帮助渲染Mandelbrot集

我已经得到了一些与Mandelbrot集的分形可视化有关的工作.

我不是在寻找一个完整的解决方案(当然),我正在寻求关于复数轨道的帮助.

假设我有一个给定的Complex数字来自复平面上的一个点.我现在需要迭代其轨道序列并根据轨道是否增加数量级来绘制点.

我如何收集复数的轨道?任何指导都非常感谢(链接等).任何关于数学函数的指针都需要测试轨道序列,例如Math.pow()

我正在使用Java,但这并不是特别相关.

再次感谢,Alex

math graphics mandelbrot

4
推荐指数
1
解决办法
1191
查看次数

如何缩放 mandelbrot 集

我已经成功实现了维基百科文章中描述的 mandelbrot 集,但我不知道如何放大特定部分。这是我正在使用的代码:

+(void)createSetWithWidth:(int)width Height:(int)height Thing:(void(^)(int, int, int, int))thing
{   
    for (int i = 0; i < height; ++i)
    for (int j = 0; j < width; ++j)
    {
        double x0 = ((4.0f * (i - (height / 2))) / (height)) - 0.0f;
        double y0 = ((4.0f * (j - (width / 2))) / (width)) + 0.0f;
        double x = 0.0f;
        double y = 0.0f;

        int iteration = 0;
        int max_iteration = 15;

        while ((((x * x) + (y * …
Run Code Online (Sandbox Code Playgroud)

objective-c mandelbrot

4
推荐指数
2
解决办法
1万
查看次数

无法计算mandelbrot集迭代

所以我读了这篇文章:http://www.wikihow.com/Plot-the-Mandelbrot-Set-By-Hand 但我陷入了第7步.我在javascript画布中绘制了这个集合.

我所需要的只是基本上我猜的C值.

for (var y = 0; y < ImageHeight; y++) {
    for (var x = 0; x < ImageWidth; x++) {

        // Pixel-Position for ImageObject
        var xy = (x + y * image.width) * 4;

        // Convert Image-Dimension to a radius of 2
        var xi = ((x / ImageWidth) * 4) - 2;
        var yi = ((y / ImageHeight) * 4) - 2;

        for (var n = 0; n < MaxIterations; n++) {

            // Complex …
Run Code Online (Sandbox Code Playgroud)

javascript fractals mandelbrot

4
推荐指数
1
解决办法
2702
查看次数

Mandelbrot在OpenMP中设置

有人可以帮助我改进这些代码并给我一些提示.我试图自己创建一个OpenMP版本的Mandelbrot.我是OpenMP初学者,在这里我没有加快速度,这可能是因为#pragma omp critical我现在想不出更好的主意.

int main()
{
    // picture resolution 
    int iX,iY;
    const int ImageWidth = 1000; 
    const int ImageHeight = 1000;

    double Cx,Cy;
    const double CxMin=-2.5;
    const double CxMax=1.5;
    const double CyMin=-2.0;
    const double CyMax=2.0;

    double PixelWidth=(CxMax-CxMin)/ImageWidth;  /* scaled x coordinate of pixel (must be scaled to lie somewhere in the Mandelbrot
                                                    X scale (-2.5, 1.5) */
    double PixelHeight=(CyMax-CyMin)/ImageHeight;/* scaled y coordinate of pixel (must be scaled to lie somewhere in the Mandelbrot
                                                    Y scale (-2.0, 2.0) */ …
Run Code Online (Sandbox Code Playgroud)

c parallel-processing openmp mandelbrot

4
推荐指数
1
解决办法
3457
查看次数

AVX计算精度

我写了一个程序来显示mandelbrot集.为了加快速度,我通过<immintrin.h>标题使用了AVX(真正的AVX2)指令.
问题是:AVX计算的结果(具有双精度)具有伪像,并且它与使用"正常"双精度计算时的结果不同.
详细地,存在一个函数getIterationCount,该函数计算直到曼德尔布尔序列超过4的迭代次数,或假设如果序列在前N个步骤期间不超过4则该点包括在该组中.
代码如下所示:

#include "stdafx.h"
#include <iostream>
#include <complex>
#include <immintrin.h>

class MandelbrotSet {
public:
    int getIterationCount(const std::complex<double>, const int) const noexcept;
    __m256i getIterationCount(__m256d cReal, __m256d cIm, unsigned maxIterations) const noexcept;
};

inline int MandelbrotSet::getIterationCount(const std::complex<double> c, const int maxIterations) const noexcept
{
    double currentReal = 0;
    double currentIm = 0;
    double realSquare;
    double imSquare;
    for (int i = 0; i < maxIterations; ++i) {
        realSquare = currentReal * currentReal;
        imSquare = currentIm * currentIm; …
Run Code Online (Sandbox Code Playgroud)

c++ mandelbrot avx avx2

4
推荐指数
1
解决办法
230
查看次数

Mandelbrot设置平滑着色函数

我用 python 编写了 Mandelbrot 集,但这看起来很奇怪,所以我寻找平滑的颜色。我已经使用对数和线性插值编写了一个平滑的着色函数,但无论我尝试什么,我都无法得到我想要的:

self.palette = [(3, 25, 61),(5, 43, 107),(7, 61, 153),(20, 96, 226),(20, 164, 226),(74, 181, 226),(138, 211, 242),(205, 234, 247),(225, 237, 242),(255,255,255)]
Run Code Online (Sandbox Code Playgroud)

这是我的调色板

if n == self.max_iterations:
    self.screen.set_at((x, y), (110, 13, 13))
else:
    gradient = 1 + n - math.log(math.log(abs(m))) / math.log(2.0)
    iteration = n + 1 - gradient
    color1 = list(self.palette[n % 10])
    if n % 10 <= 8:
        color2 = list(self.palette[n % 10+1])
    else:
        color2 = list(self.palette[-1])

    color = [[], [], []]
    for number, …
Run Code Online (Sandbox Code Playgroud)

python math mandelbrot python-3.x

4
推荐指数
1
解决办法
468
查看次数

我如何获得无限小的数字(对于分形)

我正在使用 OpenGL 使用 C++ 对 Mandelbrotset 进行编程,但遇到了一个问题:我发送到着色器并在着色器中计算的浮点数只能容纳一定数量的小数位。因此,如果我放大得太远,它就会变得像素化。

我想过创建自定义数组函数,但我无法真正弄清楚。除了使用数组还有其他方法吗?如果不是,我如何使用数组来计算东西,就好像它们是单个数字一样?(例如 arr[1,2] x arr[0,2] 应该给出与仅计算 1.2 x 0.2 相同的输出)

in vec4 gl_FragCoord;
 
out vec4 frag_color;
uniform float zoom;
uniform float x;
uniform float y;
#define maximum_iterations 1000

int mandelbrot_iterations()
{
    float real = ((gl_FragCoord.x / 1440.0f - 0.5f) * zoom + x) * 4.0f;
    float imag = ((gl_FragCoord.y / 1440.0f - 0.5f) * zoom + y) * 4.0f;
 
    int iterations = 0;
    float const_real = real;
    float const_imag = imag;
 
    
    while (iterations < …
Run Code Online (Sandbox Code Playgroud)

c++ opengl glsl fractals mandelbrot

4
推荐指数
1
解决办法
3666
查看次数

渲染曼德尔布罗集的最快算法是什么?

我尝试了许多用于渲染曼德尔布罗特集的算法,包括朴素的逃逸时间算法,以及优化的逃逸时间算法。但是,是否有更快的算法可以像我们在 YouTube 上看到的那样有效地产生真正深度的缩放。另外,我很想了解一些关于如何提高 C/C++ 之外的精度的想法 double

c c++ graphics optimization mandelbrot

4
推荐指数
1
解决办法
6043
查看次数

我的曼德尔布罗特集在进行少量迭代绘图时显示错误的轮廓

我正在编写一个用 C 语言绘制 Mandelbrot 集的程序。我已经能够显示它并且看起来不错,但是当我减少迭代次数时,我得到了这种效果,生成了我只能描述为“云”的效果: 曼德尔布罗特集

它应该是这样的(我从网站上得到的):

右曼德尔布罗集

我怎样才能让我的看起来像上面的那样?这是绘制单个点的代码:

double getFracPoint(double x,double y){

    //scale x and y
    x = x * ((plotEnd.x-plotStart.x) / SCREENWIDTH) + plotStart.x;
    y = y * ((plotEnd.y-plotStart.y) / SCREENHEIGHT) + plotStart.y;

    x/=zoom;
    y/=zoom;

    //instead of using the complex number library of the C standard
    //I decided to use regular numbers as it turns out to be faster.

    //The first number is the real part the second number is the imaginary
    //part.
    double z[2];
    z[0] = z[1] = …
Run Code Online (Sandbox Code Playgroud)

c math fractals mandelbrot

4
推荐指数
1
解决办法
151
查看次数