Skip to content

Instantly share code, notes, and snippets.

Avatar

Al-buharie harieamjari

View GitHub Profile
@harieamjari
harieamjari / heat.c
Created May 3, 2021
Solving the heat equation
View heat.c
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
double init_fluid(double x) {
return 10.0 * sin(2.0 * M_PI * x / 30.0) + 8.0 * cos(x / 2.0) +
2.0 * sin(x / 2.0);
}
int main() {
View calc.c
/* Tiny calc
*
* Copyright (c) 2021 Al-buharie Amjari <healer.harie@gmail.com>
*
* This file is license under MIT license
*
*/
#include <ctype.h>
#include <stdio.h>
View packet.c
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
double init_fluid(double x) {
return 100.0 * sin(2.0 * M_PI * 0.4 * x) *
pow(M_E, -pow(x - 15.0, 2.0) / (3.6 * 2.0)) / (3.6 * sqrt(2.0 * M_PI));
}
@harieamjari
harieamjari / half.c
Created Apr 24, 2021
Integration of a normal distribution from 0 to +inf
View half.c
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
static double derivative(double x){
return pow(M_E, -pow(x, 2.0)/2.0)/sqrt(2.0*M_PI);}
int main(int argc, char **argv) {
View box2.c
#include <assert.h> // so I wont have to do error handling
#include <math.h>
#include <png.h> // to output frames as png files
#include <stdio.h> // I/O
#include <stdlib.h>
#include <string.h>
#define FRAMES 50
/* this may be a vertex or a vector */
View triangle.c
#include <assert.h>
#include <math.h>
#include <png.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define FRAMES 300
struct vec3D {
double x, y, z;
View gold.c
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#define UNEXPECTED(c) \
{ \
if (c != TOK_ERROR) { \
fprintf(stderr, "stream:%d:%d error: unexpected %s\n", line_tok_found, \
column_tok_found, tok_str(c)); \
} \
View wut.c
const int main[] = {
-476053503, -443744256, -442695680, -494927871,
-443744256, -476045300, -509603825, -494858196,
-476053503, -476024828, -285212672, -352321537,
-442695680, -481296284, -905969664, -352321551,
-476053504, -476024831, -285212672, 1819043176,
1634017391, 174617714, -1610612736, 805248739,
225, 2147483420, 1
};
@harieamjari
harieamjari / 2dwave00.c
Last active Apr 7, 2021
2D wave equation solver
View 2dwave00.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <png.h>
#ifdef NDEBUG
#error "Don't turn NDEBUG!!"
#endif
View lb.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <png.h>
#ifdef NDEBUG
#error "Don't turn NDEBUG!!"
#endif