static uint32_t num_itters = 32;
static uint32_t num_clusters = 16;
struct rgb_t {
uint8_t r, g, b;
};
struct cluster_t {
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static const float bl_sqr_1024[] = { | |
0.097529f, 0.289545f, 0.472608f, 0.641306f, 0.791023f, 0.918181f, 1.020420f, 1.096688f, | |
1.147256f, 1.173645f, 1.178479f, 1.165270f, 1.138160f, 1.101625f, 1.060181f, 1.018096f, | |
0.979137f, 0.946363f, 0.921979f, 0.907263f, 0.902558f, 0.907333f, 0.920304f, 0.939604f, | |
0.962981f, 0.988014f, 1.012329f, 1.033791f, 1.050671f, 1.061757f, 1.066433f, 1.064683f, | |
1.057065f, 1.044619f, 1.028753f, 1.011100f, 0.993361f, 0.977153f, 0.963869f, 0.954573f, | |
0.949915f, 0.950097f, 0.954878f, 0.963611f, 0.975324f, 0.988818f, 1.002784f, 1.015926f, | |
1.027076f, 1.035291f, 1.039934f, 1.040715f, 1.037706f, 1.031323f, 1.022269f, 1.011470f, | |
0.999976f, 0.988866f, 0.979147f, 0.971666f, 0.967040f, 0.965603f, 0.967391f, 0.972140f, | |
0.979327f, 0.988219f, 0.997949f, 1.007598f, 1.016279f, 1.023220f, 1.027828f, 1.029741f, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import csv | |
import StringIO | |
import random | |
def sinc(x): | |
theta = 2.0 * x * math.pi * 4.0 | |
try: | |
return min(1.0, math.sin(theta) / theta) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <stdint.h> | |
#include <array.h> | |
// read variable length quantity | |
uint32_t _vlq_read(const uint8_t *&out) { | |
uint32_t val = 0; | |
for (;;) { | |
const uint8_t c = *(out++); | |
val = (val << 7) | (c & 0x7f); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct prefix_code_t { | |
uint8_t index; // length sorted index | |
uint8_t size; // number of bits in prefix code | |
uint32_t code; // bit encoded prefix code | |
}; | |
static const prefix_code_t codes[] = | |
{ 0x0fd, 0x12, 0x0003ffff }, // 00000000000000111111111111111111 | |
{ 0x0ff, 0x13, 0x0005ffff }, // 00000000000001011111111111111111 | |
{ 0x0fe, 0x13, 0x0001ffff }, // 00000000000000011111111111111111 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <string> | |
#include <vector> | |
#include <stdio.h> | |
#include <stdlib.h> | |
static int _coin_toss() { return ((rand() % 100) < 80) ? 1 : 0; } | |
struct code_t { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _CRT_SECURE_NO_WARNINGS | |
#include <algorithm> | |
#include <array> | |
#include <cassert> | |
#include <cstdint> | |
#include <cstring> | |
#include <vector> | |
struct entry_t { | |
bool match; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <assert.h> | |
#include <intrin.h> | |
#include <array> | |
#define WIN32_LEAN_AND_MEAN | |
#include <Windows.h> | |
#undef min | |
#undef max |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// triangle setup | |
// | |
struct tri_setup_t { | |
tri_setup_t(const std::array<float2, 3> & t) | |
: _t(t) | |
, _i(tri_calc(t)) | |
{ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <CL/cl.h> | |
#include <array> | |
const char *source = R"( | |
kernel void mult(global float *data) { | |
const int id = get_global_id(0); | |
data[id] *= 2.f; | |
} | |
)"; |