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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
#define SDL_MAIN_HANDLED | |
#include <SDL2/SDL.h> | |
void* xmalloc(size_t size) { | |
void* ptr = malloc(size); | |
if (ptr == NULL) { |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <math.h> | |
void* xmalloc(size_t size) { | |
void* ptr = malloc(size); | |
if (ptr == NULL) { | |
fprintf(stderr, "Failed to allocate %ld bytes\n", size); | |
exit(EXIT_FAILURE); |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdarg.h> | |
#include <string.h> | |
#include <assert.h> | |
#include <signal.h> | |
#include <execinfo.h> | |
void panic(const char* format, ...) { |
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
#include <stdio.h> | |
#include <stdarg.h> | |
void fmt_int(char* buf, int n) { | |
int i = 0; | |
if (n < 0) { | |
*buf++ = '-'; | |
n = -n; | |
} |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
void cholesky(float* m, int n) { | |
for (int i = 0; i < n; i++) { | |
for (int j = 0; j < i; j++) { | |
float sum = 0; | |
for (int k = 0; k < j; k++) { | |
sum += m[i * n + k] * m[j * n + k]; |
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
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <math.h> | |
#define STB_IMAGE_IMPLEMENTATION | |
#include "stb_image.h" | |
#define STB_IMAGE_WRITE_IMPLEMENTATION |
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
#include <iostream> | |
#include <vector> | |
#include <optional> | |
#include <functional> | |
#include <cctype> | |
using namespace std; | |
struct unit { |
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
public class MainProgram { | |
public static void main(String[] args) { | |
Nat n1 = Nat.int2Nat(10); | |
Nat n2 = Nat.int2Nat(20); | |
Nat n3 = n1.add(n2); | |
int x = Nat.nat2Int(n3); | |
System.out.println(x); |
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
#include <stdint.h> | |
#include <math.h> | |
#define STB_IMAGE_WRITE_IMPLEMENTATION | |
#include "stb_image_write.h" | |
struct rgb { | |
uint8_t r; | |
uint8_t g; | |
uint8_t b; |
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
#include <stdio.h> | |
typedef struct mat4 { | |
float m[16]; | |
} mat4; | |
typedef struct vec3 { | |
float x; | |
float y; | |
float z; |