File: mandelbrot_aottest.cpp

package info (click to toggle)
halide 21.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 55,752 kB
  • sloc: cpp: 289,334; ansic: 22,751; python: 7,486; makefile: 4,299; sh: 2,508; java: 1,549; javascript: 282; pascal: 207; xml: 127; asm: 9
file content (37 lines) | stat: -rw-r--r-- 918 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <cmath>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

#include "HalideBuffer.h"
#include "mandelbrot.h"

using namespace Halide::Runtime;

int main(int argc, char **argv) {
    Buffer<int, 2> output(100, 30);
    const char *code = " .:-~*={}&%#@";
    const int iters = (int)strlen(code) - 1;

    // Compute 100 different julia sets
    for (float t = 0; t < 100; t++) {
        float fx = cos(t / 10.0f), fy = sin(t / 10.0f);
        mandelbrot(-2.0f, 2.0f, -1.4f, 1.4f, fx, fy, iters, output.width(), output.height(),
                   output);
    }

    char buf[4096];
    char *buf_ptr = buf;
    for (int y = 0; y < output.height(); y++) {
        for (int x = 0; x < output.width(); x++) {
            *buf_ptr++ = code[output(x, y)];
        }
        *buf_ptr++ = '\n';
    }
    *buf_ptr++ = 0;
    printf("%s", buf);
    fflush(stdout);

    printf("Success!\n");
    return 0;
}