This file contains 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
#ifndef M_ACTION_MAX | |
#define M_ACTION_MAX 256 | |
#endif | |
struct m_action; | |
typedef void (*m_action_fun)(void *); | |
struct m_action | |
{ |
This file contains 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
// simple lossy procedure preceding lz4 compression | |
// default: win_size = 64, max_loss = 2 | |
// tested with lz4hc - LZ4HC_CLEVEL_DEFAULT | |
void lossy_lz4_rgb(uint8_t *data, int w, int h, int win_size, float max_loss) | |
{ | |
float max_loss2 = max_loss*max_loss; | |
int y, x; | |
for (y = 0; y < h; y++) |
This file contains 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 mnist_images | |
{ | |
unsigned char *data; | |
float *dataf; | |
int count; | |
int w, h; | |
}; | |
struct mnist_labels | |
{ |
This file contains 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
#version 110 | |
/* Subtle CRT shader usable in fullscreen - Anaël Seghezzi [anael(at)maratis3d.com] | |
This shader is free software distributed under the terms of the GNU General Public | |
License version 3 or higher. This gives you the right to redistribute and/or | |
modify the program as long as you follow the terms of the license. See the file | |
COPYING for full license details. | |
*/ | |
#define M_PI 3.14159265358979323846 |
This file contains 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 ann_sigmoid(s) (1.0f / (1.0f + expf(-(s)))) | |
#define ann_gaussian(s) (expf(-(s) * (s))) | |
#define ann_sin(s) (sinf(s)) | |
#define ann_cos(s) (cosf(s)) | |
#define ann_linear(s) (s) | |
#define ann_relu(s) ((s) < 0.0f ? FLT_EPSILON * (s) : (s)) | |
#define ann_sigmoid_d(v) ((v) * (1.0f - (v))) | |
#define ann_gaussian_d(v, s) (-2.0f * (s) * v) |
This file contains 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
// hyper-sphere coordinates | |
void n_sphere(float *out, float *in, int n) | |
{ | |
double x; int i; | |
x = in[0] * in[0] + in[1] * in[1]; | |
out[1] = in[0] < 0 ? M_PI*2 - acos(in[1] / sqrt(x)) : acos(in[1] / sqrt(x)); | |
for (i = 2; i < n; i++) { | |
x += in[i] * in[i]; |
This file contains 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
#ifdef __TINYC__ | |
#if _WIN32 | |
// TODO VirtualAlloc, VirtualFree | |
#else | |
// mmap | |
#define PROT_READ 1 | |
#define PROT_WRITE 2 | |
#define PROT_EXEC 4 |
This file contains 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 fl4{ float x, y, z, w; }; | |
void asm_test(void) | |
{ | |
struct fl4 v1, v2, v3; | |
v1.x = 0.1; | |
v1.y = 0.2; | |
v1.z = 0.4; | |
v1.w = 0.3; |
This file contains 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
DEF_ASM_OP0(clc, 0xf8) /* must be first OP0 */ | |
DEF_ASM_OP0(cld, 0xfc) | |
DEF_ASM_OP0(cli, 0xfa) | |
DEF_ASM_OP0(clts, 0x0f06) | |
DEF_ASM_OP0(cmc, 0xf5) | |
DEF_ASM_OP0(lahf, 0x9f) | |
DEF_ASM_OP0(sahf, 0x9e) | |
DEF_ASM_OP0(pushfl, 0x9c) | |
DEF_ASM_OP0(popfl, 0x9d) | |
DEF_ASM_OP0(pushf, 0x9c) |