<commit_before>"""
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Logistic Map and Mandelbrot set animation using taichi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Adapted from iq's shadertoy work at "https://www.shadertoy.com/view/XdSXWt"

Press `s` to save screenshot and `ESCAPE` to exit.
"""
import taichi as ti
import numpy as np


ti.init(debug=False, arch=ti.gpu)

WIDTH, HEIGHT = 1200, 600
ymin, ymax = -1, 1
xmin, xmax = -WIDTH / HEIGHT, WIDTH/ HEIGHT
pixels = ti.Vector(3, dt=ti.f32, shape=(WIDTH, HEIGHT))
ox, oy = np.mgrid[xmin: xmax: WIDTH*1j, ymin: ymax: HEIGHT*1j]
grid = ti.Vector(2, dt=ti.f32, shape=(WIDTH, HEIGHT))
grid.from_numpy(np.stack((ox, oy), axis=2))


@ti.func
def log2(x):
    return ti.log(x) / ti.log(2)


@ti.func
def cadd(a, z):
    """
    add a real number `a` to a complex `z`.
    """
    return ti.Vector([a + z[0], z[1]])


@ti.func
def cmul(a, b):
    """
    Multiply two complex numbers `a` and `b`.
    """
    return ti.Vector([a[0] * b[0] - a[1] * b[1],
                      a[0] * b[1] + a[1] * b[0]])


@ti.func
def mix(x, y, a):
    """
    Mix two vectors `x` and `y` weighted by a real number `a`.
    """
    return ti.Vector([
        x[0] * (1.0 - a) + y[0] * a,
        x[1] * (1.0 - a) + y[1] * a,
        x[2] * (1.0 - a) + y[2] * a])

<commit_msg>add taichi exmaple code for mandelbrot fractal<commit_after>"""
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Logistic Map and Mandelbrot set animation using taichi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Adapted from iq's shadertoy work at "https://www.shadertoy.com/view/XdSXWt"

Press `s` to save screenshot and `ESCAPE` to exit.
"""
import taichi as ti
import numpy as np


ti.init(debug=False, arch=ti.gpu)

WIDTH, HEIGHT = 1200, 600
ymin, ymax = -1, 1
xmin, xmax = -WIDTH / HEIGHT, WIDTH/ HEIGHT
pixels = ti.Vector(3, dt=ti.f32, shape=(WIDTH, HEIGHT))
ox, oy = np.mgrid[xmin: xmax: WIDTH*1j, ymin: ymax: HEIGHT*1j]
grid = ti.Vector(2, dt=ti.f32, shape=(WIDTH, HEIGHT))
grid.from_numpy(np.stack((ox, oy), axis=2))


@ti.func
def log2(x):
    return ti.log(x) / ti.log(2)


@ti.func
def cadd(a, z):
    """
    add a real number `a` to a complex `z`.
    """
    return ti.Vector([a + z[0], z[1]])


@ti.func
def cmul(a, b):
    """
    Multiply two complex numbers `a` and `b`.
    """
    return ti.Vector([a[0] * b[0] - a[1] * b[1],
                      a[0] * b[1] + a[1] * b[0]])


@ti.func
def mix(x, y, a):
    """
    Mix two vectors `x` and `y` weighted by a real number `a`.
    """
    return ti.Vector([x[0] * (1.0 - a) + y[0] * a,
                      x[1] * (1.0 - a) + y[1] * a,
                      x[2] * (1.0 - a) + y[2] * a])


{'fraction_non_alphanumeric': 0.25443786982248523, 'fraction_numerical': 0.03106508875739645, 'mean_word_length': 2.8864942528735633, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2109459', 'n_tokens_mistral': 1150, 'n_tokens_neox': 1094, 'n_words': 299}